File: test_fs_fat

package info (click to toggle)
parted 3.2-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,312 kB
  • ctags: 12,128
  • sloc: ansic: 68,106; sh: 18,156; makefile: 632; perl: 179; python: 45; asm: 36; sed: 16
file content (180 lines) | stat: -rwxr-xr-x 3,737 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#! /bin/bash

do_diff()
{
	mount -t vfat ${TEST_DRIVE}1 $TEST_MOUNT_POINT > /dev/null

	if diff -rq $1 $2 >> test_log; then
		ped_test_ok
	else
		ped_test_failed
	fi

	umount $TEST_MOUNT_POINT 2>&1 > /dev/null
}

do_test_diff()
{
	ped_testing "$1"
	if ped_test_get_val "$4" "$5" "$6" "$7"; then
		ped_test_failed
		return 1
	fi
	do_diff "$2" "$3"
}

test_mkpartfs()
{
	ped_test "mkpartfs fat16 minimum size"\
		"mklabel $TEST_FS_USE_DISK_LABEL\
		mkpartfs primary fat16 0 1\
		check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"

	ped_test "mkpartfs fat32 minimum size"\
		"mklabel $TEST_FS_USE_DISK_LABEL\
		mkpartfs primary fat32 0 1\
		check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"

	ped_test "mkpartfs"\
		"mklabel $TEST_FS_USE_DISK_LABEL\
		mkpartfs primary fat32 1 $DEFAULT_END\
		check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"

	ped_test "mkfs"\
		"mkfs 1 fat32\
		 check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
}

prepare_resize_tests()
{
	part_num=1
	part=$TEST_DRIVE$part_num
	hole_parent=`echo $TEST_DATA_HOLE | sed -e "s/[-_.a-zA-Z0-9]+\///g"`

	umount $TEST_MOUNT_POINT 2>&1 > /dev/null

	mount $part $TEST_MOUNT_POINT -t vfat \
	&& cp -r $TEST_DATA/* $TEST_MOUNT_POINT \
	&& cp -r $TEST_DATA $TEST_MOUNT_POINT/tmp_copy \
	&& rm -rf $TEST_MOUNT_POINT/$TEST_DATA_HOLE \
	&& mv $TEST_MOUNT_POINT/tmp_copy/$TEST_DATA_HOLE \
	      $TEST_MOUNT_POINT/$hole_parent \
	&& rm -rf $TEST_MOUNT_POINT/tmp_copy
	umount $TEST_MOUNT_POINT
}

clearfat()
{
	$TEST_PARTED_CLEARFAT $TEST_DRIVE $1
}

test_resize_move_start_forward()
{
# geometry beforehand:  1 to $DEFAULT_END
	do_test_diff "resize: move start forward"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 5 $DEFAULT_END check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

test_resize_move_start_backward()
{
# geometry beforehand: 5 to $DEFAULT_END
	do_test_diff "resize: move start backward"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 1 $DEFAULT_END check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

test_resize_move_end_forward()
{
# geometry beforehand: 1 to $DEFAULT_END
	do_test_diff "resize: move end forward"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 1 $[ $DEFAULT_END + 5 ] check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

test_resize_move_end_backward()
{
# geometry beforehand:  1 to $[$DEFAULT_END + 5]
	do_test_diff "resize: move end backward"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 1 $DEFAULT_END check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

test_convert_fat16_fat32_shrink_cluster()
{
# geometry beforehand:  1 to $DEFAULT_END
	do_test_diff \
	"resize: convert from FAT16 to FAT32, shrinking the cluster size"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 1 $FAT32_END check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

test_convert_fat32_fat16()
{
# geometry beforehand:  1 to $FAT16_SMALL_END
	do_test_diff "resize: convert from FAT32 to FAT16"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 1 $FAT32_END check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

test_convert_fat16_fat32()
{
# geometry beforehand:  1 to $FAT32_END
	do_test_diff "resize: convert from FAT16 to FAT32"\
		$TEST_DATA $TEST_MOUNT_POINT \
		"resize 1 1 $FAT16_SMALL_END check 1"\
		"/sbin/dosfsck ${TEST_DRIVE}1"
	clearfat 1
}

#test_convert_fat32_fat16_shrink_cluster()
#{
#}

#test_fat16_shrink_cluster()
#{
#}

#test_fat32_shrink_cluster()
#{
#}

main()
{
	export DEFAULT_END=300
	export FAT32_END=600
	export FAT16_SMALL_END=200

	if ! test_mkpartfs; then
		return 1
	fi

	prepare_resize_tests
	test_resize_move_start_forward
	test_resize_move_start_backward
	test_resize_move_end_forward
	test_resize_move_end_backward

#	prepare_resize_tests
	test_convert_fat16_fat32_shrink_cluster
	test_convert_fat32_fat16
	test_convert_fat16_fat32
}

main