Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ed3605

Browse files
committed
Implement a dry-run mode for isolationtester
This mode prints out the permutations that would be run by the givenspec file, in the same format used by the permutation lines in specfiles. This helps in building new spec files.Author: Alexander Shulgin, with some tweaks by me
1 parent94cd0f1 commit7ed3605

File tree

1 file changed

+63
-10
lines changed

1 file changed

+63
-10
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ static PGconn **conns = NULL;
3535
staticconstchar**backend_pids=NULL;
3636
staticintnconns=0;
3737

38+
/* In dry run only output permutations to be run by the tester. */
39+
staticintdry_run= false;
40+
41+
staticvoidrun_testspec(TestSpec*testspec);
3842
staticvoidrun_all_permutations(TestSpec*testspec);
3943
staticvoidrun_all_permutations_recurse(TestSpec*testspec,intnsteps,
4044
Step**steps);
@@ -69,20 +73,46 @@ main(int argc, char **argv)
6973
inti;
7074
PGresult*res;
7175
PQExpBufferDatawait_query;
76+
intopt;
77+
78+
while ((opt=getopt(argc,argv,"n"))!=-1)
79+
{
80+
switch (opt)
81+
{
82+
case'n':
83+
dry_run= true;
84+
break;
85+
default:
86+
fprintf(stderr,"Usage: isolationtester [-n] [CONNINFO]\n");
87+
returnEXIT_FAILURE;
88+
}
89+
}
7290

7391
/*
74-
* If the user supplies a parameter on the command line, use it as the
75-
* conninfo string; otherwise default to setting dbname=postgres and using
76-
* environment variables or defaults for all other connection parameters.
92+
* If the user supplies a non-option parameter on the command line, use it
93+
* as the conninfo string; otherwise default to setting dbname=postgres and
94+
* using environment variables or defaults for all other connection
95+
* parameters.
7796
*/
78-
if (argc>1)
79-
conninfo=argv[1];
97+
if (argc>optind)
98+
conninfo=argv[optind];
8099
else
81100
conninfo="dbname = postgres";
82101

83102
/* Read the test spec from stdin */
84103
spec_yyparse();
85104
testspec=&parseresult;
105+
106+
/*
107+
* In dry-run mode, just print the permutations that would be run, and
108+
* exit.
109+
*/
110+
if (dry_run)
111+
{
112+
run_testspec(testspec);
113+
return0;
114+
}
115+
86116
printf("Parsed test spec with %d sessions\n",testspec->nsessions);
87117

88118
/*
@@ -240,10 +270,7 @@ main(int argc, char **argv)
240270
* Run the permutations specified in the spec, or all if none were
241271
* explicitly specified.
242272
*/
243-
if (testspec->permutations)
244-
run_named_permutations(testspec);
245-
else
246-
run_all_permutations(testspec);
273+
run_testspec(testspec);
247274

248275
/* Clean up and exit */
249276
for (i=0;i<nconns;i++)
@@ -253,6 +280,19 @@ main(int argc, char **argv)
253280

254281
staticint*piles;
255282

283+
/*
284+
* Run the permutations specified in the spec, or all if none were
285+
* explicitly specified.
286+
*/
287+
staticvoid
288+
run_testspec(TestSpec*testspec)
289+
{
290+
if (testspec->permutations)
291+
run_named_permutations(testspec);
292+
else
293+
run_all_permutations(testspec);
294+
}
295+
256296
/*
257297
* Run all permutations of the steps and sessions.
258298
*/
@@ -437,6 +477,19 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
437477
inti;
438478
Step*waiting=NULL;
439479

480+
/*
481+
* In dry run mode, just display the permutation in the same format used by
482+
* spec files, and return.
483+
*/
484+
if (dry_run)
485+
{
486+
printf("permutation");
487+
for (i=0;i<nsteps;i++)
488+
printf(" \"%s\"",steps[i]->name);
489+
printf("\n");
490+
return;
491+
}
492+
440493
printf("\nstarting permutation:");
441494
for (i=0;i<nsteps;i++)
442495
printf(" %s",steps[i]->name);
@@ -649,7 +702,7 @@ try_complete_step(Step *step, int flags)
649702
}
650703
/* Detail may contain xid values, so just show primary. */
651704
step->errormsg=malloc(5+
652-
strlen(PQresultErrorField(res,PG_DIAG_SEVERITY))+
705+
strlen(PQresultErrorField(res,PG_DIAG_SEVERITY))+
653706
strlen(PQresultErrorField(res,
654707
PG_DIAG_MESSAGE_PRIMARY)));
655708
sprintf(step->errormsg,"%s: %s",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp