forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pikatests.sh
executable file
·78 lines (64 loc) · 1.49 KB
/
pikatests.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
#!/bin/bash
# clear the log file
function cleanup() {
rm -rf ./log[0-9]*
rm -rf ./db[0-9]*
rm -rf dbsync/
rm src/redis-server
}
# check if tcl is installed
function check_tcl {
if [ -z "$(which tclsh)" ]; then
echo "tclsh is not installed"
exit 1
fi
}
# handle different build directories.
function setup_build_dir {
BUILD_DIR=""
if [ -d "./build" ] && [ -d "./output" ]; then
echo "Both build and output directories exist. Please remove one of them."
exit 1
fi
if [ -d "./build" ]; then
BUILD_DIR="build"
fi
if [ -d "./output" ]; then
BUILD_DIR="output"
fi
if [ -z "$BUILD_DIR" ]; then
echo "No build directory found. Please build the project first."
exit 1
fi
echo "BUILD_DIR: $BUILD_DIR"
}
# setup pika bin and conf
function setup_pika_bin {
PIKA_BIN="./$BUILD_DIR/pika"
if [ ! -f "$PIKA_BIN" ]; then
echo "pika bin not found"
exit 1
fi
cp $PIKA_BIN src/redis-server
cp conf/pika.conf tests/assets/default.conf
}
cleanup
check_tcl
setup_build_dir
setup_pika_bin
echo "run pika tests $1"
if [ "$1" == "all" ]; then
tclsh tests/test_helper.tcl --clients 1
else
tclsh tests/test_helper.tcl --clients 1 --single unit/$1
fi
if [ $? -ne 0 ]; then
echo "pika tests failed"
cleanup
exit 1
fi
# You can use './pikatests.sh all clean 'to ensure that the
# data can be deleted immediately after the test
if [ "$2" == "clean" ]; then
cleanup
fi