This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanitytest.sh
executable file
·124 lines (112 loc) · 2.94 KB
/
sanitytest.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash -ue
#-*-sh-*-
#
# Author: Markus Stenberg <[email protected]>
#
# Copyright (c) 2017 Markus Stenberg
#
# Created: Tue Jan 2 15:24:47 2018 mstenber
# Last modified: Thu Jan 18 17:06:25 2018 mstenber
# Edit time: 75 min
#
STORAGEDIR=/tmp/sanity-tfhfs-storage
MOUNTDIR=/tmp/x
STORAGEDIR2=/tmp/sanity-tfhfs-storage2
MOUNTDIR2=/tmp/y
MLOG=.
ARGS=${ARGS:-}
out () {
cd $ORIGDIR
echo $*
sleep 1
umount $MOUNTDIR
exit 1
}
mount2 () {
echo "mount2 $*"
mountdir=$1
shift
storagedir=$1
shift
if [ $# == 1 ]; then
if [ "$1" = "d" ]; then
# debug
MLOG=$MLOG echocmd ./tfhfs `echo $ARGS` $mountdir $storagedir >& ,log2 &
# profile
waitmount $mountdir
return
fi
if [ "$1" = "p" ]; then
# profiling
echocmd ./tfhfs `echo $ARGS` -memprofile mem.prof -cpuprofile cpu.prof $mountdir $storagedir >& ,log2 &
waitmount $mountdir
return
fi
if [ "$1" = "r" ]; then
# race detector
echocmd go run `echo $ARGS` -race ./tfhfs.go $mountdir $storagedir >& ,log2 &
waitmount $mountdir
return
fi
fi
# fast
echocmd ./tfhfs `echo $ARGS` $mountdir $storagedir >& ,log2 &
waitmount $mountdir
}
echocmd () {
echo "# $*"
$*
}
waitmount () {
mountdir=$1
mount | grep -q $mountdir && return || (echo "Waiting for mount.."; sleep 1 ; waitmount $mountdir)
}
mount1 () {
echo "mount1 $*"
mountdir=$1
shift
storagedir=$1
shift
logname=$1
shift
mount | grep -q $mountdir && umount $mountdir || true
rm -rf $mountdir
mkdir -p $mountdir
rm -rf $storagedir
mkdir -p $storagedir
echocmd ./tfhfs $* `echo $ARGS` $mountdir $storagedir >& $logname &
waitmount $mountdir
}
make tfhfs tfhfs-connector
ADDRESS=localhost:12345
ADDRESS2=localhost:12346
MLOG=$MLOG mount1 $MOUNTDIR $STORAGEDIR ,log -address $ADDRESS
MLOG=$MLOG mount1 $MOUNTDIR2 $STORAGEDIR2 ,log1 -address $ADDRESS2
ORIGDIR=`pwd`
cd $MOUNTDIR
mkdir dir
echo foo > foo
echo bar > bar
echo baz > baz
ln -v -s foo symlink || out "symlink broken"
ln -v foo hardlink || out "hardlink broken"
[ -d "dir" ] || out "dir not dir"
[ -f "foo" ] || out "foo not present"
[ ! -f "nonexistent" ] || out "nonexistent present"
ls -il $MOUNTDIR
GOT=`ls -l $MOUNTDIR | wc -l`
[ $GOT = "7" ] || out "not 7 lines in ls ($GOT)"
cp /bin/ls $MOUNTDIR || out "ls cp failed"
cmp -s /bin/ls $MOUNTDIR/ls || out "copied ls differs"
ls -l $MOUNTDIR/ls
cd $ORIGDIR
echocmd ./tfhfs-connector -interval 0s $ADDRESS root s2 $ADDRESS2 root s1 >& ,logc
[ -f $MOUNTDIR2/ls ] || out "sync mount: copied ls not present"
ls -l $MOUNTDIR2/ls
umount $MOUNTDIR2
umount $MOUNTDIR
sleep 1
mount2 $MOUNTDIR $STORAGEDIR $*
[ -f $MOUNTDIR/ls ] || out "second mount: copied ls not present"
ls -l $MOUNTDIR/ls
cmp -s /bin/ls $MOUNTDIR/ls || out "second mount: ls differs"