1
0
mirror of https://github.com/systemd/systemd synced 2026-03-19 11:34:46 +01:00

Compare commits

..

7 Commits

Author SHA1 Message Date
Yu Watanabe
b905f3bbba
Merge pull request #19990 from mrc0mmand/test-tweaks
A couple of stability-related test tweaks
2021-06-23 01:45:04 +09:00
Yu Watanabe
de806cd6b6
Merge pull request #19991 from bluca/bash_compl_unbound_vars
completion: fix 'unbound variables' errors
2021-06-23 01:44:30 +09:00
Luca Boccassi
36ec026830 completion: fix 'unbound variables' errors
Fixes https://github.com/systemd/systemd/issues/19987
2021-06-22 14:56:47 +01:00
Luca Boccassi
6a0667d2b6 completion/systemd-delta,-resolve: autocomplete with parameters 2021-06-22 14:56:47 +01:00
Luca Boccassi
df7ca94009 completion/hostnamectl: do not dereference non-existing OPTS[ARGUNKNOWN] 2021-06-22 14:56:47 +01:00
Frantisek Sumsal
179ca4d2b1 test: correctly mask supporting services in tests
It turns out the "supporting services" were run in _all_ tests if
TEST-01-BASIC was run as the first test (which is usually the case),
since with the original condition in test_create_image() we would skip
the masking and then propagate the change to the default image used by
other tests. This has been causing multiple bogus test timeouts
(especially when the hwdb was being rebuilt in tests with short
timeouts, like TEST-52-HONORFIRSTSHUTDOWN).

Let's "fix" this by making the call to mask_supporting_services()
uncoditional and override the test_create_image() function in
TEST-01-BASIC to avoid the masking in this single case.
2021-06-22 12:34:31 +02:00
Frantisek Sumsal
907300c3c3 test: ignore the "freezing" & "thawing" intermediate states
When checking the unit state after `systemctl freeze|thaw` we can be
"too fast" and get the intermediate state (freezing/thawing) which we're
not interested in. Let's wait a bit and try to get the state again in
such cases to avoid unnecessary flakiness.

```
[   29.390203] testsuite-38.sh[218]: + state=thawing
[   29.390203] testsuite-38.sh[218]: + '[' thawing = running ']'
[   29.390203] testsuite-38.sh[218]: + echo 'error: unexpected freezer state, expected: running, actual: thawing'
[   29.390203] testsuite-38.sh[218]: error: unexpected freezer state, expected: running, actual: thawing
[   29.390203] testsuite-38.sh[218]: + exit 1
```
2021-06-22 12:12:34 +02:00
21 changed files with 46 additions and 33 deletions

View File

@ -69,7 +69,7 @@ _bootctl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
comps='' comps=''

View File

@ -140,7 +140,7 @@ _busctl() {
n=$(($COMP_CWORD - $i)) n=$(($COMP_CWORD - $i))
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
comps='' comps=''

View File

@ -83,7 +83,7 @@ _coredumpctl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then
comps='' comps=''

View File

@ -170,7 +170,7 @@ _homectl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[NAME]}; then elif __contains_word "$verb" ${VERBS[NAME]}; then
comps=$(__get_homes) comps=$(__get_homes)

View File

@ -39,7 +39,7 @@ _hostnamectl() {
[ARG]='-H --host -M --machine --json' [ARG]='-H --host -M --machine --json'
) )
if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in case $prev in
--host|-H) --host|-H)
comps=$(compgen -A hostname) comps=$(compgen -A hostname)
@ -77,7 +77,7 @@ _hostnamectl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[CHASSIS]}; then elif __contains_word "$verb" ${VERBS[CHASSIS]}; then
comps='desktop laptop convertible server tablet handset watch embedded vm container' comps='desktop laptop convertible server tablet handset watch embedded vm container'

View File

@ -67,7 +67,7 @@ _localectl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[VARIANTS]}; then elif __contains_word "$verb" ${VERBS[VARIANTS]}; then
comps=$(command localectl list-x11-keymap-layouts) comps=$(command localectl list-x11-keymap-layouts)

View File

