File: test.sh

package info (click to toggle)
safecopy 1.7-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,388 kB
  • sloc: ansic: 2,751; sh: 1,925; makefile: 19
file content (43 lines) | stat: -rwxr-xr-x 1,949 bytes parent folder | download | duplicates (5)
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
#!/bin/sh

test_name="safecopy, continuing aborted safecopy run with arbitrary sizes"

source "../libtestsuite.sh"

function test_current() {

	testsuite_debug "copying reference files for safecopy"
	cp "test1.dat" "$testsuite_tmpdir/test2.dat" >/dev/null 2>&1
	cp "test2.dat" "$testsuite_tmpdir/test3.dat" >/dev/null 2>&1
	testsuite_assert_files_identical "test1.dat" "$testsuite_tmpdir/test2.dat"
	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test3.dat"
	
	testsuite_debug "Test, safecopy must copy the first half of the damaged file"
	LD_PRELOAD="$preload" $safecopy -M "MARKBAAD" -R 2 -b 1024 -f 1* -l 10 debug "$testsuite_tmpdir/test1.dat" >"$testsuite_tmpdir/test1.out" 2>&1
	if [ $? != 1 ]; then
		testsuite_error "Run of safecopy returned wrong exit code. Output:"
                testsuite_debug_file "$testsuite_tmpdir/test1.out"
	fi
	testsuite_assert_files_identical "test1.dat" "$testsuite_tmpdir/test1.dat"

	testsuite_debug "Test, safecopy must continue with the second half"
	LD_PRELOAD="$preload" $safecopy -M "MARKBAAD" -R 2 -b 1024 -f 1* -c 10 debug "$testsuite_tmpdir/test2.dat" >"$testsuite_tmpdir/test2.out" 2>&1
	if [ $? != 1 ]; then
		testsuite_error "Run of safecopy returned wrong exit code. Output:"
                testsuite_debug_file "$testsuite_tmpdir/test2.out"
	fi
	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test2.dat"
	
	testsuite_debug "Test, continue in the middle with limited length"
	testsuite_debug " Must recover soft recoverable blocks and not touch rest"
	LD_PRELOAD="$preload" $safecopy -M "MARKBAAD" -R 3 -b 1024 -f 1* -c 5 -l 13 debug "$testsuite_tmpdir/test3.dat" >"$testsuite_tmpdir/test3.out" 2>&1
	if [ $? != 1 ]; then
		testsuite_error "Run of safecopy returned wrong exit code. Output:"
                testsuite_debug_file "$testsuite_tmpdir/test3.out"
	fi
	testsuite_assert_files_identical "test3.dat" "$testsuite_tmpdir/test3.dat"

}

testsuite_runtest