Commit 43b4a168 authored by Robert Haas's avatar Robert Haas

Reject isolation test specifications with duplicate step names.

alter-table-1.spec has such a case, so change one instance of step
rx1 to rx3 instead.
parent ec79978d
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -66,10 +66,14 @@ main(int argc, char **argv) ...@@ -66,10 +66,14 @@ main(int argc, char **argv)
{ {
const char *conninfo; const char *conninfo;
TestSpec *testspec; TestSpec *testspec;
int i; int i,
j;
int n;
PGresult *res; PGresult *res;
PQExpBufferData wait_query; PQExpBufferData wait_query;
int opt; int opt;
int nallsteps;
Step **allsteps;
while ((opt = getopt(argc, argv, "nV")) != -1) while ((opt = getopt(argc, argv, "nV")) != -1)
{ {
...@@ -109,6 +113,36 @@ main(int argc, char **argv) ...@@ -109,6 +113,36 @@ main(int argc, char **argv)
spec_yyparse(); spec_yyparse();
testspec = &parseresult; testspec = &parseresult;
/* Create a lookup table of all steps. */
nallsteps = 0;
for (i = 0; i < testspec->nsessions; i++)
nallsteps += testspec->sessions[i]->nsteps;
allsteps = malloc(nallsteps * sizeof(Step *));
n = 0;
for (i = 0; i < testspec->nsessions; i++)
{
for (j = 0; j < testspec->sessions[i]->nsteps; j++)
allsteps[n++] = testspec->sessions[i]->steps[j];
}
qsort(allsteps, nallsteps, sizeof(Step *), &step_qsort_cmp);
testspec->nallsteps = nallsteps;
testspec->allsteps = allsteps;
/* Verify that all step names are unique */
for (i = 1; i < testspec->nallsteps; i++)
{
if (strcmp(testspec->allsteps[i - 1]->name,
testspec->allsteps[i]->name) == 0)
{
fprintf(stderr, "duplicate step name: %s\n",
testspec->allsteps[i]->name);
exit_nicely();
}
}
/* /*
* In dry-run mode, just print the permutations that would be run, and * In dry-run mode, just print the permutations that would be run, and
* exit. * exit.
...@@ -367,25 +401,6 @@ run_named_permutations(TestSpec *testspec) ...@@ -367,25 +401,6 @@ run_named_permutations(TestSpec *testspec)
{ {
int i, int i,
j; j;
int n;
int nallsteps;
Step **allsteps;
/* First create a lookup table of all steps */
nallsteps = 0;
for (i = 0; i < testspec->nsessions; i++)
nallsteps += testspec->sessions[i]->nsteps;
allsteps = malloc(nallsteps * sizeof(Step *));
n = 0;
for (i = 0; i < testspec->nsessions; i++)
{
for (j = 0; j < testspec->sessions[i]->nsteps; j++)
allsteps[n++] = testspec->sessions[i]->steps[j];
}
qsort(allsteps, nallsteps, sizeof(Step *), &step_qsort_cmp);
for (i = 0; i < testspec->npermutations; i++) for (i = 0; i < testspec->npermutations; i++)
{ {
...@@ -397,8 +412,10 @@ run_named_permutations(TestSpec *testspec) ...@@ -397,8 +412,10 @@ run_named_permutations(TestSpec *testspec)
/* Find all the named steps using the lookup table */ /* Find all the named steps using the lookup table */
for (j = 0; j < p->nsteps; j++) for (j = 0; j < p->nsteps; j++)
{ {
Step **this = (Step **) bsearch(p->stepnames[j], allsteps, Step **this = (Step **) bsearch(p->stepnames[j],
nallsteps, sizeof(Step *), testspec->allsteps,
testspec->nallsteps,
sizeof(Step *),
&step_bsearch_cmp); &step_bsearch_cmp);
if (this == NULL) if (this == NULL)
......
...@@ -49,6 +49,8 @@ typedef struct ...@@ -49,6 +49,8 @@ typedef struct
int nsessions; int nsessions;
Permutation **permutations; Permutation **permutations;
int npermutations; int npermutations;
Step **allsteps;
int nallsteps;
} TestSpec; } TestSpec;
extern TestSpec parseresult; extern TestSpec parseresult;
......
...@@ -28,5 +28,5 @@ session "s2" ...@@ -28,5 +28,5 @@ session "s2"
setup { BEGIN; } setup { BEGIN; }
step "rx1" { SELECT * FROM b WHERE a_id = 1 LIMIT 1; } step "rx1" { SELECT * FROM b WHERE a_id = 1 LIMIT 1; }
step "wx" { INSERT INTO b VALUES (0); } step "wx" { INSERT INTO b VALUES (0); }
step "rx1" { SELECT * FROM b WHERE a_id = 3 LIMIT 3; } step "rx3" { SELECT * FROM b WHERE a_id = 3 LIMIT 3; }
step "c2" { COMMIT; } step "c2" { COMMIT; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment