/
selftest
executable file
·65 lines (56 loc) · 1.55 KB
/
selftest
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
#! /bin/bash
#
# Run selftests and check memory
cd ../model
./generate
cd ../src
gcc -g -o fmq_selftest fmq_selftest.c \
fmq_chunk.c \
fmq_client.c \
fmq_config.c \
fmq_dir.c \
fmq_file.c \
fmq_msg.c \
fmq_patch.c \
fmq_sasl.c \
fmq_sha.c \
fmq_server.c \
../sha-1.1/sha1.c \
${CFLAGS} ${LDFLAGS} -DHAVE_CONFIG_H -lczmq -lzmq
if [ $? -eq 0 ]; then
if [ "$1" == "-q" ]; then
./fmq_selftest
else
echo "Starting Valgrind memcheck..."
valgrind --tool=memcheck --leak-check=full --show-reachable=yes --suppressions=valgrind.supp ./fmq_selftest
fi
fi
rm -f vgcore.*
function push_file {
dd if=/dev/urandom of=./fmqroot/$1 bs=$3 count=$2 2> /dev/null
}
# Start server and client
killall -q fmq_selftest -r ".*fmq_selftest.*"
rm -rf fmqroot/send/* fmqroot/recv/* fmqroot/logs
mkdir fmqroot/logs fmqroot/send/photos
./fmq_selftest -c &
./fmq_selftest -s &
sleep 1
# Push some files into photos and logs
push_file logs/log.1 2500 100
push_file logs/log.2 9999 100
echo ./fmqroot/logs/log.2 > ./fmqroot/logs/log.3.ln
push_file send/photos/DSCF0001.jpg 1000 1000
push_file send/photos/DSCF0002.jpg 2000 1000
push_file send/photos/DSCF0003.jpg 4000 1000
push_file send/photos/DSCF0004.jpg 8000 1000
push_file send/photos/DSCF0005.jpg 16000 1000
push_file send/photos/DSCF0006.jpg 32000 1000
echo "Step 1..."
sleep 2
# Replace some files
push_file photos/DSCF0002.jpg 3500 1000
push_file photos/DSCF0003.jpg 4000 1000
echo "Step 2..."
sleep 3
killall -q fmq_selftest -r ".*fmq_selftest.*"