-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildAndTest.sh
More file actions
executable file
·166 lines (144 loc) · 6.57 KB
/
buildAndTest.sh
File metadata and controls
executable file
·166 lines (144 loc) · 6.57 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env bash
# automated build and test script for the datacompressor.
# the functions containing the actual tests can be found in separate scripts in the same directory
# the emulator function is used by the testfunctions and also contained in another file.
set -euo pipefail
workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$workdir/emulator.sh"
source "$workdir/test_dega.sh"
source "$workdir/test_lzmh.sh"
source "$workdir/test_copy.sh"
dataCompressorPath="../data-compressor"
is_numeric_regex='^[0-9]+$'
linux_dccli_sep="\#"
windows_dccli_sep="\#"
linux_dccli_build_dir="$dataCompressorPath/DataCompressor/build/gcc/"
linux_dccli_command="$dataCompressorPath/DataCompressor/build/gcc/DCCLI"
testdata_input="$dataCompressorPath/DataCompressor/DCCLI/testdata/input.txt"
testdata_output="$dataCompressorPath/DataCompressor/DCCLI/testdata/output.txt"
windows_compiler="/c/Program\ Files\ \(x86\)/MSBuild/12.0/Bin/MSBuild.exe"
windows_project_file="$dataCompressorPath/DataCompressor/build/MSVC/DataCompressor.sln"
win32_dccli_command="$dataCompressorPath/DataCompressor/build/MSVC/Release/DCCLI.exe"
win_x64_dccli_command="$dataCompressorPath/DataCompressor/build/MSVC/x64/Release/DCCLI.exe"
script_name="$(basename "$0")"
success="success"
err_msg() {
echo "Error: $1"
echo "Linux: $script_name <i386|x86_64|armhf> <IO_SIZE_BITS>"
echo "Raspberry: $script_name <arm> <IO_SIZE_BITS>"
echo "Windows: $script_name <win32|x64> <IO_SIZE_BITS>"
}
tests() {
# arg 1: IO_SIZE_BITS for copy blocksize
if ! [ $# -eq 1 ] || ! [[ $1 =~ $is_numeric_regex ]]; then
echo "tests: exactly one numeric argument expected"
exit 1
fi
local result_dega result_lzmh result_copy
echo "=========================================================="
echo "testing DEGA"
echo "=========================================================="
test_dega result_dega
echo "=========================================================="
echo "testing LZMH"
echo "=========================================================="
test_lzmh result_lzmh
echo "=========================================================="
# echo "testing copy"
# echo "=========================================================="
# test_copy "$1" result_copy
# echo "=========================================================="
# echo "test results"
# echo "=========================================================="
echo "dega: $result_dega"
echo "lzmh: $result_lzmh"
# echo "copy: $result_copy"
# if ! [[ "$result_dega" == "$success" && "$result_lzmh" == "$success" && "$result_copy" == "$success" ]]; then
if ! [[ "$result_dega" == "$success" && "$result_lzmh" == "$success" ]]; then
echo "Error. Some tests did not pass."
exit 1
fi
}
# #######################################
# start of script.
# #######################################
if ! [ $# -eq 2 ]; then
err_msg "not enough / too much arguments"
exit 1
fi
if ! [[ $2 =~ $is_numeric_regex ]] ; then
err_msg "arg 2 has to be numeric"
exit 1
fi
platform="$1"
IO_SIZE_BITS="$2"
kernel="$(uname -s)"
machine="$(uname -m)"
if [[ $kernel == Linux* ]]; then
sep="$linux_dccli_sep"
dccli_command="$linux_dccli_command"
if [[ $machine == x86_64 ]]; then
case "$platform" in
"i386")
echo "i386"
make -C "$linux_dccli_build_dir" clean
COMMON_CFLAGS="IO_SIZE_BITS=$IO_SIZE_BITS" CFLAGS="-m32" LDFLAGS="-m32" make -C "$linux_dccli_build_dir" release
tests "$IO_SIZE_BITS"
;;
"x86_64")
echo "x86_64"
make -C "$linux_dccli_build_dir" clean
COMMON_CFLAGS="IO_SIZE_BITS=$IO_SIZE_BITS" make -C "$linux_dccli_build_dir" release
tests "$IO_SIZE_BITS"
;;
"armhf")
echo "armhf"
make -C "$linux_dccli_build_dir" clean
COMMON_CFLAGS="IO_SIZE_BITS=$IO_SIZE_BITS" make CC=arm-linux-gnueabihf-gcc -C "$linux_dccli_build_dir" release
tests "$IO_SIZE_BITS"
;;
*)
err_msg "no such target"
exit 1
;;
esac
elif [[ $machine == armv* ]] || [[ $machine == aarch64 ]]; then
case "$platform" in
"arm")
echo "arch: $machine - building on rpi"
make -C "$linux_dccli_build_dir" clean
COMMON_CFLAGS="IO_SIZE_BITS=$IO_SIZE_BITS" make CC=gcc -C "$linux_dccli_build_dir" release
tests "$IO_SIZE_BITS"
;;
*)
err_msg "on the raspberry pi, we won't build and test other platforms"
exit 1
;;
esac
fi
elif [[ $kernel == MINGW64* && $machine == x86_64 ]]; then
sep="$windows_dccli_sep"
case "$platform" in
"win32")
dccli_command="$win32_dccli_command"
echo "win32"
bash -c "$windows_compiler $windows_project_file //t:Clean"
bash -c "$windows_compiler $windows_project_file //t:Rebuild //p:Configuration=Release //p:Platform=Win32"
tests "$IO_SIZE_BITS"
;;
"x64")
dccli_command="$win_x64_dccli_command"
echo "win x64"
bash -c "$windows_compiler $windows_project_file //t:Clean"
bash -c "$windows_compiler $windows_project_file //t:Rebuild //p:Configuration=Release //p:Platform=x64"
tests "$IO_SIZE_BITS"
;;
*)
err_msg "no such target"
exit 1
;;
esac
else
echo "Error. This runs on x86_64 machines, either with linux or windows (mingw)"
exit 1
fi