2021-02-10 06:27:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-08-24 13:42:45 +00:00
|
|
|
export CCACHE_BASEDIR="$(pwd)"
|
|
|
|
export CCACHE_DIR="$CCACHE_BASEDIR/ccache"
|
|
|
|
export CCACHE_MAXSIZE="500M"
|
|
|
|
export PATH="$CCACHE_WRAPPERSDIR:$PATH"
|
|
|
|
|
|
|
|
# Enable these conditionally since their best use case is during
|
|
|
|
# non-interactive workloads without having a Shell
|
|
|
|
if ! [ -t 1 ]; then
|
|
|
|
export VIR_TEST_VERBOSE="1"
|
|
|
|
export VIR_TEST_DEBUG="1"
|
|
|
|
fi
|
2019-08-15 12:28:17 +00:00
|
|
|
|
2023-08-25 14:12:32 +00:00
|
|
|
GIT_ROOT="$(git rev-parse --show-toplevel)"
|
2023-08-24 13:45:44 +00:00
|
|
|
run_cmd() {
|
|
|
|
printf "\e[32m[RUN COMMAND]: '%s'\e[0m\n" "$*"
|
|
|
|
"$@"
|
|
|
|
}
|
2023-08-24 13:44:52 +00:00
|
|
|
|
2023-09-19 08:46:08 +00:00
|
|
|
run_cmd_quiet() {
|
|
|
|
printf "\e[32m[RUN COMMAND]: '%s'\e[0m\n" "$*"
|
|
|
|
"$@" 1>/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2023-08-24 13:44:52 +00:00
|
|
|
run_meson_setup() {
|
|
|
|
run_cmd meson setup build --error -Dsystem=true $MESON_OPTS $MESON_ARGS || \
|
|
|
|
(cat "${GIT_ROOT}/build/meson-logs/meson-log.txt" && exit 1)
|
|
|
|
}
|
2023-08-24 13:46:53 +00:00
|
|
|
|
|
|
|
run_build() {
|
|
|
|
test -f $GIT_ROOT/build/build.ninja || run_meson_setup
|
|
|
|
run_cmd meson compile -C build $BUILD_ARGS
|
|
|
|
}
|
2023-08-24 13:47:48 +00:00
|
|
|
|
|
|
|
run_dist() {
|
|
|
|
test -f $GIT_ROOT/build/build.ninja || run_meson_setup
|
|
|
|
|
|
|
|
# dist is unhappy in local container environment complaining about
|
|
|
|
# uncommitted changes in the repo which is often not the case - refreshing
|
|
|
|
# git's index solves the problem
|
|
|
|
git update-index --refresh
|
|
|
|
run_cmd meson dist -C build --no-tests
|
|
|
|
}
|
2023-08-24 13:48:46 +00:00
|
|
|
|
|
|
|
run_test() {
|
2023-09-13 10:51:01 +00:00
|
|
|
TEST_ARGS="${TEST_ARGS:=--no-suite syntax-check --print-errorlogs}"
|
|
|
|
|
2023-08-24 13:48:46 +00:00
|
|
|
test -f $GIT_ROOT/build/build.ninja || run_meson_setup
|
2023-09-13 10:51:01 +00:00
|
|
|
|
2023-08-24 13:48:46 +00:00
|
|
|
run_cmd meson test -C build $TEST_ARGS
|
|
|
|
}
|
2023-08-24 13:49:19 +00:00
|
|
|
|
|
|
|
run_codestyle() {
|
|
|
|
BUILD_ARGS="libvirt-pot-dep"
|
|
|
|
TEST_ARGS="--suite syntax-check --no-rebuild --print-errorlogs"
|
|
|
|
|
|
|
|
run_build
|
|
|
|
run_test
|
|
|
|
}
|
2023-08-24 13:48:46 +00:00
|
|
|
|
|
|
|
run_potfile() {
|
|
|
|
# since meson would run jobs for each of the following target in parallel,
|
|
|
|
# we'd have dependency issues such that one target might depend on a
|
|
|
|
# generated file which hasn't been generated yet by the other target, hence
|
|
|
|
# we limit potfile job to a single build job (luckily potfile build has
|
|
|
|
# negligible performance impact)
|
|
|
|
BUILD_ARGS="-j1 libvirt-pot-dep libvirt-pot"
|
|
|
|
|
|
|
|
run_build
|
|
|
|
}
|
2023-08-24 13:49:19 +00:00
|
|
|
|
|
|
|
run_rpmbuild() {
|
|
|
|
run_dist
|
2023-11-02 10:16:20 +00:00
|
|
|
|
|
|
|
# The spec file supports three types of builds: native, mingw32
|
|
|
|
# and mingw64. By default they're all enabled, but each of the
|
|
|
|
# containers in which our CI jobs are executed is only set up for
|
|
|
|
# one of them, so we have to explicitly disable the other two.
|
|
|
|
case "$CROSS" in
|
|
|
|
mingw32)
|
|
|
|
build1="native"
|
|
|
|
build2="mingw64"
|
|
|
|
;;
|
|
|
|
mingw64)
|
|
|
|
build1="native"
|
|
|
|
build2="mingw32"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
build1="mingw32"
|
|
|
|
build2="mingw64"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-08-24 13:49:19 +00:00
|
|
|
run_cmd rpmbuild \
|
|
|
|
--clean \
|
2023-11-02 10:16:20 +00:00
|
|
|
--define "_without_$build1 1" \
|
|
|
|
--define "_without_$build2 1" \
|
2023-08-24 13:49:19 +00:00
|
|
|
-ta build/meson-dist/libvirt-*.tar.xz
|
|
|
|
}
|
2023-08-24 13:49:19 +00:00
|
|
|
|
|
|
|
run_website_build() {
|
|
|
|
export DESTDIR="${GIT_ROOT}/install"
|
|
|
|
BUILD_ARGS="install-web"
|
|
|
|
|
|
|
|
run_build
|
|
|
|
}
|
2023-09-15 12:23:21 +00:00
|
|
|
|
|
|
|
run_integration() {
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd sudo pip3 install --prefix=/usr avocado-framework
|
2023-09-15 12:23:21 +00:00
|
|
|
|
2023-01-20 09:10:40 +00:00
|
|
|
# Explicitly allow storing cores globally
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd sudo sh -c "echo DefaultLimitCORE=infinity >> /etc/systemd/system.conf"
|
2023-09-15 12:23:21 +00:00
|
|
|
|
2023-01-20 09:10:40 +00:00
|
|
|
# Need to reexec systemd after changing config
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd sudo systemctl daemon-reexec
|
2023-01-20 09:10:40 +00:00
|
|
|
|
|
|
|
# Source the os-release file to query the vendor-provided variables
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd . /etc/os-release
|
2023-09-13 15:05:02 +00:00
|
|
|
if test "$ID" = "centos" && test "$VERSION_ID" -eq 8
|
2023-09-15 12:23:21 +00:00
|
|
|
then
|
|
|
|
DAEMONS="libvirtd virtlockd virtlogd"
|
|
|
|
else
|
|
|
|
DAEMONS="virtinterfaced virtlockd virtlogd virtnetworkd virtnodedevd virtnwfilterd virtproxyd virtqemud virtsecretd virtstoraged"
|
|
|
|
fi
|
2023-09-13 09:21:08 +00:00
|
|
|
|
|
|
|
echo "DAEMONS=$DAEMONS"
|
2023-09-15 12:23:21 +00:00
|
|
|
for daemon in $DAEMONS
|
|
|
|
do
|
|
|
|
LOG_OUTPUTS="1:file:/var/log/libvirt/${daemon}.log"
|
|
|
|
LOG_FILTERS="3:remote 4:event 3:util.json 3:util.object 3:util.dbus 3:util.netlink 3:node_device 3:rpc 3:access 1:*"
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd_quiet sudo augtool set /files/etc/libvirt/${daemon}.conf/log_filters "'$LOG_FILTERS'"
|
|
|
|
run_cmd_quiet sudo augtool set /files/etc/libvirt/${daemon}.conf/log_outputs "'$LOG_OUTPUTS'"
|
|
|
|
run_cmd_quiet sudo systemctl --quiet stop ${daemon}.service
|
|
|
|
run_cmd_quiet sudo systemctl restart ${daemon}.socket
|
2023-09-15 12:23:21 +00:00
|
|
|
done
|
|
|
|
|
2023-01-20 09:10:40 +00:00
|
|
|
# Make sure the default network is started on all platforms
|
|
|
|
# The reason for the '|| true' here is solely that GitLab executes all
|
|
|
|
# Shell scripts with -e by default and virsh returns an error if one tries
|
|
|
|
# to start a machine/network that is already active which is both fine and
|
|
|
|
# should also be a non-fatal error
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd_quiet sudo virsh --quiet net-start default || true
|
2023-09-15 12:23:21 +00:00
|
|
|
|
2023-09-13 09:49:09 +00:00
|
|
|
# SCRATCH_DIR is normally set inside the GitLab CI job to /tmp/scratch.
|
|
|
|
# However, for local executions inside a VM we need to make sure some
|
|
|
|
# scratch directory exists and also that it is created outside of /tmp for
|
|
|
|
# storage space reasons (if multiple project repos are to be cloned).
|
|
|
|
SCRATCH_DIR="${SCRATCH_DIR:=$GIT_ROOT/ci/scratch)}"
|
|
|
|
|
|
|
|
test ! -d "$SCRATCH_DIR" && run_cmd mkdir "$SCRATCH_DIR"
|
2023-09-12 14:30:19 +00:00
|
|
|
run_cmd cd "$SCRATCH_DIR"
|
|
|
|
run_cmd git clone --depth 1 https://gitlab.com/libvirt/libvirt-tck.git
|
|
|
|
run_cmd cd libvirt-tck
|
|
|
|
run_cmd sudo avocado --config avocado.config run --job-results-dir "$SCRATCH_DIR"/avocado
|
2023-09-15 12:23:21 +00:00
|
|
|
}
|