1
0
mirror of https://github.com/systemd/systemd synced 2026-03-29 11:14:50 +02:00

Compare commits

..

No commits in common. "2e016f3a0be2160d977ad3e5c202d5ae85ed0780" and "fab79a85af29ba1c1e237ace6c8078357c04b488" have entirely different histories.

30 changed files with 188 additions and 232 deletions

View File

@ -75,7 +75,7 @@ if [[ "$COMPILER" == clang ]]; then
# Following snippet was borrowed from https://apt.llvm.org/llvm.sh # Following snippet was borrowed from https://apt.llvm.org/llvm.sh
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main" add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main"
PACKAGES+=("clang-$COMPILER_VERSION" "lldb-$COMPILER_VERSION" "lld-$COMPILER_VERSION" "clangd-$COMPILER_VERSION") PACKAGES+=(clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION)
elif [[ "$COMPILER" == gcc ]]; then elif [[ "$COMPILER" == gcc ]]; then
CC="gcc-$COMPILER_VERSION" CC="gcc-$COMPILER_VERSION"
CXX="g++-$COMPILER_VERSION" CXX="g++-$COMPILER_VERSION"
@ -83,7 +83,7 @@ elif [[ "$COMPILER" == gcc ]]; then
# Latest gcc stack deb packages provided by # Latest gcc stack deb packages provided by
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
add-apt-repository -y ppa:ubuntu-toolchain-r/test add-apt-repository -y ppa:ubuntu-toolchain-r/test
PACKAGES+=("gcc-$COMPILER_VERSION") PACKAGES+=(gcc-$COMPILER_VERSION)
else else
fatal "Unknown compiler: $COMPILER" fatal "Unknown compiler: $COMPILER"
fi fi
@ -108,7 +108,6 @@ for args in "${ARGS[@]}"; do
SECONDS=0 SECONDS=0
info "Checking build with $args" info "Checking build with $args"
# shellcheck disable=SC2086
if ! AR="$AR" CC="$CC" CXX="$CXX" CFLAGS="-Werror" CXXFLAGS="-Werror" meson -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror $args build; then if ! AR="$AR" CC="$CC" CXX="$CXX" CFLAGS="-Werror" CXXFLAGS="-Werror" meson -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror $args build; then
fatal "meson failed with $args" fatal "meson failed with $args"
fi fi

View File

@ -1,38 +0,0 @@
---
# https://github.com/marketplace/actions/super-linter
name: Lint Code Base
on:
pull_request:
branches:
- main
jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Repo checkout
uses: actions/checkout@v2
with:
# We need a full repo clone
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v3
env:
DEFAULT_BRANCH: main
# Excludes:
# - man/.* - all snippets in man pages (false positives due to
# missing shebangs)
# - kernel-install/.* - false-positives for dropins (and I'm afraid
# to touch kernel-install)
# - .*\.(in|SKELETON) - all template/skeleton files
# - tools/coverity\.sh - external file (with some modifications)
FILTER_REGEX_EXCLUDE: .*/(man/.*|src/kernel-install/.*|.*\.(in|SKELETON)|tools/coverity\.sh)$
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MULTI_STATUS: true
VALIDATE_ALL_CODEBASE: false
VALIDATE_BASH: true

