Remove building with NOCRYPTO option
[minix.git] / tests / rump / modautoload / t_modautoload.c
blobf28ad556808a7b2eaacf72b56bb1f04ae3f1f886
1 /* $NetBSD: t_modautoload.c,v 1.2 2014/03/10 22:38:53 pooka Exp $ */
3 #include <sys/types.h>
4 #include <sys/mount.h>
5 #include <sys/module.h>
6 #include <sys/dirent.h>
7 #include <sys/sysctl.h>
9 #include <atf-c.h>
10 #include <err.h>
11 #include <errno.h>
12 #include <fcntl.h>
13 #include <stdio.h>
14 #include <unistd.h>
15 #include <string.h>
16 #include <stdlib.h>
18 #include <rump/rump.h>
19 #include <rump/rump_syscalls.h>
21 #include <miscfs/kernfs/kernfs.h>
23 #include "../../h_macros.h"
25 ATF_TC(modautoload);
26 ATF_TC_HEAD(modautoload, tc)
29 atf_tc_set_md_var(tc, "descr", "tests that kernel module "
30 "autoload works in rump");
33 static void
34 mountkernfs(void)
37 if (!rump_nativeabi_p())
38 atf_tc_skip("host kernel modules not supported");
40 rump_init();
42 if (rump_sys_mkdir("/kern", 0777) == -1)
43 atf_tc_fail_errno("mkdir /kern");
44 if (rump_sys_mount(MOUNT_KERNFS, "/kern", 0, NULL, 0) == -1)
45 atf_tc_fail_errno("could not mount kernfs");
49 * Why use kernfs here? It talks to plenty of other parts with the
50 * kernel (e.g. vfs_attach() in modcmd), but is still easy to verify
51 * it's working correctly.
54 #define MAGICNUM 1323
55 ATF_TC_BODY(modautoload, tc)
57 extern int rumpns_hz;
58 char buf[64];
59 int fd;
61 mountkernfs();
62 rumpns_hz = MAGICNUM;
63 if ((fd = rump_sys_open("/kern/hz", O_RDONLY)) == -1)
64 atf_tc_fail_errno("open /kern/hz");
65 if (rump_sys_read(fd, buf, sizeof(buf)) <= 0)
66 atf_tc_fail_errno("read");
67 ATF_REQUIRE(atoi(buf) == MAGICNUM);
70 ATF_TP_ADD_TCS(tp)
72 ATF_TP_ADD_TC(tp, modautoload);
74 return atf_no_error();