5 atf_set "descr" "fstyp(8) should detect cd9660 filesystems"
8 atf_check -s exit:0 mkdir -p dir/emptydir # makefs requires a nonempty directory
9 atf_check -s exit:0 -o ignore makefs -t cd9660 -Z -s 64m cd9660.img dir
10 atf_check -s exit:0 -o inline:"cd9660\n" fstyp cd9660.img
11 atf_check -s exit:0 -o inline:"cd9660\n" fstyp -l cd9660.img
14 atf_test_case cd9660_label
16 atf_set "descr" "fstyp(8) can read the label on a cd9660 filesystem"
19 atf_check -s exit:0 mkdir -p dir/emptydir # makefs requires a nonempty directory
20 atf_check -s exit:0 -o ignore makefs -t cd9660 -o label=Foo -Z -s 64m cd9660.img dir
21 atf_check -s exit:0 -o inline:"cd9660\n" fstyp cd9660.img
22 # Note: cd9660 labels are always upper case
23 atf_check -s exit:0 -o inline:"cd9660 FOO\n" fstyp -l cd9660.img
28 atf_set "descr" "fstyp(8) should fail on a directory"
31 atf_check -s exit:0 mkdir dir
32 atf_check -s exit:1 -e match:"not a disk" fstyp dir
37 atf_set "descr" "fstyp(8) should fail on an empty file"
40 atf_check -s exit:0 touch empty
41 atf_check -s exit:1 -e match:"filesystem not recognized" fstyp empty
46 atf_set "descr" "fstyp(8) can detect ext2 filesystems"
49 bzcat $(atf_get_srcdir)/ext2.img.bz2 > ext2.img
50 atf_check -s exit:0 -o inline:"ext2fs\n" fstyp ext2.img
51 atf_check -s exit:0 -o inline:"ext2fs\n" fstyp -l ext2.img
56 atf_set "descr" "fstyp(8) can detect ext3 filesystems"
59 bzcat $(atf_get_srcdir)/ext3.img.bz2 > ext3.img
60 atf_check -s exit:0 -o inline:"ext2fs\n" fstyp ext3.img
61 atf_check -s exit:0 -o inline:"ext2fs\n" fstyp -l ext3.img
66 atf_set "descr" "fstyp(8) can detect ext4 filesystems"
69 bzcat $(atf_get_srcdir)/ext4.img.bz2 > ext4.img
70 atf_check -s exit:0 -o inline:"ext2fs\n" fstyp ext4.img
71 atf_check -s exit:0 -o inline:"ext2fs\n" fstyp -l ext4.img
74 atf_test_case ext4_label
76 atf_set "descr" "fstyp(8) can read the label on an ext4 filesystem"
79 bzcat $(atf_get_srcdir)/ext4_with_label.img.bz2 > ext4_with_label.img
80 atf_check -s exit:0 -o inline:"ext2fs foo\n" fstyp -l ext4_with_label.img
85 atf_set "descr" "fstyp(8) can detect FAT12 filesystems"
88 atf_check -s exit:0 truncate -s 64m msdos.img
89 atf_check -s exit:0 -o ignore -e ignore newfs_msdos -F 12 ./msdos.img
90 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp msdos.img
91 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp -l msdos.img
96 atf_set "descr" "fstyp(8) can detect FAT16 filesystems"
99 atf_check -s exit:0 truncate -s 64m msdos.img
100 atf_check -s exit:0 -o ignore -e ignore newfs_msdos -F 16 ./msdos.img
101 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp msdos.img
102 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp -l msdos.img
107 atf_set "descr" "fstyp(8) can detect FAT32 filesystems"
110 atf_check -s exit:0 truncate -s 64m msdos.img
111 atf_check -s exit:0 -o ignore -e ignore newfs_msdos -F 32 -c 1 \
113 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp msdos.img
114 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp -l msdos.img
117 atf_test_case fat32_label
119 atf_set "descr" "fstyp(8) can read the label on an msdos filesystem"
122 atf_check -s exit:0 truncate -s 64m msdos.img
123 atf_check -s exit:0 -o ignore -e ignore newfs_msdos -F 32 -L Foo -c 1 \
125 atf_check -s exit:0 -o inline:"msdosfs\n" fstyp msdos.img
126 # Note: msdos labels are always upper case
127 atf_check -s exit:0 -o inline:"msdosfs FOO\n" fstyp -l msdos.img
132 atf_set "descr" "fstyp(8) can detect ntfs filesystems"
135 bzcat $(atf_get_srcdir)/ntfs.img.bz2 > ntfs.img
136 atf_check -s exit:0 -o inline:"ntfs\n" fstyp ntfs.img
137 atf_check -s exit:0 -o inline:"ntfs\n" fstyp -l ntfs.img
140 atf_test_case ntfs_with_label
141 ntfs_with_label_head() {
142 atf_set "descr" "fstyp(8) can read labels on ntfs filesystems"
144 ntfs_with_label_body() {
145 bzcat $(atf_get_srcdir)/ntfs_with_label.img.bz2 > ntfs_with_label.img
146 atf_check -s exit:0 -o inline:"ntfs\n" fstyp ntfs_with_label.img
147 atf_check -s exit:0 -o inline:"ntfs Foo\n" fstyp -l ntfs_with_label.img
152 atf_set "descr" "fstyp(8) should detect UFS version 1 filesystems"
155 atf_check -s exit:0 mkdir dir
156 atf_check -s exit:0 -o ignore makefs -Z -s 64m ufs.img dir
157 atf_check -s exit:0 -o inline:"ufs\n" fstyp ufs.img
158 atf_check -s exit:0 -o inline:"ufs\n" fstyp -l ufs.img
163 atf_set "descr" "fstyp(8) should detect UFS version 2 filesystems"
166 atf_check -s exit:0 mkdir dir
167 atf_check -s exit:0 -o ignore makefs -o version=2 -Z -s 64m ufs.img dir
168 atf_check -s exit:0 -o inline:"ufs\n" fstyp ufs.img
169 atf_check -s exit:0 -o inline:"ufs\n" fstyp -l ufs.img
172 atf_test_case ufs2_label
174 atf_set "descr" "fstyp(8) can read the label on a UFS v2 filesystem"
177 atf_check -s exit:0 mkdir dir
178 atf_check -s exit:0 -o ignore makefs -o version=2,label="foo" -Z -s 64m ufs.img dir
179 atf_check -s exit:0 -o inline:"ufs foo\n" fstyp -l ufs.img
182 atf_test_case ufs_on_device cleanup
183 ufs_on_device_head() {
184 atf_set "descr" "fstyp(8) should work on device nodes"
185 atf_set "require.user" "root"
187 ufs_on_device_body() {
188 mdconfig -a -t swap -s 64m > mdname
190 if [ -z "$md" ]; then
191 atf_fail "Failed to create md(4) device"
193 atf_check -s exit:0 -o ignore newfs -L foo /dev/$md
194 atf_check -s exit:0 -o inline:"ufs\n" fstyp /dev/$md
195 atf_check -s exit:0 -o inline:"ufs foo\n" fstyp -l /dev/$md
197 ufs_on_device_cleanup() {
199 if [ -n "$md" ]; then
206 atf_set "descr" "fstyp(8) should fail on a zero-filled file"
209 atf_check -s exit:0 truncate -s 256m zeros
210 atf_check -s exit:1 -e match:"filesystem not recognized" fstyp zeros
214 atf_init_test_cases() {
215 atf_add_test_case cd9660
216 atf_add_test_case cd9660_label
217 atf_add_test_case dir
218 atf_add_test_case empty
219 atf_add_test_case ext2
220 atf_add_test_case ext3
221 atf_add_test_case ext4
222 atf_add_test_case ext4_label
223 atf_add_test_case fat12
224 atf_add_test_case fat16
225 atf_add_test_case fat32
226 atf_add_test_case fat32_label
227 atf_add_test_case ntfs
228 atf_add_test_case ntfs_with_label
229 atf_add_test_case ufs1
230 atf_add_test_case ufs2
231 atf_add_test_case ufs2_label
232 atf_add_test_case ufs_on_device
233 atf_add_test_case zeros