Blame view

.travis.sh 4.58 KB
redmine authored
1
#!/bin/sh -x
Andrew Savchenko authored
2

redmine authored
3 4 5 6
# configuration

TIMEOUT_SYNC=15

redmine authored
7 8 9 10 11 12 13 14 15
case $(uname -s) in
	Linux)
		MAKE='make'
		;;
	*)
		MAKE='gmake'
		;;
esac

Andrew Savchenko authored
16
# test aggressive optimizations
redmine authored
17
export CFLAGS="$CFLAGS -O3 -march=native"
Andrew Savchenko authored
18 19
autoreconf -if

Andrew Savchenko authored
20 21
# Build unit test
build_test() {
redmine authored
22
	$MAKE clean
redmine authored
23 24
	echo ">>> Testing with \"$@\""
	# make sure we test paralled build as they tend to fail when single works
redmine authored
25 26
	#./configure -C $@ >/dev/null || rm -f config.cache && ./configure -C $@ >/dev/null && $MAKE -j5 >/dev/null || {
	./configure $@ >/dev/null && $MAKE -j5 >/dev/null || {
redmine authored
27
		echo "!!! test with \"$@\" configure options failed"
redmine authored
28 29
		cat config.log
		echo "!!! test with \"$@\" configure options failed"
redmine authored
30 31
		exit 1
	}
Andrew Savchenko authored
32 33
}

redmine authored
34 35
# Cleanup functions for run_example()
run_example_cleanup_success() {
redmine authored
36
	rm -rf "examples/testdir"/{to,from}/*
redmine authored
37
	sudo pkill -F "$CLSYNC_PIDFILE"
redmine authored
38 39
}
run_example_cleanup_failure() {
redmine authored
40
	sudo pkill -F "$CLSYNC_PIDFILE" 2>/dev/null
redmine authored
41
	echo "$@" >&2
redmine authored
42 43 44 45
	exit 1
}

# Run example script
redmine authored
46
run_example_counter=0
redmine authored
47
run_example() {
redmine authored
48
	MODE="$1"; shift;
redmine authored
49

redmine authored
50 51 52
	export CLSYNC_PIDFILE="/tmp/clsync-example-$MODE.$$.${run_example_counter}.pid"

	run_example_counter=$(( $run_example_counter + 1 ))
redmine authored
53

redmine authored
54 55
	rm -rf "examples/testdir"/*/*
	mkdir -p "examples/testdir/to" "examples/testdir/from"
redmine authored
56 57

	trap run_example_cleanup_failure INT TERM
redmine authored
58 59 60 61
	(
		cd examples
		bash -x clsync-start-"$MODE".sh --background --pid-file "$CLSYNC_PIDFILE" --config-file '/NULL/' -w1 -t1 -d0 $@
	)
redmine authored
62 63 64

	sleep 1
	mkdir -p examples/testdir/from/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/DIR
redmine authored
65 66 67
	touch examples/testdir/from/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a
	touch examples/testdir/from/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/b
	touch examples/testdir/from/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/c
redmine authored
68
	touch examples/testdir/from/a/b/c/d/e/f/g/h/7
redmine authored
69 70 71 72
	touch examples/testdir/from/test
	mkdir examples/testdir/from/dontSync
	i=0
	while [ "$i" -le "$TIMEOUT_SYNC" ]; do
redmine authored
73
		if [ -f "examples/testdir/to/test" -a -f "examples/testdir/to/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a" -a -d "examples/testdir/to/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/DIR" ]; then
redmine authored
74 75 76 77
			sleep 1
			break
		fi
		sleep 1
redmine authored
78
		i=$(( $i + 1 ))
redmine authored
79 80
	done
	if [ "$i" -gt "$TIMEOUT_SYNC" ]; then
redmine authored
81
		run_example_cleanup_failure "$MODE" "timed out on initial syncing"
redmine authored
82 83
	fi
	if ! [ -f "$CLSYNC_PIDFILE" ]; then
redmine authored
84
		run_example_cleanup_failure "$MODE" "no pidfile"
redmine authored
85 86 87 88 89 90
	fi
	touch "examples/testdir/from/file" "examples/testdir/from/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/DIR/file"
	rm -rf "examples/testdir/from/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/DIR"
	i=0
	while [ "$i" -le "$TIMEOUT_SYNC" ]; do
		if ! [ -f "$CLSYNC_PIDFILE" ]; then
redmine authored
91
			run_example_cleanup_failure "$MODE" "premature exit"
redmine authored
92
		fi
redmine authored
93
		if [ -f "examples/testdir/to/file" -a ! -d "examples/testdir/to/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/DIR" ]; then
redmine authored
94 95 96 97 98
			sleep 1
			run_example_cleanup_success
			return
		fi
		sleep 1
redmine authored
99
		i=$(( $i + 1 ))
redmine authored
100
	done
redmine authored
101
	run_example_cleanup_failure "$MODE" "no successful sync"
redmine authored
102 103
}