@ -93,7 +93,7 @@ _loginctl () {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps="${VERBS[*]}" comps="${VERBS[*]}"
elif __contains_word "$verb" ${VERBS[SESSIONS]}; then elif __contains_word "$verb" ${VERBS[SESSIONS]}; then

View File

@ -95,7 +95,7 @@ _machinectl() {
return 0 return 0
fi fi
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then

View File

@ -69,7 +69,7 @@ _networkctl() {
return 0 return 0
fi fi
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
comps='' comps=''

View File

@ -79,7 +79,7 @@ _portablectl() {
n=$(($COMP_CWORD - $i)) n=$(($COMP_CWORD - $i))
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
comps='' comps=''

View File

@ -87,7 +87,7 @@ _resolvectl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps="${VERBS[*]}" comps="${VERBS[*]}"
elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[DOMAIN]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[DOMAIN]}; then

View File

@ -254,7 +254,7 @@ _systemctl () {
cur_orig="$(printf '%q' $cur)" cur_orig="$(printf '%q' $cur)"
fi fi
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps="${VERBS[*]}" comps="${VERBS[*]}"
elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then

View File

@ -93,12 +93,12 @@ _systemd_analyze() {
return 0 return 0
fi fi
if [[ -z $verb && $cur = -* ]]; then if [[ -z ${verb-} && $cur = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0 return 0
fi fi
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then

View File

@ -48,12 +48,12 @@ _systemd-delta() {
return 0 return 0
fi fi
if [[ "$cur" = -* ]]; then if [[ "$cur" = -* ]] || [[ -z ${comps-} ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0 return 0
fi fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) COMPREPLY=( $(compgen -W '${comps-}' -- "$cur") )
return 0 return 0
} }

View File

@ -61,7 +61,7 @@ _systemd_id128() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
comps='' comps=''

View File

@ -71,7 +71,7 @@ _systemd-resolve() {
return 0 return 0
fi fi
if [[ "$cur" = -* ]]; then if [[ "$cur" = -* ]] || [[ -z ${comps-} ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0 return 0
fi fi

View File

@ -76,7 +76,7 @@ _timedatectl() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
comps=${VERBS[*]} comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then
comps='true false' comps='true false'

View File

@ -73,7 +73,7 @@ _udevadm() {
fi fi
done done
if [[ -z $verb ]]; then if [[ -z ${verb-} ]]; then
if [[ "$cur" = -* ]]; then if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[COMMON]} ${OPTS[DEBUG]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${OPTS[COMMON]} ${OPTS[DEBUG]}' -- "$cur") )
else else

View File

@ -9,6 +9,18 @@ TEST_REQUIRE_INSTALL_TESTS=0
# shellcheck source=test/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions" . "${TEST_BASE_DIR:?}/test-functions"
# Explicitly override the default test_create_image() function to avoid the
# call to mask_supporting_services(), since we want to run them in TEST-01-BASIC
test_create_image() {
create_empty_image_rootdir
# Create what will eventually be our root filesystem onto an overlay
(
LOG_LEVEL=5
setup_basic_environment
)
}
test_append_files() { test_append_files() {
# install tests manually so the test is functional even when -Dinstall-tests=false # install tests manually so the test is functional even when -Dinstall-tests=false
local dst="${1:?}/usr/lib/systemd/tests/testdata/units/" local dst="${1:?}/usr/lib/systemd/tests/testdata/units/"

View File

@ -2416,13 +2416,7 @@ test_create_image() {
( (
LOG_LEVEL=5 LOG_LEVEL=5
setup_basic_environment setup_basic_environment
mask_supporting_services
# We want to test all services in TEST-01-BASIC, but mask them in
# all other tests
if [[ "$TESTID" != "01" ]]; then
dinfo "Masking supporting services"
mask_supporting_services
fi
) )
} }

View File

@ -82,11 +82,18 @@ check_freezer_state() {
name="${1%.$suffix}" name="${1%.$suffix}"
object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}" object_path="/org/freedesktop/systemd1/unit/${name//-/_2d}_2e${suffix}"
state=$(busctl get-property \ for _ in {0..10}; do
org.freedesktop.systemd1 \ state=$(busctl get-property \
"${object_path}" \ org.freedesktop.systemd1 \
org.freedesktop.systemd1.Unit \ "${object_path}" \
FreezerState | cut -d " " -f2 | tr -d '"') org.freedesktop.systemd1.Unit \
FreezerState | cut -d " " -f2 | tr -d '"')
# Ignore the intermediate freezing & thawing states in case we check
# the unit state too quickly
[[ "$state" =~ ^(freezing|thawing)$ ]] || break
sleep .5
done
[ "$state" = "$2" ] || { [ "$state" = "$2" ] || {
echo "error: unexpected freezer state, expected: $2, actual: $state" >&2 echo "error: unexpected freezer state, expected: $2, actual: $state" >&2