File: test-cache.sh.in

package info (click to toggle)
casync 2%2B20201210-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,952 kB
  • sloc: ansic: 31,284; sh: 423; python: 69; makefile: 6
file content (78 lines) | stat: -rwxr-xr-x 3,014 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash -ex
# SPDX-License-Identifier: LGPL-2.1+

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

mkdir $SCRATCH_DIR/src/casync
if [ $UID = 0 ]; then
    cp -a @top_srcdir@/{test-files,src} $SCRATCH_DIR/src/casync/
else
    # If we lack privileges we use rsync rather than cp to copy, as it will just skip over device nodes
    rsync -a --exclude=.cacac @top_srcdir@/{test-files,src} $SCRATCH_DIR/src/casync/
fi

cd $SCRATCH_DIR/src

@top_builddir@/casync list   >$SCRATCH_DIR/test.list
@top_builddir@/casync mtree  >$SCRATCH_DIR/test.mtree
@top_builddir@/casync digest >$SCRATCH_DIR/test.digest

# Make three versions of the caidx: one with no cache, one with an unpopulated cache, and one with a populated cache
@top_builddir@/casync make $SCRATCH_DIR/test1.caidx
@top_builddir@/casync make --cache $SCRATCH_DIR/test.cache $SCRATCH_DIR/test2.caidx
@top_builddir@/casync make --cache $SCRATCH_DIR/test.cache $SCRATCH_DIR/test3.caidx

cmp $SCRATCH_DIR/test1.caidx $SCRATCH_DIR/test2.caidx
cmp $SCRATCH_DIR/test1.caidx $SCRATCH_DIR/test3.caidx

for f in test1 test2 test3 ; do
    @top_builddir@/casync list   $SCRATCH_DIR/$f.caidx >$SCRATCH_DIR/$f.list
    @top_builddir@/casync mtree  $SCRATCH_DIR/$f.caidx >$SCRATCH_DIR/$f.mtree
    @top_builddir@/casync digest $SCRATCH_DIR/$f.caidx >$SCRATCH_DIR/$f.digest

    diff -q $SCRATCH_DIR/test.list   $SCRATCH_DIR/$f.list
    diff -q $SCRATCH_DIR/test.mtree  $SCRATCH_DIR/$f.mtree
    diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/$f.digest
done

# Make some changes: one in the beginning, one in the middle, one at the end
mkdir casync/000-early
touch casync/000-early/testa
mkdir casync/ggg-middle
touch casync/ggg-middle/testb
mkdir casync/zzz-late
touch casync/zzz-late/testc

# Also remove a file
rm casync/src/notify.*

# And update an existing one
chmod +w casync/src/compressor.c
echo xxx >>casync/src/compressor.c

@top_builddir@/casync list   >$SCRATCH_DIR/testx.list
@top_builddir@/casync mtree  >$SCRATCH_DIR/testx.mtree
@top_builddir@/casync digest >$SCRATCH_DIR/testx.digest

@top_builddir@/casync make $SCRATCH_DIR/test4.caidx
@top_builddir@/casync make --cache $SCRATCH_DIR/test.cache $SCRATCH_DIR/test5.caidx
@top_builddir@/casync make --cache $SCRATCH_DIR/test.cache $SCRATCH_DIR/test6.caidx
@top_builddir@/casync make $SCRATCH_DIR/test7.caidx

cmp $SCRATCH_DIR/test4.caidx $SCRATCH_DIR/test5.caidx
cmp $SCRATCH_DIR/test4.caidx $SCRATCH_DIR/test6.caidx
cmp $SCRATCH_DIR/test4.caidx $SCRATCH_DIR/test7.caidx

for f in test4 test5 test6 test7; do
    @top_builddir@/casync list   $SCRATCH_DIR/$f.caidx >$SCRATCH_DIR/$f.list
    @top_builddir@/casync mtree  $SCRATCH_DIR/$f.caidx >$SCRATCH_DIR/$f.mtree
    @top_builddir@/casync digest $SCRATCH_DIR/$f.caidx >$SCRATCH_DIR/$f.digest

    diff -q $SCRATCH_DIR/testx.list   $SCRATCH_DIR/$f.list
    diff -q $SCRATCH_DIR/testx.mtree  $SCRATCH_DIR/$f.mtree
    diff -q $SCRATCH_DIR/testx.digest $SCRATCH_DIR/$f.digest
done

chmod -R u+rwx $SCRATCH_DIR
rm -rf $SCRATCH_DIR