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