LCOV - differential code coverage report
Current view: top level - src/test/isolation - isolation_main.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DUB DCB
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 82.1 % 39 32 1 6 6 26 6 6
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 3 3 1 2
Baseline: 16@8cea358b128 Branches: 57.1 % 14 8 1 5 1 7
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: 83.3 % 6 5 1 5
(240..) days: 81.8 % 33 27 6 1 26
Function coverage date bins:
(240..) days: 100.0 % 3 3 1 2
Branch coverage date bins:
(240..) days: 57.1 % 14 8 1 5 1 7

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * isolation_main --- pg_regress test launcher for isolation tests
                                  4                 :                :  *
                                  5                 :                :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
                                  6                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  7                 :                :  *
                                  8                 :                :  * src/test/isolation/isolation_main.c
                                  9                 :                :  *
                                 10                 :                :  *-------------------------------------------------------------------------
                                 11                 :                :  */
                                 12                 :                : 
                                 13                 :                : #include "postgres_fe.h"
                                 14                 :                : 
                                 15                 :                : #include "lib/stringinfo.h"
                                 16                 :                : #include "pg_regress.h"
                                 17                 :                : 
                                 18                 :                : char        saved_argv0[MAXPGPATH];
                                 19                 :                : char        isolation_exec[MAXPGPATH];
                                 20                 :                : bool        looked_up_isolation_exec = false;
                                 21                 :                : 
                                 22                 :                : #define PG_ISOLATION_VERSIONSTR "isolationtester (PostgreSQL) " PG_VERSION "\n"
                                 23                 :                : 
                                 24                 :                : /*
                                 25                 :                :  * start an isolation tester process for specified file (including
                                 26                 :                :  * redirection), and return process ID
                                 27                 :                :  */
                                 28                 :                : static PID_TYPE
 4815 heikki.linnakangas@i       29                 :CBC         132 : isolation_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                 :                :     /* need to do the path lookup here, check isolation_init() for details */
 3806 rhaas@postgresql.org       42         [ +  + ]:            132 :     if (!looked_up_isolation_exec)
                                 43                 :                :     {
                                 44                 :                :         /* look for isolationtester binary */
                                 45         [ -  + ]:              6 :         if (find_other_exec(saved_argv0, "isolationtester",
                                 46                 :                :                             PG_ISOLATION_VERSIONSTR, isolation_exec) != 0)
                                 47                 :                :         {
 3806 rhaas@postgresql.org       48                 :UBC           0 :             fprintf(stderr, _("could not find proper isolationtester binary\n"));
                                 49                 :              0 :             exit(2);
                                 50                 :                :         }
 3806 rhaas@postgresql.org       51                 :CBC           6 :         looked_up_isolation_exec = true;
                                 52                 :                :     }
                                 53                 :                : 
                                 54                 :                :     /*
                                 55                 :                :      * Look for files in the output dir first, consistent with a vpath search.
                                 56                 :                :      * This is mainly to create more reasonable error messages if the file is
                                 57                 :                :      * not found.  It also allows local test overrides when running pg_regress
                                 58                 :                :      * outside of the source tree.
                                 59                 :                :      */
 4815 heikki.linnakangas@i       60                 :            132 :     snprintf(infile, sizeof(infile), "%s/specs/%s.spec",
                                 61                 :                :              outputdir, testname);
                                 62         [ +  - ]:            132 :     if (!file_exists(infile))
                                 63                 :            132 :         snprintf(infile, sizeof(infile), "%s/specs/%s.spec",
                                 64                 :                :                  inputdir, testname);
                                 65                 :                : 
                                 66                 :            132 :     snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
                                 67                 :                :              outputdir, testname);
                                 68                 :                : 
                                 69                 :            132 :     snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
                                 70                 :                :              outputdir, testname);
                                 71         [ +  - ]:            132 :     if (!file_exists(expectfile))
                                 72                 :            132 :         snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
                                 73                 :                :                  inputdir, testname);
                                 74                 :                : 
                                 75                 :            132 :     add_stringlist_item(resultfiles, outfile);
                                 76                 :            132 :     add_stringlist_item(expectfiles, expectfile);
                                 77                 :                : 
   63 peter@eisentraut.org       78                 :GNC         132 :     initStringInfo(&psql_cmd);
                                 79                 :                : 
 4815 heikki.linnakangas@i       80         [ -  + ]:            132 :     if (launcher)
   63 peter@eisentraut.org       81                 :UNC           0 :         appendStringInfo(&psql_cmd, "%s ", launcher);
                                 82                 :                : 
   63 peter@eisentraut.org       83                 :GNC         132 :     appendStringInfo(&psql_cmd,
                                 84                 :                :                      "\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1",
                                 85                 :                :                      isolation_exec,
                                 86                 :            132 :                      dblist->str,
                                 87                 :                :                      infile,
                                 88                 :                :                      outfile);
                                 89                 :                : 
 1201 tgl@sss.pgh.pa.us          90                 :CBC         132 :     appnameenv = psprintf("isolation/%s", testname);
                                 91                 :            132 :     setenv("PGAPPNAME", appnameenv, 1);
                                 92                 :            132 :     free(appnameenv);
                                 93                 :                : 
   63 peter@eisentraut.org       94                 :GNC         132 :     pid = spawn_process(psql_cmd.data);
                                 95                 :                : 
 4815 heikki.linnakangas@i       96         [ -  + ]:CBC         132 :     if (pid == INVALID_PID)
                                 97                 :                :     {
 4815 heikki.linnakangas@i       98                 :UBC           0 :         fprintf(stderr, _("could not start process for test %s\n"),
                                 99                 :                :                 testname);
 4486 peter_e@gmx.net           100                 :              0 :         exit(2);
                                101                 :                :     }
                                102                 :                : 
 1692 tgl@sss.pgh.pa.us         103                 :CBC         132 :     unsetenv("PGAPPNAME");
                                104                 :                : 
   63 peter@eisentraut.org      105                 :GNC         132 :     pfree(psql_cmd.data);
                                106                 :                : 
 4815 heikki.linnakangas@i      107                 :CBC         132 :     return pid;
                                108                 :                : }
                                109                 :                : 
                                110                 :                : static void
 3810 rhaas@postgresql.org      111                 :              6 : isolation_init(int argc, char **argv)
                                112                 :                : {
                                113                 :                :     size_t      argv0_len;
                                114                 :                : 
                                115                 :                :     /*
                                116                 :                :      * We unfortunately cannot do the find_other_exec() lookup to find the
                                117                 :                :      * "isolationtester" binary here.  regression_main() calls the
                                118                 :                :      * initialization functions before parsing the commandline arguments and
                                119                 :                :      * thus hasn't changed the library search path at this point which in turn
                                120                 :                :      * can cause the "isolationtester -V" invocation that find_other_exec()
                                121                 :                :      * does to fail since it's linked to libpq.  So we instead copy argv[0]
                                122                 :                :      * and do the lookup the first time through isolation_start_test().
                                123                 :                :      */
 3803 kgrittn@postgresql.o      124                 :              6 :     argv0_len = strlcpy(saved_argv0, argv[0], MAXPGPATH);
                                125         [ -  + ]:              6 :     if (argv0_len >= MAXPGPATH)
                                126                 :                :     {
 2928 peter_e@gmx.net           127                 :UBC           0 :         fprintf(stderr, _("path for isolationtester executable is longer than %d bytes\n"),
                                128                 :                :                 (int) (MAXPGPATH - 1));
 3803 kgrittn@postgresql.o      129                 :              0 :         exit(2);
                                130                 :                :     }
                                131                 :                : 
                                132                 :                :     /* set default regression database name */
 2828 tgl@sss.pgh.pa.us         133                 :CBC           6 :     add_stringlist_item(&dblist, "isolation_regression");
 4815 heikki.linnakangas@i      134                 :              6 : }
                                135                 :                : 
                                136                 :                : int
                                137                 :              6 : main(int argc, char *argv[])
                                138                 :                : {
 1189 tgl@sss.pgh.pa.us         139                 :              6 :     return regression_main(argc, argv,
                                140                 :                :                            isolation_init,
                                141                 :                :                            isolation_start_test,
                                142                 :                :                            NULL /* no postfunc needed */ );
                                143                 :                : }
        

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