-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtravisRun.sh
executable file
·121 lines (97 loc) · 2.81 KB
/
travisRun.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
BUILD_DIR=build2
msg() {
echo -e "\x1b[1;33m[ MSG ]\x1b[0;33m $@\x1b[0m"
}
msg_ok() {
echo -e "\x1b[1;32m[ OK ]\x1b[0;32m $@\x1b[0m"
}
msg_error() {
echo -e "\x1b[1;31m[ERROR]\x1b[0;31m $@\x1b[0m"
}
print_version() {
msg " - $1: \x1b[1m$(pacman -Qi $1 | grep Version | sed 's/[^:]*: //g')"
}
ERROR_COUNT=0
__EXEC__() {
SUDO_EXEC=
(( $1 == 1 )) && SUDO_EXEC="sudo -u nobody"
echo ""
$SUDO_EXEC "${@:3}"
ERROR=$?
echo -e "\n"
if (( ERROR == 0 || ( $2 == 1 && ERROR != 0 ) )); then
msg_ok "Command '${@:3}' returned $ERROR"
return
fi
msg_error "Command '${@:3}' returned $ERROR"
(( ERROR_COUNT++ ))
}
testExec() { __EXEC__ 0 0 "$@"; }
testFail() { __EXEC__ 0 1 "$@"; }
testExecNoRoot() { __EXEC__ 1 0 "$@"; }
testExecNoRootFail() { __EXEC__ 1 1 "$@"; }
cd "$(dirname $0)"
if [ -z "$1" ]; then
msg_error "Compiler not set! Usage: $0 <c++ compiler>"
exit 1
fi
if [[ "$1" == "g++" ]]; then
msg "Detected compiler \x1b[1;33mGCC"
msg "Enabling Coverage data collection"
export CXX=g++
export CC=gcc
elif [[ "$1" == "clang++" ]]; then
msg "Detected compiler \x1b[1;33mLLVM / CLANG"
msg "Disabling Coverage data collection"
export CXX=clang++
export CC=clang
else
msg_error "Unknown compiler '$1'"
exit 1
fi
msg "Versions:"
print_version cmake
print_version gcc
print_version clang
print_version qt5-base
msg "Updating wireshark disector"
testExec pushd /opt/wireshark/build
testExec git pull
testExec git submodule update --init --recursive
testExec umask 0022 && make install
testExec cp ./run/libcapchild.a /EPL/lib
testExec cp ./run/libcaputils.a /EPL/lib
testExec pushd ..
testExec mkdir -p "/EPL/include/wireshark"
testExec find . -name "*.h" ! -path "*build*" -exec cp --parents {} "/EPL/include/wireshark" \;
testExec popd
testExec popd
msg "Setting up the build env"
testExec lcov --directory . --zerocounters
testExec ./checkFormat.sh --only-check
testExec mkdir $BUILD_DIR
testExec cd $BUILD_DIR
msg "START BUILD"
testExec cmake -DENABLE_CODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/EPL -DWireshark_DIR=/EPL ..
testExec make
testExec ln -s /EPL/bin/dumpcap ./bin
testExec chmod -R a+rwx .
msg "START TEST"
testExec ./bin/tests
testExecFail ./bin/tests --asd-asdf
if (( $ERROR_COUNT == 0 )); then
msg "Installing files"
testExec make install
fi
if [[ "$CXX" == "g++" ]]; then
msg "Parsing coverage data"
testExec lcov --directory . --capture --output-file coverage.info
testExec lcov --remove coverage.info '/usr/*' '/EPL/*' '*catch*.h*' '*/FakeIt/*' '*/external/*' '*/EPLEnum2Str*' '*/tests/*' '*.cxx' '*.h' --output-file coverage.info
testExec lcov --list coverage.info
testExec cp coverage.info /
else
msg "Creating a dummy coverage file"
testExec touch /coverage.info
fi
exit $ERROR_COUNT