]>
Commit | Line | Data |
---|---|---|
a9145fc4 FS |
1 | #!/bin/bash |
2 | ||
3 | # Run this script from the root of the systemd's git repository | |
4 | # or set REPO_ROOT to a correct path. | |
5 | # | |
6 | # Example execution on Fedora: | |
0d589dfc | 7 | # dnf install docker |
a9145fc4 FS |
8 | # systemctl start docker |
9 | # export CONT_NAME="my-fancy-container" | |
10 | # travis-ci/managers/fedora.sh SETUP RUN CLEANUP | |
11 | ||
79f6178e | 12 | PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP}) |
a9145fc4 FS |
13 | FEDORA_RELEASE="${FEDORA_RELEASE:-rawhide}" |
14 | CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}" | |
15 | DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}" | |
16 | DOCKER_RUN="${DOCKER_RUN:-docker run}" | |
17 | REPO_ROOT="${REPO_ROOT:-$PWD}" | |
05b36f1f | 18 | ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan python3-pyparsing python3-evdev libubsan clang llvm) |
a9145fc4 FS |
19 | |
20 | function info() { | |
21 | echo -e "\033[33;1m$1\033[0m" | |
22 | } | |
23 | ||
24 | set -e | |
25 | ||
d419b75c EV |
26 | source "$(dirname $0)/travis_wait.bash" |
27 | ||
a9145fc4 FS |
28 | for phase in "${PHASES[@]}"; do |
29 | case $phase in | |
30 | SETUP) | |
31 | info "Setup phase" | |
32 | info "Using Fedora $FEDORA_RELEASE" | |
a9145fc4 FS |
33 | # Pull a Docker image and start a new container |
34 | docker pull fedora:$FEDORA_RELEASE | |
35 | info "Starting container $CONT_NAME" | |
36 | $DOCKER_RUN -v $REPO_ROOT:/build:rw \ | |
a9145fc4 FS |
37 | -w /build --privileged=true --name $CONT_NAME \ |
38 | -dit --net=host fedora:$FEDORA_RELEASE /sbin/init | |
532a92fb FS |
39 | # Beautiful workaround for Fedora's version of Docker |
40 | sleep 1 | |
a9145fc4 FS |
41 | $DOCKER_EXEC dnf makecache |
42 | # Install necessary build/test requirements | |
532a92fb | 43 | $DOCKER_EXEC dnf -y --exclude selinux-policy\* upgrade |
a9145fc4 FS |
44 | $DOCKER_EXEC dnf -y install "${ADDITIONAL_DEPS[@]}" |
45 | $DOCKER_EXEC dnf -y builddep systemd | |
46 | ;; | |
47 | RUN) | |
48 | info "Run phase" | |
49 | # Build systemd | |
7970a525 | 50 | $DOCKER_EXEC meson --werror -Dtests=unsafe -Dslow-tests=true build |
eeec5f2a | 51 | $DOCKER_EXEC ninja -v -C build |
1667d63a | 52 | $DOCKER_EXEC ninja -C build test |
a2ab58da | 53 | $DOCKER_EXEC tools/check-directives.sh |
79f6178e | 54 | ;; |
37cbcd46 EV |
55 | RUN_CLANG) |
56 | docker exec -e CC=clang -e CXX=clang++ -it $CONT_NAME meson --werror -Dtests=unsafe -Dslow-tests=true build | |
57 | $DOCKER_EXEC ninja -v -C build | |
58 | $DOCKER_EXEC ninja -C build test | |
59 | ;; | |
b8366c54 EV |
60 | RUN_ASAN|RUN_CLANG_ASAN) |
61 | if [[ "$phase" = "RUN_CLANG_ASAN" ]]; then | |
62 | ENV_VARS="-e CC=clang -e CXX=clang++" | |
63 | MESON_ARGS="-Db_lundef=false" # See https://github.com/mesonbuild/meson/issues/764 | |
64 | fi | |
65 | docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Db_sanitize=address,undefined $MESON_ARGS build | |
1667d63a | 66 | $DOCKER_EXEC ninja -v -C build |
6dfe7f43 EV |
67 | |
68 | # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb. | |
b6b35f0e EV |
69 | travis_wait docker exec --interactive=false \ |
70 | -e UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 \ | |
71 | -e ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \ | |
f5f9a580 | 72 | -e "TRAVIS=$TRAVIS" \ |
b6b35f0e EV |
73 | -t $CONT_NAME \ |
74 | meson test --timeout-multiplier=3 -C ./build/ --print-errorlogs | |
a9145fc4 FS |
75 | ;; |
76 | CLEANUP) | |
77 | info "Cleanup phase" | |
78 | docker stop $CONT_NAME | |
79 | docker rm -f $CONT_NAME | |
80 | ;; | |
81 | *) | |
82 | echo >&2 "Unknown phase '$phase'" | |
83 | exit 1 | |
84 | esac | |
85 | done |