-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·55 lines (40 loc) · 1.02 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
#!/bin/bash
TESTS_NUMBER=0
TESTS_PASSED=0
function unit () {
TESTS_NUMBER=$((TESTS_NUMBER+1))
bash -c "$2"
if [[ $? -ne 0 ]]; then
echo $1 " [failed]"
else
echo $1 " [ok]"
TESTS_PASSED=$((TESTS_PASSED+1))
fi
}
mkdir -p test
if [[ ! -e build/rsramfs.ko ]]; then
make
fi
unit "Insert Module..." "sudo insmod build/rsramfs.ko"
unit "Mount..." "sudo mount -t rsramfs none test"
unit "Create File..." "echo 'Hello World' > test/file"
TESTS_NUMBER=$((TESTS_NUMBER+1))
if [[ `cat test/file` = "Hello World" ]]; then
echo "File contents... [ok]"
TESTS_PASSED=$((TESTS_PASSED+1))
else
echo "File contents... [failed]"
fi
unit "Create Directory..." "mkdir test/dir"
TESTS_NUMBER=$((TESTS_NUMBER+1))
if [[ -e test/dir ]]; then
echo "Directory... [ok]"
TESTS_PASSED=$((TESTS_PASSED+1))
else
echo "Directory... [failed]"
fi
unit "Unmount..." "sudo umount test"
unit "Remove Module..." "sudo rmmod rsramfs"
rm -rf test
echo "Passed $TESTS_PASSED/$TESTS_NUMBER tests"
exit $((TESTS_NUMBER-TESTS_PASSED))