LCOV - differential code coverage report
Current view: top level - src/test/isolation - specparse.y (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage HEAD vs 15 Lines: 95.9 % 98 94 4 94
Current Date: 2023-04-08 15:15:32 Functions: - 0 0
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : %{
       2                 : /*-------------------------------------------------------------------------
       3                 :  *
       4                 :  * specparse.y
       5                 :  *    bison grammar for the isolation test file format
       6                 :  *
       7                 :  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
       8                 :  * Portions Copyright (c) 1994, Regents of the University of California
       9                 :  *
      10                 :  *-------------------------------------------------------------------------
      11                 :  */
      12                 : 
      13                 : #include "postgres_fe.h"
      14                 : 
      15                 : #include "isolationtester.h"
      16                 : 
      17                 : 
      18                 : TestSpec        parseresult;            /* result of parsing is left here */
      19                 : 
      20                 : %}
      21                 : 
      22                 : %expect 0
      23                 : %name-prefix="spec_yy"
      24                 : 
      25                 : %union
      26                 : {
      27                 :     char       *str;
      28                 :     int         integer;
      29                 :     Session    *session;
      30                 :     Step       *step;
      31                 :     Permutation *permutation;
      32                 :     PermutationStep *permutationstep;
      33                 :     PermutationStepBlocker *blocker;
      34                 :     struct
      35                 :     {
      36                 :         void  **elements;
      37                 :         int     nelements;
      38                 :     }           ptr_list;
      39                 : }
      40                 : 
      41                 : %type <ptr_list> setup_list
      42                 : %type <str>  opt_setup opt_teardown
      43                 : %type <str> setup
      44                 : %type <ptr_list> step_list session_list permutation_list opt_permutation_list
      45                 : %type <ptr_list> permutation_step_list blocker_list
      46                 : %type <session> session
      47                 : %type <step> step
      48                 : %type <permutation> permutation
      49                 : %type <permutationstep> permutation_step
      50                 : %type <blocker> blocker
      51                 : 
      52                 : %token <str> sqlblock identifier
      53                 : %token <integer> INTEGER
      54                 : %token NOTICES PERMUTATION SESSION SETUP STEP TEARDOWN TEST
      55                 : 
      56                 : %%
      57                 : 
      58                 : TestSpec:
      59                 :             setup_list
      60                 :             opt_teardown
      61                 :             session_list
      62                 :             opt_permutation_list
      63                 :             {
      64 CBC         131 :                 parseresult.setupsqls = (char **) $1.elements;
      65             131 :                 parseresult.nsetupsqls = $1.nelements;
      66             131 :                 parseresult.teardownsql = $2;
      67             131 :                 parseresult.sessions = (Session **) $3.elements;
      68             131 :                 parseresult.nsessions = $3.nelements;
      69             131 :                 parseresult.permutations = (Permutation **) $4.elements;
      70             131 :                 parseresult.npermutations = $4.nelements;
      71                 :             }
      72                 :         ;
      73                 : 
      74                 : setup_list:
      75                 :             /* EMPTY */
      76                 :             {
      77             131 :                 $$.elements = NULL;
      78             131 :                 $$.nelements = 0;
      79                 :             }
      80                 :             | setup_list setup
      81                 :             {
      82             270 :                 $$.elements = pg_realloc($1.elements,
      83             135 :                                          ($1.nelements + 1) * sizeof(void *));
      84             135 :                 $$.elements[$1.nelements] = $2;
      85             135 :                 $$.nelements = $1.nelements + 1;
      86                 :             }
      87                 :         ;
      88                 : 
      89                 : opt_setup:
      90             124 :             /* EMPTY */         { $$ = NULL; }
      91             196 :             | setup             { $$ = $1; }
      92                 :         ;
      93                 : 
      94                 : setup:
      95             331 :             SETUP sqlblock      { $$ = $2; }
      96                 :         ;
      97                 : 
      98                 : opt_teardown:
      99             306 :             /* EMPTY */         { $$ = NULL; }
     100             145 :             | TEARDOWN sqlblock { $$ = $2; }
     101                 :         ;
     102                 : 
     103                 : session_list:
     104                 :             session_list session
     105                 :             {
     106             378 :                 $$.elements = pg_realloc($1.elements,
     107             189 :                                          ($1.nelements + 1) * sizeof(void *));
     108             189 :                 $$.elements[$1.nelements] = $2;
     109             189 :                 $$.nelements = $1.nelements + 1;
     110                 :             }
     111                 :             | session
     112                 :             {
     113             131 :                 $$.nelements = 1;
     114             131 :                 $$.elements = pg_malloc(sizeof(void *));
     115             131 :                 $$.elements[0] = $1;
     116                 :             }
     117                 :         ;
     118                 : 
     119                 : session:
     120                 :             SESSION identifier opt_setup step_list opt_teardown
     121                 :             {
     122             320 :                 $$ = pg_malloc(sizeof(Session));
     123             320 :                 $$->name = $2;
     124             320 :                 $$->setupsql = $3;
     125             320 :                 $$->steps = (Step **) $4.elements;
     126             320 :                 $$->nsteps = $4.nelements;
     127             320 :                 $$->teardownsql = $5;
     128                 :             }
     129                 :         ;
     130                 : 
     131                 : step_list:
     132                 :             step_list step
     133                 :             {
     134            2000 :                 $$.elements = pg_realloc($1.elements,
     135            1000 :                                          ($1.nelements + 1) * sizeof(void *));
     136            1000 :                 $$.elements[$1.nelements] = $2;
     137            1000 :                 $$.nelements = $1.nelements + 1;
     138                 :             }
     139                 :             | step
     140                 :             {
     141             320 :                 $$.nelements = 1;
     142             320 :                 $$.elements = pg_malloc(sizeof(void *));
     143             320 :                 $$.elements[0] = $1;
     144                 :             }
     145                 :         ;
     146                 : 
     147                 : 
     148                 : step:
     149                 :             STEP identifier sqlblock
     150                 :             {
     151            1320 :                 $$ = pg_malloc(sizeof(Step));
     152            1320 :                 $$->name = $2;
     153            1320 :                 $$->sql = $3;
     154            1320 :                 $$->session = -1; /* until filled */
     155            1320 :                 $$->used = false;
     156                 :             }
     157                 :         ;
     158                 : 
     159                 : 
     160                 : opt_permutation_list:
     161                 :             permutation_list
     162                 :             {
     163             117 :                 $$ = $1;
     164                 :             }
     165                 :             | /* EMPTY */
     166                 :             {
     167              14 :                 $$.elements = NULL;
     168              14 :                 $$.nelements = 0;
     169                 :             }
     170                 : 
     171                 : permutation_list:
     172                 :             permutation_list permutation
     173                 :             {
     174            2084 :                 $$.elements = pg_realloc($1.elements,
     175            1042 :                                          ($1.nelements + 1) * sizeof(void *));
     176            1042 :                 $$.elements[$1.nelements] = $2;
     177            1042 :                 $$.nelements = $1.nelements + 1;
     178                 :             }
     179                 :             | permutation
     180                 :             {
     181             117 :                 $$.nelements = 1;
     182             117 :                 $$.elements = pg_malloc(sizeof(void *));
     183             117 :                 $$.elements[0] = $1;
     184                 :             }
     185                 :         ;
     186                 : 
     187                 : 
     188                 : permutation:
     189                 :             PERMUTATION permutation_step_list
     190                 :             {
     191            1159 :                 $$ = pg_malloc(sizeof(Permutation));
     192            1159 :                 $$->nsteps = $2.nelements;
     193            1159 :                 $$->steps = (PermutationStep **) $2.elements;
     194                 :             }
     195                 :         ;
     196                 : 
     197                 : permutation_step_list:
     198                 :             permutation_step_list permutation_step
     199                 :             {
     200           14950 :                 $$.elements = pg_realloc($1.elements,
     201            7475 :                                          ($1.nelements + 1) * sizeof(void *));
     202            7475 :                 $$.elements[$1.nelements] = $2;
     203            7475 :                 $$.nelements = $1.nelements + 1;
     204                 :             }
     205                 :             | permutation_step
     206                 :             {
     207            1159 :                 $$.nelements = 1;
     208            1159 :                 $$.elements = pg_malloc(sizeof(void *));
     209            1159 :                 $$.elements[0] = $1;
     210                 :             }
     211                 :         ;
     212                 : 
     213                 : permutation_step:
     214                 :             identifier
     215                 :             {
     216            8586 :                 $$ = pg_malloc(sizeof(PermutationStep));
     217            8586 :                 $$->name = $1;
     218            8586 :                 $$->blockers = NULL;
     219            8586 :                 $$->nblockers = 0;
     220            8586 :                 $$->step = NULL;
     221                 :             }
     222                 :             | identifier '(' blocker_list ')'
     223                 :             {
     224              48 :                 $$ = pg_malloc(sizeof(PermutationStep));
     225              48 :                 $$->name = $1;
     226              48 :                 $$->blockers = (PermutationStepBlocker **) $3.elements;
     227              48 :                 $$->nblockers = $3.nelements;
     228              48 :                 $$->step = NULL;
     229                 :             }
     230                 :         ;
     231                 : 
     232                 : blocker_list:
     233                 :             blocker_list ',' blocker
     234                 :             {
     235 UBC           0 :                 $$.elements = pg_realloc($1.elements,
     236               0 :                                          ($1.nelements + 1) * sizeof(void *));
     237               0 :                 $$.elements[$1.nelements] = $3;
     238               0 :                 $$.nelements = $1.nelements + 1;
     239                 :             }
     240                 :             | blocker
     241                 :             {
     242 CBC          48 :                 $$.nelements = 1;
     243              48 :                 $$.elements = pg_malloc(sizeof(void *));
     244              48 :                 $$.elements[0] = $1;
     245                 :             }
     246                 :         ;
     247                 : 
     248                 : blocker:
     249                 :             identifier
     250                 :             {
     251              36 :                 $$ = pg_malloc(sizeof(PermutationStepBlocker));
     252              36 :                 $$->stepname = $1;
     253              36 :                 $$->blocktype = PSB_OTHER_STEP;
     254              36 :                 $$->num_notices = -1;
     255              36 :                 $$->step = NULL;
     256              36 :                 $$->target_notices = -1;
     257                 :             }
     258                 :             | identifier NOTICES INTEGER
     259                 :             {
     260               1 :                 $$ = pg_malloc(sizeof(PermutationStepBlocker));
     261               1 :                 $$->stepname = $1;
     262               1 :                 $$->blocktype = PSB_NUM_NOTICES;
     263               1 :                 $$->num_notices = $3;
     264               1 :                 $$->step = NULL;
     265               1 :                 $$->target_notices = -1;
     266                 :             }
     267                 :             | '*'
     268                 :             {
     269              11 :                 $$ = pg_malloc(sizeof(PermutationStepBlocker));
     270              11 :                 $$->stepname = NULL;
     271              11 :                 $$->blocktype = PSB_ONCE;
     272              11 :                 $$->num_notices = -1;
     273              11 :                 $$->step = NULL;
     274              11 :                 $$->target_notices = -1;
     275                 :             }
     276                 :         ;
     277                 : 
     278                 : %%
        

Generated by: LCOV version v1.16-55-g56c0a2a