LCOV - differential code coverage report
Current view: top level - src/test/regress - pg_regress_main.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DUB DCB
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 87.5 % 32 28 2 2 6 22 7 6
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 3 3 1 2
Baseline: 16@8cea358b128 Branches: 58.3 % 12 7 2 3 2 5
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (60,120] days: 75.0 % 8 6 2 6
(240..) days: 91.7 % 24 22 2 22
Function coverage date bins:
(240..) days: 100.0 % 3 3 1 2
Branch coverage date bins:
(60,120] days: 50.0 % 4 2 2 2
(240..) days: 62.5 % 8 5 3 5

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * pg_regress_main --- regression test for the main backend
                                  4                 :                :  *
                                  5                 :                :  * This is a C implementation of the previous shell script for running
                                  6                 :                :  * the regression tests, and should be mostly compatible with it.
                                  7                 :                :  * Initial author of C translation: Magnus Hagander
                                  8                 :                :  *
                                  9                 :                :  * This code is released under the terms of the PostgreSQL License.
                                 10                 :                :  *
                                 11                 :                :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
                                 12                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 13                 :                :  *
                                 14                 :                :  * src/test/regress/pg_regress_main.c
                                 15                 :                :  *
                                 16                 :                :  *-------------------------------------------------------------------------
                                 17                 :                :  */
                                 18                 :                : 
                                 19                 :                : #include "postgres_fe.h"
                                 20                 :                : 
                                 21                 :                : #include "lib/stringinfo.h"
                                 22                 :                : #include "pg_regress.h"
                                 23                 :                : 
                                 24                 :                : /*
                                 25                 :                :  * start a psql test process for specified file (including redirection),
                                 26                 :                :  * and return process ID
                                 27                 :                :  */
                                 28                 :                : static PID_TYPE
 6151 magnus@hagander.net        29                 :CBC         955 : psql_start_test(const char *testname,
                                 30                 :                :                 _stringlist **resultfiles,
                                 31                 :                :                 _stringlist **expectfiles,
                                 32                 :                :                 _stringlist **tags)
                                 33                 :                : {
                                 34                 :                :     PID_TYPE    pid;
                                 35                 :                :     char        infile[MAXPGPATH];
                                 36                 :                :     char        outfile[MAXPGPATH];
                                 37                 :                :     char        expectfile[MAXPGPATH];
                                 38                 :                :     StringInfoData psql_cmd;
                                 39                 :                :     char       *appnameenv;
                                 40                 :                : 
                                 41                 :                :     /*
                                 42                 :                :      * Look for files in the output dir first, consistent with a vpath search.
                                 43                 :                :      * This is mainly to create more reasonable error messages if the file is
                                 44                 :                :      * not found.  It also allows local test overrides when running pg_regress
                                 45                 :                :      * outside of the source tree.
                                 46                 :                :      */
                                 47                 :            955 :     snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
                                 48                 :                :              outputdir, testname);
 5674 peter_e@gmx.net            49         [ +  - ]:            955 :     if (!file_exists(infile))
                                 50                 :            955 :         snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
                                 51                 :                :                  inputdir, testname);
                                 52                 :                : 
 6151 magnus@hagander.net        53                 :            955 :     snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
                                 54                 :                :              outputdir, testname);
                                 55                 :                : 
                                 56                 :            955 :     snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
                                 57                 :                :              expecteddir, testname);
 5674 peter_e@gmx.net            58         [ +  + ]:            955 :     if (!file_exists(expectfile))
                                 59                 :            446 :         snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
                                 60                 :                :                  inputdir, testname);
                                 61                 :                : 
 6151 magnus@hagander.net        62                 :            955 :     add_stringlist_item(resultfiles, outfile);
                                 63                 :            955 :     add_stringlist_item(expectfiles, expectfile);
                                 64                 :                : 
   63 peter@eisentraut.org       65                 :GNC         955 :     initStringInfo(&psql_cmd);
                                 66                 :                : 
 4830 rhaas@postgresql.org       67         [ -  + ]:CBC         955 :     if (launcher)
   63 peter@eisentraut.org       68                 :UNC           0 :         appendStringInfo(&psql_cmd, "%s ", launcher);
                                 69                 :                : 
                                 70                 :                :     /*
                                 71                 :                :      * Use HIDE_TABLEAM to hide different AMs to allow to use regression tests
                                 72                 :                :      * against different AMs without unnecessary differences.
                                 73                 :                :      */
                                 74                 :              0 :     appendStringInfo(&psql_cmd,
                                 75                 :                :                      "\"%s%spsql\" -X -a -q -d \"%s\" %s < \"%s\" > \"%s\" 2>&1",
   63 peter@eisentraut.org       76         [ -  + ]:GNC         955 :                      bindir ? bindir : "",
                                 77                 :            955 :                      bindir ? "/" : "",
                                 78         [ -  + ]:            955 :                      dblist->str,
                                 79                 :                :                      "-v HIDE_TABLEAM=on -v HIDE_TOAST_COMPRESSION=on",
                                 80                 :                :                      infile,
                                 81                 :                :                      outfile);
                                 82                 :                : 
 1201 tgl@sss.pgh.pa.us          83                 :CBC         955 :     appnameenv = psprintf("pg_regress/%s", testname);
                                 84                 :            955 :     setenv("PGAPPNAME", appnameenv, 1);
                                 85                 :            955 :     free(appnameenv);
                                 86                 :                : 
   63 peter@eisentraut.org       87                 :GNC         955 :     pid = spawn_process(psql_cmd.data);
                                 88                 :                : 
 6151 magnus@hagander.net        89         [ -  + ]:CBC         955 :     if (pid == INVALID_PID)
                                 90                 :                :     {
 6151 magnus@hagander.net        91                 :UBC           0 :         fprintf(stderr, _("could not start process for test %s\n"),
                                 92                 :                :                 testname);
 4486 peter_e@gmx.net            93                 :              0 :         exit(2);
                                 94                 :                :     }
                                 95                 :                : 
 2753 peter_e@gmx.net            96                 :CBC         955 :     unsetenv("PGAPPNAME");
                                 97                 :                : 
   63 peter@eisentraut.org       98                 :GNC         955 :     pfree(psql_cmd.data);
                                 99                 :                : 
 6151 magnus@hagander.net       100                 :CBC         955 :     return pid;
                                101                 :                : }
                                102                 :                : 
                                103                 :                : static void
 3810 rhaas@postgresql.org      104                 :            345 : psql_init(int argc, char **argv)
                                105                 :                : {
                                106                 :                :     /* set default regression database name */
 6151 magnus@hagander.net       107                 :            345 :     add_stringlist_item(&dblist, "regression");
                                108                 :            345 : }
                                109                 :                : 
                                110                 :                : int
                                111                 :            345 : main(int argc, char *argv[])
                                112                 :                : {
 1189 tgl@sss.pgh.pa.us         113                 :            345 :     return regression_main(argc, argv,
                                114                 :                :                            psql_init,
                                115                 :                :                            psql_start_test,
                                116                 :                :                            NULL /* no postfunc needed */ );
                                117                 :                : }
        

Generated by: LCOV version 2.1-beta2-3-g6141622