Follow-up to r29036: Now that the "mergeinfo" transaction file is no
[svn.git] / contrib / server-side / svnmirror-test.sh
blob59b9fcaa7a3dfb0947efe7a7c6f2bba7747d7997
1 #!/bin/sh
2 #######################################################################
4 # svnmirror-test.sh
6 #######################################################################
8 SVNMIRROR="$PWD/svnmirror.sh"
10 if [ ! -d tmp ]; then
11 mkdir tmp
13 cd tmp
14 TMPDIR="$PWD"
16 TMPOUT="$TMPDIR/svnmirror.out"
17 TMPERR="$TMPDIR/svnmirror.err"
19 RHOST="localhost"
20 LREPOS="${TMPDIR}/lrepos"
21 RREPOS="${TMPDIR}/rrepos"
22 LWC="${TMPDIR}/lwc"
23 RWC="${TMPDIR}/rwc"
25 PARAMS="push:none pull:none push:filter pull:filter"
27 mirror_check() {
28 EXPRC="$1"
29 EXPOUT="$2"
30 EXPERR="$3"
31 ERR=0
32 $SVNMIRROR > $TMPOUT 2> $TMPERR
33 RC="$?"
34 RC2=0
35 if [ $RC -gt 0 ]; then
36 RC2=1
38 if [ "$RC2" != "$RC" ]; then
39 echo "unexpected return code: $RC (expected $EXPRC)"
40 ERR=1
42 if [ -n "$EXPOUT" ]; then
43 egrep "$EXPOUT" "$TMPOUT" > /dev/null 2>&1
44 GRC="$?"
45 if [ $GRC -gt 0 ]; then
46 echo "expected out not found"
47 ERR=1
50 if [ -n "$EXPERR" ]; then
51 egrep "$EXPERR" "$TMPERR" > /dev/null 2>&1
52 GRC="$?"
53 if [ $GRC -gt 0 ]; then
54 echo "expected err not found"
55 ERR=1
58 if [ "$ERR" = "0" ]; then
59 echo "OK."
60 else
61 echo "+++ STDOUT +++"
62 cat "$TMPOUT"
63 echo "+++ STDERR +++"
64 cat "$TMPERR"
65 echo "+++ END +++"
69 for P in ${PARAMS}; do
70 MODE=`echo "$P" | sed 's/:.*$//'`
71 FLTR=`echo "$P" | sed 's/^.*://'`
72 echo ""
73 echo "*** Testing $MODE filter $FLTR ***"
74 echo ""
75 if [ "$MODE" = "push" ]; then
76 SRCREPOS="$LREPOS"
77 DSTREPOS="$RREPOS"
78 SRCWC="$LWC"
79 DSTWC="$RWC"
80 else
81 SRCREPOS="$RREPOS"
82 DSTREPOS="$LREPOS"
83 SRCWC="$RWC"
84 DSTWC="$LWC"
86 FILTER=""
87 if [ "$FLTR" = "filter" ]; then
88 FILTER="include trunk"
90 if [ -d "$LREPOS" ]; then
91 rm -rf "$LREPOS"
93 if [ -d "$RREPOS" ]; then
94 rm -rf "$RREPOS"
96 if [ -d "$LWC" ]; then
97 rm -rf "$LWC"
99 if [ -d "$RWC" ]; then
100 rm -rf "$RWC"
102 svnadmin create "$RREPOS"
103 svnadmin create "$LREPOS"
104 svn co "file://$LREPOS" "$LWC" > /dev/null
105 svn co "file://$RREPOS" "$RWC" > /dev/null
106 export MODE FILTER LREPOS RREPOS RHOST
108 echo "Test 1: both repos empty"
109 mirror_check 0 "both repositories are already at" ""
111 echo "Test 2: add trunk branches and tags."
112 svn mkdir "$SRCWC/trunk" > /dev/null
113 svn mkdir "$SRCWC/branches" > /dev/null
114 svn mkdir "$SRCWC/tags" > /dev/null
115 svn ci "$SRCWC" -m "add trunk branches and tags." > /dev/null
116 mirror_check 0 "successfull completed." ""
118 echo "Test 3: filter check."
119 svn ls "file://$SRCREPOS" > "$TMPOUT"
120 svn ls "file://$DSTREPOS" > "$TMPERR"
121 if [ "$FLTR" = "none" ]; then
122 CMD="cat"
123 else
124 CMD="egrep ^trunk/"
126 N=`$CMD "$TMPOUT" | diff - "$TMPERR" | wc -l`
127 if [ $N -gt 0 ]; then
128 echo "error."
129 echo "+++ STDOUT +++"
130 cat "$TMPOUT"
131 echo "+++ STDERR +++"
132 cat "$TMPERR"
133 echo "+++ END +++"
134 else
135 echo "OK."
138 # should be the last test bacause all following would fail
139 echo "Test 99: commit to destination repos."
140 svn up "$DSTWC" > /dev/null
141 echo "wrong repos" > "$DSTWC/trunk/wrong_repos.txt"
142 svn add "$DSTWC/trunk/wrong_repos.txt" > /dev/null
143 svn ci "$DSTWC" -m "commit to wrong repos" > /dev/null
144 mirror_check 1 "" "revision of .* repos is higher than .* one"
145 done