]> git.ipfire.org Git - thirdparty/systemd.git/blob - travis-ci/managers/fedora.sh
Merge pull request #14441 from GothAck/gothack_type.d_dropin_test_master
[thirdparty/systemd.git] / travis-ci / managers / fedora.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/fedora.sh SETUP RUN CLEANUP
11
12 PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP})
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}"
18 ADDITIONAL_DEPS=(dnf-plugins-core
19 jq iputils
20 hostname libasan
21 python3-pyparsing
22 python3-evdev
23 libubsan
24 clang
25 llvm
26 perl)
27
28 function info() {
29 echo -e "\033[33;1m$1\033[0m"
30 }
31
32 set -e
33
34 source "$(dirname $0)/travis_wait.bash"
35
36 for phase in "${PHASES[@]}"; do
37 case $phase in
38 SETUP)
39 info "Setup phase"
40 info "Using Fedora $FEDORA_RELEASE"
41 # Pull a Docker image and start a new container
42 docker pull fedora:$FEDORA_RELEASE
43 info "Starting container $CONT_NAME"
44 $DOCKER_RUN -v $REPO_ROOT:/build:rw \
45 -w /build --privileged=true --name $CONT_NAME \
46 -dit --net=host fedora:$FEDORA_RELEASE /sbin/init
47 # Wait for the container to properly boot up, otherwise we were
48 # running following dnf commands during the initializing/starting
49 # (early/late bootup) phase, which caused nasty race conditions
50 $DOCKER_EXEC bash -c 'systemctl is-system-running --wait || :'
51 $DOCKER_EXEC dnf makecache
52 # Install necessary build/test requirements
53 $DOCKER_EXEC dnf -y --exclude selinux-policy\* upgrade
54 $DOCKER_EXEC dnf -y install "${ADDITIONAL_DEPS[@]}"
55 $DOCKER_EXEC dnf -y builddep systemd
56 ;;
57 RUN)
58 info "Run phase"
59 # Build systemd
60 $DOCKER_EXEC meson --werror -Dtests=unsafe -Dslow-tests=true build
61 $DOCKER_EXEC ninja -v -C build
62 $DOCKER_EXEC ninja -C build test
63 ;;
64 RUN_CLANG)
65 docker exec -e CC=clang -e CXX=clang++ -it $CONT_NAME meson --werror -Dtests=unsafe -Dslow-tests=true -Dman=true build
66 $DOCKER_EXEC ninja -v -C build
67 $DOCKER_EXEC ninja -C build test
68 ;;
69 RUN_ASAN|RUN_CLANG_ASAN)
70 if [[ "$phase" = "RUN_CLANG_ASAN" ]]; then
71 ENV_VARS="-e CC=clang -e CXX=clang++"
72 MESON_ARGS="-Db_lundef=false" # See https://github.com/mesonbuild/meson/issues/764
73 fi
74 docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Db_sanitize=address,undefined $MESON_ARGS build
75 $DOCKER_EXEC ninja -v -C build
76
77 # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb.
78 travis_wait docker exec --interactive=false \
79 -e UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 \
80 -e ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \
81 -e "TRAVIS=$TRAVIS" \
82 -t $CONT_NAME \
83 meson test --timeout-multiplier=3 -C ./build/ --print-errorlogs
84 ;;
85 CLEANUP)
86 info "Cleanup phase"
87 docker stop $CONT_NAME
88 docker rm -f $CONT_NAME
89 ;;
90 *)
91 echo >&2 "Unknown phase '$phase'"
92 exit 1
93 esac
94 done