blob: ea28971e8ee6abfcd3c0394c6d8b143c75ac12dd [file] [log] [blame]
Ævar Arnfjörð Bjarmason7a98d9a2022-04-13 22:01:47 +02001if test -z "$TEST_FAILS_SANITIZE_LEAK"
2then
3 TEST_PASSES_SANITIZE_LEAK=true
4fi
Eric Wong36f5b1f2006-05-23 19:23:41 -07005. ./test-lib.sh
6
Eric Wong60d02cc2006-07-06 00:14:16 -07007if test -n "$NO_SVN_TESTS"
8then
Ævar Arnfjörð Bjarmasonfadb5152010-06-24 17:44:48 +00009 skip_all='skipping git svn tests, NO_SVN_TESTS defined'
Eric Wong60d02cc2006-07-06 00:14:16 -070010 test_done
Eric Wong60d02cc2006-07-06 00:14:16 -070011fi
Jeff King1b19ccd2009-04-03 15:33:59 -040012if ! test_have_prereq PERL; then
Ævar Arnfjörð Bjarmasonfadb5152010-06-24 17:44:48 +000013 skip_all='skipping git svn tests, perl not available'
Jeff King1b19ccd2009-04-03 15:33:59 -040014 test_done
15fi
Eric Wong60d02cc2006-07-06 00:14:16 -070016
Eric Wong36f5b1f2006-05-23 19:23:41 -070017GIT_DIR=$PWD/.git
Adam Brewster6f5748e2009-08-11 23:14:27 -040018GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
Eric Wonga5e0ced2006-06-12 15:23:48 -070019SVN_TREE=$GIT_SVN_DIR/svn-tree
SZEDER Gáborfa840582019-01-05 02:08:58 +010020test_set_port SVNSERVE_PORT
Eric Wong36f5b1f2006-05-23 19:23:41 -070021
Eric Wong36f5b1f2006-05-23 19:23:41 -070022svn >/dev/null 2>&1
Junio C Hamano4b832e82006-07-07 03:17:16 -070023if test $? -ne 1
Eric Wong36f5b1f2006-05-23 19:23:41 -070024then
Todd Zullinger78109772017-12-01 10:56:52 -050025 skip_all='skipping git svn tests, svn not found'
26 test_done
Eric Wong36f5b1f2006-05-23 19:23:41 -070027fi
28
29svnrepo=$PWD/svnrepo
Bryan Donlancdf3ec02008-05-04 01:37:57 -040030export svnrepo
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040031svnconf=$PWD/svnconf
32export svnconf
Eric Wong36f5b1f2006-05-23 19:23:41 -070033
Jeff King94221d22013-10-28 21:23:03 -040034perl -w -e "
Eric Wongc6d499a2006-12-31 21:49:45 -080035use SVN::Core;
36use SVN::Repos;
37\$SVN::Core::VERSION gt '1.1.0' or exit(42);
Bryan Donlancdf3ec02008-05-04 01:37:57 -040038system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
Shawn O. Pearce38434f22007-01-14 03:22:47 -050039" >&3 2>&4
Eric Wongc6d499a2006-12-31 21:49:45 -080040x=$?
41if test $x -ne 0
Eric Wongdc62e252006-06-28 03:07:14 -070042then
Eric Wongc6d499a2006-12-31 21:49:45 -080043 if test $x -eq 42; then
Ævar Arnfjörð Bjarmasone8344e82010-07-08 01:16:06 +000044 skip_all='Perl SVN libraries must be >= 1.1.0'
Eric Wonge66191f2007-01-13 02:47:53 -080045 elif test $x -eq 41; then
Ævar Arnfjörð Bjarmasone8344e82010-07-08 01:16:06 +000046 skip_all='svnadmin failed to create fsfs repository'
Eric Wongc6d499a2006-12-31 21:49:45 -080047 else
Ævar Arnfjörð Bjarmasone8344e82010-07-08 01:16:06 +000048 skip_all='Perl SVN libraries not found or unusable'
Eric Wongc6d499a2006-12-31 21:49:45 -080049 fi
Eric Wongc6d499a2006-12-31 21:49:45 -080050 test_done
Eric Wongdc62e252006-06-28 03:07:14 -070051fi
52
sam@vilain.net2edb9c52006-12-05 16:17:38 +110053rawsvnrepo="$svnrepo"
Eric Wonge1516112006-11-27 21:46:50 -080054svnrepo="file://$svnrepo"
Eric Wong36f5b1f2006-05-23 19:23:41 -070055
Michael Spang7b3fab82007-02-12 19:33:37 -050056poke() {
Nguyễn Thái Ngọc Duy0e496492018-03-24 08:44:31 +010057 test-tool chmtime +1 "$1"
Michael Spang7b3fab82007-02-12 19:33:37 -050058}
Eric Wong29633bb2007-07-15 21:53:50 -070059
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040060# We need this, because we should pass empty configuration directory to
61# the 'svn commit' to avoid automated property changes and other stuff
62# that could be set from user's configuration files in ~/.subversion.
63svn_cmd () {
64 [ -d "$svnconf" ] || mkdir "$svnconf"
65 orig_svncmd="$1"; shift
66 if [ -z "$orig_svncmd" ]; then
67 svn
68 return
69 fi
70 svn "$orig_svncmd" --config-dir "$svnconf" "$@"
71}
72
Eric Wonga8a5d252016-07-23 04:26:08 +000073maybe_start_httpd () {
74 loc=${1-svn}
Eric Wong29633bb2007-07-15 21:53:50 -070075
SZEDER Gábor43a2afe2019-11-22 14:14:36 +010076 if test_bool_env GIT_TEST_SVN_HTTPD false
Ævar Arnfjörð Bjarmason3b072c52019-06-21 12:18:11 +020077 then
Eric Wonga8a5d252016-07-23 04:26:08 +000078 . "$TEST_DIRECTORY"/lib-httpd.sh
79 LIB_HTTPD_SVN="$loc"
80 start_httpd
Ævar Arnfjörð Bjarmason3b072c52019-06-21 12:18:11 +020081 fi
Eric Wong29633bb2007-07-15 21:53:50 -070082}
Eric Wong060610c2007-12-08 23:27:41 -080083
84convert_to_rev_db () {
brian m. carlson148f1932020-06-22 18:04:11 +000085 perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF
Eric Wong060610c2007-12-08 23:27:41 -080086use strict;
brian m. carlson148f1932020-06-22 18:04:11 +000087my $oidlen = shift;
David Aguilarb9784032013-02-24 14:48:39 -080088@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
brian m. carlson148f1932020-06-22 18:04:11 +000089my $record_size = $oidlen + 4;
90my $hexlen = $oidlen * 2;
Eric Wong060610c2007-12-08 23:27:41 -080091open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
92open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
93my $size = (stat($rd))[7];
brian m. carlson148f1932020-06-22 18:04:11 +000094($size % $record_size) == 0 or die "Inconsistent size: $size";
95while (sysread($rd, my $buf, $record_size) == $record_size) {
96 my ($r, $c) = unpack("NH$hexlen", $buf);
97 my $offset = $r * ($hexlen + 1);
Eric Wong060610c2007-12-08 23:27:41 -080098 seek $wr, 0, 2 or die $!;
99 my $pos = tell $wr;
100 if ($pos < $offset) {
brian m. carlson148f1932020-06-22 18:04:11 +0000101 for (1 .. (($offset - $pos) / ($hexlen + 1))) {
102 print $wr (('0' x $hexlen),"\n") or die $!;
Eric Wong060610c2007-12-08 23:27:41 -0800103 }
104 }
105 seek $wr, $offset, 0 or die $!;
106 print $wr $c,"\n" or die $!;
107}
108close $wr or die $!;
109close $rd or die $!;
110EOF
111}
Alec Berrymandd9da512008-09-14 17:14:15 -0400112
113require_svnserve () {
SZEDER Gábor43a2afe2019-11-22 14:14:36 +0100114 if ! test_bool_env GIT_TEST_SVNSERVE false
Todd Zullinger78109772017-12-01 10:56:52 -0500115 then
Todd Zullingerbf9d7df2017-12-01 10:56:53 -0500116 skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)'
Todd Zullinger78109772017-12-01 10:56:52 -0500117 test_done
118 fi
Alec Berrymandd9da512008-09-14 17:14:15 -0400119}
120
121start_svnserve () {
Todd Zullinger78109772017-12-01 10:56:52 -0500122 svnserve --listen-port $SVNSERVE_PORT \
123 --root "$rawsvnrepo" \
124 --listen-once \
125 --listen-host 127.0.0.1 &
Alec Berrymandd9da512008-09-14 17:14:15 -0400126}
127
Đoàn Trần Công Danh482c9622021-06-08 13:56:28 +0700128prepare_utf8_locale () {
129 if test -z "$GIT_TEST_UTF8_LOCALE"
130 then
131 case "${LC_ALL:-$LANG}" in
132 *.[Uu][Tt][Ff]8 | *.[Uu][Tt][Ff]-8)
133 GIT_TEST_UTF8_LOCALE="${LC_ALL:-$LANG}"
134 ;;
135 *)
136 GIT_TEST_UTF8_LOCALE=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
137 p
138 q
139 }')
140 ;;
141 esac
142 fi
143 if test -n "$GIT_TEST_UTF8_LOCALE"
Eric Wong3df0d262016-02-22 02:17:51 +0000144 then
145 test_set_prereq UTF8
146 else
147 say "# UTF-8 locale not available, some tests are skipped"
148 fi
149}