3 6ae16afd 2022-10-31 stsp # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
5 6ae16afd 2022-10-31 stsp # Permission to use, copy, modify, and distribute this software for any
6 6ae16afd 2022-10-31 stsp # purpose with or without fee is hereby granted, provided that the above
7 6ae16afd 2022-10-31 stsp # copyright notice and this permission notice appear in all copies.
9 6ae16afd 2022-10-31 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 6ae16afd 2022-10-31 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 6ae16afd 2022-10-31 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 6ae16afd 2022-10-31 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 6ae16afd 2022-10-31 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 6ae16afd 2022-10-31 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 6ae16afd 2022-10-31 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 6ae16afd 2022-10-31 stsp . ../cmdline/common.sh
18 6ae16afd 2022-10-31 stsp . ./common.sh
20 6ae16afd 2022-10-31 stsp test_send_basic() {
21 6ae16afd 2022-10-31 stsp local testroot=`test_init send_basic 1`
23 6ae16afd 2022-10-31 stsp ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.before
25 6ae16afd 2022-10-31 stsp got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
27 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
28 6ae16afd 2022-10-31 stsp echo "got clone failed unexpectedly" >&2
29 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
33 5dd8d22b 2023-01-09 stsp # create a second clone to test an incremental fetch with later
34 5dd8d22b 2023-01-09 stsp got clone -q -m ${GOTD_TEST_REPO_URL} $testroot/repo-clone2
36 5dd8d22b 2023-01-09 stsp if [ $ret -ne 0 ]; then
37 5dd8d22b 2023-01-09 stsp echo "got clone failed unexpectedly" >&2
38 5dd8d22b 2023-01-09 stsp test_done "$testroot" "1"
42 6ae16afd 2022-10-31 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
44 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
45 6ae16afd 2022-10-31 stsp echo "got checkout failed unexpectedly" >&2
46 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
50 6ae16afd 2022-10-31 stsp mkdir $testroot/wt/psi
51 6ae16afd 2022-10-31 stsp echo "new" > $testroot/wt/psi/new
52 6ae16afd 2022-10-31 stsp (cd $testroot/wt && got add psi/new > /dev/null)
53 6ae16afd 2022-10-31 stsp echo "more alpha" >> $testroot/wt/alpha
54 6ae16afd 2022-10-31 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
56 6ae16afd 2022-10-31 stsp got send -q -r $testroot/repo-clone
58 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
59 6ae16afd 2022-10-31 stsp echo "got send failed unexpectedly" >&2
60 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
64 6ae16afd 2022-10-31 stsp # Verify that the send operation worked fine.
65 5dd8d22b 2023-01-09 stsp got fetch -q -r $testroot/repo-clone2
67 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
68 5dd8d22b 2023-01-09 stsp echo "got fetch failed unexpectedly" >&2
69 6ae16afd 2022-10-31 stsp test_done "$testroot" "1"
73 6ae16afd 2022-10-31 stsp got tree -R -r $testroot/repo-clone2 > $testroot/stdout
74 6ae16afd 2022-10-31 stsp cat > $testroot/stdout.expected <<EOF
78 6ae16afd 2022-10-31 stsp epsilon/zeta
84 6ae16afd 2022-10-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
86 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
87 6ae16afd 2022-10-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
88 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
92 6ae16afd 2022-10-31 stsp # sending to a repository should result in a new pack file
93 6ae16afd 2022-10-31 stsp ls -R ${GOTD_TEST_REPO} > $testroot/repo-list.after
94 6ae16afd 2022-10-31 stsp diff -u $testroot/repo-list.before $testroot/repo-list.after \
95 6ae16afd 2022-10-31 stsp > $testroot/repo-list.diff
96 6ae16afd 2022-10-31 stsp grep '^+[^+]' < $testroot/repo-list.diff > $testroot/repo-list.newlines
97 6ae16afd 2022-10-31 stsp nplus=`wc -l < $testroot/repo-list.newlines | tr -d ' '`
98 6ae16afd 2022-10-31 stsp if [ "$nplus" != "2" ]; then
99 6ae16afd 2022-10-31 stsp echo "$nplus new files created"
100 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
103 6ae16afd 2022-10-31 stsp egrep -q '\+pack-[a-f0-9]{40}.pack' $testroot/repo-list.newlines
105 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
106 6ae16afd 2022-10-31 stsp echo "new pack file not found in ${GOTD_TEST_REPO}"
107 6ae16afd 2022-10-31 stsp cat $testroot/repo-list.newlines
108 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
111 6ae16afd 2022-10-31 stsp egrep -q '\+pack-[a-f0-9]{40}.idx' $testroot/repo-list.newlines
113 6ae16afd 2022-10-31 stsp if [ $ret -ne 0 ]; then
114 6ae16afd 2022-10-31 stsp echo "new pack index not found in ${GOTD_TEST_REPO}"
115 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
119 6ae16afd 2022-10-31 stsp test_done "$testroot" "$ret"
122 6ae16afd 2022-10-31 stsp test_parseargs "$@"
123 6ae16afd 2022-10-31 stsp run_test test_send_basic