1#!/bin/sh
2
3test_name="safecopy, incremental recovery with blocksize variation"
4
5source "../libtestsuite.sh"
6
7function test_current() {
8
9	testsuite_debug "copying reference files for safecopy"
10	cp "test2.dat" "$testsuite_tmpdir/test3.dat" >/dev/null 2>&1
11	cp "test2.dat" "$testsuite_tmpdir/test4.dat" >/dev/null 2>&1
12	cp "test2.dat" "$testsuite_tmpdir/test5.dat" >/dev/null 2>&1
13	cp "test2.dat" "$testsuite_tmpdir/test6.dat" >/dev/null 2>&1
14
15	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test3.dat"
16	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test4.dat"
17	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test5.dat"
18	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test6.dat"
19
20	testsuite_debug "Test, first run with big skipsize and resolution to produce output with holes"
21	LD_PRELOAD="$preload" $safecopy -R 2 -b 1150 -f 4* -r 4* -o "$testsuite_tmpdir/test1.badblocks" debug "$testsuite_tmpdir/test1.dat" >"$testsuite_tmpdir/test1.out" 2>&1
22	if [ $? != 1 ]; then
23		testsuite_error "Run of safecopy returned wrong exit code. Output:"
24                testsuite_debug_file "$testsuite_tmpdir/test1.out"
25	fi
26	testsuite_assert_files_identical "test1.dat" "$testsuite_tmpdir/test1.dat"
27	testsuite_assert_files_identical "test1.badblocks" "$testsuite_tmpdir/test1.badblocks"
28
29	testsuite_debug "Test, first run with big skipsize and resolution to produce output with holes + marking"
30	LD_PRELOAD="$preload" $safecopy -M "MARKBAAD" -R 2 -b 1150 -f 4* -r 4* -o "$testsuite_tmpdir/test2.badblocks" debug "$testsuite_tmpdir/test2.dat" >"$testsuite_tmpdir/test2.out" 2>&1
31	if [ $? != 1 ]; then
32		testsuite_error "Run of safecopy returned wrong exit code. Output:"
33                testsuite_debug_file "$testsuite_tmpdir/test2.out"
34	fi
35	testsuite_assert_files_identical "test2.dat" "$testsuite_tmpdir/test2.dat"
36	testsuite_assert_files_identical "test1.badblocks" "$testsuite_tmpdir/test2.badblocks"
37
38	testsuite_debug "Test, incremental, big skipsize, small resolution."
39	testsuite_debug " Must transpose badblocks to correct new sectorsize."
40	testsuite_debug " Must recover data at the end of bad areas but not overwrite already recovered data."
41	LD_PRELOAD="$preload" $safecopy -R 2 -b 1024 -f 8* -i 1150 -I "$testsuite_tmpdir/test1.badblocks" -o "$testsuite_tmpdir/test3.badblocks" debug "$testsuite_tmpdir/test3.dat" >"$testsuite_tmpdir/test3.out" 2>&1
42	if [ $? != 1 ]; then
43		testsuite_error "Run of safecopy returned wrong exit code. Output:"
44                testsuite_debug_file "$testsuite_tmpdir/test3.out"
45	fi
46	testsuite_assert_files_identical "test3.dat" "$testsuite_tmpdir/test3.dat"
47	testsuite_assert_files_identical "test3.badblocks" "$testsuite_tmpdir/test3.badblocks"
48
49	testsuite_debug "Test, incremental, small skipsize and atomic resolution."
50	testsuite_debug " Must recover all recoverable data"
51	LD_PRELOAD="$preload" $safecopy -R 2 -b 1024 -f 1* -r 1 -i 1150 -I "$testsuite_tmpdir/test1.badblocks" -o "$testsuite_tmpdir/test4.badblocks" debug "$testsuite_tmpdir/test4.dat" >"$testsuite_tmpdir/test4.out" 2>&1
52	if [ $? != 1 ]; then
53		testsuite_error "Run of safecopy returned wrong exit code. Output:"
54                testsuite_debug_file "$testsuite_tmpdir/test4.out"
55	fi
56	testsuite_assert_files_identical "test4.dat" "$testsuite_tmpdir/test4.dat"
57	testsuite_assert_files_identical "test4.badblocks" "$testsuite_tmpdir/test4.badblocks"
58
59	testsuite_debug "Test, incremental, big skipsize, small resolution this time with marking."
60	testsuite_debug " Must recover data at the end of bad areas."
61	testsuite_debug " this one may overwrite successfully rescued data as long"
62	testsuite_debug " as it affects only blocks marked as bad in the include file"
63	testsuite_debug " (will affect block 7 starting at position 8050"
64	testsuite_debug "  since its marked for the bad data starting at 9000)"
65	LD_PRELOAD="$preload" $safecopy -M "MARKBAAD" -R 2 -b 1024 -f 8* -i 1150 -I "$testsuite_tmpdir/test1.badblocks" -o "$testsuite_tmpdir/test5.badblocks" debug "$testsuite_tmpdir/test5.dat" >"$testsuite_tmpdir/test5.out" 2>&1
66	if [ $? != 1 ]; then
67		testsuite_error "Run of safecopy returned wrong exit code. Output:"
68                testsuite_debug_file "$testsuite_tmpdir/test5.out"
69	fi
70	testsuite_assert_files_identical "test5.dat" "$testsuite_tmpdir/test5.dat"
71	testsuite_assert_files_identical "test3.badblocks" "$testsuite_tmpdir/test5.badblocks"
72
73	testsuite_debug "Test, incremental, small skipsize and atomic resolution, with marking."
74	testsuite_debug " Must only differ from test4.dat by shifts of marker strings, no real data differences"
75	LD_PRELOAD="$preload" $safecopy -M "MARKBAAD" -R 2 -b 1024 -f 1* -r 1 -i 1150 -I "$testsuite_tmpdir/test1.badblocks" -o "$testsuite_tmpdir/test6.badblocks" debug "$testsuite_tmpdir/test6.dat" >"$testsuite_tmpdir/test6.out" 2>&1
76	if [ $? != 1 ]; then
77		testsuite_error "Run of safecopy returned wrong exit code. Output:"
78                testsuite_debug_file "$testsuite_tmpdir/test6.out"
79	fi
80	testsuite_assert_files_identical "test6.dat" "$testsuite_tmpdir/test6.dat"
81	testsuite_assert_files_identical "test4.badblocks" "$testsuite_tmpdir/test6.badblocks"
82
83}
84
85testsuite_runtest
86
87