t_mount.c revision 1.8 1 1.8 pooka /* $NetBSD: t_mount.c,v 1.8 2010/08/09 17:42:26 pooka Exp $ */
2 1.1 njoly
3 1.1 njoly /*
4 1.8 pooka * Basic tests for mounting
5 1.8 pooka */
6 1.8 pooka
7 1.8 pooka /*
8 1.8 pooka * 48Kimage:
9 1.1 njoly * Adapted for rump and atf from a testcase supplied
10 1.1 njoly * by Hubert Feyrer on netbsd-users@
11 1.1 njoly */
12 1.1 njoly
13 1.1 njoly #include <atf-c.h>
14 1.1 njoly
15 1.1 njoly #define IMGNAME "image.ffs"
16 1.1 njoly #define IMGSIZE (96 * 512)
17 1.1 njoly
18 1.1 njoly #define MNTDIR "/mnt"
19 1.1 njoly
20 1.6 pooka #include "../common/h_fsmacros.h"
21 1.6 pooka
22 1.8 pooka #include <sys/types.h>
23 1.8 pooka #include <sys/mount.h>
24 1.8 pooka
25 1.8 pooka #include <stdlib.h>
26 1.8 pooka
27 1.8 pooka #include <ufs/ufs/ufsmount.h>
28 1.8 pooka
29 1.8 pooka #include <rump/rump.h>
30 1.8 pooka #include <rump/rump_syscalls.h>
31 1.8 pooka
32 1.8 pooka #include "../../h_macros.h"
33 1.8 pooka
34 1.1 njoly ATF_TC(48Kimage);
35 1.1 njoly ATF_TC_HEAD(48Kimage, tc)
36 1.1 njoly {
37 1.1 njoly atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image");
38 1.1 njoly atf_tc_set_md_var(tc, "use.fs", "true");
39 1.1 njoly }
40 1.1 njoly
41 1.1 njoly ATF_TC_BODY(48Kimage, tc)
42 1.1 njoly {
43 1.1 njoly void *tmp;
44 1.1 njoly
45 1.7 pooka if (ffs_fstest_newfs(tc, &tmp, IMGNAME, IMGSIZE, NULL) != 0)
46 1.1 njoly atf_tc_fail("newfs failed");
47 1.1 njoly
48 1.3 pooka atf_tc_expect_fail("PR kern/43573");
49 1.5 njoly if (ffs_fstest_mount(tc, tmp, MNTDIR, 0) != 0) {
50 1.1 njoly atf_tc_fail("mount failed");
51 1.2 jmmv }
52 1.3 pooka atf_tc_expect_pass();
53 1.3 pooka
54 1.5 njoly if (ffs_fstest_unmount(tc, MNTDIR, 0) != 0)
55 1.1 njoly atf_tc_fail("unmount failed");
56 1.1 njoly
57 1.5 njoly if (ffs_fstest_delfs(tc, tmp) != 0)
58 1.1 njoly atf_tc_fail("delfs failed");
59 1.1 njoly }
60 1.1 njoly
61 1.8 pooka ATF_TC(fsbsize2big);
62 1.8 pooka ATF_TC_HEAD(fsbsize2big, tc)
63 1.8 pooka {
64 1.8 pooka
65 1.8 pooka atf_tc_set_md_var(tc, "descr", "mounts file system with "
66 1.8 pooka "blocksize > MAXPHYS");
67 1.8 pooka atf_tc_set_md_var(tc, "use.fs", "true");
68 1.8 pooka /* PR kern/43727 */
69 1.8 pooka }
70 1.8 pooka
71 1.8 pooka #define MYBLOCKSIZE 131072
72 1.8 pooka #if MAXPHYS >= MYBLOCKSIZE
73 1.8 pooka #error MAXPHYS too large for test to work
74 1.8 pooka #endif
75 1.8 pooka ATF_TC_BODY(fsbsize2big, tc)
76 1.8 pooka {
77 1.8 pooka char cmd[1024];
78 1.8 pooka struct ufs_args args;
79 1.8 pooka struct statvfs svb;
80 1.8 pooka
81 1.8 pooka snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 "
82 1.8 pooka "ffs.img > /dev/null", MYBLOCKSIZE);
83 1.8 pooka if (system(cmd))
84 1.8 pooka atf_tc_fail("cannot create file system");
85 1.8 pooka
86 1.8 pooka rump_init();
87 1.8 pooka if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK))
88 1.8 pooka atf_tc_fail("cannot register rump fake device");
89 1.8 pooka
90 1.8 pooka args.fspec = __UNCONST("/devdisk");
91 1.8 pooka
92 1.8 pooka if (rump_sys_mkdir("/mp", 0777) == -1)
93 1.8 pooka atf_tc_fail_errno("create mountpoint");
94 1.8 pooka
95 1.8 pooka /* mount succeeded? bad omen. confirm we're in trouble. */
96 1.8 pooka if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) {
97 1.8 pooka rump_sys_statvfs1("/mp", &svb, ST_WAIT);
98 1.8 pooka }
99 1.8 pooka
100 1.8 pooka /* otherwise we're do-ne */
101 1.8 pooka }
102 1.8 pooka
103 1.1 njoly ATF_TP_ADD_TCS(tp)
104 1.1 njoly {
105 1.8 pooka
106 1.1 njoly ATF_TP_ADD_TC(tp, 48Kimage);
107 1.8 pooka ATF_TP_ADD_TC(tp, fsbsize2big);
108 1.8 pooka
109 1.1 njoly return atf_no_error();
110 1.1 njoly }
111