Skip to content

Commit 1f5dc06

Browse files
committed
tests: Print a warning if nbdkit does not start after 30 seconds
When running the OCaml test under valgrind, for some reason downloading debug symbols from debuginfod takes an extremely long time (as in 10+ minutes). This caused the test to fail in a rather obscure way which was not immediately easy to diagnose. We wait for nbdkit to create a PID file, but if it hasn't been created within 30 seconds then we continue anyway. This causes a later failure (in this case qemu being unable to connect to the NBD socket). While this commit doesn't fix any of the underlying problems, we can at least add a useful error message to the log file when we exceed the timeout without the PID file having been created. For the root cause of the valgrind problem, see commit 8c94611 ("wrapper: Unset DEBUGINFOD_URLS")
1 parent 9edbe3a commit 1f5dc06

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/test.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include <stdio.h>
3636
#include <stdlib.h>
37+
#include <stdbool.h>
3738
#include <stdarg.h>
3839
#include <string.h>
3940
#include <unistd.h>
@@ -136,6 +137,7 @@ test_start_nbdkit (const char *arg, ...)
136137
{
137138
size_t i, len;
138139
struct test_nbdkit *kit = malloc (sizeof *kit);
140+
bool exists;
139141

140142
if (!kit) {
141143
perror ("malloc");
@@ -217,12 +219,20 @@ test_start_nbdkit (const char *arg, ...)
217219
perror ("kill");
218220
}
219221

220-
if (access (kit->pidpath, F_OK) == 0)
222+
exists = access (kit->pidpath, F_OK) == 0;
223+
if (exists)
221224
break;
222225

223226
sleep (1);
224227
}
225228

229+
if (!exists) {
230+
fprintf (stderr,
231+
"%s: nbdkit did not create pidfile %s within "
232+
"%d seconds, continuing anyway\n",
233+
program_name, kit->pidpath, NBDKIT_START_TIMEOUT);
234+
}
235+
226236
return 0;
227237
}
228238

0 commit comments

Comments
 (0)