Skip to content

Commit 812e485

Browse files
committed
test: add explicit test for seed
The test checks if the seed is fully reliable and sufficient as a chunk store: it packs up a tree, then removes the chunk store, but retaining hte original tree to us as seed in place ot the chunk store.
1 parent 719e24c commit 812e485

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

meson.build

+8
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ test_cache = find_program(test_cache_sh)
313313
test('test-cache.sh', test_cache,
314314
timeout : 30 * 60)
315315

316+
test_seed_sh = configure_file(
317+
output : 'test-seed.sh',
318+
input : 'test/test-seed.sh.in',
319+
configuration : substs)
320+
test_seed = find_program(test_seed_sh)
321+
test('test-seed.sh', test_seed,
322+
timeout : 30 * 60)
323+
316324
udev_rule = configure_file(
317325
output : '75-casync.rules',
318326
input : 'src/75-casync.rules.in',

test/test-seed.sh.in

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
SCRATCH_DIR=${TMPDIR:-/var/tmp}/test-casync.$RANDOM
6+
mkdir -p $SCRATCH_DIR/src
7+
8+
mkdir $SCRATCH_DIR/src/casync
9+
if [ $UID = 0 ]; then
10+
cp -a @top_srcdir@/{test-files,src} $SCRATCH_DIR/src/casync/
11+
else
12+
# If we lack privileges we use rsync rather than cp to copy, as it will just skip over device nodes
13+
rsync -a --exclude=.cacac @top_srcdir@/{test-files,src} $SCRATCH_DIR/src/casync/
14+
fi
15+
16+
cd $SCRATCH_DIR/src
17+
18+
@top_builddir@/casync make -v $SCRATCH_DIR/test.caidx
19+
@top_builddir@/casync extract -v $SCRATCH_DIR/test.caidx $SCRATCH_DIR/first
20+
@top_builddir@/casync extract -v --seed=$SCRATCH_DIR/src $SCRATCH_DIR/test.caidx $SCRATCH_DIR/second
21+
22+
# Now, let's flush out the chunk store. If everything works correctly, the seed
23+
# should be sufficient as a source for chunks
24+
rm -rf $SCRATCH_DIR/default.castr/*
25+
26+
@top_builddir@/casync extract -v --seed=$SCRATCH_DIR/src $SCRATCH_DIR/test.caidx $SCRATCH_DIR/third

0 commit comments

Comments
 (0)