]> git.ipfire.org Git - thirdparty/systemd.git/blob - travis-ci/managers/debian.sh
travis: compile with -O1 with clang
[thirdparty/systemd.git] / travis-ci / managers / debian.sh
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:
7 # dnf install docker
8 # systemctl start docker
9 # export CONT_NAME="my-fancy-container"
10 # travis-ci/managers/debian.sh SETUP RUN CLEANUP
11
12 PHASES=(${@:-SETUP RUN RUN_ASAN_UBSAN CLEANUP})
13 DEBIAN_RELEASE="${DEBIAN_RELEASE:-testing}"
14 CONT_NAME="${CONT_NAME:-systemd-debian-$DEBIAN_RELEASE}"
15 DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
16 DOCKER_RUN="${DOCKER_RUN:-docker run}"
17 REPO_ROOT="${REPO_ROOT:-$PWD}"
18 ADDITIONAL_DEPS=(
19 clang
20 fdisk
21 libfdisk-dev
22 libp11-kit-dev
23 libpwquality-dev
24 libssl-dev
25 libzstd-dev
26 perl
27 python3-libevdev
28 python3-pyparsing
29 zstd
30 )
31
32 function info() {
33 echo -e "\033[33;1m$1\033[0m"
34 }
35
36 set -e
37
38 source "$(dirname $0)/travis_wait.bash"
39
40 for phase in "${PHASES[@]}"; do
41 case $phase in
42 SETUP)
43 info "Setup phase"
44 info "Using Debian $DEBIAN_RELEASE"
45 printf "FROM debian:$DEBIAN_RELEASE\nRUN bash -c 'apt-get -y update && apt-get install -y systemd'\n" | docker build -t debian-with-systemd/latest -
46 info "Starting container $CONT_NAME"
47 $DOCKER_RUN -v $REPO_ROOT:/build:rw -e container=docker \
48 -w /build --privileged=true --name $CONT_NAME \
49 -dit --net=host debian-with-systemd/latest /bin/systemd
50 $DOCKER_EXEC bash -c "echo deb-src http://deb.debian.org/debian $DEBIAN_RELEASE main >>/etc/apt/sources.list"
51 # Wait for the container to properly boot up, otherwise we were
52 # running following apt-get commands during the initializing/starting
53 # (early/late bootup) phase, which caused nasty race conditions
54 $DOCKER_EXEC bash -c 'systemctl is-system-running --wait || :'
55 $DOCKER_EXEC apt-get -y update
56 $DOCKER_EXEC apt-get -y build-dep systemd
57 $DOCKER_EXEC apt-get -y install "${ADDITIONAL_DEPS[@]}"
58 ;;
59 RUN|RUN_GCC|RUN_CLANG)
60 if [[ "$phase" = "RUN_CLANG" ]]; then
61 ENV_VARS="-e CC=clang -e CXX=clang++"
62 MESON_ARGS="--optimization=1"
63 fi
64 docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Dslow-tests=true -Dsplit-usr=true -Dman=true $MESON_ARGS build
65 $DOCKER_EXEC ninja -v -C build
66 docker exec -e "TRAVIS=$TRAVIS" -it $CONT_NAME ninja -C build test
67 ;;
68 RUN_ASAN_UBSAN|RUN_GCC_ASAN_UBSAN|RUN_CLANG_ASAN_UBSAN)
69 if [[ "$phase" = "RUN_CLANG_ASAN_UBSAN" ]]; then
70 ENV_VARS="-e CC=clang -e CXX=clang++"
71 # Build fuzzer regression tests only with clang (for now),
72 # see: https://github.com/systemd/systemd/pull/15886#issuecomment-632689604
73 # -Db_lundef=false: See https://github.com/mesonbuild/meson/issues/764
74 MESON_ARGS="-Db_lundef=false -Dfuzz-tests=true --optimization=1"
75 fi
76 docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Db_sanitize=address,undefined -Dsplit-usr=true $MESON_ARGS build
77 $DOCKER_EXEC ninja -v -C build
78
79 # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb.
80 travis_wait docker exec --interactive=false \
81 -e UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 \
82 -e ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \
83 -e "TRAVIS=$TRAVIS" \
84 -t $CONT_NAME \
85 meson test --timeout-multiplier=3 -C ./build/ --print-errorlogs
86 ;;
87 CLEANUP)
88 info "Cleanup phase"
89 docker stop $CONT_NAME
90 docker rm -f $CONT_NAME
91 ;;
92 *)
93 echo >&2 "Unknown phase '$phase'"
94 exit 1
95 esac
96 done