diff options
author | ngie <ngie@FreeBSD.org> | 2014-10-02 23:26:49 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2014-10-02 23:26:49 +0000 |
commit | 3f09b8d0af642c2aeb96a4d667cefb7fe3bce443 (patch) | |
tree | 544932e2a2c5a5a202b752beefba0b3e327b3858 /contrib/netbsd-tests/fs/union/t_pr.c | |
parent | b941fec92da62b0eab650295f4e8a381dbbc04b4 (diff) | |
parent | e1f2d32c0e0678782c353c48364cddedfae58b0a (diff) | |
download | FreeBSD-src-3f09b8d0af642c2aeb96a4d667cefb7fe3bce443.zip FreeBSD-src-3f09b8d0af642c2aeb96a4d667cefb7fe3bce443.tar.gz |
Import the NetBSD test suite from ^/vendor/NetBSD/tests/09.30.2014_20.45 ,
minus the vendor Makefiles
Provide directions for how to bootstrap the vendor sources in
FREEBSD-upgrade
MFC after 2 weeks
Discussed with: rpaulo
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/netbsd-tests/fs/union/t_pr.c')
-rw-r--r-- | contrib/netbsd-tests/fs/union/t_pr.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/fs/union/t_pr.c b/contrib/netbsd-tests/fs/union/t_pr.c new file mode 100644 index 0000000..2d0c0c8 --- /dev/null +++ b/contrib/netbsd-tests/fs/union/t_pr.c @@ -0,0 +1,130 @@ +/* $NetBSD: t_pr.c,v 1.8 2011/08/10 06:27:02 hannken Exp $ */ + +#include <sys/types.h> +#include <sys/mount.h> + +#include <atf-c.h> +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> + +#include <rump/rump.h> +#include <rump/rump_syscalls.h> + +#include <miscfs/union/union.h> + +#include "../../h_macros.h" + +ATF_TC(multilayer); +ATF_TC_HEAD(multilayer, tc) +{ + atf_tc_set_md_var(tc, "descr", "mount_union -b twice"); +} + +ATF_TC_BODY(multilayer, tc) +{ + struct union_args unionargs; + + rump_init(); + + if (rump_sys_mkdir("/Tunion", 0777) == -1) + atf_tc_fail_errno("mkdir mp1"); + if (rump_sys_mkdir("/Tunion2", 0777) == -1) + atf_tc_fail_errno("mkdir mp2"); + if (rump_sys_mkdir("/Tunion2/A", 0777) == -1) + atf_tc_fail_errno("mkdir A"); + if (rump_sys_mkdir("/Tunion2/B", 0777) == -1) + atf_tc_fail_errno("mkdir B"); + + unionargs.target = __UNCONST("/Tunion2/A"); + unionargs.mntflags = UNMNT_BELOW; + + if (rump_sys_mount(MOUNT_UNION, "/Tunion", 0, + &unionargs, sizeof(unionargs)) == -1) + atf_tc_fail_errno("union mount"); + + unionargs.target = __UNCONST("/Tunion2/B"); + unionargs.mntflags = UNMNT_BELOW; + + rump_sys_mount(MOUNT_UNION, "/Tunion", 0,&unionargs,sizeof(unionargs)); +} + +ATF_TC(devnull1); +ATF_TC_HEAD(devnull1, tc) +{ + atf_tc_set_md_var(tc, "descr", "mount_union -b and " + "'echo x > /un/null'"); +} + +ATF_TC_BODY(devnull1, tc) +{ + struct union_args unionargs; + int fd, res; + + rump_init(); + + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("mkdir mp"); + + unionargs.target = __UNCONST("/dev"); + unionargs.mntflags = UNMNT_BELOW; + + if (rump_sys_mount(MOUNT_UNION, "/mp", 0, + &unionargs, sizeof(unionargs)) == -1) + atf_tc_fail_errno("union mount"); + + fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_TRUNC); + + if (fd == -1) + atf_tc_fail_errno("open"); + + res = rump_sys_write(fd, &fd, sizeof(fd)); + if (res != sizeof(fd)) + atf_tc_fail("write"); +} + +ATF_TC(devnull2); +ATF_TC_HEAD(devnull2, tc) +{ + atf_tc_set_md_var(tc, "descr", "mount_union -b and " + "'echo x >> /un/null'"); +} + +ATF_TC_BODY(devnull2, tc) +{ + struct union_args unionargs; + int fd, res; + + rump_init(); + + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("mkdir mp"); + + unionargs.target = __UNCONST("/dev"); + unionargs.mntflags = UNMNT_BELOW; + + if (rump_sys_mount(MOUNT_UNION, "/mp", 0, + &unionargs, sizeof(unionargs)) == -1) + atf_tc_fail_errno("union mount"); + + fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_APPEND); + if (fd == -1) + atf_tc_fail_errno("open"); + + res = rump_sys_write(fd, &fd, sizeof(fd)); + if (res != sizeof(fd)) + atf_tc_fail("write"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, multilayer); + ATF_TP_ADD_TC(tp, devnull1); + ATF_TP_ADD_TC(tp, devnull2); + + return atf_no_error(); +} |