Merge lp:~gl-az/percona-xtrabackup/2.1-testrun-summary into lp:percona-xtrabackup/2.1

Proposed by George Ormond Lorch III
Status: Rejected
Rejected by: Alexey Kopytov
Proposed branch: lp:~gl-az/percona-xtrabackup/2.1-testrun-summary
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 187 lines (+62/-14)
2 files modified
test/testrun.c (+49/-11)
test/testrun.sh (+13/-3)
To merge this branch: bzr merge lp:~gl-az/percona-xtrabackup/2.1-testrun-summary
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Registry Administrators Pending
Review via email: mp+167697@code.launchpad.net

This proposal supersedes a proposal from 2013-06-04.

Description of the change

Fixed issue in testrun.c where specifying testsuite would find the tests in the corredt directory but would still try to execute them out of ./t

Added test status tracking and summary report at end of test run cycle to make it wasy to see what passed, skipped and failed at a glance, similar to MTR.

Changed testrun.sh slightly to return same code out of testrun.sh as the test that was executed when only a single test was run.

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Same comments as for the 2.0 MP.

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Same comments as for 2.0 MP.

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) :
review: Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Unmerged revisions

610. By George Ormond Lorch III

Fixed issue in testrun.c where specifying testsuite would find the tests in the corredt directory but would still try to execute them out of ./t

Added test status tracking and summary report at end of test run cycle to make it wasy to see what passed, skipped and failed at a glance, similar to MTR.

