@@ -78,6 +78,7 @@ char *launcher = NULL;
7878static _stringlist * loadlanguage = NULL ;
7979static _stringlist * loadextension = NULL ;
8080static int max_connections = 0 ;
81+ static int max_concurrent_tests = 0 ;
8182static char * encoding = NULL ;
8283static _stringlist * schedulelist = NULL ;
8384static _stringlist * extra_tests = NULL ;
@@ -1592,9 +1593,9 @@ run_schedule(const char *schedule, test_function tfunc)
15921593 FILE * scf ;
15931594 int line_num = 0 ;
15941595
1595- memset (resultfiles , 0 , sizeof (_stringlist * ) * MAX_PARALLEL_TESTS );
1596- memset (expectfiles , 0 , sizeof (_stringlist * ) * MAX_PARALLEL_TESTS );
1597- memset (tags , 0 , sizeof (_stringlist * ) * MAX_PARALLEL_TESTS );
1596+ memset (resultfiles , 0 , sizeof (resultfiles ) );
1597+ memset (expectfiles , 0 , sizeof (expectfiles ) );
1598+ memset (tags , 0 , sizeof (tags ) );
15981599
15991600 scf = fopen (schedule , "r" );
16001601 if (!scf )
@@ -1614,6 +1615,7 @@ run_schedule(const char *schedule, test_function tfunc)
16141615
16151616 line_num ++ ;
16161617
1618+ /* clear out string lists left over from previous line */
16171619 for (i = 0 ; i < MAX_PARALLEL_TESTS ; i ++ )
16181620 {
16191621 if (resultfiles [i ] == NULL )
@@ -1667,8 +1669,8 @@ run_schedule(const char *schedule, test_function tfunc)
16671669 if (num_tests >= MAX_PARALLEL_TESTS )
16681670 {
16691671 /* can't print scbuf here, it's already been trashed */
1670- fprintf (stderr , _ ("too many parallel tests in schedule file \"%s\", line %d\n" ),
1671- schedule , line_num );
1672+ fprintf (stderr , _ ("too many parallel tests (more than %d) in schedule file \"%s\" line %d\n" ),
1673+ MAX_PARALLEL_TESTS , schedule , line_num );
16721674 exit (2 );
16731675 }
16741676 tests [num_tests ] = c ;
@@ -1691,6 +1693,13 @@ run_schedule(const char *schedule, test_function tfunc)
16911693 wait_for_tests (pids , statuses , NULL , 1 );
16921694 /* status line is finished below */
16931695 }
1696+ else if (max_concurrent_tests > 0 && max_concurrent_tests < num_tests )
1697+ {
1698+ /* can't print scbuf here, it's already been trashed */
1699+ fprintf (stderr , _ ("too many parallel tests (more than %d) in schedule file \"%s\" line %d\n" ),
1700+ max_concurrent_tests , schedule , line_num );
1701+ exit (2 );
1702+ }
16941703 else if (max_connections > 0 && max_connections < num_tests )
16951704 {
16961705 int oldest = 0 ;
@@ -1999,6 +2008,8 @@ help(void)
19992008 printf (_ (" tests; can appear multiple times\n" ));
20002009 printf (_ (" --max-connections=N maximum number of concurrent connections\n" ));
20012010 printf (_ (" (default is 0, meaning unlimited)\n" ));
2011+ printf (_ (" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n" ));
2012+ printf (_ (" (default is 0, meaning unlimited)\n" ));
20022013 printf (_ (" --outputdir=DIR place output files in DIR (default \".\")\n" ));
20032014 printf (_ (" --schedule=FILE use test ordering schedule from FILE\n" ));
20042015 printf (_ (" (can be used multiple times to concatenate)\n" ));
@@ -2048,6 +2059,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
20482059 {"launcher" , required_argument , NULL , 21 },
20492060 {"load-extension" , required_argument , NULL , 22 },
20502061 {"config-auth" , required_argument , NULL , 24 },
2062+ {"max-concurrent-tests" , required_argument , NULL , 25 },
20512063 {NULL , 0 , NULL , 0 }
20522064 };
20532065
@@ -2161,6 +2173,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
21612173 case 24 :
21622174 config_auth_datadir = pg_strdup (optarg );
21632175 break ;
2176+ case 25 :
2177+ max_concurrent_tests = atoi (optarg );
2178+ break ;
21642179 default :
21652180 /* getopt_long already emitted a complaint */
21662181 fprintf (stderr , _ ("\nTry \"%s -h\" for more information.\n" ),
0 commit comments