Remove building with NOCRYPTO option
[minix.git] / tests / fs / union / t_pr.c
blob2d0c0c84db495e3f93f0dbeeb231a6d79cd4d12e
1 /* $NetBSD: t_pr.c,v 1.8 2011/08/10 06:27:02 hannken Exp $ */
3 #include <sys/types.h>
4 #include <sys/mount.h>
6 #include <atf-c.h>
7 #include <err.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <stdio.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <stdlib.h>
15 #include <rump/rump.h>
16 #include <rump/rump_syscalls.h>
18 #include <miscfs/union/union.h>
20 #include "../../h_macros.h"
22 ATF_TC(multilayer);
23 ATF_TC_HEAD(multilayer, tc)
25 atf_tc_set_md_var(tc, "descr", "mount_union -b twice");
28 ATF_TC_BODY(multilayer, tc)
30 struct union_args unionargs;
32 rump_init();
34 if (rump_sys_mkdir("/Tunion", 0777) == -1)
35 atf_tc_fail_errno("mkdir mp1");
36 if (rump_sys_mkdir("/Tunion2", 0777) == -1)
37 atf_tc_fail_errno("mkdir mp2");
38 if (rump_sys_mkdir("/Tunion2/A", 0777) == -1)
39 atf_tc_fail_errno("mkdir A");
40 if (rump_sys_mkdir("/Tunion2/B", 0777) == -1)
41 atf_tc_fail_errno("mkdir B");
43 unionargs.target = __UNCONST("/Tunion2/A");
44 unionargs.mntflags = UNMNT_BELOW;
46 if (rump_sys_mount(MOUNT_UNION, "/Tunion", 0,
47 &unionargs, sizeof(unionargs)) == -1)
48 atf_tc_fail_errno("union mount");
50 unionargs.target = __UNCONST("/Tunion2/B");
51 unionargs.mntflags = UNMNT_BELOW;
53 rump_sys_mount(MOUNT_UNION, "/Tunion", 0,&unionargs,sizeof(unionargs));
56 ATF_TC(devnull1);
57 ATF_TC_HEAD(devnull1, tc)
59 atf_tc_set_md_var(tc, "descr", "mount_union -b and "
60 "'echo x > /un/null'");
63 ATF_TC_BODY(devnull1, tc)
65 struct union_args unionargs;
66 int fd, res;
68 rump_init();
70 if (rump_sys_mkdir("/mp", 0777) == -1)
71 atf_tc_fail_errno("mkdir mp");
73 unionargs.target = __UNCONST("/dev");
74 unionargs.mntflags = UNMNT_BELOW;
76 if (rump_sys_mount(MOUNT_UNION, "/mp", 0,
77 &unionargs, sizeof(unionargs)) == -1)
78 atf_tc_fail_errno("union mount");
80 fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_TRUNC);
82 if (fd == -1)
83 atf_tc_fail_errno("open");
85 res = rump_sys_write(fd, &fd, sizeof(fd));
86 if (res != sizeof(fd))
87 atf_tc_fail("write");
90 ATF_TC(devnull2);
91 ATF_TC_HEAD(devnull2, tc)
93 atf_tc_set_md_var(tc, "descr", "mount_union -b and "
94 "'echo x >> /un/null'");
97 ATF_TC_BODY(devnull2, tc)
99 struct union_args unionargs;
100 int fd, res;
102 rump_init();
104 if (rump_sys_mkdir("/mp", 0777) == -1)
105 atf_tc_fail_errno("mkdir mp");
107 unionargs.target = __UNCONST("/dev");
108 unionargs.mntflags = UNMNT_BELOW;
110 if (rump_sys_mount(MOUNT_UNION, "/mp", 0,
111 &unionargs, sizeof(unionargs)) == -1)
112 atf_tc_fail_errno("union mount");
114 fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_APPEND);
115 if (fd == -1)
116 atf_tc_fail_errno("open");
118 res = rump_sys_write(fd, &fd, sizeof(fd));
119 if (res != sizeof(fd))
120 atf_tc_fail("write");
123 ATF_TP_ADD_TCS(tp)
125 ATF_TP_ADD_TC(tp, multilayer);
126 ATF_TP_ADD_TC(tp, devnull1);
127 ATF_TP_ADD_TC(tp, devnull2);
129 return atf_no_error();