summaryrefslogtreecommitdiff
path: root/src/test/isolation/isolationtester.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-06-17 11:57:44 +0900
committerMichael Paquier <michael@paquier.xyz>2021-06-17 11:57:44 +0900
commit484c81bf7765862a02a2866466b140a097e36c8c (patch)
tree9c46d8d7800887b7663a88c6c9722b1e1751c01d /src/test/isolation/isolationtester.c
parentb7cd5c5b02fa38c2f2ae9a0a3642c46e625e1b97 (diff)
Detect unused steps in isolation specs and do some cleanup
This is useful for developers to find out if an isolation spec is over-engineered or if it needs more work by warning at the end of a test run if a step is not used, generating a failure with extra diffs. While on it, clean up all the specs which include steps not used in any permutations to simplify them. This is a backpatch of 989d23b and 06fdc4e, as it is becoming useful to make all the branches consistent for an upcoming patch that will improve the output generated by isolationtester. Author: Michael Paquier Reviewed-by: Asim Praveen, Melanie Plageman Discussion: https://postgr.es/m/20190819080820.GG18166@paquier.xyz Discussion: https://postgr.es/m/794820.1623872009@sss.pgh.pa.us Backpatch-through: 9.6
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r--src/test/isolation/isolationtester.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c
index b801880da90..7b916a94230 100644
--- a/src/test/isolation/isolationtester.c
+++ b/src/test/isolation/isolationtester.c
@@ -90,7 +90,7 @@ main(int argc, char **argv)
puts("isolationtester (PostgreSQL) " PG_VERSION);
exit(0);
default:
- fprintf(stderr, "Usage: isolationtester [-n] [CONNINFO]\n");
+ fprintf(stderr, "Usage: isolationtester [CONNINFO]\n");
return EXIT_FAILURE;
}
}
@@ -254,10 +254,23 @@ static int *piles;
static void
run_testspec(TestSpec *testspec)
{
+ int i;
+
if (testspec->permutations)
run_named_permutations(testspec);
else
run_all_permutations(testspec);
+
+ /*
+ * Verify that all steps have been used, complaining about anything
+ * defined but not used.
+ */
+ for (i = 0; i < testspec->nallsteps; i++)
+ {
+ if (!testspec->allsteps[i]->used)
+ fprintf(stderr, "unused step name: %s\n",
+ testspec->allsteps[i]->name);
+ }
}
/*
@@ -457,7 +470,11 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
printf("\nstarting permutation:");
for (i = 0; i < nsteps; i++)
+ {
+ /* Track the permutation as in-use */
+ steps[i]->used = true;
printf(" %s", steps[i]->name);
+ }
printf("\n");
/* Perform setup */