-
Notifications
You must be signed in to change notification settings - Fork 28
/
test.sh
executable file
·49 lines (38 loc) · 1.31 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
#!/bin/bash
TEST_DIR=/tmp/test-loggedfs
mkdir $TEST_DIR
####################################################################
## Test 1: log actions in a file
####################################################################
# launch loggedfs
./loggedfs -l ~/log.txt $TEST_DIR
# create file
echo "bar" >> $TEST_DIR/foo && ls $TEST_DIR
sudo umount $TEST_DIR
# make sure the actions have been logged in the log file
COUNT=$(grep -c "write 4 bytes to $TEST_DIR/foo at offset 0" ~/log.txt)
if [ "$COUNT" -ne "1" ]; then
echo "write should have been logged in file"
exit 1
fi
# make sure the actions have not been logged in syslog
COUNT=$(grep -c "write 4 bytes to $TEST_DIR/foo at offset 0" /var/log/syslog)
if [ "$COUNT" -ne "0" ]; then
echo "nothing should have been logged in syslog"
exit 1
fi
rm ~/log.txt
####################################################################
## Test 2: log actions to syslog
####################################################################
# launch loggedfs
./loggedfs $TEST_DIR
# create file
echo "bar" >> $TEST_DIR/foo2 && ls $TEST_DIR
sudo umount $TEST_DIR
# make sure the actions have been logged in syslog
COUNT=$(grep -c "write 4 bytes to $TEST_DIR/foo2 at offset 0" /var/log/syslog)
if [ "$COUNT" -ne "1" ]; then
echo "write should have been logged in syslog"
exit 1
fi