Remove building with NOCRYPTO option
[minix3.git] / tests / rump / rumpkern / h_client / h_sigcli.c
blob9134f98b574131a7fc983e5c7fa8244d67068ea6
1 /* $NetBSD: h_sigcli.c,v 1.3 2011/02/07 20:05:09 pooka Exp $ */
3 #include <sys/types.h>
4 #include <sys/sysctl.h>
6 #include <err.h>
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <unistd.h>
12 #include <rump/rump_syscalls.h>
13 #include <rump/rumpclient.h>
15 static const int hostnamemib[] = { CTL_KERN, KERN_HOSTNAME };
16 static char hostnamebuf[128];
18 static volatile sig_atomic_t sigexecs;
20 static void
21 sighand(int sig)
23 char buf[128];
24 size_t blen = sizeof(buf);
26 if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
27 buf, &blen, NULL, 0) == -1)
28 err(1, "sighand sysctl");
29 if (strcmp(buf, hostnamebuf) != 0)
30 errx(1, "sighandler hostname");
31 sigexecs++;
34 int
35 main(void)
37 char buf[128];
38 time_t tstart;
39 struct itimerval itv;
40 size_t hnbsize;
41 int i;
42 size_t blen;
44 if (rumpclient_init() == -1)
45 err(1, "rumpclient init");
47 hnbsize = sizeof(hostnamebuf);
48 if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
49 hostnamebuf, &hnbsize, NULL, 0) == -1)
50 err(1, "sysctl");
52 if (signal(SIGALRM, sighand) == SIG_ERR)
53 err(1, "signal");
55 itv.it_interval.tv_sec = itv.it_value.tv_sec = 0;
56 itv.it_interval.tv_usec = itv.it_value.tv_usec = 10000; /* 10ms */
58 if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
59 err(1, "itimer");
61 tstart = time(NULL);
62 for (i = 0;; i++) {
63 blen = sizeof(buf);
64 if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
65 buf, &blen, NULL, 0) == -1)
66 err(1, "sysctl");
67 if (strcmp(buf, hostnamebuf) != 0)
68 errx(1, "main hostname");
71 * check every 100 cycles to avoid doing
72 * nothing but gettimeofday()
74 if (i == 100) {
75 if (time(NULL) - tstart > 5)
76 break;
77 i = 0;
81 if (!sigexecs) {
82 printf("no signal handlers run. test busted?\n");