Skip to content

Commit f06dcdc

Browse files
committed
test-daemon: sleep just a little bit by default
With previous commits, test-daemon is one of the slowest tests. Under normal circumstances, the notifications go nowhere anyway, because the test process does not have privileges. The timeout can be specified as an argument. This is useful to e.g. test handling of the notifications, which is much easier with a longer timeout.
1 parent 86d0608 commit f06dcdc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/test/test-daemon.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@
2121

2222
#include "sd-daemon.h"
2323

24+
#include "parse-util.h"
2425
#include "strv.h"
2526

2627
int main(int argc, char*argv[]) {
2728
_cleanup_strv_free_ char **l = NULL;
2829
int n, i;
30+
usec_t duration = USEC_PER_SEC / 10;
31+
32+
if (argc >= 2) {
33+
unsigned x;
34+
35+
assert_se(safe_atou(argv[1], &x) >= 0);
36+
duration = x * USEC_PER_SEC;
37+
}
2938

3039
n = sd_listen_fds_with_names(false, &l);
3140
if (n < 0) {
@@ -38,27 +47,27 @@ int main(int argc, char*argv[]) {
3847

3948
sd_notify(0,
4049
"STATUS=Starting up");
41-
sleep(1);
50+
usleep(duration);
4251

4352
sd_notify(0,
4453
"STATUS=Running\n"
4554
"READY=1");
46-
sleep(1);
55+
usleep(duration);
4756

4857
sd_notify(0,
4958
"STATUS=Reloading\n"
5059
"RELOADING=1");
51-
sleep(1);
60+
usleep(duration);
5261

5362
sd_notify(0,
5463
"STATUS=Running\n"
5564
"READY=1");
56-
sleep(1);
65+
usleep(duration);
5766

5867
sd_notify(0,
5968
"STATUS=Quitting\n"
6069
"STOPPING=1");
61-
sleep(1);
70+
usleep(duration);
6271

6372
return EXIT_SUCCESS;
6473
}

0 commit comments

Comments
 (0)