d47cd512a20249a397165e14021b8c9feeb8cccc
[nivanova/samba-autobuild/.git] / source3 / script / tests / test_shadow_copy_torture.sh
1 #!/bin/bash
2 #
3 # Blackbox test for shadow_copy2 VFS.
4 #
5
6 if [ $# -lt 7 ]; then
7 cat <<EOF
8 Usage: test_shadow_copy SERVER SERVER_IP DOMAIN USERNAME PASSWORD WORKDIR SMBTORTURE
9 EOF
10 exit 1;
11 fi
12
13 SERVER=${1}
14 SERVER_IP=${2}
15 DOMAIN=${3}
16 USERNAME=${4}
17 PASSWORD=${5}
18 WORKDIR=${6}
19 SMBTORTURE="$VALGRIND ${7}"
20 shift 7
21
22 incdir=`dirname $0`/../../../testprogs/blackbox
23 . $incdir/subunit.sh
24
25 SNAPSHOT="@GMT-2015.10.31-19.40.30"
26
27 failed=0
28
29 # build a hierarchy of files, symlinks, and directories
30 build_files()
31 {
32     local destdir
33     destdir=$1
34
35     echo "$content" > $destdir/foo
36 }
37
38 # build a snapshots directory
39 build_snapshots()
40 {
41     local snapdir
42
43     snapdir=$WORKDIR/.snapshots
44
45     mkdir -p $snapdir
46     mkdir $snapdir/$SNAPSHOT
47
48     build_files $snapdir/$SNAPSHOT
49 }
50
51 test_shadow_copy_write()
52 {
53     local msg
54
55     msg=$1
56
57     #delete snapshots from previous tests
58     find $WORKDIR -name ".snapshots" -exec rm -rf {} \; 1>/dev/null 2>&1
59     build_snapshots
60
61     testit "writing to shadow copy of a file" \
62            $SMBTORTURE \
63            -U$USERNAME%$PASSWORD \
64            "//$SERVER/shadow_write" \
65            --option="torture:twrp_file=foo" \
66            --option="torture:twrp_snapshot=$SNAPSHOT" \
67            smb2.twrp.write || \
68         failed=`expr $failed + 1`
69 }
70
71 build_files $WORKDIR
72
73 # test open for writing and write behaviour of snapshoted files
74 test_shadow_copy_write "write behaviour of snapshoted files"
75
76 exit $failed