View File

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=SC2206
PHASES=(${@:-SETUP RUN RUN_ASAN_UBSAN CLEANUP}) PHASES=(${@:-SETUP RUN RUN_ASAN_UBSAN CLEANUP})
RELEASE="$(lsb_release -cs)" RELEASE="$(lsb_release -cs)"
ADDITIONAL_DEPS=( ADDITIONAL_DEPS=(

View File

@ -1,19 +1,17 @@
#!/bin/bash #!/bin/bash
set -eux set -eux
set -o pipefail
# default to Debian testing # default to Debian testing
DISTRO="${DISTRO:-debian}" DISTRO=${DISTRO:-debian}
RELEASE="${RELEASE:-bullseye}" RELEASE=${RELEASE:-bullseye}
BRANCH="${BRANCH:-upstream-ci}" BRANCH=${BRANCH:-upstream-ci}
ARCH="${ARCH:-amd64}" ARCH=${ARCH:-amd64}
CONTAINER="${RELEASE}-${ARCH}" CONTAINER=${RELEASE}-${ARCH}
CACHE_DIR="${SEMAPHORE_CACHE_DIR:-/tmp}" CACHE_DIR=${SEMAPHORE_CACHE_DIR:=/tmp}
AUTOPKGTEST_DIR="${CACHE_DIR}/autopkgtest" AUTOPKGTEST_DIR="${CACHE_DIR}/autopkgtest"
# semaphore cannot expose these, but useful for interactive/local runs # semaphore cannot expose these, but useful for interactive/local runs
ARTIFACTS_DIR=/tmp/artifacts ARTIFACTS_DIR=/tmp/artifacts
# shellcheck disable=SC2206
PHASES=(${@:-SETUP RUN}) PHASES=(${@:-SETUP RUN})
UBUNTU_RELEASE="$(lsb_release -cs)" UBUNTU_RELEASE="$(lsb_release -cs)"
@ -22,18 +20,18 @@ create_container() {
# GPG key from keyserver", so retry a few times with different keyservers. # GPG key from keyserver", so retry a few times with different keyservers.
for keyserver in "" "keys.gnupg.net" "keys.openpgp.org" "keyserver.ubuntu.com"; do for keyserver in "" "keys.gnupg.net" "keys.openpgp.org" "keyserver.ubuntu.com"; do
for retry in {1..5}; do for retry in {1..5}; do
sudo lxc-create -n "$CONTAINER" -t download -- -d "$DISTRO" -r "$RELEASE" -a "$ARCH" ${keyserver:+--keyserver "$keyserver"} && break 2 sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH ${keyserver:+--keyserver "$keyserver"} && break 2
sleep $((retry*retry)) sleep $((retry*retry))
done done
done done
# unconfine the container, otherwise some tests fail # unconfine the container, otherwise some tests fail
echo 'lxc.apparmor.profile = unconfined' | sudo tee -a "/var/lib/lxc/$CONTAINER/config" echo 'lxc.apparmor.profile = unconfined' | sudo tee -a /var/lib/lxc/$CONTAINER/config
sudo lxc-start -n "$CONTAINER" sudo lxc-start -n $CONTAINER
# enable source repositories so that apt-get build-dep works # enable source repositories so that apt-get build-dep works
sudo lxc-attach -n "$CONTAINER" -- sh -ex <<EOF sudo lxc-attach -n $CONTAINER -- sh -ex <<EOF
sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list
# wait until online # wait until online
while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done
@ -46,11 +44,11 @@ apt-get purge --auto-remove -y unattended-upgrades
systemctl unmask systemd-networkd systemctl unmask systemd-networkd
systemctl enable systemd-networkd systemctl enable systemd-networkd
EOF EOF
sudo lxc-stop -n "$CONTAINER" sudo lxc-stop -n $CONTAINER
} }
for phase in "${PHASES[@]}"; do for phase in "${PHASES[@]}"; do
case "$phase" in case $phase in
SETUP) SETUP)
# remove semaphore repos, some of them don't work and cause error messages # remove semaphore repos, some of them don't work and cause error messages
sudo rm -f /etc/apt/sources.list.d/* sudo rm -f /etc/apt/sources.list.d/*
@ -61,17 +59,17 @@ for phase in "${PHASES[@]}"; do
sudo apt-get install -y -t "$UBUNTU_RELEASE-backports" lxc sudo apt-get install -y -t "$UBUNTU_RELEASE-backports" lxc
sudo apt-get install -y python3-debian git dpkg-dev fakeroot python3-jinja2 sudo apt-get install -y python3-debian git dpkg-dev fakeroot python3-jinja2
[ -d "$AUTOPKGTEST_DIR" ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTEST_DIR" [ -d $AUTOPKGTEST_DIR ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTEST_DIR"
create_container create_container
;; ;;
RUN) RUN)
# add current debian/ packaging # add current debian/ packaging
git fetch --depth=1 https://salsa.debian.org/systemd-team/systemd.git "$BRANCH" git fetch --depth=1 https://salsa.debian.org/systemd-team/systemd.git $BRANCH
git checkout FETCH_HEAD debian git checkout FETCH_HEAD debian
# craft changelog # craft changelog
UPSTREAM_VER="$(git describe | sed 's/^v//;s/-/./g')" UPSTREAM_VER=$(git describe | sed 's/^v//;s/-/./g')
cat << EOF > debian/changelog.new cat << EOF > debian/changelog.new
systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
@ -80,7 +78,7 @@ systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
-- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R) -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
EOF EOF
cat debian/changelog >>debian/changelog.new cat debian/changelog >> debian/changelog.new
mv debian/changelog.new debian/changelog mv debian/changelog.new debian/changelog
# clean out patches # clean out patches
@ -93,15 +91,15 @@ EOF
echo '1.0' > debian/source/format echo '1.0' > debian/source/format
# build source package # build source package
dpkg-buildpackage -S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc dpkg-buildpackage -S -I -I$(basename "$CACHE_DIR") -d -us -uc -nc
# now build the package and run the tests # now build the package and run the tests
rm -rf "$ARTIFACTS_DIR" rm -rf "$ARTIFACTS_DIR"
# autopkgtest exits with 2 for "some tests skipped", accept that # autopkgtest exits with 2 for "some tests skipped", accept that
"$AUTOPKGTEST_DIR/runner/autopkgtest" --env DEB_BUILD_OPTIONS=noudeb \ $AUTOPKGTEST_DIR/runner/autopkgtest --env DEB_BUILD_OPTIONS=noudeb \
--env TEST_UPSTREAM=1 ../systemd_*.dsc \ --env TEST_UPSTREAM=1 ../systemd_*.dsc \
-o "$ARTIFACTS_DIR" \ -o "$ARTIFACTS_DIR" \
-- lxc -s "$CONTAINER" \ -- lxc -s $CONTAINER \
|| [ $? -eq 2 ] || [ $? -eq 2 ]
;; ;;
*) *)

View File

@ -10,20 +10,19 @@ EXCLUDED_PATHS=(
"src/libsystemd/sd-journal/lookup3.c" "src/libsystemd/sd-journal/lookup3.c"
) )
TOP_DIR="$(git rev-parse --show-toplevel)" top="$(git rev-parse --show-toplevel)"
ARGS=() args=
# Create an array from files tracked by git... # Create an array from files tracked by git...
mapfile -t FILES < <(git ls-files ':/*.[ch]') mapfile -t files < <(git ls-files ':/*.[ch]')
# ...and filter everything that matches patterns from EXCLUDED_PATHS # ...and filter everything that matches patterns from EXCLUDED_PATHS
for excl in "${EXCLUDED_PATHS[@]}"; do for excl in "${EXCLUDED_PATHS[@]}"; do
# shellcheck disable=SC2206 files=(${files[@]//$excl})
FILES=(${FILES[@]//$excl})
done done
case "$1" in case "$1" in
-i) -i)
ARGS+=(--in-place) args="$args --in-place"
shift shift
;; ;;
esac esac
@ -33,14 +32,12 @@ if ! parallel -h >/dev/null; then
exit 1 exit 1
fi fi
[[ ${#@} -ne 0 ]] && SCRIPTS=("$@") || SCRIPTS=("$TOP_DIR"/coccinelle/*.cocci) for SCRIPT in ${@-$top/coccinelle/*.cocci}; do
echo "--x-- Processing $SCRIPT --x--"
for script in "${SCRIPTS[@]}"; do TMPFILE=`mktemp`
echo "--x-- Processing $script --x--" echo "+ spatch --sp-file $SCRIPT $args ..."
TMPFILE="$(mktemp)"
echo "+ spatch --sp-file $script ${ARGS[*]} ..."
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
spatch --macro-file="$TOP_DIR/coccinelle/macros.h" --sp-file "$script" "${ARGS[@]}" ::: "${FILES[@]}" \ spatch --macro-file="$top/coccinelle/macros.h" --sp-file $SCRIPT $args ::: "${files[@]}" \
2>"$TMPFILE" || cat "$TMPFILE" 2>"$TMPFILE" || cat "$TMPFILE"
echo -e "--x-- Processed $script --x--\n" echo -e "--x-- Processed $SCRIPT --x--\n"
done done

23
configure vendored
View File

@ -2,23 +2,22 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
set -e set -e
cflags="CFLAGS=${CFLAGS-}" cflags=CFLAGS="$CFLAGS"
cxxflags="CXXFLAGS=${CXXFLAGS-}" cxxflags=CXXFLAGS="$CXXFLAGS"
args=() declare -a args
j=0
for arg in "$@"; do for i in "$@"; do
case "$arg" in case "$i" in
CFLAGS=*) CFLAGS=*)
cflags="$arg" cflags="$i";;
;;
CXXFLAGS=*) CXXFLAGS=*)
cxxflags="$arg" cxxflags="$i";;
;;
*) *)
args+=("$arg") args[$j]="$i"
j=$((j+1))
esac esac
done done
export "${cflags?}" "${cxxflags?}" export "$cflags" "$cxxflags"
set -x set -x
exec meson build "${args[@]}" exec meson build "${args[@]}"

View File

@ -14,7 +14,7 @@ test_append_files() {
# On openSUSE the static linked version of busybox is named "busybox-static". # On openSUSE the static linked version of busybox is named "busybox-static".
busybox="$(type -P busybox-static || type -P busybox)" busybox="$(type -P busybox-static || type -P busybox)"
inst_simple "$busybox" "$(dirname "$busybox")/busybox" inst_simple "$busybox" "$(dirname $busybox)/busybox"
if selinuxenabled >/dev/null; then if selinuxenabled >/dev/null; then
image_install selinuxenabled image_install selinuxenabled

View File

@ -2,7 +2,6 @@
set -e set -e
TEST_DESCRIPTION="test OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo=" TEST_DESCRIPTION="test OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo="
# shellcheck source=test/test-functions . $TEST_BASE_DIR/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@" 57 do_test "$@" 57

View File

@ -1,10 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="test systemd-repart" TEST_DESCRIPTION="test systemd-repart"
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@" do_test "$@"

View File

@ -1,10 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test auto restart of exited services which are stuck in reloading state" TEST_DESCRIPTION="Test auto restart of exited services which are stuck in reloading state"
TEST_NO_QEMU=1 TEST_NO_QEMU=1
# shellcheck source=test/test-functions . $TEST_BASE_DIR/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@" do_test "$@"

View File

@ -1,9 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
TEST_DESCRIPTION="Test that mount/unmount storms can enter/exit rate limit state and will not leak units" TEST_DESCRIPTION="Test that mount/unmount storms can enter/exit rate limit state and will not leak units"
# shellcheck source=test/test-functions . $TEST_BASE_DIR/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@" do_test "$@"

View File

@ -1,10 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test RestrictNetworkInterfaces="
TEST_NO_NSPAWN=1 TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions set -e
. "$TEST_BASE_DIR/test-functions" TEST_DESCRIPTION="test RestrictNetworkInterfaces="
. $TEST_BASE_DIR/test-functions
do_test "$@" do_test "$@" 62

View File

@ -10,7 +10,7 @@
set -e set -e
export SYSTEMD_LOG_LEVEL=info export SYSTEMD_LOG_LEVEL=info
ROOTDIR="$(dirname "$(dirname "$(readlink -f "$0")")")" ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
SYSTEMD_HWDB="${1:?missing argument}" SYSTEMD_HWDB="${1:?missing argument}"
if [ ! -x "$SYSTEMD_HWDB" ]; then if [ ! -x "$SYSTEMD_HWDB" ]; then
@ -18,8 +18,7 @@ if [ ! -x "$SYSTEMD_HWDB" ]; then
exit 1 exit 1
fi fi
D="$(mktemp --tmpdir --directory "hwdb-test.XXXXXXXXXX")" D=$(mktemp --tmpdir --directory "hwdb-test.XXXXXXXXXX")
# shellcheck disable=SC2064
trap "rm -rf '$D'" EXIT INT QUIT PIPE trap "rm -rf '$D'" EXIT INT QUIT PIPE
mkdir -p "$D/etc/udev" mkdir -p "$D/etc/udev"
ln -s "$ROOTDIR/hwdb.d" "$D/etc/udev/hwdb.d" ln -s "$ROOTDIR/hwdb.d" "$D/etc/udev/hwdb.d"

27
test/mocks/fsck Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
fd=0
OPTIND=1
while getopts "C:aTlM" opt; do
case "$opt" in
C)
fd=$OPTARG
;;
\?);;
esac
done
shift "$((OPTIND-1))"
device=$1
echo "Running fake fsck on $device"
declare -a maxpass=(30 5 2 30 60)
for pass in {1..5}; do
maxprogress=${maxpass[$((pass-1))]}
for (( current=0; current<=${maxprogress}; current++)); do
echo "$pass $current $maxprogress $device">&$fd
sleep 0.1
done
done

View File

@ -3,7 +3,7 @@ set -e
if [ "$NO_BUILD" ]; then if [ "$NO_BUILD" ]; then
BUILD_DIR="" BUILD_DIR=""
elif BUILD_DIR="$("$(dirname "$0")/../tools/find-build-dir.sh")"; then elif BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"; then
ninja -C "$BUILD_DIR" ninja -C "$BUILD_DIR"
else else
echo "No build found, please set BUILD_DIR or NO_BUILD" >&2 echo "No build found, please set BUILD_DIR or NO_BUILD" >&2
@ -73,36 +73,35 @@ fi
# Run actual tests (if requested) # Run actual tests (if requested)
if [[ $args =~ [a-z] ]]; then if [[ $args =~ [a-z] ]]; then
for TEST in $SELECTED_TESTS; do for TEST in $SELECTED_TESTS; do
COUNT=$((COUNT+1)) COUNT=$(($COUNT+1))
pass_deny_list "$TEST" || continue pass_deny_list $TEST || continue
start=$(date +%s) start=$(date +%s)
echo -e "\n--x-- Running $TEST --x--" echo -e "\n--x-- Running $TEST --x--"
set +e set +e
# shellcheck disable=SC2086
( set -x ; make -C "$TEST" $args ) ( set -x ; make -C "$TEST" $args )
RESULT=$? RESULT=$?
set -e set -e
echo "--x-- Result of $TEST: $RESULT --x--" echo "--x-- Result of $TEST: $RESULT --x--"
results["$TEST"]="$RESULT" results["$TEST"]="$RESULT"
times["$TEST"]=$(( $(date +%s) - start )) times["$TEST"]=$(( $(date +%s) - $start ))
[ "$RESULT" -ne "0" ] && FAILURES=$((FAILURES+1)) [ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1))
done done
fi fi
# Run clean-again, if requested, and if no tests failed # Run clean-again, if requested, and if no tests failed
if [[ $FAILURES -eq 0 && $CLEANAGAIN -eq 1 ]]; then if [ $FAILURES -eq 0 -a $CLEANAGAIN = 1 ]; then
for TEST in "${!results[@]}"; do for TEST in ${!results[@]}; do
( set -x ; make -C "$TEST" clean-again ) ( set -x ; make -C "$TEST" clean-again )
done done
fi fi
echo "" echo ""
for TEST in "${!results[@]}"; do for TEST in ${!results[@]}; do
RESULT="${results[$TEST]}" RESULT="${results[$TEST]}"
time="${times[$TEST]}" time="${times[$TEST]}"
string=$([ "$RESULT" = "0" ] && echo "SUCCESS" || echo "FAIL") string=$([ "$RESULT" = "0" ] && echo "SUCCESS" || echo "FAIL")

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2030,SC2031 # shellcheck disable=SC2031
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh tw=180 # ex: ts=8 sw=4 sts=4 et filetype=sh tw=180
# Note: the shellcheck line above disables warning for variables which were # Note: the shellcheck line above disables warning for variables which were
@ -992,11 +992,9 @@ install_iscsi() {
# dumps a list of files (perl modules) required by `tgt-admin` at # dumps a list of files (perl modules) required by `tgt-admin` at
# the runtime plus any DSOs loaded via DynaLoader. This list is then # the runtime plus any DSOs loaded via DynaLoader. This list is then
# passed to `inst_simple` which installs the necessary files into the image # passed to `inst_simple` which installs the necessary files into the image
#
# shellcheck disable=SC2016
while read -r file; do while read -r file; do
inst_simple "$file" inst_simple "$file"
done < <(perl -- <(cat "$(command -v tgt-admin)" <(echo -e 'use DynaLoader; print map { "$_\n" } values %INC; print join("\n", @DynaLoader::dl_shared_objects)')) -p | awk '/^\// { print $1 }') done < <(perl -- <(cat $(command -v tgt-admin) <(echo -e 'use DynaLoader; print map { "$_\n" } values %INC; print join("\n", @DynaLoader::dl_shared_objects)')) -p | awk '/^\// { print $1 }')
fi fi
} }
@ -1531,7 +1529,7 @@ install_haveged() {
dinfo "Install haveged files" dinfo "Install haveged files"
inst /usr/sbin/haveged inst /usr/sbin/haveged
for u in /usr/lib/systemd/system/haveged*; do for u in /usr/lib/systemd/system/haveged*; do
inst "$u" inst $u
done done
fi fi
} }
@ -1720,7 +1718,6 @@ install_pam() {
done done
} }
# shellcheck disable=SC2120
install_keymaps() { install_keymaps() {
dinfo "Install keymaps" dinfo "Install keymaps"
# The first three paths may be deprecated. # The first three paths may be deprecated.

View File

@ -18,13 +18,11 @@ for f in "$src"/test-*.input; do
( (
out=$(mktemp --tmpdir --directory "test-network-generator-conversion.XXXXXXXXXX") out=$(mktemp --tmpdir --directory "test-network-generator-conversion.XXXXXXXXXX")
# shellcheck disable=SC2064
trap "rm -rf '$out'" EXIT INT QUIT PIPE trap "rm -rf '$out'" EXIT INT QUIT PIPE
# shellcheck disable=SC2046 $generator --root "$out" -- $(cat $f)
$generator --root "$out" -- $(cat "$f")
if ! diff -u "$out/run/systemd/network" "${f%.input}.expected"; then if ! diff -u "$out"/run/systemd/network ${f%.input}.expected; then
echo "**** Unexpected output for $f" echo "**** Unexpected output for $f"
exit 1 exit 1
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
echo "$0 $*" echo "$0 $@"
test "$(basename "$0")" = "script.sh" || exit 1 test "$(basename $0)" = "script.sh" || exit 1
test "$1" = "--version" || exit 2 test "$1" = "--version" || exit 2
echo "Life is good" echo "Life is good"

View File

@ -1,62 +1,62 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eux set -x
set -e
set -o pipefail set -o pipefail
# sleep interval (seconds) # sleep interval (seconds)
sleep_interval="${sleep_interval:-1}" : ${sleep_interval:=1}
# extend_timeout_interval second(s) # extend_timeout_interval second(s)
extend_timeout_interval="${extend_timeout_interval:-1}" : ${extend_timeout_interval:=1}
# number of sleep_intervals before READY=1 # number of sleep_intervals before READY=1
start_intervals="${start_intervals:-10}" : ${start_intervals:=10}
# number of sleep_intervals before exiting # number of sleep_intervals before exiting
stop_intervals="${stop_intervals:-10}" : ${stop_intervals:=10}
# run intervals, number of sleep_intervals to run # run intervals, number of sleep_intervals to run
run_intervals="${run_intervals:-7}" : ${run_intervals:=7}
# We convert to usec # We convert to usec
extend_timeout_interval=$((extend_timeout_interval * 1000000)) extend_timeout_interval=$(( $extend_timeout_interval * 1000000 ))
# shellcheck disable=SC2064
trap "{ touch /${SERVICE}.terminated; exit 1; }" SIGTERM SIGABRT trap "{ touch /${SERVICE}.terminated; exit 1; }" SIGTERM SIGABRT
rm -f "/${SERVICE}".* rm -f /${SERVICE}.*
touch "/${SERVICE}.startfail" touch /${SERVICE}.startfail
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval" systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
while [[ $start_intervals -gt 0 ]] while [ $start_intervals -gt 0 ]
do do
sleep "$sleep_interval" sleep $sleep_interval
start_intervals=$((start_intervals - 1)) start_intervals=$(( $start_intervals - 1 ))
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval" systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
done done
systemd-notify --ready --status="Waiting for your request" systemd-notify --ready --status="Waiting for your request"
touch "/${SERVICE}.runtimefail" touch /${SERVICE}.runtimefail
rm "/${SERVICE}.startfail" rm /${SERVICE}.startfail
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval" systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
while [[ $run_intervals -gt 0 ]] while [ $run_intervals -gt 0 ]
do do
sleep "$sleep_interval" sleep $sleep_interval
run_intervals=$((run_intervals - 1)) run_intervals=$(( $run_intervals - 1 ))
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval" systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
done done
systemd-notify STOPPING=1 systemd-notify STOPPING=1
touch "/${SERVICE}.stopfail" touch /${SERVICE}.stopfail
rm "/${SERVICE}.runtimefail" rm /${SERVICE}.runtimefail
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval" systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
while [[ $stop_intervals -gt 0 ]] while [ $stop_intervals -gt 0 ]
do do
sleep "$sleep_interval" sleep $sleep_interval
stop_intervals=$((stop_intervals - 1)) stop_intervals=$(( $stop_intervals - 1 ))
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval" systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
done done
touch "/${SERVICE}.success" touch /${SERVICE}.success
rm "/${SERVICE}.stopfail" rm /${SERVICE}.stopfail
exit 0 exit 0

View File

@ -8,11 +8,10 @@ input="$2"
expected="$3" expected="$3"
output=$(mktemp --tmpdir "test-udev-dmi-memory-id.XXXXXXXXXX") output=$(mktemp --tmpdir "test-udev-dmi-memory-id.XXXXXXXXXX")
# shellcheck disable=SC2064
trap "rm '$output'" EXIT INT QUIT PIPE trap "rm '$output'" EXIT INT QUIT PIPE
( (
set -x set -x
"$dmi_memory_id" -F "$input" >"$output" "$dmi_memory_id" -F "$input" >$output
diff -u "$output" "$expected" diff -u "$output" "$expected"
) )

View File

@ -7,7 +7,7 @@ trap "journalctl --rotate --vacuum-size=16M" EXIT
# Rotation/flush test, see https://github.com/systemd/systemd/issues/19895 # Rotation/flush test, see https://github.com/systemd/systemd/issues/19895
journalctl --relinquish-var journalctl --relinquish-var
for _ in {0..50}; do for i in {0..50}; do
dd if=/dev/urandom bs=1M count=1 | base64 | systemd-cat dd if=/dev/urandom bs=1M count=1 | base64 | systemd-cat
done done
journalctl --rotate journalctl --rotate
@ -116,7 +116,7 @@ cmp /expected /output
# test that LogLevelMax can also suppress logging about services, not only by services # test that LogLevelMax can also suppress logging about services, not only by services
systemctl start silent-success systemctl start silent-success
journalctl --sync journalctl --sync
[[ -z "$(journalctl -b -q -u silent-success.service)" ]] [[ -z `journalctl -b -q -u silent-success.service` ]]
# Add new tests before here, the journald restarts below # Add new tests before here, the journald restarts below
# may make tests flappy. # may make tests flappy.

View File

@ -8,9 +8,9 @@ function check_validity() {
local f ID_OR_HANDLE local f ID_OR_HANDLE
for f in /run/udev/watch/*; do for f in /run/udev/watch/*; do
ID_OR_HANDLE="$(readlink "$f")" ID_OR_HANDLE=$(readlink $f)
test -L "/run/udev/watch/${ID_OR_HANDLE}" test -L /run/udev/watch/${ID_OR_HANDLE}
test "$(readlink "/run/udev/watch/${ID_OR_HANDLE}")" = "$(basename "$f")" test $(readlink /run/udev/watch/${ID_OR_HANDLE}) = $(basename $f)
done done
} }
@ -49,7 +49,7 @@ check
MAJOR=$(udevadm info /dev/sda | grep -e '^E: MAJOR=' | sed -e 's/^E: MAJOR=//') MAJOR=$(udevadm info /dev/sda | grep -e '^E: MAJOR=' | sed -e 's/^E: MAJOR=//')
MINOR=$(udevadm info /dev/sda | grep -e '^E: MINOR=' | sed -e 's/^E: MINOR=//') MINOR=$(udevadm info /dev/sda | grep -e '^E: MINOR=' | sed -e 's/^E: MINOR=//')
test -L "/run/udev/watch/b${MAJOR}:${MINOR}" test -L /run/udev/watch/b${MAJOR}:${MINOR}
cat >/run/udev/rules.d/50-testsuite.rules <<EOF cat >/run/udev/rules.d/50-testsuite.rules <<EOF
ACTION=="change", SUBSYSTEM=="block", KERNEL=="sda", OPTIONS:="nowatch" ACTION=="change", SUBSYSTEM=="block", KERNEL=="sda", OPTIONS:="nowatch"
@ -59,7 +59,7 @@ check
MAJOR=$(udevadm info /dev/sda | grep -e '^E: MAJOR=' | sed -e 's/^E: MAJOR=//') MAJOR=$(udevadm info /dev/sda | grep -e '^E: MAJOR=' | sed -e 's/^E: MAJOR=//')
MINOR=$(udevadm info /dev/sda | grep -e '^E: MINOR=' | sed -e 's/^E: MINOR=//') MINOR=$(udevadm info /dev/sda | grep -e '^E: MINOR=' | sed -e 's/^E: MINOR=//')
test ! -e "/run/udev/watch/b${MAJOR}:${MINOR}" test ! -e /run/udev/watch/b${MAJOR}:${MINOR}
rm /run/udev/rules.d/00-debug.rules rm /run/udev/rules.d/00-debug.rules
rm /run/udev/rules.d/50-testsuite.rules rm /run/udev/rules.d/50-testsuite.rules

View File

@ -43,7 +43,7 @@ if systemctl --version | grep -q -- +OPENSSL ; then
systemd-creds encrypt --name=test-54 /tmp/test-54-plaintext /tmp/test-54-ciphertext systemd-creds encrypt --name=test-54 /tmp/test-54-plaintext /tmp/test-54-ciphertext
systemd-creds decrypt --name=test-54 /tmp/test-54-ciphertext | cmp /tmp/test-54-plaintext systemd-creds decrypt --name=test-54 /tmp/test-54-ciphertext | cmp /tmp/test-54-plaintext
systemd-run -p SetCredentialEncrypted=test-54:"$(cat /tmp/test-54-ciphertext)" \ systemd-run -p SetCredentialEncrypted=test-54:"`cat /tmp/test-54-ciphertext`" \
--wait \ --wait \
--pipe \ --pipe \
cat '${CREDENTIALS_DIRECTORY}/test-54' | cmp /tmp/test-54-plaintext cat '${CREDENTIALS_DIRECTORY}/test-54' | cmp /tmp/test-54-plaintext

View File

@ -3,7 +3,6 @@ set -eux
set -o pipefail set -o pipefail
TESTS_GLOB="test-loop-block" TESTS_GLOB="test-loop-block"
# shellcheck source=test/units/testsuite-02.sh . $(dirname $0)/testsuite-02.sh
. "$(dirname "$0")/testsuite-02.sh"
exit 0 exit 0

View File

@ -6,28 +6,28 @@ setup() {
systemd-analyze log-level debug systemd-analyze log-level debug
systemd-analyze log-target console systemd-analyze log-target console
for i in {0..3}; for i in `seq 0 3`;
do do
ip netns del "ns${i}" || true ip netns del ns${i} || true
ip link del "veth${i}" || true ip link del veth${i} || true
ip netns add "ns${i}" ip netns add ns${i}
ip link add "veth${i}" type veth peer name "veth${i}_" ip link add veth${i} type veth peer name veth${i}_
ip link set "veth${i}_" netns "ns${i}" ip link set veth${i}_ netns ns${i}
ip -n "ns${i}" link set dev "veth${i}_" up ip -n ns${i} link set dev veth${i}_ up
ip -n "ns${i}" link set dev lo up ip -n ns${i} link set dev lo up
ip -n "ns${i}" addr add "192.168.113."$((4*i+1))/30 dev "veth${i}_" ip -n ns${i} addr add "192.168.113."$((4*i+1))/30 dev veth${i}_
ip link set dev "veth${i}" up ip link set dev veth${i} up
ip addr add "192.168.113."$((4*i+2))/30 dev "veth${i}" ip addr add "192.168.113."$((4*i+2))/30 dev veth${i}
done done
} }
teardown() { teardown() {
set +e set +e
for i in {0..3}; for i in `seq 0 3`;
do do
ip netns del "ns${i}" ip netns del ns${i}
ip link del "veth${i}" ip link del veth${i}
done done
systemd-analyze log-level info systemd-analyze log-level info

View File

@ -76,8 +76,6 @@ helper_wait_for_pvscan() {
# Get major and minor numbers from the udev database # Get major and minor numbers from the udev database
# (udevadm returns MAJOR= and MINOR= expressions, so let's pull them into # (udevadm returns MAJOR= and MINOR= expressions, so let's pull them into
# the current environment via `source` for easier parsing) # the current environment via `source` for easier parsing)
#
# shellcheck source=/dev/null
source <(udevadm info -q property "$real_dev" | grep -E "(MAJOR|MINOR)=") source <(udevadm info -q property "$real_dev" | grep -E "(MAJOR|MINOR)=")
# Sanity check if we got correct major and minor numbers # Sanity check if we got correct major and minor numbers
test -e "/sys/dev/block/$MAJOR:$MINOR/" test -e "/sys/dev/block/$MAJOR:$MINOR/"

View File

@ -3,37 +3,33 @@
# Download and extract coverity tool # Download and extract coverity tool
set -e
set -o pipefail
# Environment check # Environment check
if [ -z "$COVERITY_SCAN_TOKEN" ]; then [ -z "$COVERITY_SCAN_TOKEN" ] && echo 'ERROR: COVERITY_SCAN_TOKEN must be set' && exit 1
echo >&2 'ERROR: COVERITY_SCAN_TOKEN must be set'
exit 1
fi
# Use default values if not set # Use default values if not set
PLATFORM="$(uname)" PLATFORM=$(uname)
TOOL_BASE="${TOOL_BASE:-/tmp/coverity-scan-analysis}"
TOOL_ARCHIVE="${TOOL_ARCHIVE:-/tmp/cov-analysis-${PLATFORM}.tgz}" TOOL_BASE=${TOOL_BASE:="/tmp/coverity-scan-analysis"}
TOOL_ARCHIVE=${TOOL_ARCHIVE:="/tmp/cov-analysis-${PLATFORM}.tgz"}
TOOL_URL="https://scan.coverity.com/download/${PLATFORM}" TOOL_URL="https://scan.coverity.com/download/${PLATFORM}"
# Make sure wget is installed # Make sure wget is installed
sudo apt-get update && sudo apt-get -y install wget sudo apt-get update && sudo apt-get -y install wget
# Get coverity tool # Get coverity tool
if [ ! -d "$TOOL_BASE" ]; then if [ ! -d $TOOL_BASE ]; then
# Download Coverity Scan Analysis Tool # Download Coverity Scan Analysis Tool
if [ ! -e "$TOOL_ARCHIVE" ]; then if [ ! -e $TOOL_ARCHIVE ]; then
echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m"
wget -nv -O "$TOOL_ARCHIVE" "$TOOL_URL" --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
fi fi
# Extract Coverity Scan Analysis Tool # Extract Coverity Scan Analysis Tool
echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
mkdir -p "$TOOL_BASE" mkdir -p $TOOL_BASE
pushd "$TOOL_BASE" pushd $TOOL_BASE
tar xzf "$TOOL_ARCHIVE" tar xzf $TOOL_ARCHIVE
popd popd
fi fi

View File

@ -9,14 +9,13 @@ options="$4"
CC="$5" CC="$5"
CXX="$6" CXX="$6"
# shellcheck disable=SC2086
[ -f "$dst/ninja.build" ] || CC="$CC" CXX="$CXX" meson "$src" "$dst" $options [ -f "$dst/ninja.build" ] || CC="$CC" CXX="$CXX" meson "$src" "$dst" $options
# Locate ninja binary, on CentOS 7 it is called ninja-build, so # Locate ninja binary, on CentOS 7 it is called ninja-build, so
# use that name if available. # use that name if available.
ninja="ninja" ninja=ninja
if which ninja-build >/dev/null 2>&1 ; then if which ninja-build >/dev/null 2>&1 ; then
ninja="ninja-build" ninja=ninja-build
fi fi
"$ninja" -C "$dst" "$target" "$ninja" -C "$dst" "$target"

View File

@ -21,11 +21,11 @@ export LDFLAGS=${LDFLAGS:--L${clang_lib}}
export WORK=${WORK:-$(pwd)} export WORK=${WORK:-$(pwd)}
export OUT=${OUT:-$(pwd)/out} export OUT=${OUT:-$(pwd)/out}
mkdir -p "$OUT" mkdir -p $OUT
build="$WORK/build" build=$WORK/build
rm -rf "$build" rm -rf $build
mkdir -p "$build" mkdir -p $build
if [ -z "$FUZZING_ENGINE" ]; then if [ -z "$FUZZING_ENGINE" ]; then
fuzzflag="llvm-fuzz=true" fuzzflag="llvm-fuzz=true"
@ -38,28 +38,28 @@ else
fi fi
fi fi
if ! meson "$build" "-D$fuzzflag" -Db_lundef=false; then if ! meson $build -D$fuzzflag -Db_lundef=false; then
cat "$build/meson-logs/meson-log.txt" cat $build/meson-logs/meson-log.txt
exit 1 exit 1
fi fi
ninja -v -C "$build" fuzzers ninja -v -C $build fuzzers
# The seed corpus is a separate flat archive for each fuzzer, # The seed corpus is a separate flat archive for each fuzzer,
# with a fixed name ${fuzzer}_seed_corpus.zip. # with a fixed name ${fuzzer}_seed_corpus.zip.
for d in "$(dirname "$0")/../test/fuzz/fuzz-"*; do for d in "$(dirname "$0")/../test/fuzz/fuzz-"*; do
zip -jqr "$OUT/$(basename "$d")_seed_corpus.zip" "$d" zip -jqr $OUT/$(basename "$d")_seed_corpus.zip "$d"
done done
# get fuzz-dns-packet corpus # get fuzz-dns-packet corpus
df="$build/dns-fuzzing" df=$build/dns-fuzzing
git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing "$df" git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing $df
zip -jqr "$OUT/fuzz-dns-packet_seed_corpus.zip" "$df/packet" zip -jqr $OUT/fuzz-dns-packet_seed_corpus.zip $df/packet
install -Dt "$OUT/src/shared/" "$build"/src/shared/libsystemd-shared-*.so install -Dt $OUT/src/shared/ $build/src/shared/libsystemd-shared-*.so
wget -O "$OUT/fuzz-json.dict" https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/json.dict wget -O $OUT/fuzz-json.dict https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/json.dict
find "$build" -maxdepth 1 -type f -executable -name "fuzz-*" -exec mv {} "$OUT" \; find $build -maxdepth 1 -type f -executable -name "fuzz-*" -exec mv {} $OUT \;
find src -type f -name "fuzz-*.dict" -exec cp {} "$OUT" \; find src -type f -name "fuzz-*.dict" -exec cp {} $OUT \;
cp src/fuzz/*.options "$OUT" cp src/fuzz/*.options $OUT

View File

@ -1,6 +1,5 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
# shellcheck disable=SC2154,SC2174
set -eu set -eu
i=1 i=1