blob: 17b30f83c48a6ea211d118c53b024286972c82d9 (
plain)
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
|
#!/bin/sh -e
. ../../lib/sh-test-lib
OUTPUT="$(pwd)/output"
RESULT_FILE="${OUTPUT}/result.txt"
export RESULT_FILE
STATIC=false
usage() {
echo "Usage: $0 [-s <true|flase>] [-t <true|flase>]" 1>&2
exit 1
}
while getopts "s:t:h" o; do
case "$o" in
t) STATIC=${OPTARG} ;;
s) SKIP_INSTALL="${OPTARG}" ;;
h|*) usage ;;
esac
done
install() {
dist_name
# shellcheck disable=SC2154
case "${dist}" in
Debian|Ubuntu)
pkgs="build-essential"
install_deps "${pkgs}"
;;
Fedora|CentOS)
pkgs="gcc glibc-static"
install_deps "${pkgs}"
;;
*) error_msg "Unsupported distribution" ;;
esac
}
! check_root && error_msg "You need to be root to run this script."
[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
mkdir -p "${OUTPUT}"
if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
info_msg "gcc package installation skipped"
else
install
fi
FLAGS=""
if [ "${STATIC}" = "true" ] || [ "${STATIC}" = "True" ]; then
FLAGS="-static"
fi
skip_list="execute_binary"
command="gcc ${FLAGS} -o hello hello.c"
run_test_case "${command}" "gcc${FLAGS}" "${skip_list}"
command="./hello | grep -x 'Hello world'"
# skip_list is used as test case name to avoid typing mistakes
run_test_case "${command}" "${skip_list}"
|