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