]> git.ipfire.org Git - thirdparty/systemd.git/blame - travis-ci/managers/fedora.sh
travis.yml: replace test-capability with a script exiting with 77
[thirdparty/systemd.git] / travis-ci / managers / fedora.sh
CommitLineData
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 12PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP})
a9145fc4
FS
13FEDORA_RELEASE="${FEDORA_RELEASE:-rawhide}"
14CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}"
15DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
16DOCKER_RUN="${DOCKER_RUN:-docker run}"
17REPO_ROOT="${REPO_ROOT:-$PWD}"
6dfe7f43 18ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan python3-pyparsing python3-evdev libubsan)
a9145fc4
FS
19
20function info() {
21 echo -e "\033[33;1m$1\033[0m"
22}
23
24set -e
25
26for phase in "${PHASES[@]}"; do
27 case $phase in
28 SETUP)
29 info "Setup phase"
30 info "Using Fedora $FEDORA_RELEASE"
a9145fc4
FS
31 # Pull a Docker image and start a new container
32 docker pull fedora:$FEDORA_RELEASE
33 info "Starting container $CONT_NAME"
34 $DOCKER_RUN -v $REPO_ROOT:/build:rw \
a9145fc4
FS
35 -w /build --privileged=true --name $CONT_NAME \
36 -dit --net=host fedora:$FEDORA_RELEASE /sbin/init
532a92fb
FS
37 # Beautiful workaround for Fedora's version of Docker
38 sleep 1
a9145fc4
FS
39 $DOCKER_EXEC dnf makecache
40 # Install necessary build/test requirements
532a92fb 41 $DOCKER_EXEC dnf -y --exclude selinux-policy\* upgrade
a9145fc4
FS
42 $DOCKER_EXEC dnf -y install "${ADDITIONAL_DEPS[@]}"
43 $DOCKER_EXEC dnf -y builddep systemd
44 ;;
45 RUN)
46 info "Run phase"
47 # Build systemd
b9abc935 48 $DOCKER_EXEC meson -Dslow-tests=true build
eeec5f2a 49 $DOCKER_EXEC ninja -v -C build
1667d63a 50 $DOCKER_EXEC ninja -C build test
79f6178e
EV
51 ;;
52 RUN_ASAN)
1667d63a 53 $DOCKER_EXEC git clean -dxff
6dfe7f43 54 $DOCKER_EXEC meson -Db_sanitize=address,undefined build
1667d63a 55 $DOCKER_EXEC ninja -v -C build
99347684 56 $DOCKER_EXEC sh -c "printf '#!/bin/sh\necho The test is failing under ASan, skipping; exit 77' >/build/build/test-capability"
6dfe7f43
EV
57
58 # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb.
59 $DOCKER_EXEC sh -c "UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 ninja -C build test"
a9145fc4
FS
60 ;;
61 CLEANUP)
62 info "Cleanup phase"
63 docker stop $CONT_NAME
64 docker rm -f $CONT_NAME
65 ;;
66 *)
67 echo >&2 "Unknown phase '$phase'"
68 exit 1
69 esac
70done