redmine authored
104
if true; then
redmine authored
105

redmine authored
106 107 108 109 110 111 112
	# Test all possible package-specific configure options.
	# Do not test empty cases save as no options at all.

	build_test

	# clsync enabled
	a0="--enable-clsync"
redmine authored
113 114
	for a1 in "--enable-cluster" "--disable-cluster"; do
#	for a2 in "--enable-debug" "--disable-debug"; do
redmine authored
115
	for a3 in "--enable-paranoid=0" "--enable-paranoid=1" "--enable-paranoid=2" ; do
redmine authored
116
	for a4 in "--enable-capabilities" "--disable-capabilities"; do
redmine authored
117 118
	for a5 in "--enable-socket" "--disable-socket"; do
	for a6 in "--enable-socket-library" "--disable-socket-library"; do
redmine authored
119
	for a7 in "--enable-highload-locks" ""; do
redmine authored
120
#	for a8 in "--with-libcgroup" "--without-libcgroup"; do
redmine authored
121
#	for a9 in "--enable-seccomp" "--disable-seccomp"; do
redmine authored
122
		arg="$a0 $a1 $a2 $a3 $a4 $a5 $a6 $a7 $a8 $a9"
redmine authored
123 124 125 126
		build_test "$arg"
	done
	done
	done
redmine authored
127
	done
Andrew Savchenko authored
128
	done
redmine authored
129
	done
redmine authored
130 131 132
#	done
#	done
#	done
redmine authored
133

redmine authored
134 135
	# clsync disabled, libclsync enabled
	a0="--disable-clsync --enable-socket-library"
redmine authored
136
#	for a2 in "--enable-debug" "--disable-debug"; do
redmine authored
137 138 139
	for a3 in "--enable-paranoid=0" "--enable-paranoid=1" "--enable-paranoid=2" ; do
		arg="$a0 $a1 $a2"
		build_test "$arg"
redmine authored
140
#	done
redmine authored
141
	done
redmine authored
142

redmine authored
143 144
	# clsync disabled, libclsync disabled
	build_test "--disable-clsync --disable-socket-library"
redmine authored
145

redmine authored
146
fi
redmine authored
147

redmine authored
148
if true; then
redmine authored
149
	export PATH="$(pwd):$PATH"
redmine authored
150

redmine authored
151
	# Functionality test
redmine authored
152

redmine authored
153
	build_test --enable-cluster --enable-debug --enable-paranoid=0 --enable-capabilities --without-mhash
redmine authored
154
	run_example rsyncdirect
redmine authored
155 156 157 158
	run_example rsyncdirect --splitting=thread --threading=off
	run_example rsyncdirect --splitting=process --threading=off
	run_example rsyncdirect --threading=safe
#	run_example rsyncshell
redmine authored
159 160 161
#	run_example rsyncso
	#run_example so
	#run_example cluster
redmine authored
162

redmine authored
163
fi
redmine authored
164 165

exit 0