1 /* $NetBSD: t_mount.c,v 1.13 2012/11/27 16:01:49 jakllsch Exp $ */
4 * Basic tests for mounting
9 * Adapted for rump and atf from a testcase supplied
10 * by Hubert Feyrer on netbsd-users@
15 #define FSTEST_IMGSIZE (96 * 512)
16 #include "../common/h_fsmacros.h"
18 #include <sys/types.h>
19 #include <sys/mount.h>
23 #include <ufs/ufs/ufsmount.h>
25 #include <rump/rump.h>
26 #include <rump/rump_syscalls.h>
28 #include "../../h_macros.h"
31 ATF_TC_HEAD(48Kimage
, tc
)
33 atf_tc_set_md_var(tc
, "descr", "mount small 48K ffs image");
36 ATF_TC_BODY(48Kimage
, tc
)
40 atf_tc_expect_fail("PR kern/43573");
41 FSTEST_CONSTRUCTOR(tc
, ffs
, tmp
);
44 FSTEST_DESTRUCTOR(tc
, ffs
, tmp
);
47 ATF_TC(fsbsizeovermaxphys
);
48 ATF_TC_HEAD(fsbsizeovermaxphys
, tc
)
51 atf_tc_set_md_var(tc
, "descr", "mounts file system with "
52 "blocksize > MAXPHYS");
56 ATF_TC_BODY(fsbsizeovermaxphys
, tc
)
63 * We cannot pass newfs parameters via the fstest interface,
64 * so do things the oldfashioned manual way.
66 snprintf(cmd
, sizeof(cmd
), "newfs -G -b %d -F -s 10000 "
67 "ffs.img > /dev/null", MAXPHYS
* 2);
69 atf_tc_fail("cannot create file system");
72 if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK
))
73 atf_tc_fail("cannot register rump fake device");
75 args
.fspec
= __UNCONST("/devdisk");
77 if (rump_sys_mkdir("/mp", 0777) == -1)
78 atf_tc_fail_errno("create mountpoint");
80 /* mount succeeded? bad omen. confirm we're in trouble. */
81 if (rump_sys_mount(MOUNT_FFS
, "/mp", 0, &args
, sizeof(args
)) != -1) {
82 rump_sys_statvfs1("/mp", &svb
, ST_WAIT
);
83 atf_tc_fail("not expecting to be alive");
86 /* otherwise we're do-ne */
89 ATF_TC(fsbsizeovermaxbsize
);
90 ATF_TC_HEAD(fsbsizeovermaxbsize
, tc
)
93 atf_tc_set_md_var(tc
, "descr", "mounts file system with "
94 "blocksize > MAXBSIZE");
97 ATF_TC_BODY(fsbsizeovermaxbsize
, tc
)
100 struct ufs_args args
;
104 * We cannot pass newfs parameters via the fstest interface,
105 * so do things the oldfashioned manual way.
107 snprintf(cmd
, sizeof(cmd
), "newfs -G -b %d -F -s 10000 "
108 "ffs.img > /dev/null", MAXBSIZE
* 2);
110 atf_tc_fail("cannot create file system");
113 if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK
))
114 atf_tc_fail("cannot register rump fake device");
116 args
.fspec
= __UNCONST("/devdisk");
118 if (rump_sys_mkdir("/mp", 0777) == -1)
119 atf_tc_fail_errno("create mountpoint");
121 /* mount succeeded? bad omen. confirm we're in trouble. */
122 if (rump_sys_mount(MOUNT_FFS
, "/mp", 0, &args
, sizeof(args
)) != -1) {
123 rump_sys_statvfs1("/mp", &svb
, ST_WAIT
);
124 atf_tc_fail("not expecting to be alive");
127 /* otherwise we're do-ne */
133 ATF_TP_ADD_TC(tp
, 48Kimage
);
134 ATF_TP_ADD_TC(tp
, fsbsizeovermaxphys
);
135 ATF_TP_ADD_TC(tp
, fsbsizeovermaxbsize
);
137 return atf_no_error();