+Mon Jul 7 11:02:56 BST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+ * tests/testutils.c: Allow OOM testing to be parallelized by
+ setting VIR_TEST_MP=1
+
Mon Jul 7 11:59:07 CEST 2008 Daniel Veillard <veillard@redhat.com>
* proxy/libvirt_proxy.c: fix a compilation problem without Xen
int n;
char *oomStr = NULL, *debugStr;
int oomCount;
-
+ int mp = 0;
+ pid_t *workers;
+ int worker = 0;
if ((debugStr = getenv("VIR_TEST_DEBUG")) != NULL) {
if (virStrToLong_ui(debugStr, NULL, 10, &testDebug) < 0)
testDebug = 0;
testOOM = 1;
}
+ if (getenv("VIR_TEST_MP") != NULL) {
+ mp = sysconf(_SC_NPROCESSORS_ONLN);
+ fprintf(stderr, "Using %d worker processes\n", mp);
+ if (VIR_ALLOC_N(workers, mp) < 0)
+ return EXIT_FAILURE;
+ }
+
if (testOOM)
virAllocTestInit();
else
fprintf(stderr, "%d) OOM of %d allocs ", testCounter, approxAlloc);
+ if (mp) {
+ int i;
+ for (i = 0 ; i < mp ; i++) {
+ workers[i] = fork();
+ if (workers[i] == 0) {
+ worker = i + 1;
+ break;
+ }
+ }
+ }
+
/* Run once for each alloc, failing a different one
and validating that the test case failed */
- for (n = 0; n < approxAlloc ; n++) {
+ for (n = 0; n < approxAlloc && (!mp || worker) ; n++) {
+ if ((n % mp) != (worker - 1))
+ continue;
if (!testDebug) {
- fprintf(stderr, ".");
+ if (mp)
+ fprintf(stderr, "%d", worker);
+ else
+ fprintf(stderr, ".");
fflush(stderr);
}
virAllocTestOOM(n+1, oomCount);
}
}
+ if (mp) {
+ if (worker) {
+ _exit(ret);
+ } else {
+ int i, status;
+ for (i = 0 ; i < mp ; i++) {
+ waitpid(workers[i], &status, 0);
+ if (WEXITSTATUS(status) != EXIT_SUCCESS)
+ ret = EXIT_FAILURE;
+ }
+ VIR_FREE(workers);
+ }
+ }
+
if (testDebug)
fprintf(stderr, " ... OOM of %d allocs", approxAlloc);