vcs-svn: read the preimage when applying deltas
[git/gitweb.git] / t / t9011-svn-da.sh
blob90b6058ab67d38edcd576ec040e1dd3cee2368d0
1 #!/bin/sh
3 test_description='test parsing of svndiff0 files
5 Using the "test-svn-fe -d" helper, check that svn-fe correctly
6 interprets deltas using various facilities (some from the spec,
7 some only learned from practice).
9 . ./test-lib.sh
11 >empty
12 printf foo >preimage
14 test_expect_success 'reject empty delta' '
15 test_must_fail test-svn-fe -d preimage empty 0
18 test_expect_success 'delta can empty file' '
19 printf "SVNQ" | q_to_nul >clear.delta &&
20 test-svn-fe -d preimage clear.delta 4 >actual &&
21 test_cmp empty actual
24 test_expect_success 'reject svndiff2' '
25 printf "SVN\002" >bad.filetype &&
26 test_must_fail test-svn-fe -d preimage bad.filetype 4
29 test_expect_success 'one-window empty delta' '
30 printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow &&
31 test-svn-fe -d preimage clear.onewindow 9 >actual &&
32 test_cmp empty actual
35 test_expect_success 'reject incomplete window header' '
36 printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow &&
37 printf "SVNQ%s" "QQ" | q_to_nul >clear.partialwindow &&
38 test_must_fail test-svn-fe -d preimage clear.onewindow 6 &&
39 test_must_fail test-svn-fe -d preimage clear.partialwindow 6
42 test_expect_success 'reject declared delta longer than actual delta' '
43 printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow &&
44 printf "SVNQ%s" "QQ" | q_to_nul >clear.partialwindow &&
45 test_must_fail test-svn-fe -d preimage clear.onewindow 14 &&
46 test_must_fail test-svn-fe -d preimage clear.partialwindow 9
49 test_expect_success 'two-window empty delta' '
50 printf "SVNQ%s%s" "QQQQQ" "QQQQQ" | q_to_nul >clear.twowindow &&
51 test-svn-fe -d preimage clear.twowindow 14 >actual &&
52 test_must_fail test-svn-fe -d preimage clear.twowindow 13 &&
53 test_cmp empty actual
56 test_expect_success 'noisy zeroes' '
57 printf "SVNQ%s" \
58 "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQ" |
59 tr R "\200" |
60 q_to_nul >clear.noisy &&
61 len=$(wc -c <clear.noisy) &&
62 test-svn-fe -d preimage clear.noisy $len &&
63 test_cmp empty actual
66 test_expect_success 'reject variable-length int in magic' '
67 printf "SVNRQ" | tr R "\200" | q_to_nul >clear.badmagic &&
68 test_must_fail test-svn-fe -d preimage clear.badmagic 5
71 test_expect_success 'reject truncated integer' '
72 printf "SVNQ%s%s" "QQQQQ" "QQQQRRQ" |
73 tr R "\200" |
74 q_to_nul >clear.fullint &&
75 printf "SVNQ%s%s" "QQQQQ" "QQQQRR" |
76 tr RT "\201" |
77 q_to_nul >clear.partialint &&
78 test_must_fail test-svn-fe -d preimage clear.fullint 15 &&
79 test-svn-fe -d preimage clear.fullint 16 &&
80 test_must_fail test-svn-fe -d preimage clear.partialint 15
83 test_expect_success 'nonempty (but unused) preimage view' '
84 printf "SVNQ%b" "Q\003QQQ" | q_to_nul >clear.readpreimage &&
85 test-svn-fe -d preimage clear.readpreimage 9 >actual &&
86 test_cmp empty actual
89 test_expect_success 'preimage view: right endpoint cannot backtrack' '
90 printf "SVNQ%b%b" "Q\003QQQ" "Q\002QQQ" |
91 q_to_nul >clear.backtrack &&
92 test_must_fail test-svn-fe -d preimage clear.backtrack 14
95 test_expect_success 'preimage view: left endpoint can advance' '
96 printf "SVNQ%b%b" "Q\003QQQ" "\001\002QQQ" |
97 q_to_nul >clear.preshrink &&
98 printf "SVNQ%b%b" "Q\003QQQ" "\001\001QQQ" |
99 q_to_nul >clear.shrinkbacktrack &&
100 test-svn-fe -d preimage clear.preshrink 14 >actual &&
101 test_must_fail test-svn-fe -d preimage clear.shrinkbacktrack 14 &&
102 test_cmp empty actual
105 test_expect_success 'preimage view: offsets compared by value' '
106 printf "SVNQ%b%b" "\001\001QQQ" "\0200Q\003QQQ" |
107 q_to_nul >clear.noisybacktrack &&
108 printf "SVNQ%b%b" "\001\001QQQ" "\0200\001\002QQQ" |
109 q_to_nul >clear.noisyadvance &&
110 test_must_fail test-svn-fe -d preimage clear.noisybacktrack 15 &&
111 test-svn-fe -d preimage clear.noisyadvance 15 &&
112 test_cmp empty actual
115 test_expect_success 'preimage view: reject truncated preimage' '
116 printf "SVNQ%b" "\010QQQQ" | q_to_nul >clear.lateemptyread &&
117 printf "SVNQ%b" "\010\001QQQ" | q_to_nul >clear.latenonemptyread &&
118 printf "SVNQ%b" "\001\010QQQ" | q_to_nul >clear.longread &&
119 test_must_fail test-svn-fe -d preimage clear.lateemptyread 9 &&
120 test_must_fail test-svn-fe -d preimage clear.latenonemptyread 9 &&
121 test_must_fail test-svn-fe -d preimage clear.longread 9
124 test_done