-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·71 lines (57 loc) · 1.41 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
#!/usr/bin/env bash
TEST_DIR="testDir"
REQUIRED_CMD=(gcc python awk grep)
msg1() { echo -e "\x1b[1;32m==> \x1b[39m$*\x1b[0m"; }
msg2() { echo -e "\x1b[1;34m --> \x1b[39m$*\x1b[0m"; }
error() { echo -e "\x1b[1;31mERROR: \x1b[0;31m$*\x1b[0m"; }
cd "$(dirname "$0")"
CMD=""
requireOK() {
msg2 "Running '$*'"
CMD="$*"
"$@"
RES=$?
if (( RES != 0 )); then
error "Command $* failed"
fi
}
exists() {
local i
for i in $*; do
if [ ! -e $i ]; then
error "File $i does not exist"
fi
done
}
test_baseTest() {
requireOK ../enumGen.py parse ../test/test1.hpp test1.json
requireOK ../enumGen.py parse ../test/vulkan_core.h vulkan_core.json
exists test1.json vulkan_core.json
requireOK ../enumGen.py -c ../test/cfg.json generate Enum2Str Enum2Str.{hpp,cpp} *.json
exists Enum2Str.{hpp,cpp}
requireOK gcc -c -Wall -std=c++17 -fpic Enum2Str.cpp
requireOK gcc -shared -o Enum2Str.so Enum2Str.o
}
main() {
# check for requirements
local ERRORS=0
for i in "${REQUIRED_CMD[@]}"; do
which "$i" &> /dev/null
RET=$?
if (( RET != 0 )); then
error "Required command $i not found"
(( ERRORS++ ))
fi
done
(( ERRORS > 0 )) && exit 1
# Setup test env
[ -d "$TEST_DIR" ] && rm -rf "$TEST_DIR"
mkdir "$TEST_DIR"
cd "$TEST_DIR"
local i
for i in $(typeset -f | awk '/ \(\) $/ {print $1}' | grep test_); do
msg1 "Running test '$i'"
$i
done
}
main