mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 13:47:13 +03:00
ALlow OOM tests to be parallelized
This commit is contained in:
parent
8d18d826a4
commit
0caf27a2b0
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
Mon Jul 7 11:59:07 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* proxy/libvirt_proxy.c: fix a compilation problem without Xen
|
* proxy/libvirt_proxy.c: fix a compilation problem without Xen
|
||||||
|
@ -330,7 +330,9 @@ int virtTestMain(int argc,
|
|||||||
int n;
|
int n;
|
||||||
char *oomStr = NULL, *debugStr;
|
char *oomStr = NULL, *debugStr;
|
||||||
int oomCount;
|
int oomCount;
|
||||||
|
int mp = 0;
|
||||||
|
pid_t *workers;
|
||||||
|
int worker = 0;
|
||||||
if ((debugStr = getenv("VIR_TEST_DEBUG")) != NULL) {
|
if ((debugStr = getenv("VIR_TEST_DEBUG")) != NULL) {
|
||||||
if (virStrToLong_ui(debugStr, NULL, 10, &testDebug) < 0)
|
if (virStrToLong_ui(debugStr, NULL, 10, &testDebug) < 0)
|
||||||
testDebug = 0;
|
testDebug = 0;
|
||||||
@ -346,6 +348,13 @@ int virtTestMain(int argc,
|
|||||||
testOOM = 1;
|
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)
|
if (testOOM)
|
||||||
virAllocTestInit();
|
virAllocTestInit();
|
||||||
|
|
||||||
@ -371,11 +380,27 @@ int virtTestMain(int argc,
|
|||||||
else
|
else
|
||||||
fprintf(stderr, "%d) OOM of %d allocs ", testCounter, approxAlloc);
|
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
|
/* Run once for each alloc, failing a different one
|
||||||
and validating that the test case failed */
|
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) {
|
if (!testDebug) {
|
||||||
fprintf(stderr, ".");
|
if (mp)
|
||||||
|
fprintf(stderr, "%d", worker);
|
||||||
|
else
|
||||||
|
fprintf(stderr, ".");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
virAllocTestOOM(n+1, oomCount);
|
virAllocTestOOM(n+1, oomCount);
|
||||||
@ -386,6 +411,20 @@ int virtTestMain(int argc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
if (testDebug)
|
||||||
fprintf(stderr, " ... OOM of %d allocs", approxAlloc);
|
fprintf(stderr, " ... OOM of %d allocs", approxAlloc);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user