Boot-to-ramdisk image generation scripts
[minix3.git] / tests / fs / ffs / t_mount.c
blob6a8f74f455f88ea7e0218bd4c75b9c60734425a5
1 /* $NetBSD: t_mount.c,v 1.13 2012/11/27 16:01:49 jakllsch Exp $ */
3 /*
4 * Basic tests for mounting
5 */
7 /*
8 * 48Kimage:
9 * Adapted for rump and atf from a testcase supplied
10 * by Hubert Feyrer on netbsd-users@
13 #include <atf-c.h>
15 #define FSTEST_IMGSIZE (96 * 512)
16 #include "../common/h_fsmacros.h"
18 #include <sys/types.h>
19 #include <sys/mount.h>
21 #include <stdlib.h>
23 #include <ufs/ufs/ufsmount.h>
25 #include <rump/rump.h>
26 #include <rump/rump_syscalls.h>
28 #include "../../h_macros.h"
30 ATF_TC(48Kimage);
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)
38 void *tmp;
40 atf_tc_expect_fail("PR kern/43573");
41 FSTEST_CONSTRUCTOR(tc, ffs, tmp);
42 atf_tc_expect_pass();
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");
53 /* PR kern/43727 */
56 ATF_TC_BODY(fsbsizeovermaxphys, tc)
58 char cmd[1024];
59 struct ufs_args args;
60 struct statvfs svb;
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);
68 if (system(cmd))
69 atf_tc_fail("cannot create file system");
71 rump_init();
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)
99 char cmd[1024];
100 struct ufs_args args;
101 struct statvfs svb;
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);
109 if (system(cmd))
110 atf_tc_fail("cannot create file system");
112 rump_init();
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 */
130 ATF_TP_ADD_TCS(tp)
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();