Changed testrun.sh slightly to return same code out of testrun.sh as the test that was executed when only a single test was run.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'test/testrun.c'
--- test/testrun.c 2013-01-11 13:00:50 +0000
+++ test/testrun.c 2013-06-06 05:54:39 +0000
@@ -41,6 +41,7 @@
41 char *buf;41 char *buf;
42 size_t end_of_buf;42 size_t end_of_buf;
43 size_t bufsz;43 size_t bufsz;
44 int status;
44};45};
4546
46pid_t *childpid;47pid_t *childpid;
@@ -96,6 +97,7 @@
96 (*cases)[i].buf= NULL;97 (*cases)[i].buf= NULL;
97 (*cases)[i].end_of_buf= 0;98 (*cases)[i].end_of_buf= 0;
98 (*cases)[i].bufsz= 0;99 (*cases)[i].bufsz= 0;
100 (*cases)[i].status= 0;
99 free(namelist[i]);101 free(namelist[i]);
100 }102 }
101103
@@ -113,7 +115,41 @@
113 free(cases);115 free(cases);
114}116}
115117
116static int run_testcase_in_child(int nr, struct testcase *t, pid_t *cpid, const char* xbtarget)118static void report_status(struct testcase *cases, int n)
119{
120 int i;
121 int failed=0;
122 int skipped=0;
123 for (i=0; i<n; i++)
124 if (WEXITSTATUS(cases[i].status) != 0)
125 if (WEXITSTATUS(cases[i].status) == 200)
126 skipped++;
127 else
128 failed++;
129
130 printf("SUMMARY: %d run, %d successful, %d skipped, %d failed\n", n, n - failed - skipped, skipped, failed);
131 if (skipped)
132 {
133 printf("Skipped cases:");
134 for (i=0; i<n; i++)
135 if (WEXITSTATUS(cases[i].status) == 200)
136 printf(" %s", cases[i].name);
137 printf("\n");
138 }
139
140 if (failed)
141 {
142 printf("Failing cases:");
143 for (i=0; i<n; i++)
144 if (WEXITSTATUS(cases[i].status) != 0 && WEXITSTATUS(cases[i].status) != 200)
145 printf(" %s", cases[i].name);
146 printf("\n");
147 }
148}
149
150static int run_testcase_in_child(const char* suitedir, int nr,
151 struct testcase *t, pid_t *cpid,
152 const char* xbtarget)
117{153{
118 int fd[2];154 int fd[2];
119155
@@ -132,7 +168,7 @@
132 close(fd[0]);168 close(fd[0]);
133169
134 char tname[500];170 char tname[500];
135 snprintf(tname, sizeof(tname), "t/%s",t->name);171 snprintf(tname, sizeof(tname), "%s/%s",suitedir, t->name);
136172
137 char basedir[PATH_MAX];173 char basedir[PATH_MAX];
138 char cwd[PATH_MAX];174 char cwd[PATH_MAX];
@@ -195,14 +231,14 @@
195 free(buf);231 free(buf);
196}232}
197233
198static void run_testcases(struct testcase *testcases, int nrcases,234static void run_testcases(const char* suitedir, struct testcase *testcases,
199 int njobs, int timeout, const char* xbtarget)235 int nrcases, int njobs, int timeout,
236 const char* xbtarget)
200{237{
201 int childfd[njobs];238 int childfd[njobs];
202 int nfds= 0;239 int nfds= 0;
203 int retval;240 int retval;
204 pid_t chpid[njobs];241 pid_t chpid[njobs];
205 int status;
206 int next_testcase= 0;242 int next_testcase= 0;
207 int i;243 int i;
208 fd_set rfds;244 fd_set rfds;
@@ -223,7 +259,7 @@
223 for(i=0; i<njobs; i++)259 for(i=0; i<njobs; i++)
224 {260 {
225 childtest[i]=next_testcase++;261 childtest[i]=next_testcase++;
226 childfd[i]= run_testcase_in_child(i, &testcases[childtest[i]], &childpid[i], xbtarget);262 childfd[i]= run_testcase_in_child(suitedir, i, &testcases[childtest[i]], &childpid[i], xbtarget);
227 }263 }
228264
229 fflush(stdout);265 fflush(stdout);
@@ -277,8 +313,8 @@
277 t->end_of_buf+= r;313 t->end_of_buf+= r;
278 } while(r>0);314 } while(r>0);
279315
280 pid_t waited= waitpid(childpid[i], &status, WNOHANG);316 pid_t waited= waitpid(childpid[i], &testcases[childtest[i]].status, WNOHANG);
281 if (!(WIFEXITED(status) || WIFSIGNALED(status)))317 if (!(WIFEXITED(testcases[childtest[i]].status) || WIFSIGNALED(testcases[childtest[i]].status)))
282 continue;318 continue;
283319
284 if (waited != childpid[i])320 if (waited != childpid[i])
@@ -289,14 +325,14 @@
289325
290 close(childfd[i]);326 close(childfd[i]);
291 printf("[%d] completed %s status %d\n",327 printf("[%d] completed %s status %d\n",
292 i, testcases[childtest[i]].name, WEXITSTATUS(status));328 i, testcases[childtest[i]].name, WEXITSTATUS(testcases[childtest[i]].status));
293 childfd[i]=-1;329 childfd[i]=-1;
294 nchildren--;330 nchildren--;
295331
296 if (next_testcase < nrcases)332 if (next_testcase < nrcases)
297 {333 {
298 childtest[i]=next_testcase++;334 childtest[i]=next_testcase++;
299 childfd[i]= run_testcase_in_child(i, &testcases[childtest[i]], &childpid[i], xbtarget);335 childfd[i]= run_testcase_in_child(suitedir, i, &testcases[childtest[i]], &childpid[i], xbtarget);
300 nfds= (childfd[i] > nfds)? childfd[i] : nfds;336 nfds= (childfd[i] > nfds)? childfd[i] : nfds;
301 nchildren++;337 nchildren++;
302 }338 }
@@ -397,7 +433,9 @@
397433
398 printf("Found %d testcases\n", nrcases);434 printf("Found %d testcases\n", nrcases);
399435
400 run_testcases(testcases, nrcases, njobs, timeout, xbtarget);436 run_testcases(suitedir, testcases, nrcases, njobs, timeout, xbtarget);
437
438 report_status(testcases, nrcases);
401439
402 free_testcases(testcases, nrcases);440 free_testcases(testcases, nrcases);
403441
404442
=== modified file 'test/testrun.sh'
--- test/testrun.sh 2013-05-17 11:07:26 +0000
+++ test/testrun.sh 2013-06-06 05:54:39 +0000
@@ -281,6 +281,7 @@
281281
282failed_count=0282failed_count=0
283failed_tests=283failed_tests=
284skipped_count=0
284total_count=0285total_count=0
285286
286export OUTFILE="$PWD/results/setup"287export OUTFILE="$PWD/results/setup"
@@ -334,6 +335,7 @@
334 test -r $SKIPPED_REASON && sreason=`cat $SKIPPED_REASON`335 test -r $SKIPPED_REASON && sreason=`cat $SKIPPED_REASON`
335 echo "[skipped] $sreason"336 echo "[skipped] $sreason"
336 subunit_skip_test $t >> $SUBUNIT_OUT337 subunit_skip_test $t >> $SUBUNIT_OUT
338 skipped_count=`expr $skipped_count + 1`
337 else339 else
338 echo "[failed]"340 echo "[failed]"
339341
@@ -345,7 +347,7 @@
345347
346 failed_count=$((failed_count+1))348 failed_count=$((failed_count+1))
347 failed_tests="$failed_tests $t"349 failed_tests="$failed_tests $t"
348 result=1350 result=$rc
349 if [ -z "$force" ]351 if [ -z "$force" ]
350 then352 then
351 break;353 break;
@@ -356,10 +358,18 @@
356echo "========================================================================"358echo "========================================================================"
357echo359echo
358360
359if [ $result -eq 1 ]361if [ $result -ne 0 ]
360then362then
361 echo363 echo
362 echo "$failed_count/$total_count tests have failed: $failed_tests"364 echo "$failed_count/$total_count tests have failed: $failed_tests"
363 echo "See results/ for detailed output"365 echo "See results/ for detailed output"
364 exit -1366 if [ $total_count -gt 1 ]
367 then
368 exit -1
369 else
370 exit $result
371 fi
372elif [ $total_count -eq 1 ] && [ $skipped_count -eq 1 ]
373then
374 exit $SKIPPED_EXIT_CODE
365fi375fi

Subscribers

People subscribed via source and target branches