-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.sh
executable file
·76 lines (61 loc) · 1.46 KB
/
test.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
#!/bin/sh
#
# Basic tests to make sure our filesystem supports
# basic UNIX shell operations such as mkdir, rm, cp etc
#
# Assummes that test filesystem is mounted under `pwd`/test
#
MOUNTPOINT="`pwd`/test"
RSTRING_GEN="uuidgen | sed 's|-||g'"
UNIXTIME="date '+%s'"
TESTS="container_ops object_ops"
test_container_ops() {
echo "== test container operations"
dirname=`eval ${RSTRING_GEN}`
echo -n "* creating container... "
mkdir ${dirname}
echo "ok"
echo -n "* removing container... "
rmdir ${dirname}
echo "ok"
}
test_object_ops() {
echo "== test object operations"
echo -n "* preparing container... "
dirname=`eval ${RSTRING_GEN}`
mkdir ${dirname}
echo "ok"
echo -n "* generating test file... "
tmpfile_name=`eval ${RSTRING_GEN}`
tmpfile="/tmp/${tmpfile_name}"
uname -a > ${tmpfile}
hostname >> ${tmpfile}
date >> ${tmpfile}
echo "ok"
echo -n "* copying in test file to the storage... "
cp ${tmpfile} ${dirname}
echo "ok"
echo -n "* testing if files are idential... "
cmp ${tmpfile} ${dirname}/${tmpfile_name}
if test $? -eq 0; then
echo "ok"
else
echo "FAIL"
fi
echo -n "* removing test file..."
rm ${tmpfile}
echo "ok"
}
run_tests() {
echo "starting tests @ ${MOUNTPOINT}"
cd ${MOUNTPOINT}
for testname in ${TESTS}; do
test_func="test_${testname}"
start_time=`eval ${UNIXTIME}`
$test_func
end_time=`eval ${UNIXTIME}`
total_time=`expr ${end_time} - ${start_time}`
echo "== ${testname}: ${total_time} seconds"
done
}
run_tests