Debian Codegraph @

t/t-malformed-pointers.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 begin_test "malformed pointers"
6 (
7 set -e
8
9 reponame="malformed-pointers"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
12
13 gitscip-shell system . . git. lfs track "*.dat"
14 gitscip-shell system . . git. add .gitattributes
15 gitscip-shell system . . git. commit -m "initial commit"
16
17 # Test with file sizes smaller than, equal to, and larger than the
18 # size of the read buffer used when decoding pointers.
19 # See https://github.com/git-lfs/git-lfs/issues/1729
20 # and https://github.com/git-lfs/git-lfs/pull/1796.
21 max_pointer_size="$(lfstest-getlimit --max-pointer-size)"
22 lfstest-genrandom --base64 $((max_pointer_size - 1)) >malformed_small.dat
23 lfstest-genrandom --base64 "$max_pointer_size" >malformed_exact.dat
24 lfstest-genrandom --base64 $((max_pointer_size + 1)) >malformed_large.dat
25
26 # Test with a file size significantly larger than the default pipe capacity
27 # of Linux/macOS. See https://github.com/git-lfs/git-lfs/pull/1922
28 # and https://github.com/git-lfs/git-lfs/pull/1932.
29 max_pipe_capacity="65536"
30 lfstest-genrandom --base64 $((max_pipe_capacity * 16)) >malformed_xxl.dat
31
32 gitscip-shell system . . git. \
33 -c "filter.lfs.process=" \
34 -c "filter.lfs.clean=cat" \
35 -c "filter.lfs.required=false" \
36 add *.dat
37 gitscip-shell system . . git. commit -m "add malformed pointer"
38
39 gitscip-shell system . . git. push origin main
40
41 pushd .. >/dev/nullscip-shell filesystem . . `/dev/null`.
42 clone_repo "$reponame" "$reponame-assert"
43
44 grepscip-shell system . . grep. "malformed_small.dat" clone.log
45 grepscip-shell system . . grep. "malformed_exact.dat" clone.log
46 grepscip-shell system . . grep. "malformed_large.dat" clone.log
47 grepscip-shell system . . grep. "malformed_xxl.dat" clone.log
48
49 expected_small="$(catscip-shell system . . cat. ../$reponame/malformed_small.dat)"
50 expected_exact="$(catscip-shell system . . cat. ../$reponame/malformed_exact.dat)"
51 expected_large="$(catscip-shell system . . cat. ../$reponame/malformed_large.dat)"
52 expected_xxl="$(catscip-shell system . . cat. ../$reponame/malformed_xxl.dat)"
53
54 actual_small="$(catscip-shell system . . cat. malformed_small.dat)"
55 actual_exact="$(catscip-shell system . . cat. malformed_exact.dat)"
56 actual_large="$(catscip-shell system . . cat. malformed_large.dat)"
57 actual_xxl="$(catscip-shell system . . cat. malformed_xxl.dat)"
58
59 [scip-shell system . . `[`. "$expected_small" = "$actual_small" ]
60 [scip-shell system . . `[`. "$expected_exact" = "$actual_exact" ]
61 [scip-shell system . . `[`. "$expected_large" = "$actual_large" ]
62 [scip-shell system . . `[`. "$expected_xxl" = "$actual_xxl" ]
63 popd >/dev/nullscip-shell filesystem . . `/dev/null`.
64 )
65 end_test
66
67 begin_test "empty pointers"
68 (
69 set -e
70
71 reponame="empty-pointers"
72 setup_remote_repo "$reponame"
73 clone_repo "$reponame" "$reponame"
74
75 gitscip-shell system . . git. lfs track "*.dat"
76 gitscip-shell system . . git. add .gitattributes
77 gitscip-shell system . . git. commit -m "initial commit"
78
79 touchscip-shell system . . touch. empty.dat
80
81 gitscip-shell system . . git. \
82 -c "filter.lfs.process=" \
83 -c "filter.lfs.clean=cat" \
84 -c "filter.lfs.required=false" \
85 add empty.dat
86 gitscip-shell system . . git. commit -m "add empty pointer"
87
88 [scip-shell system . . `[`. "0" -eq "$(gitscip-shell system . . git. cat-file -p :empty.dat | wcscip-shell system . . wc. -c)" ]
89 [scip-shell system . . `[`. "0" -eq "$(wcscip-shell system . . wc. -c < empty.dat)" ]
90
91 gitscip-shell system . . git. push origin main
92
93 pushd .. >/dev/nullscip-shell filesystem . . `/dev/null`.
94 clone_repo "$reponame" "$reponame-assert"
95
96 [scip-shell system . . `[`. "0" -eq "$(grepscip-shell system . . grep. -c "empty.dat" clone.log)" ]
97
98 [scip-shell system . . `[`. "0" -eq "$(gitscip-shell system . . git. cat-file -p :empty.dat | wcscip-shell system . . wc. -c)" ]
99 [scip-shell system . . `[`. "0" -eq "$(wcscip-shell system . . wc. -c < empty.dat)" ]
100 popd >/dev/nullscip-shell filesystem . . `/dev/null`.
101 )
102 end_test