Skip to content

Commit 7588a7c

Browse files
committed
test: less use verbose shell constructs
1 parent f76e1c0 commit 7588a7c

File tree

4 files changed

+18
-39
lines changed

4 files changed

+18
-39
lines changed

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: 3 additions & 9 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,7 +29,7 @@ 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

4135
if test -e /dev/nbd0 ; then

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)