Skip to content

Commit 6ba855f

Browse files
authored
Merge pull request #187 from keszybz/semaphore
Semaphore fixes.
2 parents 4337343 + b5de1ba commit 6ba855f

File tree

6 files changed

+61
-55
lines changed

6 files changed

+61
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.pyc
66
*.stamp
77
*.swp
8+
.gdb_history
89
*~
910
/*.tar.bz2
1011
/*.tar.gz

test/semaphore-run

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# SPDX-License-Identifier: LGPL-2.1+
33

4-
DEVPKGS="pkg-config liblzma-dev libcurl4-openssl-dev libssl-dev libacl1-dev libfuse-dev zlib1g-dev libzstd-dev libudev-dev"
4+
DEVPKGS=(
5+
pkg-config
6+
liblzma-dev
7+
libcurl4-openssl-dev
8+
libssl-dev
9+
libacl1-dev
10+
libfuse-dev
11+
zlib1g-dev
12+
libzstd-dev
13+
libudev-dev
14+
)
515

616
echo
717
echo "============= Installing amd64 build dependencies =============="
818
set -eu
919
(
1020
set -x
11-
sudo apt-get install -y software-properties-common
12-
sudo add-apt-repository -y ppa:pitti/systemd-semaphore
21+
22+
sudo rm /etc/apt/sources.list.d/*
23+
24+
sudo apt install -y software-properties-common
25+
sudo add-apt-repository -y ppa:jonathonf/python-3.6
26+
sudo add-apt-repository -y ppa:ginggs/backports
27+
sudo apt -y update
28+
sudo apt -y --no-install-recommends install \
29+
python3.6 \
30+
squashfs-tools
31+
1332
sudo dpkg --add-architecture i386
1433
sudo apt-get update
1534

16-
sudo apt-get install -y $DEVPKGS rsync python3 meson python-sphinx
35+
sudo apt -y --no-install-recommends install \
36+
rsync \
37+
python3-pip \
38+
python3-setuptools \
39+
python3-wheel \
40+
python-sphinx \
41+
"${DEVPKGS[@]}"
42+
python3.6 -m pip install --user meson ninja
1743
)
1844

1945
echo
@@ -35,30 +61,30 @@ echo
3561
echo "============= Running amd64 tests as root =============="
3662
(
3763
set -x
38-
sudo ninja -C build test
64+
sudo CASYNC_TEST_NBD=0 $(which ninja) -C build test
3965
)
4066

4167
echo
4268
echo "============= Installing i386 build dependencies =============="
43-
# help apt to figure out replacing GI dependencies (we don't need them
44-
# anyway, but a lot of stuff is pre-installed in semaphore)
45-
(
46-
set -x
47-
sudo apt-get purge --auto-remove -y python3-gi gir1.2-glib-2.0
48-
)
4969

5070
# library -dev packages are not co-installable for multiple architectures,
5171
# so this can't go into the setup step
5272
(
5373
set -x
54-
sudo apt-get install -y --no-install-recommends gcc-multilib $(echo "$DEVPKGS " | sed 's/\b /:i386 /g')
74+
# both arch versions provide /usr/bin/curl-config, which can't go well
75+
sudo apt remove -y libcurl4-openssl-dev
76+
sudo apt-get install -y --no-install-recommends \
77+
gcc-multilib \
78+
libgcc-5-dev:i386 \
79+
"${DEVPKGS[@]/%/:i386}"
5580
)
5681

5782
echo
5883
echo "============= Building i386 =============="
5984
(
6085
set -x
61-
CFLAGS=-m32 LDFLAGS=-m32 meson build-i386
86+
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu
87+
CC=gcc-5 CFLAGS=-m32 LDFLAGS=-m32 meson build-i386
6288
ninja -C build-i386
6389
)
6490

@@ -73,5 +99,5 @@ echo
7399
echo "============= Running i386 tests as root =============="
74100
(
75101
set -x
76-
sudo linux32 ninja -C build-i386 test
102+
sudo CASYNC_TEST_NBD=0 linux32 $(which ninja) -C build-i386 test
77103
)

test/test-cache.sh.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SCRATCH_DIR=${TMPDIR:-/var/tmp}/test-casync.$RANDOM
55
mkdir -p $SCRATCH_DIR/src
66

7-
if [ `id -u` == 0 ] ; then
7+
if [ $UID = 0 ]; then
88
cp -aT @top_srcdir@ $SCRATCH_DIR/src/casync
99
else
1010
# If we lack privileges we use rsync rather than cp to copy, as it will just skip over device nodes
@@ -63,7 +63,7 @@ cmp $SCRATCH_DIR/test4.caidx $SCRATCH_DIR/test5.caidx
6363
cmp $SCRATCH_DIR/test4.caidx $SCRATCH_DIR/test6.caidx
6464
cmp $SCRATCH_DIR/test4.caidx $SCRATCH_DIR/test7.caidx
6565

66-
for f in test4 test5 test6 test7 ; do
66+
for f in test4 test5 test6 test7; do
6767
@top_builddir@/casync list $SCRATCH_DIR/$f.caidx > $SCRATCH_DIR/$f.list
6868
@top_builddir@/casync mtree $SCRATCH_DIR/$f.caidx > $SCRATCH_DIR/$f.mtree
6969
@top_builddir@/casync digest $SCRATCH_DIR/$f.caidx > $SCRATCH_DIR/$f.digest

test/test-fuse.sh.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export CASYNC_PROTOCOL_PATH
99
SCRATCH_DIR=${TMPDIR:-/var/tmp}/test-casync.$RANDOM
1010
mkdir -p $SCRATCH_DIR/src
1111

12-
if [ `id -u` == 0 ] ; then
12+
if [ $UID = 0 ]; then
1313
cp -a @top_srcdir@ $SCRATCH_DIR/src
1414
else
1515
# If we lack privileges we use rsync rather than cp to copy, as it will just skip over device nodes
@@ -28,9 +28,9 @@ diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/test.caidx.digest
2828

2929
diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/extract.digest
3030

31-
if [ `id -u` == 0 ] ; then
31+
if [ $UID = 0 ]; then
3232
modprobe fuse ||:
33-
if test -e /dev/fuse ; then
33+
if [ -e /dev/fuse ]; then
3434
MOUNT_PID=`@top_builddir@/notify-wait @top_builddir@/casync $PARAMS mount $SCRATCH_DIR/test.caidx $SCRATCH_DIR/mount`
3535

3636
@top_builddir@/casync $PARAMS digest $SCRATCH_DIR/extract > $SCRATCH_DIR/mount.digest

test/test-nbd.sh.in

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
#!/bin/bash -ex
22
# SPDX-License-Identifier: LGPL-2.1+
33

4-
if [ -z "$1" ] ; then
5-
DIGEST=sha512-256
6-
else
7-
DIGEST="$1"
8-
fi
9-
4+
DIGEST=${1:-sha512-256}
105
PARAMS="-v --digest=$DIGEST"
116

12-
CASYNC_PROTOCOL_PATH=@top_builddir@
13-
export CASYNC_PROTOCOL_PATH
7+
export CASYNC_PROTOCOL_PATH=@top_builddir@
148

159
SCRATCH_DIR=${TMPDIR:-/var/tmp}/test-casync.$RANDOM
1610
mkdir -p $SCRATCH_DIR
@@ -35,10 +29,10 @@ diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/test.caibx.digest
3529
diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/extract.digest
3630
diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/extract2.digest
3731

38-
if [ `id -u` == 0 ] ; then
32+
if [ $UID = 0 ]; then
3933
modprobe nbd ||:
4034

41-
if test -e /dev/nbd0 ; then
35+
if [ -e /dev/nbd0 -a ${CASYNC_TEST_NBD:-1} = 1 ]; then
4236
MKDEV_PID=`@top_builddir@/notify-wait @top_builddir@/casync $PARAMS mkdev $SCRATCH_DIR/test.caibx $SCRATCH_DIR/test-node`
4337

4438
dd if=$SCRATCH_DIR/test-node bs=102400 count=80 | @top_builddir@/test-calc-digest $DIGEST > $SCRATCH_DIR/mkdev.digest

test/test-script.sh.in

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
#!/bin/bash -ex
22
# SPDX-License-Identifier: LGPL-2.1+
33

4-
if [ -z "$1" ] ; then
5-
DIGEST=sha512-256
6-
else
7-
DIGEST="$1"
8-
fi
4+
DIGEST=${1:-sha512-256}
5+
COMPRESSION=${2:-zstd}
96

10-
if [ -z "$2" ] ; then
11-
COMPRESSION=zstd
12-
else
13-
COMPRESSION="$2"
7+
PARAMS="-v --digest=$DIGEST --compression=$COMPRESSION"
8+
if [ $UID != 0 ]; then
9+
PARAMS="$PARAMS --without=privileged"
1410
fi
1511

16-
if [ `id -u` == 0 ] ; then
17-
PARAMS="-v --digest=$DIGEST --compression=$COMPRESSION"
18-
else
19-
PARAMS="-v --without=privileged --digest=$DIGEST --compression=$COMPRESSION"
20-
fi
21-
22-
CASYNC_PROTOCOL_PATH=@top_builddir@
23-
export CASYNC_PROTOCOL_PATH
12+
export CASYNC_PROTOCOL_PATH=@top_builddir@
2413

2514
SCRATCH_DIR=${TMPDIR:-/var/tmp}/test-casync.$RANDOM
2615
mkdir -p $SCRATCH_DIR/src
2716

28-
if [ `id -u` == 0 ] ; then
17+
if [ $UID = 0 ]; then
2918
cp -aT @top_srcdir@ $SCRATCH_DIR/src/casync
3019
else
3120
# If we lack privileges we use rsync rather than cp to copy, as it will just skip over device nodes
@@ -136,11 +125,8 @@ diff -q $SCRATCH_DIR/original-seek.mtree $SCRATCH_DIR/extract-seek-caidx.mtree
136125

137126
### Test SSH Remoting
138127

139-
CASYNC_SSH_PATH=@top_srcdir@/test/pseudo-ssh
140-
export CASYNC_SSH_PATH
141-
142-
CASYNC_REMOTE_PATH=@top_builddir@/casync
143-
export CASYNC_REMOTE_PATH
128+
export CASYNC_SSH_PATH=@top_srcdir@/test/pseudo-ssh
129+
export CASYNC_REMOTE_PATH=@top_builddir@/casync
144130

145131
@top_builddir@/casync $PARAMS list localhost:$SCRATCH_DIR/test.caidx > $SCRATCH_DIR/test-remote.caidx.list
146132
@top_builddir@/casync $PARAMS mtree localhost:$SCRATCH_DIR/test.caidx > $SCRATCH_DIR/test-remote.caidx.mtree
@@ -180,8 +166,7 @@ diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/test2.catar.digest
180166

181167
HTTP_PORT=$((10000 + $$ % 10000))
182168

183-
CASYNC_PROTOCOL_PATH=@top_builddir@
184-
export CASYNC_PROTOCOL_PATH
169+
export CASYNC_PROTOCOL_PATH=@top_builddir@
185170

186171
HTTP_PID=`@top_builddir@/notify-wait @top_srcdir@/test/http-server.py $SCRATCH_DIR $HTTP_PORT`
187172

0 commit comments

Comments
 (0)