]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #19248 from keszybz/make-tests-test
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Apr 2021 05:56:04 +0000 (07:56 +0200)
committerGitHub <noreply@github.com>
Fri, 9 Apr 2021 05:56:04 +0000 (07:56 +0200)
Make tests test

57 files changed:
man/homectl.xml
man/systemd-tmpfiles.xml
src/home/homectl.c
src/tmpfiles/tmpfiles.c
test/TEST-52-HONORFIRSTSHUTDOWN/test.sh
test/test-execute/exec-standardoutput-append.service
test/test-execute/exec-standardoutput-file.service
test/test-execute/exec-standardoutput-truncate.service
test/test-functions
test/testsuite-28.units/specifier-j-wants.service
test/testsuite-52.units/testsuite-52.sh
test/units/testsuite-03.sh
test/units/testsuite-04.sh
test/units/testsuite-12.sh
test/units/testsuite-13.sh
test/units/testsuite-15.sh
test/units/testsuite-17.01.sh
test/units/testsuite-17.02.sh
test/units/testsuite-17.03.sh
test/units/testsuite-17.04.sh
test/units/testsuite-17.05.sh
test/units/testsuite-18.sh
test/units/testsuite-19.sh
test/units/testsuite-20.sh
test/units/testsuite-22.01.sh
test/units/testsuite-22.02.sh
test/units/testsuite-22.03.sh
test/units/testsuite-22.04.sh
test/units/testsuite-22.06.sh
test/units/testsuite-22.07.sh
test/units/testsuite-22.08.sh
test/units/testsuite-23.sh
test/units/testsuite-25.sh
test/units/testsuite-26.sh
test/units/testsuite-29.sh
test/units/testsuite-30.sh
test/units/testsuite-31.sh
test/units/testsuite-33.sh
test/units/testsuite-34.sh
test/units/testsuite-36.sh
test/units/testsuite-37.sh
test/units/testsuite-38.sh
test/units/testsuite-39.sh
test/units/testsuite-40.sh
test/units/testsuite-41.sh
test/units/testsuite-42.sh
test/units/testsuite-43.sh
test/units/testsuite-44.sh
test/units/testsuite-46.sh
test/units/testsuite-47-repro.sh
test/units/testsuite-47.sh
test/units/testsuite-48.sh
test/units/testsuite-49.sh
test/units/testsuite-50.sh
test/units/testsuite-54.sh
test/units/testsuite-55.sh
test/units/testsuite-56.sh

index 184bdcf6fd0305271faf9e0e6d6127192bbb3923..f2858166f7babdde64d67265d4bb9ed83ab532fc 100644 (file)
     <title>Exit status</title>
 
     <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
+
+    <para>When a command is invoked with <command>with</command>, the exit status of the child is
+    propagated. Effectively, <command>homectl</command> will exit without error if the command is
+    successfully invoked <emphasis>and</emphasis> finishes successfully.</para>
   </refsect1>
 
   <xi:include href="common-variables.xml" />
index 5f97e37025f3b530de4c56efd7d3e91a96c5dcbb..15bc1ea889b830d5c029513611e82dd79899f5fa 100644 (file)
   <refsect1>
     <title>Exit status</title>
 
-    <para>On success, 0 is returned. If the configuration was syntactically invalid (syntax errors,
-    missing arguments, …), so some lines had to be ignored, but no other errors occurred,
-    <constant>65</constant> is returned (<constant>EX_DATAERR</constant> from
-    <filename>/usr/include/sysexits.h</filename>). If the configuration was syntactically valid, but
-    could not be executed (lack of permissions, creation of files in missing directories, invalid
-    contents when writing to <filename>/sys/</filename> values, …), <constant>73</constant> is
-    returned (<constant>EX_CANTCREAT</constant> from <filename>/usr/include/sysexits.h</filename>).
-    Otherwise, <constant>1</constant> is returned (<constant>EXIT_FAILURE</constant> from
-    <filename>/usr/include/stdlib.h</filename>).
-    </para>
+    <para>On success, 0 is returned. If the configuration was syntactically invalid (syntax errors, missing
+    arguments, …), so some lines had to be ignored, but no other errors occurred, <constant>65</constant> is
+    returned (<constant>EX_DATAERR</constant> from <filename>/usr/include/sysexits.h</filename>). If the
+    configuration was syntactically valid, but could not be executed (lack of permissions, creation of files
+    in missing directories, invalid contents when writing to <filename>/sys/</filename> values, …),
+    <constant>73</constant> is returned (<constant>EX_CANTCREAT</constant> from
+    <filename>/usr/include/sysexits.h</filename>). Otherwise, <constant>1</constant> is returned
+    (<constant>EXIT_FAILURE</constant> from <filename>/usr/include/stdlib.h</filename>).</para>
+
+    <para>Note: when creating items, if the target already exists, but is of the wrong type or otherwise does
+    not match the requested state, and forced operation has not been requested with <literal>+</literal>,
+    a message is emitted, but the failure is otherwise ignored.</para>
   </refsect1>
 
   <refsect1>
index cf1a2d9f9bb4e2a3477dc89d240b2e654d2f3f31..a187a75d863c9dc1c0492e09d84a9a133a05944b 100644 (file)
@@ -3362,4 +3362,4 @@ static int run(int argc, char *argv[]) {
         return dispatch_verb(argc, argv, verbs, NULL);
 }
 
-DEFINE_MAIN_FUNCTION(run);
+DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
index f11b4eed7cc91135d97bc9427dccdc21790b94db..6b26dc8b9c333a65a195959b60f04235c056f8a6 100644 (file)
@@ -1656,10 +1656,9 @@ static int create_directory_or_subvolume(const char *path, mode_t mode, bool sub
                         return log_error_errno(r, "%s does not exist and cannot be created as the file system is read-only.", path);
                 if (k < 0)
                         return log_error_errno(k, "Failed to check if %s exists: %m", path);
-                if (!k) {
-                        log_warning("\"%s\" already exists and is not a directory.", path);
-                        return -EEXIST;
-                }
+                if (!k)
+                        return log_warning_errno(SYNTHETIC_ERRNO(EEXIST),
+                                                 "\"%s\" already exists and is not a directory.", path);
 
                 *creation = CREATION_EXISTING;
         } else
@@ -1742,10 +1741,10 @@ static int empty_directory(Item *i, const char *path) {
         }
         if (r < 0)
                 return log_error_errno(r, "is_dir() failed on path %s: %m", path);
-        if (r == 0)
-                return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
-                                       "'%s' already exists and is not a directory.",
-                                       path);
+        if (r == 0) {
+                log_warning("\"%s\" already exists and is not a directory.", path);
+                return 0;
+        }
 
         return path_set_perms(i, path);
 }
@@ -1804,7 +1803,7 @@ static int create_device(Item *i, mode_t file_type) {
                                         return log_error_errno(r, "Failed to create device node \"%s\": %m", i->path);
                                 creation = CREATION_FORCE;
                         } else {
-                                log_debug("%s is not a device node.", i->path);
+                                log_warning("\"%s\" already exists is not a device node.", i->path);
                                 return 0;
                         }
                 } else
@@ -2575,7 +2574,9 @@ static int patch_var_run(const char *fname, unsigned line, char **path) {
         /* Also log about this briefly. We do so at LOG_NOTICE level, as we fixed up the situation automatically, hence
          * there's no immediate need for action by the user. However, in the interest of making things less confusing
          * to the user, let's still inform the user that these snippets should really be updated. */
-        log_syntax(NULL, LOG_NOTICE, fname, line, 0, "Line references path below legacy directory /var/run/, updating %s → %s; please update the tmpfiles.d/ drop-in file accordingly.", *path, n);
+        log_syntax(NULL, LOG_NOTICE, fname, line, 0,
+                   "Line references path below legacy directory /var/run/, updating %s → %s; please update the tmpfiles.d/ drop-in file accordingly.",
+                   *path, n);
 
         free_and_replace(*path, n);
 
index a0848ef6723deea89c9cf30b24424b266a797a06..28b97fadb08767de6aa85dcaffce2d4977e3ca30 100755 (executable)
@@ -16,4 +16,4 @@ NSPAWN_TIMEOUT=20
 # only found from the console during the poweroff.
 rm -f /tmp/honorfirstshutdown.log >/dev/null
 
-do_test "$@" 52 > /tmp/honorfirstshutdown.log
+do_test "$@" 52 >/tmp/honorfirstshutdown.log
index 8983bb056b23457d6ff0891ab5f44f86f1d690ac..2118bfc2a661c0f022f2489b007f9b23a740a7a1 100644 (file)
@@ -2,8 +2,8 @@
 Description=Test for StandardOutput=append:
 
 [Service]
-ExecStartPre=sh -c 'printf "hello\n" > /tmp/test-exec-standardoutput-output'
-ExecStartPre=sh -c 'printf "hello\nhello\n" > /tmp/test-exec-standardoutput-expected'
+ExecStartPre=sh -c 'printf "hello\n" >/tmp/test-exec-standardoutput-output'
+ExecStartPre=sh -c 'printf "hello\nhello\n" >/tmp/test-exec-standardoutput-expected'
 StandardInput=data
 StandardInputText=hello
 StandardOutput=append:/tmp/test-exec-standardoutput-output
index 71e2604b942ca26b8a742e7e6dd42036a9a4d140..8d484a456e6b4eec1901de9b9969b213d329d067 100644 (file)
@@ -2,8 +2,8 @@
 Description=Test for StandardOutput=file:
 
 [Service]
-ExecStartPre=sh -c 'printf "nooo\nhello\n" > /tmp/test-exec-standardoutput-output'
-ExecStartPre=sh -c 'printf "hello\nello\n" > /tmp/test-exec-standardoutput-expected'
+ExecStartPre=sh -c 'printf "nooo\nhello\n" >/tmp/test-exec-standardoutput-output'
+ExecStartPre=sh -c 'printf "hello\nello\n" >/tmp/test-exec-standardoutput-expected'
 StandardInput=data
 StandardInputText=hello
 StandardOutput=file:/tmp/test-exec-standardoutput-output
index 4b4bb87b758bb97a4ba2ba68fe58ee8c05dfe313..8d6ea2769fed3fa9e80db45a8fe04eb0a608fb9e 100644 (file)
@@ -2,8 +2,8 @@
 Description=Test for StandardOutput=truncate:
 
 [Service]
-ExecStartPre=sh -c 'printf "hello\n" > /tmp/test-exec-standardoutput-output'
-ExecStartPre=sh -c 'printf "hi\n" > /tmp/test-exec-standardoutput-expected'
+ExecStartPre=sh -c 'printf "hello\n" >/tmp/test-exec-standardoutput-output'
+ExecStartPre=sh -c 'printf "hi\n" >/tmp/test-exec-standardoutput-expected'
 StandardInput=data
 StandardInputText=hi
 StandardOutput=truncate:/tmp/test-exec-standardoutput-output
index 6b94058fd366a989544f5acf97b1406d70162389..063a6096fdcdd0df36365910088a265b4a0a7fd5 100644 (file)
@@ -503,13 +503,13 @@ install_verity_minimal() {
         ln -s ../usr/lib/os-release $initdir/etc/os-release
         touch $initdir/etc/machine-id $initdir/etc/resolv.conf
         touch $initdir/opt/some_file
-        echo MARKER=1 >> $initdir/usr/lib/os-release
-        echo -e "[Service]\nExecStartPre=cat /usr/lib/os-release\nExecStart=sleep 120" > $initdir/usr/lib/systemd/system/app0.service
+        echo MARKER=1 >>$initdir/usr/lib/os-release
+        echo -e "[Service]\nExecStartPre=cat /usr/lib/os-release\nExecStart=sleep 120" >$initdir/usr/lib/systemd/system/app0.service
         cp $initdir/usr/lib/systemd/system/app0.service $initdir/usr/lib/systemd/system/app0-foo.service
 
         mksquashfs $initdir $oldinitdir/usr/share/minimal_0.raw
         veritysetup format $oldinitdir/usr/share/minimal_0.raw $oldinitdir/usr/share/minimal_0.verity | \
-            grep '^Root hash:' | cut -f2 | tr -d '\n' > $oldinitdir/usr/share/minimal_0.roothash
+            grep '^Root hash:' | cut -f2 | tr -d '\n' >$oldinitdir/usr/share/minimal_0.roothash
 
         sed -i "s/MARKER=1/MARKER=2/g" $initdir/usr/lib/os-release
         rm $initdir/usr/lib/systemd/system/app0-foo.service
@@ -517,7 +517,7 @@ install_verity_minimal() {
 
         mksquashfs $initdir $oldinitdir/usr/share/minimal_1.raw
         veritysetup format $oldinitdir/usr/share/minimal_1.raw $oldinitdir/usr/share/minimal_1.verity | \
-            grep '^Root hash:' | cut -f2 | tr -d '\n' > $oldinitdir/usr/share/minimal_1.roothash
+            grep '^Root hash:' | cut -f2 | tr -d '\n' >$oldinitdir/usr/share/minimal_1.roothash
 
         # Rolling distros like Arch do not set VERSION_ID
         local version_id=""
@@ -527,42 +527,42 @@ install_verity_minimal() {
 
         export initdir=$TESTDIR/app0
         mkdir -p $initdir/usr/lib/extension-release.d $initdir/usr/lib/systemd/system $initdir/opt
-        grep "^ID=" $os_release > $initdir/usr/lib/extension-release.d/extension-release.app0
-        echo "${version_id}" >> $initdir/usr/lib/extension-release.d/extension-release.app0
-        cat <<EOF > $initdir/usr/lib/systemd/system/app0.service
+        grep "^ID=" $os_release >$initdir/usr/lib/extension-release.d/extension-release.app0
+        echo "${version_id}" >>$initdir/usr/lib/extension-release.d/extension-release.app0
+        cat <<EOF >$initdir/usr/lib/systemd/system/app0.service
 [Service]
 Type=oneshot
 RemainAfterExit=yes
 ExecStart=/opt/script0.sh
 EOF
-        cat <<EOF > $initdir/opt/script0.sh
+        cat <<EOF >$initdir/opt/script0.sh
 #!/bin/bash
 set -e
 test -e /usr/lib/os-release
 cat /usr/lib/extension-release.d/extension-release.app0
 EOF
         chmod +x $initdir/opt/script0.sh
-        echo MARKER=1 > $initdir/usr/lib/systemd/system/some_file
+        echo MARKER=1 >$initdir/usr/lib/systemd/system/some_file
         mksquashfs $initdir $oldinitdir/usr/share/app0.raw
 
         export initdir=$TESTDIR/app1
         mkdir -p $initdir/usr/lib/extension-release.d $initdir/usr/lib/systemd/system $initdir/opt
-        grep "^ID=" $os_release > $initdir/usr/lib/extension-release.d/extension-release.app1
-        echo "${version_id}" >> $initdir/usr/lib/extension-release.d/extension-release.app1
-        cat <<EOF > $initdir/usr/lib/systemd/system/app1.service
+        grep "^ID=" $os_release >$initdir/usr/lib/extension-release.d/extension-release.app1
+        echo "${version_id}" >>$initdir/usr/lib/extension-release.d/extension-release.app1
+        cat <<EOF >$initdir/usr/lib/systemd/system/app1.service
 [Service]
 Type=oneshot
 RemainAfterExit=yes
 ExecStart=/opt/script1.sh
 EOF
-        cat <<EOF > $initdir/opt/script1.sh
+        cat <<EOF >$initdir/opt/script1.sh
 #!/bin/bash
 set -e
 test -e /usr/lib/os-release
 cat /usr/lib/extension-release.d/extension-release.app1
 EOF
         chmod +x $initdir/opt/script1.sh
-        echo MARKER=1 > $initdir/usr/lib/systemd/system/other_file
+        echo MARKER=1 >$initdir/usr/lib/systemd/system/other_file
         mksquashfs $initdir $oldinitdir/usr/share/app1.raw
     )
 }
@@ -700,7 +700,7 @@ if [[ "$ASAN_COMPILER" == "clang" ]]; then
   # Let's add the ASan DSO's path to the dynamic linker's cache. This is pretty
   # unnecessary for gcc & libasan, however, for clang this is crucial, as its
   # runtime ASan DSO is in a non-standard (library) path.
-  echo "${ASAN_RT_PATH%/*}" > /etc/ld.so.conf.d/asan-path-override.conf
+  echo "${ASAN_RT_PATH%/*}" >/etc/ld.so.conf.d/asan-path-override.conf
   ldconfig
 fi
 echo DefaultEnvironment=\$DEFAULT_ENVIRONMENT >>/etc/systemd/system.conf
@@ -741,7 +741,7 @@ printf "[Service]\nEnvironment=ASAN_OPTIONS=leak_check_at_exit=false\n" >/etc/sy
 # they're uninstrumented (like dmsetup). Let's add a simple rule which sets
 # LD_PRELOAD to the ASan RT library to fix this.
 mkdir -p /etc/udev/rules.d
-cat > /etc/udev/rules.d/00-set-LD_PRELOAD.rules << INNER_EOF
+cat >/etc/udev/rules.d/00-set-LD_PRELOAD.rules <<INNER_EOF
 SUBSYSTEM=="block", ENV{LD_PRELOAD}="$ASAN_RT_PATH"
 INNER_EOF
 chmod 0644 /etc/udev/rules.d/00-set-LD_PRELOAD.rules
@@ -856,9 +856,9 @@ install_systemd() {
     [[ "$LOOKS_LIKE_SUSE" ]] && setup_suse
 
     # enable debug logging in PID1
-    echo LogLevel=debug >> $initdir/etc/systemd/system.conf
+    echo LogLevel=debug >>$initdir/etc/systemd/system.conf
     # store coredumps in journal
-    echo Storage=journal >> $initdir/etc/systemd/coredump.conf
+    echo Storage=journal >>$initdir/etc/systemd/coredump.conf
 }
 
 get_ldpath() {
@@ -1174,12 +1174,12 @@ install_config_files() {
     inst_any /etc/os-release /usr/lib/os-release
     inst /etc/localtime
     # we want an empty environment
-    > $initdir/etc/environment
-    > $initdir/etc/machine-id
-    > $initdir/etc/resolv.conf
+    >$initdir/etc/environment
+    >$initdir/etc/machine-id
+    >$initdir/etc/resolv.conf
 
     # set the hostname
-    echo systemd-testsuite > $initdir/etc/hostname
+    echo systemd-testsuite >$initdir/etc/hostname
 
     # let's set up just one image with the traditional verbose output
     if [ ${IMAGE_NAME} != "basic" ]; then
@@ -1202,9 +1202,9 @@ install_debug_tools() {
         # Set default TERM from vt220 to linux, so at least basic key shortcuts work
         local _getty_override="$initdir/etc/systemd/system/serial-getty@.service.d"
         mkdir -p "$_getty_override"
-        echo -e "[Service]\nEnvironment=TERM=linux" > "$_getty_override/default-TERM.conf"
+        echo -e "[Service]\nEnvironment=TERM=linux" >"$_getty_override/default-TERM.conf"
 
-        cat > "$initdir/etc/motd" << EOF
+        cat >"$initdir/etc/motd" <<EOF
 To adjust the terminal size use:
     export COLUMNS=xx
     export LINES=yy
@@ -1246,7 +1246,7 @@ install_dbus() {
 
     # setup policy for Type=dbus test
     mkdir -p $initdir/etc/dbus-1/system.d
-    cat > $initdir/etc/dbus-1/system.d/systemd.test.ExecStopPost.conf <<EOF
+    cat >$initdir/etc/dbus-1/system.d/systemd.test.ExecStopPost.conf <<EOF
 <?xml version="1.0"?>
 <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
         "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
@@ -1987,7 +1987,7 @@ install_kmod_with_fw() {
     fi
 
     [ -d "$initdir/.kernelmodseen" ] && \
-        > "$initdir/.kernelmodseen/${1##*/}"
+        >"$initdir/.kernelmodseen/${1##*/}"
 
     inst_simple "$1" "/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" \
         || return $?
@@ -2059,11 +2059,11 @@ filter_kernel_modules_by_path () (
     for _modname in $(eval $_filtercmd); do
         case $_modname in
             *.ko) "$2" "$_modname" && echo "$_modname";;
-            *.ko.gz) gzip -dc "$_modname" > $initdir/$$.ko
+            *.ko.gz) gzip -dc "$_modname" >$initdir/$$.ko
                 $2 $initdir/$$.ko && echo "$_modname"
                 rm -f $initdir/$$.ko
                 ;;
-            *.ko.xz) xz -dc "$_modname" > $initdir/$$.ko
+            *.ko.xz) xz -dc "$_modname" >$initdir/$$.ko
                 $2 $initdir/$$.ko && echo "$_modname"
                 rm -f $initdir/$$.ko
                 ;;
@@ -2276,7 +2276,7 @@ test_setup() {
         fi
 
         local hook_defined=1
-        if declare -f -F test_append_files > /dev/null; then
+        if declare -f -F test_append_files >/dev/null; then
             hook_defined=$?
         fi
 
index facf5577be10ba31d8e5887c6b8eb1b648bf6880..766a454d6a2e66aec54c5b61b23c385243067893 100644 (file)
@@ -7,4 +7,4 @@ After=testsuite-28-pre.service
 [Service]
 Type=oneshot
 ExecStart=test -f /tmp/test-specifier-j-%j
-ExecStart=sh -c 'echo OK > /testok'
+ExecStart=sh -c 'echo OK >/testok'
index 9cccf1b6c161ec5199a69cb14f19ab13cc4997fa..e10bf561105d400d52dd90426c631048c9920aa4 100755 (executable)
@@ -3,7 +3,7 @@ set -ex
 set -o pipefail
 
 if ! test -x /usr/lib/systemd/tests/testdata/units/test-honor-first-shutdown.sh ; then
-        echo "honor-first-shutdown script not found - FAIL" > /testok
+        echo "honor-first-shutdown script not found - FAIL" >/testok
         exit 0
 fi
 
@@ -13,6 +13,6 @@ systemd-analyze log-target console
 systemctl enable test-honor-first-shutdown.service
 systemctl start test-honor-first-shutdown.service
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 85efeeb741c3428736606145841984f1f569ccb6..5a2dadd6b83d73e8759f63c0253717aae2de1ecf 100755 (executable)
@@ -6,9 +6,9 @@ set -ex
 
 systemctl start --no-block hello-after-sleep.target
 
-systemctl list-jobs > /root/list-jobs.txt
+systemctl list-jobs >/root/list-jobs.txt
 while ! grep 'sleep\.service.*running' /root/list-jobs.txt; do
-    systemctl list-jobs > /root/list-jobs.txt
+    systemctl list-jobs >/root/list-jobs.txt
 done
 
 grep 'hello\.service.*waiting' /root/list-jobs.txt
@@ -19,20 +19,20 @@ systemctl start --job-mode=ignore-dependencies hello
 END_SEC=$(date -u '+%s')
 ELAPSED=$(($END_SEC-$START_SEC))
 
-[ "$ELAPSED" -lt 3 ]
+test "$ELAPSED" -lt 3
 
 # sleep should still be running, hello not.
-systemctl list-jobs > /root/list-jobs.txt
+systemctl list-jobs >/root/list-jobs.txt
 grep 'sleep\.service.*running' /root/list-jobs.txt
 grep 'hello\.service' /root/list-jobs.txt && exit 1
 systemctl stop sleep.service hello-after-sleep.target
 
 # Some basic testing that --show-transaction does something useful
-! systemctl is-active systemd-importd
+systemctl is-active systemd-importd && { echo 'unexpected success'; exit 1; }
 systemctl -T start systemd-importd
 systemctl is-active systemd-importd
 systemctl --show-transaction stop systemd-importd
-! systemctl is-active systemd-importd
+systemctl is-active systemd-importd && { echo 'unexpected success'; exit 1; }
 
 # Test for a crash when enqueuing a JOB_NOP when other job already exists
 systemctl start --no-block hello-after-sleep.target
@@ -58,13 +58,13 @@ systemctl stop --job-mode=replace-irreversibly unstoppable.service
 systemctl start unstoppable.service
 
 # Test waiting for a started unit(s) to terminate again
-cat <<EOF >  /run/systemd/system/wait2.service
+cat <<EOF >/run/systemd/system/wait2.service
 [Unit]
 Description=Wait for 2 seconds
 [Service]
 ExecStart=/bin/sh -ec 'sleep 2'
 EOF
-cat <<EOF >  /run/systemd/system/wait5fail.service
+cat <<EOF >/run/systemd/system/wait5fail.service
 [Unit]
 Description=Wait for 5 seconds and fail
 [Service]
@@ -80,7 +80,7 @@ ELAPSED=$(($END_SEC-$START_SEC))
 
 # wait5fail fails, so systemctl should fail
 START_SEC=$(date -u '+%s')
-! systemctl start --wait wait2.service wait5fail.service || exit 1
+systemctl start --wait wait2.service wait5fail.service && { echo 'unexpected success'; exit 1; }
 END_SEC=$(date -u '+%s')
 ELAPSED=$(($END_SEC-$START_SEC))
 [[ "$ELAPSED" -ge 5 ]] && [[ "$ELAPSED" -le 7 ]] || exit 1
index 3dce73b778250854dbde499123242101931540c5..a2a1292380818f67c726472a1e325856778eed83 100755 (executable)
@@ -59,19 +59,19 @@ journalctl -b -o export --output-fields=MESSAGE,FOO --output-fields=PRIORITY,MES
 grep -q '^__CURSOR=' /output
 grep -q '^MESSAGE=foo$' /output
 grep -q '^PRIORITY=6$' /output
-! grep -q '^FOO=' /output
-! grep -q '^SYSLOG_FACILITY=' /output
+grep '^FOO=' /output && { echo 'unexpected success'; exit 1; }
+grep '^SYSLOG_FACILITY=' /output && { echo 'unexpected success'; exit 1; }
 
 # `-b all` negates earlier use of -b (-b and -m are otherwise exclusive)
-journalctl -b -1 -b all -m > /dev/null
+journalctl -b -1 -b all -m >/dev/null
 
 # -b always behaves like -b0
-journalctl -q -b-1 -b0 | head -1 > /expected
-journalctl -q -b-1 -b  | head -1 > /output
+journalctl -q -b-1 -b0 | head -1 >/expected
+journalctl -q -b-1 -b  | head -1 >/output
 cmp /expected /output
 # ... even when another option follows (both of these should fail due to -m)
-{ journalctl -ball -b0 -m 2>&1 || :; } | head -1 > /expected
-{ journalctl -ball -b  -m 2>&1 || :; } | head -1 > /output
+{ journalctl -ball -b0 -m 2>&1 || :; } | head -1 >/expected
+{ journalctl -ball -b  -m 2>&1 || :; } | head -1 >/output
 cmp /expected /output
 
 # https://github.com/systemd/systemd/issues/13708
index b5888a255bca165f8dd94917342987a19f2e2d3a..7e7b0ec25a0f9566989f0023204a66376c0bec17 100755 (executable)
@@ -14,7 +14,7 @@ SocketGroup=adm
 SocketMode=0660
 EOF
 
-cat <<'EOF' > /run/systemd/system/test12@.service
+cat <<'EOF' >/run/systemd/system/test12@.service
 [Unit]
 Description=Test service
 [Service]
index 1844323d2f17f40ac5e339f1190a4ef9be71fd6c..3e66aa9d547db6ad3bac36e890c6b6fcf770703c 100755 (executable)
@@ -51,9 +51,9 @@ function check_norbind {
     local _root="/var/lib/machines/testsuite-13.norbind-path"
     rm -rf "$_root"
     mkdir -p /tmp/binddir/subdir
-    echo -n "outer" > /tmp/binddir/subdir/file
+    echo -n "outer" >/tmp/binddir/subdir/file
     mount -t tmpfs tmpfs /tmp/binddir/subdir
-    echo -n "inner" > /tmp/binddir/subdir/file
+    echo -n "inner" >/tmp/binddir/subdir/file
     /usr/lib/systemd/tests/testdata/create-busybox-container "$_root"
     systemd-nspawn $SUSE_OPTS--register=no -D "$_root" --bind=/tmp/binddir:/mnt:norbind /bin/sh -c 'CONTENT=$(cat /mnt/subdir/file); if [[ $CONTENT != "outer" ]]; then echo "*** unexpected content: $CONTENT"; return 1; fi'
 }
@@ -73,7 +73,7 @@ if [ -n "${VERSION_ID:+set}" ] && [ "${VERSION_ID}" != "${container_host_version
 if [ -n "${BUILD_ID:+set}" ] && [ "${BUILD_ID}" != "${container_host_build_id}" ]; then exit 1; fi
 if [ -n "${VARIANT_ID:+set}" ] && [ "${VARIANT_ID}" != "${container_host_variant_id}" ]; then exit 1; fi
 cd /tmp; (cd /run/host; md5sum os-release) | md5sum -c
-if echo test >> /run/host/os-release; then exit 1; fi
+if echo test >>/run/host/os-release; then exit 1; fi
 '
 
     local _os_release_source="/etc/os-release"
@@ -82,7 +82,7 @@ if echo test >> /run/host/os-release; then exit 1; fi
     elif [ -L "${_os_release_source}" ] && rm /etc/os-release; then
         # Ensure that /etc always wins if available
         cp /usr/lib/os-release /etc
-        echo MARKER=1 >> /etc/os-release
+        echo MARKER=1 >>/etc/os-release
     fi
 
     systemd-nspawn $SUSE_OPTS--register=no -D /testsuite-13.nc-container --bind="${_os_release_source}":/tmp/os-release /bin/sh -x -e -c "$_cmd"
@@ -96,7 +96,7 @@ if echo test >> /run/host/os-release; then exit 1; fi
 function check_machinectl_bind {
     local _cmd='for i in $(seq 1 20); do if test -f /tmp/marker; then exit 0; fi; sleep 0.5; done; exit 1;'
 
-    cat <<EOF > /run/systemd/system/nspawn_machinectl_bind.service
+    cat <<EOF >/run/systemd/system/nspawn_machinectl_bind.service
 [Service]
 Type=notify
 ExecStart=systemd-nspawn $SUSE_OPTS -D /testsuite-13.nc-container --notify-ready=no /bin/sh -x -e -c "$_cmd"
index 23a39bf09014cd1721a25b83c88d9cda0940dce7..fc392c584dcff186f5ce90c7d51000a9e22ac857 100755 (executable)
@@ -165,7 +165,7 @@ test_hierarchical_dropins () {
         echo "
 [Service]
 ExecCondition=/bin/echo $dropin
-        " > /usr/lib/systemd/system/$dropin/override.conf
+        " >/usr/lib/systemd/system/$dropin/override.conf
         systemctl daemon-reload
         check_ok a-b-c ExecCondition "/bin/echo $dropin"
     done
index 573ad4107916b84ce20b2658fc3c1011c83f4271..8be27d95073e627ea150bbc0a006daeefb6b158b 100755 (executable)
@@ -19,7 +19,7 @@ while : ; do
     sleep .5
 done
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+cat >/run/udev/rules.d/50-testsuite.rules <<EOF
 ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="foobar.service"
 EOF
 udevadm control --reload
@@ -36,7 +36,7 @@ while : ; do
     sleep .5
 done
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+cat >/run/udev/rules.d/50-testsuite.rules <<EOF
 ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="waldo.service"
 EOF
 udevadm control --reload
index c21fcc781b29af7ed8387103d6059510e9decc7f..5c77ab4b6a12861fe610b7c39e6d8a9680a7b67a 100755 (executable)
@@ -4,7 +4,7 @@ set -o pipefail
 
 mkdir -p /run/udev/rules.d/
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+cat >/run/udev/rules.d/50-testsuite.rules <<EOF
 ACTION=="remove", GOTO="lo_end"
 
 SUBSYSTEM=="net", KERNEL=="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/net/devices/lo"
index 02ac2176b5ad944d3367a3222cd0fb63ecc50689..e5178ce554371c32b302ec24f6cb025367e2ea31 100755 (executable)
@@ -7,9 +7,9 @@ test_rule="/run/udev/rules.d/49-test.rules"
 setup() {
     mkdir -p "${test_rule%/*}"
     cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
-    echo 'KERNEL=="lo", SUBSYSTEM=="net", PROGRAM=="/bin/sleep 60"' > "${test_rule}"
-    echo "event_timeout=30" >> /etc/udev/udev.conf
-    echo "timeout_signal=SIGABRT" >> /etc/udev/udev.conf
+    echo 'KERNEL=="lo", SUBSYSTEM=="net", PROGRAM=="/bin/sleep 60"' >"${test_rule}"
+    echo "event_timeout=30" >>/etc/udev/udev.conf
+    echo "timeout_signal=SIGABRT" >>/etc/udev/udev.conf
 
     systemctl restart systemd-udevd.service
 }
@@ -25,7 +25,7 @@ teardown() {
 run_test() {
     since="$(date +%T)"
 
-    echo add > /sys/class/net/lo/uevent
+    echo add >/sys/class/net/lo/uevent
 
     for n in {1..20}; do
         sleep 5
index c799936c0a3b04c61e1f1788f1d83aeba16d39e4..b33d47ef6de315b0cb1641811ea8e96910384780 100755 (executable)
@@ -4,14 +4,11 @@ set -o pipefail
 
 mkdir -p /run/udev/rules.d/
 
-! test -f /run/udev/tags/added/c1:3 &&
-    ! test -f /run/udev/tags/changed/c1:3 &&
-    udevadm info /dev/null | grep -q -v 'E: TAGS=.*:added:.*' &&
-    udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
-    udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
-    udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*'
+test ! -f /run/udev/tags/added/c1:3
+test ! -f /run/udev/tags/changed/c1:3
+udevadm info /dev/null | grep -E 'E: (TAGS|CURRENT_TAGS)=.*:(added|changed):' && exit 1
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+cat >/run/udev/rules.d/50-testsuite.rules <<EOF
 ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", TAG+="added"
 ACTION=="change", SUBSYSTEM=="mem", KERNEL=="null", TAG+="changed"
 EOF
@@ -19,45 +16,39 @@ EOF
 udevadm control --reload
 udevadm trigger -c add /dev/null
 
-while : ; do
-    test -f /run/udev/tags/added/c1:3 &&
-        ! test -f /run/udev/tags/changed/c1:3 &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
-        break
-
+while   test ! -f /run/udev/tags/added/c1:3 ||
+        test -f /run/udev/tags/changed/c1:3 ||
+        ! udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' ||
+        ! udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' ||
+        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' ||
+        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*'
+do
     sleep .5
 done
 
 udevadm control --reload
 udevadm trigger -c change /dev/null
 
-while : ; do
-    test -f /run/udev/tags/added/c1:3 &&
-        test -f /run/udev/tags/changed/c1:3 &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
-        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*' &&
-        break
-
+while   test ! -f /run/udev/tags/added/c1:3 ||
+        test ! -f /run/udev/tags/changed/c1:3 ||
+        ! udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' ||
+        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' ||
+        ! udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' ||
+        ! udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*'
+do
     sleep .5
 done
 
 udevadm control --reload
 udevadm trigger -c add /dev/null
 
-while : ; do
-    test -f /run/udev/tags/added/c1:3 &&
-        test -f /run/udev/tags/changed/c1:3 &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
-        break
-
+while   test ! -f /run/udev/tags/added/c1:3 ||
+        test ! -f /run/udev/tags/changed/c1:3 ||
+        ! udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' ||
+        ! udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' ||
+        ! udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' ||
+        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*'
+do
     sleep .5
 done
 
index 0991ec9d590d71d26d32284a793b998e2bc4aea5..1e7f7f41b0a5d0de7f4fa95d540e802a7bc0ab1f 100755 (executable)
@@ -4,7 +4,7 @@ set -o pipefail
 
 mkdir -p /run/udev/rules.d/
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+cat >/run/udev/rules.d/50-testsuite.rules <<EOF
 SUBSYSTEM=="mem", KERNEL=="null", OPTIONS="log_level=debug"
 ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", IMPORT{program}="/bin/echo -e HOGE=aa\\\\x20\\\\x20\\\\x20bb\nFOO=\\\\x20aaa\\\\x20\n\n\n"
 EOF
index e471cda51b58e46940c25cc6e17757919483c7f1..c4e3ca211081aeadcbc03e601b4fd40b2e5c3883 100755 (executable)
@@ -3,13 +3,13 @@ set -ex
 set -o pipefail
 
 systemd-run --wait -p FailureAction=poweroff true
-! systemd-run --wait -p SuccessAction=poweroff false
+systemd-run --wait -p SuccessAction=poweroff false && { echo 'unexpected success'; exit 1; }
 
 if ! test -f /firstphase ; then
-    echo OK > /firstphase
+    echo OK >/firstphase
     systemd-run --wait -p SuccessAction=reboot true
 else
-    echo OK > /testok
+    echo OK >/testok
     systemd-run --wait -p FailureAction=poweroff false
 fi
 
index 57831c267f6d976237913c2c1229a7fdb1c559d7..dea2f4ba1f7f834863ff75197fe443895bad0360 100755 (executable)
@@ -34,6 +34,6 @@ else
     echo "Skipping TEST-19-DELEGATE, as the kernel doesn't actually support cgroup v2" >&2
 fi
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index d94f6b2afbcbbfcb22cc4c89624215ad738eaa46..6003e4f1813be4b865df6efd62be25d9d5b1d196 100755 (executable)
@@ -71,7 +71,7 @@ disown
 sleep infinity &
 disown
 
-echo \$MAINPID > /run/mainpidsh/pid
+echo \$MAINPID >/run/mainpidsh/pid
 EOF
 chmod +x /tmp/test20-mainpid.sh
 
@@ -95,7 +95,7 @@ disown
 sleep infinity &
 disown
 
-echo \$MAINPID > /run/mainpidsh2/pid
+echo \$MAINPID >/run/mainpidsh2/pid
 chown 1001:1001 /run/mainpidsh2/pid
 EOF
 chmod +x /tmp/test20-mainpid2.sh
@@ -126,14 +126,24 @@ test -f /run/mainpidsh3/pid
 EOF
 chmod 755 /dev/shm/test20-mainpid3.sh
 
-# This has to fail, as we shouldn't accept the dangerous PID file, and then inotify-wait on it to be corrected which we never do
-! systemd-run --unit=test20-mainpidsh3.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh3 -p PIDFile=/run/mainpidsh3/pid -p DynamicUser=1 -p TimeoutStartSec=2s /dev/shm/test20-mainpid3.sh
+# This has to fail, as we shouldn't accept the dangerous PID file, and then
+# inotify-wait on it to be corrected which we never do.
+systemd-run --unit=test20-mainpidsh3.service \
+            -p StandardOutput=tty \
+            -p StandardError=tty \
+            -p Type=forking \
+            -p RuntimeDirectory=mainpidsh3 \
+            -p PIDFile=/run/mainpidsh3/pid \
+            -p DynamicUser=1 \
+            -p TimeoutStartSec=2s \
+            /dev/shm/test20-mainpid3.sh \
+    && { echo 'unexpected success'; exit 1; }
 
 # Test that this failed due to timeout, and not some other error
-test `systemctl show -P Result test20-mainpidsh3.service` = timeout
+test $(systemctl show -P Result test20-mainpidsh3.service) = timeout
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index d233e37fb2177c39cdff4fb86d71fd2ddf621d09..b10b5aaa1aa7c0ce8b999c37475960628ba241ca 100755 (executable)
@@ -10,4 +10,4 @@ rm -fr /tmp/test
 
 echo "e /tmp/test - root root 1d" | systemd-tmpfiles --create -
 
-! test -e /tmp/test
+test ! -e /tmp/test
index d1bf1ea04b9d77c8a12b54443c524a3c45cd3c0e..c337cd6e05b829125d595e0cfa1b137091380a86 100755 (executable)
@@ -63,7 +63,7 @@ e     /tmp/e/1     0755 daemon daemon - -
 e     /tmp/e/2/*   0755 daemon daemon - -
 EOF
 
-! test -d /tmp/e/1
+test ! -d /tmp/e/1
 
 test -d /tmp/e/2
 test $(stat -c %U:%G:%a /tmp/e/2) = "root:root:777"
@@ -80,7 +80,7 @@ chmod 777 /tmp/e/3/d*
 touch /tmp/e/3/f1
 chmod 644 /tmp/e/3/f1
 
-systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF
 e     /tmp/e/3/*   0755 daemon daemon - -
 EOF
 
@@ -115,7 +115,7 @@ test $(stat -c %U:%G:%a /tmp/C/1/f1) = "daemon:daemon:755"
 test -d /tmp/C/2
 test $(stat -c %U:%G:%a /tmp/C/2/f1) = "daemon:daemon:755"
 
-systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF
 C     /tmp/C/3    0755 daemon daemon - /tmp/C/3-origin
 EOF
 
index 8d009fb5bb96bde6e73d39fa73e101033951d171..c905784bee4a4ead748177ff1647d86279b2861a 100755 (executable)
@@ -19,7 +19,7 @@ f     /tmp/f/2    0644 - - - This string should be written
 EOF
 
 ### '1' should exist and be empty
-test -f /tmp/f/1; ! test -s /tmp/f/1
+test -f /tmp/f/1; test ! -s /tmp/f/1
 test $(stat -c %U:%G:%a /tmp/f/1) = "root:root:644"
 
 test $(stat -c %U:%G:%a /tmp/f/2) = "root:root:644"
@@ -31,7 +31,7 @@ f     /tmp/f/1    0666 daemon daemon - This string should not be written
 EOF
 
 # file should be empty
-! test -s /tmp/f/1
+test ! -s /tmp/f/1
 test $(stat -c %U:%G:%a /tmp/f/1) = "daemon:daemon:666"
 
 ### But we shouldn't try to set perms on an existing file which is not a
@@ -39,7 +39,7 @@ test $(stat -c %U:%G:%a /tmp/f/1) = "daemon:daemon:666"
 mkfifo /tmp/f/fifo
 chmod 644 /tmp/f/fifo
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/f/fifo    0666 daemon daemon - This string should not be written
 EOF
 
@@ -50,11 +50,11 @@ test $(stat -c %U:%G:%a /tmp/f/fifo) = "root:root:644"
 ln -s missing /tmp/f/dangling
 ln -s /tmp/file-owned-by-root /tmp/f/symlink
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/f/dangling    0644 daemon daemon - -
 f     /tmp/f/symlink     0644 daemon daemon - -
 EOF
-! test -e /tmp/f/missing
+test ! -e /tmp/f/missing
 test $(stat -c %U:%G:%a /tmp/file-owned-by-root) = "root:root:644"
 
 ### Handle read-only filesystem gracefully: we shouldn't fail if the target
@@ -70,27 +70,27 @@ mount -o bind,ro /tmp/f/rw-fs /tmp/f/ro-fs
 systemd-tmpfiles --create - <<EOF
 f     /tmp/f/ro-fs/foo    0644 - - - - This string should not be written
 EOF
-test -f /tmp/f/ro-fs/foo; ! test -s /tmp/f/ro-fs/foo
+test -f /tmp/f/ro-fs/foo; test ! -s /tmp/f/ro-fs/foo
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/f/ro-fs/foo    0666 - - - -
 EOF
 test $(stat -c %U:%G:%a /tmp/f/fifo) = "root:root:644"
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/f/ro-fs/bar    0644 - - - -
 EOF
-! test -e /tmp/f/ro-fs/bar
+test ! -e /tmp/f/ro-fs/bar
 
 ### 'f' shouldn't follow unsafe paths.
 mkdir /tmp/f/daemon
 ln -s /root /tmp/f/daemon/unsafe-symlink
 chown -R --no-dereference daemon:daemon /tmp/f/daemon
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/f/daemon/unsafe-symlink/exploit    0644 daemon daemon - -
 EOF
-! test -e /tmp/f/daemon/unsafe-symlink/exploit
+test ! -e /tmp/f/daemon/unsafe-symlink/exploit
 
 #
 # 'F'
@@ -105,10 +105,10 @@ F     /tmp/F/truncated              0666 daemon daemon - -
 F     /tmp/F/truncated-with-content 0666 daemon daemon - new content
 EOF
 
-test -f /tmp/F/created; ! test -s /tmp/F/created
+test -f /tmp/F/created; test ! -s /tmp/F/created
 test -f /tmp/F/created-with-content
 test "$(< /tmp/F/created-with-content)" = "new content"
-test -f /tmp/F/truncated; ! test -s /tmp/F/truncated
+test -f /tmp/F/truncated; test ! -s /tmp/F/truncated
 test $(stat -c %U:%G:%a /tmp/F/truncated) = "daemon:daemon:666"
 test -s /tmp/F/truncated-with-content
 test $(stat -c %U:%G:%a /tmp/F/truncated-with-content) = "daemon:daemon:666"
@@ -117,7 +117,7 @@ test $(stat -c %U:%G:%a /tmp/F/truncated-with-content) = "daemon:daemon:666"
 ### unspecified in the other cases.
 mkfifo /tmp/F/fifo
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 F     /tmp/F/fifo                0644 - - - -
 EOF
 
@@ -127,11 +127,11 @@ test -p /tmp/F/fifo
 ln -s missing /tmp/F/dangling
 ln -s /tmp/file-owned-by-root /tmp/F/symlink
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/F/dangling    0644 daemon daemon - -
 f     /tmp/F/symlink     0644 daemon daemon - -
 EOF
-! test -e /tmp/F/missing
+test ! -e /tmp/F/missing
 test $(stat -c %U:%G:%a /tmp/file-owned-by-root) = "root:root:644"
 
 ### Handle read-only filesystem gracefully: we shouldn't fail if the target
@@ -147,40 +147,41 @@ mount -o bind,ro /tmp/F/rw-fs /tmp/F/ro-fs
 systemd-tmpfiles --create - <<EOF
 F     /tmp/F/ro-fs/foo    0644 - - - -
 EOF
-test -f /tmp/F/ro-fs/foo; ! test -s /tmp/F/ro-fs/foo
+test -f /tmp/F/ro-fs/foo; test ! -s /tmp/F/ro-fs/foo
 
 echo "truncating is not allowed anymore" >/tmp/F/rw-fs/foo
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 F     /tmp/F/ro-fs/foo    0644 - - - -
 EOF
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 F     /tmp/F/ro-fs/foo    0644 - - - - This string should not be written
 EOF
-test -f /tmp/F/ro-fs/foo; ! test -s /tmp/F/ro-fs/foo
+test -f /tmp/F/ro-fs/foo
+grep -q 'truncating is not allowed' /tmp/F/ro-fs/foo
 
 # Trying to change the perms should fail.
 >/tmp/F/rw-fs/foo
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 F     /tmp/F/ro-fs/foo    0666 - - - -
 EOF
 test $(stat -c %U:%G:%a /tmp/F/ro-fs/foo) = "root:root:644"
 
 ### Try to create a new file.
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 F     /tmp/F/ro-fs/bar    0644 - - - -
 EOF
-! test -e /tmp/F/ro-fs/bar
+test ! -e /tmp/F/ro-fs/bar
 
 ### 'F' shouldn't follow unsafe paths.
 mkdir /tmp/F/daemon
 ln -s /root /tmp/F/daemon/unsafe-symlink
 chown -R --no-dereference daemon:daemon /tmp/F/daemon
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 F     /tmp/F/daemon/unsafe-symlink/exploit    0644 daemon daemon - -
 EOF
-! test -e /tmp/F/daemon/unsafe-symlink/exploit
+test ! -e /tmp/F/daemon/unsafe-symlink/exploit
 
 #
 # 'w'
@@ -191,10 +192,10 @@ touch /tmp/w/overwritten
 systemd-tmpfiles --create - <<EOF
 w     /tmp/w/unexistent    0644 - - - new content
 EOF
-! test -e /tmp/w/unexistent
+test ! -e /tmp/w/unexistent
 
 ### no argument given -> fails.
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 w     /tmp/w/unexistent    0644 - - - -
 EOF
 
@@ -230,7 +231,7 @@ mkdir /tmp/w/daemon
 ln -s /root /tmp/w/daemon/unsafe-symlink
 chown -R --no-dereference daemon:daemon /tmp/w/daemon
 
-! systemd-tmpfiles --create - <<EOF
+systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
 f     /tmp/w/daemon/unsafe-symlink/exploit    0644 daemon daemon - -
 EOF
-! test -e /tmp/w/daemon/unsafe-symlink/exploit
+test ! -e /tmp/w/daemon/unsafe-symlink/exploit
index f916086b1edf47f59e82a5887cfa42282b411bc5..fc90ab4dc7fcce8464d226d12a6e16bf6afe612b 100755 (executable)
@@ -17,8 +17,8 @@ EOF
 test -p /tmp/p/fifo1
 test $(stat -c %U:%G:%a /tmp/p/fifo1) = "root:root:666"
 
-# it should refuse to overwrite an existing file
-systemd-tmpfiles --create - <<EOF
+# Refuse to overwrite an existing file. Error is not propagated.
+systemd-tmpfiles --create - <<EOF
 p     /tmp/p/f1    0666 - - - -
 EOF
 
index cd65ba6726508ef4ee8de1c072956f8f12c49148..8ce0a08f68a8f442c5844a20495383b68c6c578e 100755 (executable)
@@ -18,8 +18,8 @@ test -d /var/tmp/foobar-test-06
 test -d /var/tmp/foobar-test-06/important
 
 test_snippet --remove
-! test -f /var/tmp/foobar-test-06
-! test -f /var/tmp/foobar-test-06/important
+test ! -f /var/tmp/foobar-test-06
+test ! -f /var/tmp/foobar-test-06/important
 
 test_snippet --create
 test -d /var/tmp/foobar-test-06
@@ -35,4 +35,4 @@ test -f /var/tmp/foobar-test-06/something-else
 test_snippet --create --remove
 test -d /var/tmp/foobar-test-06
 test -d /var/tmp/foobar-test-06/important
-! test -f /var/tmp/foobar-test-06/something-else
+test ! -f /var/tmp/foobar-test-06/something-else
index 39c04b925cf67645ca32fb7dcd4f7ddd8328af90..74286a33057b2668ae9f274743ed823e7cb0780f 100755 (executable)
@@ -16,8 +16,8 @@ r /tmp/test-prefix
 r /tmp/test-prefix/file
 EOF
 
-! test -f /tmp/test-prefix/file
-! test -f /tmp/test-prefix
+test ! -f /tmp/test-prefix/file
+test ! -f /tmp/test-prefix
 
 mkdir /tmp/test-prefix
 touch /tmp/test-prefix/file
@@ -27,5 +27,5 @@ r /tmp/test-prefix/file
 r /tmp/test-prefix
 EOF
 
-! test -f /tmp/test-prefix/file
-! test -f /tmp/test-prefix
+test ! -f /tmp/test-prefix/file
+test ! -f /tmp/test-prefix
index e7bf0447839fefdbe11957b1fa70ea16cc2a07c0..01d3bdb50cfbe72b46222966f9287ed1bbfa4ccb 100755 (executable)
@@ -22,10 +22,12 @@ test -d /tmp/root/test2
 # Verify the command fails to write to a root-owned subdirectory under an
 # unprivileged user's directory when it's not part of the prefix, as expected
 # by the unsafe_transition function.
-! echo 'd /tmp/user/root/test' | systemd-tmpfiles --create -
-! test -e /tmp/user/root/test
-! echo 'd /user/root/test' | systemd-tmpfiles --root=/tmp --create -
-! test -e /tmp/user/root/test
+echo 'd /tmp/user/root/test' | systemd-tmpfiles --create - \
+    && { echo 'unexpected success'; exit 1; }
+test ! -e /tmp/user/root/test
+echo 'd /user/root/test' | systemd-tmpfiles --root=/tmp --create - \
+    && { echo 'unexpected success'; exit 1; }
+test ! -e /tmp/user/root/test
 
 # Verify the above works when all user-owned directories are in the prefix.
 echo 'd /test' | systemd-tmpfiles --root=/tmp/user/root --create -
index 5e2966f848e0cd60013146a4400023455794cc1c..a21523756230184e2507a0d2c49d2ff3bb572325 100755 (executable)
@@ -16,8 +16,8 @@ systemd-run --unit=three -p Type=simple /tmp/brokenbinary
 
 # And now, do the same with Type=exec, where the latter two should fail
 systemd-run --unit=four -p Type=exec /bin/sleep infinity
-! systemd-run --unit=five -p Type=exec -p User=idontexist /bin/sleep infinity
-! systemd-run --unit=six -p Type=exec /tmp/brokenbinary
+systemd-run --unit=five -p Type=exec -p User=idontexist /bin/sleep infinity && { echo 'unexpected success'; exit 1; }
+systemd-run --unit=six -p Type=exec /tmp/brokenbinary && { echo 'unexpected success'; exit 1; }
 
 systemd-run --unit=seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity
 # Both TERM and SIGINT happen to have the same number on all architectures
@@ -29,6 +29,6 @@ systemctl stop seven.service
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index e3dd43add38d95d6e891a47afd5ab7d35e586b6c..d4d2e0f9532b30a53e05a346a04f68e4f2e0a023 100755 (executable)
@@ -34,8 +34,8 @@ cmp /var/tmp/testimage.raw /var/lib/machines/testimage3.raw
 
 # Test removal
 machinectl remove testimage
-! test -f /var/lib/machines/testimage.raw
-! machinectl image-status testimage
+test ! -f /var/lib/machines/testimage.raw
+machinectl image-status testimage && { echo 'unexpected success'; exit 1; }
 
 # Test export of clone
 machinectl export-raw testimage3 /var/tmp/testimage3.raw
@@ -46,8 +46,8 @@ rm /var/tmp/testimage3.raw
 machinectl rename testimage3 testimage4
 test -f /var/lib/machines/testimage4.raw
 machinectl image-status testimage4
-! test -f /var/lib/machines/testimage3.raw
-! machinectl image-status testimage3
+test ! -f /var/lib/machines/testimage3.raw
+machinectl image-status testimage3 && { echo 'unexpected success'; exit 1; }
 cmp /var/tmp/testimage.raw /var/lib/machines/testimage4.raw
 
 # Test export of rename
@@ -57,8 +57,8 @@ rm /var/tmp/testimage4.raw
 
 # Test removal
 machinectl remove testimage4
-! test -f /var/lib/machines/testimage4.raw
-! machinectl image-status testimage4
+test ! -f /var/lib/machines/testimage4.raw
+machinectl image-status testimage4 && { echo 'unexpected success'; exit 1; }
 
 # → And now, let's test directory trees ← #
 
@@ -67,7 +67,7 @@ mkdir /var/tmp/scratch
 mv /var/tmp/testimage.raw /var/tmp/scratch/
 touch /var/tmp/scratch/anotherfile
 mkdir /var/tmp/scratch/adirectory
-echo "piep" > /var/tmp/scratch/adirectory/athirdfile
+echo "piep" >/var/tmp/scratch/adirectory/athirdfile
 
 # Test import-fs
 machinectl import-fs /var/tmp/scratch/
@@ -90,8 +90,8 @@ diff -r /var/tmp/scratch/ /var/lib/machines/scratch2
 
 # Test removal
 machinectl remove scratch
-! test -f /var/lib/machines/scratch
-! machinectl image-status scratch
+test ! -f /var/lib/machines/scratch
+machinectl image-status scratchi && { echo 'unexpected success'; exit 1; }
 
 # Test clone
 machinectl clone scratch2 scratch3
@@ -103,21 +103,21 @@ diff -r /var/tmp/scratch/ /var/lib/machines/scratch3
 
 # Test removal
 machinectl remove scratch2
-! test -f /var/lib/machines/scratch2
-! machinectl image-status scratch2
+test ! -f /var/lib/machines/scratch2
+machinectl image-status scratch2 && { echo 'unexpected success'; exit 1; }
 
 # Test rename
 machinectl rename scratch3 scratch4
 test -d /var/lib/machines/scratch4
 machinectl image-status scratch4
-! test -f /var/lib/machines/scratch3
-! machinectl image-status scratch3
+test ! -f /var/lib/machines/scratch3
+machinectl image-status scratch3 && { echo 'unexpected success'; exit 1; }
 diff -r /var/tmp/scratch/ /var/lib/machines/scratch4
 
 # Test removal
 machinectl remove scratch4
-! test -f /var/lib/machines/scratch4
-! machinectl image-status scratch4
+test ! -f /var/lib/machines/scratch4
+machinectl image-status scratch4 && { echo 'unexpected success'; exit 1; }
 
 # Test import-tar hyphen/stdin pipe behavior
 cat /var/tmp/scratch.tar.gz | machinectl import-tar - scratch5
@@ -135,9 +135,9 @@ rm -rf /var/tmp/scratch
 
 # Test removal
 machinectl remove scratch5
-! test -f /var/lib/machines/scratch5
-! machinectl image-status scratch5
+test ! -f /var/lib/machines/scratch5
+machinectl image-status scratch5 && { echo 'unexpected success'; exit 1; }
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 89c0937c8dafc7dbba060a787c3db1749ab9b982..9c1abc5916186b83639dd96ca26158c68174d3ad 100755 (executable)
@@ -22,10 +22,10 @@ systemctl show-environment | grep -q '^FOO=BAR$'
 systemctl unset-environment FOO PATH
 
 # Check that one is gone and the other reverted to the built-in
-! (systemctl show-environment | grep -q '^FOO=$')
-! (systemctl show-environment | grep -q '^PATH=.*testaddition$')
+systemctl show-environment | grep '^FOO=$' && exit 1
+systemctl show-environment | grep '^PATH=.*testaddition$' && exit 1
 systemctl show-environment | grep -q '^PATH='
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 2e55c275bf1d8443cc60fbbf50117aa60819e082..4e91aa73363ed2ff776c035e281e547f2a8c728c 100755 (executable)
@@ -93,6 +93,6 @@ umount /tmp/overlay
 umount /tmp/rootdir
 umount /tmp/app1
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index a507ffcd7bcee21ecc33617ebb0faeba39ac1c9f..cb3b46d2cbea58432c711a0f20ef9199008a2849 100755 (executable)
@@ -13,19 +13,19 @@ timedatectl set-time 1980-10-15
 systemd-run --on-timezone-change touch /tmp/timezone-changed
 systemd-run --on-clock-change touch /tmp/clock-changed
 
-! test -f /tmp/timezone-changed
-! test -f /tmp/clock-changed
+test ! -f /tmp/timezone-changed
+test ! -f /tmp/clock-changed
 
 timedatectl set-timezone Europe/Kiev
 
-while ! test -f /tmp/timezone-changed ; do sleep .5 ; done
+while test ! -f /tmp/timezone-changed ; do sleep .5 ; done
 
 timedatectl set-time 2018-1-1
 
-while ! test -f /tmp/clock-changed ; do sleep .5 ; done
+while test ! -f /tmp/clock-changed ; do sleep .5 ; done
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index fcff82d804804673f5fb4b5013c7d14e019e4b30..42873bfd833a88166bdcb84f667ae13ea7b73057 100755 (executable)
@@ -6,5 +6,5 @@ if journalctl -b -t systemd --grep '\.device: Changed plugged -> dead'; then
     exit 1
 fi
 
-echo OK > /testok
+echo OK >/testok
 exit 0
index 0a6ee57b99867cfa7f62c7a8c20d824073cf145e..929c76062be8f1d6fd2bbd5e56301dbf6e94eb3c 100755 (executable)
@@ -4,7 +4,7 @@
 set -ex
 set -o pipefail
 
-cat > /etc/systemd/system/testservice.service <<EOF
+cat >/etc/systemd/system/testservice.service <<EOF
 [Service]
 ConfigurationDirectory=testservice
 RuntimeDirectory=testservice
@@ -18,11 +18,11 @@ EOF
 
 systemctl daemon-reload
 
-! test -e /etc/testservice
-! test -e /run/testservice
-! test -e /var/lib/testservice
-! test -e /var/cache/testservice
-! test -e /var/log/testservice
+test ! -e /etc/testservice
+test ! -e /run/testservice
+test ! -e /var/lib/testservice
+test ! -e /var/cache/testservice
+test ! -e /var/log/testservice
 
 systemctl start testservice
 
@@ -32,7 +32,7 @@ test -d /var/lib/testservice
 test -d /var/cache/testservice
 test -d /var/log/testservice
 
-! systemctl clean testservice
+systemctl clean testservice && { echo 'unexpected success'; exit 1; }
 
 systemctl stop testservice
 
@@ -44,7 +44,7 @@ test -d /var/log/testservice
 
 systemctl clean testservice --what=configuration
 
-! test -e /etc/testservice
+test ! -e /etc/testservice
 test -d /run/testservice
 test -d /var/lib/testservice
 test -d /var/cache/testservice
@@ -52,29 +52,29 @@ test -d /var/log/testservice
 
 systemctl clean testservice
 
-! test -e /etc/testservice
-! test -e /run/testservice
+test ! -e /etc/testservice
+test ! -e /run/testservice
 test -d /var/lib/testservice
-! test -e /var/cache/testservice
+test ! -e /var/cache/testservice
 test -d /var/log/testservice
 
 systemctl clean testservice --what=logs
 
-! test -e /etc/testservice
-! test -e /run/testservice
+test ! -e /etc/testservice
+test ! -e /run/testservice
 test -d /var/lib/testservice
-! test -e /var/cache/testservice
-! test -e /var/log/testservice
+test ! -e /var/cache/testservice
+test ! -e /var/log/testservice
 
 systemctl clean testservice --what=all
 
-! test -e /etc/testservice
-! test -e /run/testservice
-! test -e /var/lib/testservice
-! test -e /var/cache/testservice
-! test -e /var/log/testservice
+test ! -e /etc/testservice
+test ! -e /run/testservice
+test ! -e /var/lib/testservice
+test ! -e /var/cache/testservice
+test ! -e /var/log/testservice
 
-cat > /etc/systemd/system/testservice.service <<EOF
+cat >/etc/systemd/system/testservice.service <<EOF
 [Service]
 DynamicUser=yes
 ConfigurationDirectory=testservice
@@ -89,11 +89,11 @@ EOF
 
 systemctl daemon-reload
 
-! test -e /etc/testservice
-! test -e /run/testservice
-! test -e /var/lib/testservice
-! test -e /var/cache/testservice
-! test -e /var/log/testservice
+test ! -e /etc/testservice
+test ! -e /run/testservice
+test ! -e /var/lib/testservice
+test ! -e /var/cache/testservice
+test ! -e /var/log/testservice
 
 systemctl restart testservice
 
@@ -107,7 +107,7 @@ test -L /var/lib/testservice
 test -L /var/cache/testservice
 test -L /var/log/testservice
 
-! systemctl clean testservice
+systemctl clean testservice && { echo 'unexpected success'; exit 1; }
 
 systemctl stop testservice
 
@@ -123,7 +123,7 @@ test -L /var/log/testservice
 
 systemctl clean testservice --what=configuration
 
-! test -d /etc/testservice
+test ! -d /etc/testservice
 test -d /run/private/testservice
 test -d /var/lib/private/testservice
 test -d /var/cache/private/testservice
@@ -135,41 +135,41 @@ test -L /var/log/testservice
 
 systemctl clean testservice
 
-! test -d /etc/testservice
-! test -d /run/private/testservice
+test ! -d /etc/testservice
+test ! -d /run/private/testservice
 test -d /var/lib/private/testservice
-! test -d /var/cache/private/testservice
+test ! -d /var/cache/private/testservice
 test -d /var/log/private/testservice
-! test -L /run/testservice
+test ! -L /run/testservice
 test -L /var/lib/testservice
-! test -L /var/cache/testservice
+test ! -L /var/cache/testservice
 test -L /var/log/testservice
 
 systemctl clean testservice --what=logs
 
-! test -d /etc/testservice
-! test -d /run/private/testservice
+test ! -d /etc/testservice
+test ! -d /run/private/testservice
 test -d /var/lib/private/testservice
-! test -d /var/cache/private/testservice
-! test -d /var/log/private/testservice
-! test -L /run/testservice
+test ! -d /var/cache/private/testservice
+test ! -d /var/log/private/testservice
+test ! -L /run/testservice
 test -L /var/lib/testservice
-! test -L /var/cache/testservice
-! test -L /var/log/testservice
+test ! -L /var/cache/testservice
+test ! -L /var/log/testservice
 
 systemctl clean testservice --what=all
 
-! test -d /etc/testservice
-! test -d /run/private/testservice
-! test -d /var/lib/private/testservice
-! test -d /var/cache/private/testservice
-! test -d /var/log/private/testservice
-! test -L /run/testservice
-! test -L /var/lib/testservice
-! test -L /var/cache/testservice
-! test -L /var/log/testservice
-
-cat > /etc/systemd/system/tmp-hoge.mount <<EOF
+test ! -d /etc/testservice
+test ! -d /run/private/testservice
+test ! -d /var/lib/private/testservice
+test ! -d /var/cache/private/testservice
+test ! -d /var/log/private/testservice
+test ! -L /run/testservice
+test ! -L /var/lib/testservice
+test ! -L /var/cache/testservice
+test ! -L /var/log/testservice
+
+cat >/etc/systemd/system/tmp-hoge.mount <<EOF
 [Mount]
 What=tmpfs
 Type=tmpfs
@@ -182,11 +182,11 @@ EOF
 
 systemctl daemon-reload
 
-! test -e /etc/hoge
-! test -e /run/hoge
-! test -e /var/lib/hoge
-! test -e /var/cache/hoge
-! test -e /var/log/hoge
+test ! -e /etc/hoge
+test ! -e /run/hoge
+test ! -e /var/lib/hoge
+test ! -e /var/cache/hoge
+test ! -e /var/log/hoge
 
 systemctl start tmp-hoge.mount
 
@@ -196,7 +196,7 @@ test -d /var/lib/hoge
 test -d /var/cache/hoge
 test -d /var/log/hoge
 
-! systemctl clean tmp-hoge.mount
+systemctl clean tmp-hoge.mount && { echo 'unexpected success'; exit 1; }
 
 test -d /etc/hoge
 test -d /run/hoge
@@ -207,44 +207,44 @@ test -d /var/log/hoge
 systemctl stop tmp-hoge.mount
 
 test -d /etc/hoge
-! test -d /run/hoge
+test ! -d /run/hoge
 test -d /var/lib/hoge
 test -d /var/cache/hoge
 test -d /var/log/hoge
 
 systemctl clean tmp-hoge.mount --what=configuration
 
-! test -d /etc/hoge
-! test -d /run/hoge
+test ! -d /etc/hoge
+test ! -d /run/hoge
 test -d /var/lib/hoge
 test -d /var/cache/hoge
 test -d /var/log/hoge
 
 systemctl clean tmp-hoge.mount
 
-! test -d /etc/hoge
-! test -d /run/hoge
+test ! -d /etc/hoge
+test ! -d /run/hoge
 test -d /var/lib/hoge
-! test -d /var/cache/hoge
+test ! -d /var/cache/hoge
 test -d /var/log/hoge
 
 systemctl clean tmp-hoge.mount --what=logs
 
-! test -d /etc/hoge
-! test -d /run/hoge
+test ! -d /etc/hoge
+test ! -d /run/hoge
 test -d /var/lib/hoge
-! test -d /var/cache/hoge
-! test -d /var/log/hoge
+test ! -d /var/cache/hoge
+test ! -d /var/log/hoge
 
 systemctl clean tmp-hoge.mount --what=all
 
-! test -d /etc/hoge
-! test -d /run/hoge
-! test -d /var/lib/hoge
-! test -d /var/cache/hoge
-! test -d /var/log/hoge
+test ! -d /etc/hoge
+test ! -d /run/hoge
+test ! -d /var/lib/hoge
+test ! -d /var/cache/hoge
+test ! -d /var/log/hoge
 
-cat > /etc/systemd/system/testservice.socket <<EOF
+cat >/etc/systemd/system/testservice.socket <<EOF
 [Socket]
 ListenSequentialPacket=/run/testservice.socket
 RemoveOnStop=yes
@@ -258,62 +258,62 @@ EOF
 
 systemctl daemon-reload
 
-! test -e /etc/testsocket
-! test -e /run/testsocket
-! test -e /var/lib/testsocket
-! test -e /var/cache/testsocket
-! test -e /var/log/testsocket
+test ! -e /etc/testsocket
+test ! -e /run/testsocket
+test ! -e /var/lib/testsocket
+test ! -e /var/cache/testsocket
+test ! -e /var/log/testsocket
 
 systemctl start testservice.socket
 
 test -d /etc/testsocket
-test -d /run/testsocket
+test -d /run/testsocket
 test -d /var/lib/testsocket
 test -d /var/cache/testsocket
 test -d /var/log/testsocket
 
-! systemctl clean testservice.socket
+systemctl clean testservice.socket && { echo 'unexpected success'; exit 1; }
 
 systemctl stop testservice.socket
 
 test -d /etc/testsocket
-! test -d /run/testsocket
+test ! -d /run/testsocket
 test -d /var/lib/testsocket
 test -d /var/cache/testsocket
 test -d /var/log/testsocket
 
 systemctl clean testservice.socket --what=configuration
 
-! test -e /etc/testsocket
-! test -d /run/testsocket
+test ! -e /etc/testsocket
+test ! -d /run/testsocket
 test -d /var/lib/testsocket
 test -d /var/cache/testsocket
 test -d /var/log/testsocket
 
 systemctl clean testservice.socket
 
-! test -e /etc/testsocket
-! test -e /run/testsocket
+test ! -e /etc/testsocket
+test ! -e /run/testsocket
 test -d /var/lib/testsocket
-! test -e /var/cache/testsocket
+test ! -e /var/cache/testsocket
 test -d /var/log/testsocket
 
 systemctl clean testservice.socket --what=logs
 
-! test -e /etc/testsocket
-! test -e /run/testsocket
+test ! -e /etc/testsocket
+test ! -e /run/testsocket
 test -d /var/lib/testsocket
-! test -e /var/cache/testsocket
-! test -e /var/log/testsocket
+test ! -e /var/cache/testsocket
+test ! -e /var/log/testsocket
 
 systemctl clean testservice.socket --what=all
 
-! test -e /etc/testsocket
-! test -e /run/testsocket
-! test -e /var/lib/testsocket
-! test -e /var/cache/testsocket
-! test -e /var/log/testsocket
+test ! -e /etc/testsocket
+test ! -e /run/testsocket
+test ! -e /var/lib/testsocket
+test ! -e /var/cache/testsocket
+test ! -e /var/log/testsocket
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 6d9488688a1bb4554923154641e6e98e65a714fa..ca54a01f403894defed71ba567db2f187f469b66 100755 (executable)
@@ -9,38 +9,41 @@ systemd-analyze log-target console
 
 systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz touch /var/lib/zzz/test
 systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test
-! systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing
+systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing \
+    && { echo 'unexpected success'; exit 1; }
 
 test -d /var/lib/zzz
-! test -L /var/lib/zzz
-! test -e /var/lib/private/zzz
+test ! -L /var/lib/zzz
+test ! -e /var/lib/private/zzz
 test -f /var/lib/zzz/test
-! test -f /var/lib/zzz/test-missing
+test ! -f /var/lib/zzz/test-missing
 
 # Convert to DynamicUser=1
 
 systemd-run --wait -p DynamicUser=1 -p StateDirectory=zzz test -f /var/lib/zzz/test
-! systemd-run --wait -p DynamicUser=1 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing
+systemd-run --wait -p DynamicUser=1 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing \
+    && { echo 'unexpected success'; exit 1; }
 
 test -L /var/lib/zzz
 test -d /var/lib/private/zzz
 
 test -f /var/lib/zzz/test
-! test -f /var/lib/zzz/test-missing
+test ! -f /var/lib/zzz/test-missing
 
 # Convert back
 
 systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test
-! systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing
+systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing \
+    && { echo 'unexpected success'; exit 1; }
 
 test -d /var/lib/zzz
-! test -L /var/lib/zzz
-! test -e /var/lib/private/zzz
+test ! -L /var/lib/zzz
+test ! -e /var/lib/private/zzz
 test -f /var/lib/zzz/test
-! test -f /var/lib/zzz/test-missing
+test ! -f /var/lib/zzz/test-missing
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index f5579ce8255ff21997db22f3df9cc5cf23cf6f73..3decf4b3f33ddc84aee5ea027d3b721f2ea0dfca 100755 (executable)
@@ -55,7 +55,7 @@ stopJournalctl() {
     # the --sync wait until the synchronization is complete
     echo "Force journald to write all queued messages"
     journalctl --sync
-    journalctl -u $unit --cursor-file="$journalCursorFile" > "$journalLog"
+    journalctl -u $unit --cursor-file="$journalCursorFile" >"$journalLog"
 }
 
 checkNUMA() {
@@ -64,21 +64,21 @@ checkNUMA() {
 }
 
 writePID1NUMAPolicy() {
-    echo [Manager] > $confDir/numa.conf
-    echo NUMAPolicy=$1 >> $confDir/numa.conf
-    echo NUMAMask=$2>> $confDir/numa.conf
+    echo [Manager] >$confDir/numa.conf
+    echo NUMAPolicy=$1 >>$confDir/numa.conf
+    echo NUMAMask=$2 >>$confDir/numa.conf
 }
 
 writeTestUnit() {
     mkdir -p $testUnitFile.d/
-    echo [Service] > $testUnitFile
-    echo ExecStart=/bin/sleep 3600 >> $testUnitFile
+    echo [Service] >$testUnitFile
+    echo ExecStart=/bin/sleep 3600 >>$testUnitFile
 }
 
 writeTestUnitNUMAPolicy() {
-    echo [Service] > $testUnitNUMAConf
-    echo NUMAPolicy=$1 >> $testUnitNUMAConf
-    echo NUMAMask=$2>> $testUnitNUMAConf
+    echo [Service] >$testUnitNUMAConf
+    echo NUMAPolicy=$1 >>$testUnitNUMAConf
+    echo NUMAMask=$2 >>$testUnitNUMAConf
     systemctl daemon-reload
 }
 
@@ -115,13 +115,13 @@ pid1StopUnit() {
 
 systemctlCheckNUMAProperties() {
     local LOGFILE="$(mktemp)"
-    systemctl show -p NUMAPolicy $1 > "$LOGFILE"
+    systemctl show -p NUMAPolicy $1 >"$LOGFILE"
     grep "NUMAPolicy=$2" "$LOGFILE"
 
-    > "$LOGFILE"
+    >"$LOGFILE"
 
     if [ -n "$3" ]; then
-        systemctl show -p NUMAMask $1 > "$LOGFILE"
+        systemctl show -p NUMAMask $1 >"$LOGFILE"
         grep "NUMAMask=$3" "$LOGFILE"
     fi
 }
@@ -281,7 +281,7 @@ else
 
     echo "Unit file CPUAffinity=NUMA support"
     writeTestUnitNUMAPolicy "bind" "0"
-    echo "CPUAffinity=numa" >> $testUnitNUMAConf
+    echo "CPUAffinity=numa" >>$testUnitNUMAConf
     systemctl daemon-reload
     systemctl start $testUnit
     systemctlCheckNUMAProperties $testUnit "bind" "0"
@@ -336,6 +336,6 @@ systemctl daemon-reload
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 32a9dd8694e03c7bfe5f5a16eacba6f38a439980..3ae0cb32fe166084805706ef53f98dd790fa3d6a 100755 (executable)
@@ -12,8 +12,8 @@ touch /tmp/aaa/bbb
 systemctl restart tmp-aaa.mount
 
 test -e /run/hoge/foo
-! test -e /tmp/aaa/bbb
+test ! -e /tmp/aaa/bbb
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 18b7bd6dcee27b0b8f3c8564f20c1747cf927461..707fd8a86466105a59c2de360c1ea9a4c8f903df 100755 (executable)
@@ -245,7 +245,7 @@ test_preserve_state() {
     echo "Test that freezer state is preserved when recursive freezing is initiated from outside (e.g. by manager up the tree):"
 
     echo -n "  - freeze from outside: "
-    echo 1 > /sys/fs/cgroup/"${slice}"/cgroup.freeze
+    echo 1 >/sys/fs/cgroup/"${slice}"/cgroup.freeze
     # Give kernel some time to freeze the slice
     sleep 1
 
@@ -259,7 +259,7 @@ test_preserve_state() {
     echo "[ OK ]"
 
     echo -n "  - thaw from outside: "
-    echo 0 > /sys/fs/cgroup/"${slice}"/cgroup.freeze
+    echo 0 >/sys/fs/cgroup/"${slice}"/cgroup.freeze
     sleep 1
 
     check_freezer_state "${unit}" "running"
@@ -271,8 +271,8 @@ test_preserve_state() {
     echo -n "  - thaw from outside while inner service is frozen: "
     systemctl freeze "$unit"
     check_freezer_state "${unit}" "frozen"
-    echo 1 > /sys/fs/cgroup/"${slice}"/cgroup.freeze
-    echo 0 > /sys/fs/cgroup/"${slice}"/cgroup.freeze
+    echo 1 >/sys/fs/cgroup/"${slice}"/cgroup.freeze
+    echo 0 >/sys/fs/cgroup/"${slice}"/cgroup.freeze
     check_freezer_state "${slice}" "running"
     check_freezer_state "${unit}" "frozen"
     echo "[ OK ]"
@@ -293,5 +293,5 @@ test -e /sys/fs/cgroup/system.slice/cgroup.freeze && {
     test_preserve_state
 }
 
-echo OK > /testok
+echo OK >/testok
 exit 0
index eb7363fa6a2bb182998dc9b92b60763e3069eb6c..5c0680878f352c2329dce336eeb066f58ccb7ded 100755 (executable)
@@ -11,7 +11,7 @@ SERVICE_PATH="$(mktemp /etc/systemd/system/execreloadXXX.service)"
 SERVICE_NAME="${SERVICE_PATH##*/}"
 
 echo "[#1] Failing ExecReload= should not kill the service"
-cat > "$SERVICE_PATH" << EOF
+cat >"$SERVICE_PATH" <<EOF
 [Service]
 ExecStart=/bin/sleep infinity
 ExecReload=/bin/false
@@ -21,13 +21,13 @@ systemctl daemon-reload
 systemctl start $SERVICE_NAME
 systemctl status $SERVICE_NAME
 # The reload SHOULD fail but SHOULD NOT affect the service state
-! systemctl reload $SERVICE_NAME
+systemctl reload $SERVICE_NAME && { echo 'unexpected success'; exit 1; }
 systemctl status $SERVICE_NAME
 systemctl stop $SERVICE_NAME
 
 
 echo "[#2] Failing ExecReload= should not kill the service (multiple ExecReload=)"
-cat > "$SERVICE_PATH" << EOF
+cat >"$SERVICE_PATH" <<EOF
 [Service]
 ExecStart=/bin/sleep infinity
 ExecReload=/bin/true
@@ -39,12 +39,12 @@ systemctl daemon-reload
 systemctl start $SERVICE_NAME
 systemctl status $SERVICE_NAME
 # The reload SHOULD fail but SHOULD NOT affect the service state
-! systemctl reload $SERVICE_NAME
+systemctl reload $SERVICE_NAME && { echo 'unexpected success'; exit 1; }
 systemctl status $SERVICE_NAME
 systemctl stop $SERVICE_NAME
 
 echo "[#3] Failing ExecReload=- should not affect reload's exit code"
-cat > "$SERVICE_PATH" << EOF
+cat >"$SERVICE_PATH" <<EOF
 [Service]
 ExecStart=/bin/sleep infinity
 ExecReload=-/bin/false
@@ -59,6 +59,6 @@ systemctl stop $SERVICE_NAME
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 957d22031a9416a94e293901ee375845bc9482e9..7593401369eef8d07b47021bf995a407b9032646 100755 (executable)
@@ -41,6 +41,6 @@ done
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 81fa1716f14bbf749ae811a0a76ead4696dd01f0..0a43f8ba57412a0ed908f93c2c500ec72c449c49 100755 (executable)
@@ -9,7 +9,8 @@ systemd-analyze log-level debug
 systemd-analyze log-target console
 
 # test one: Restart=on-failure should restart the service
-! systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1"
+systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1" \
+    && { echo 'unexpected success'; exit 1; }
 
 for ((secs=0; secs<$MAX_SECS; secs++)); do
   [[ "$(systemctl show one.service -P NRestarts)" -le 0 ]] || break
@@ -25,7 +26,13 @@ TMP_FILE="/tmp/test-41-oneshot-restart-test"
 
 # test two: make sure StartLimitBurst correctly limits the number of restarts
 # and restarts execution of the unit from the first ExecStart=
-! systemd-run --unit=two -p StartLimitIntervalSec=120 -p StartLimitBurst=3 -p Type=oneshot -p Restart=on-failure -p ExecStart="/bin/bash -c \"printf a >>  $TMP_FILE\"" /bin/bash -c "exit 1"
+systemd-run --unit=two \
+            -p StartLimitIntervalSec=120 \
+            -p StartLimitBurst=3 \
+            -p Type=oneshot \
+            -p Restart=on-failure \
+            -p ExecStart="/bin/bash -c \"printf a >>  $TMP_FILE\"" /bin/bash -c "exit 1" \
+    && { echo 'unexpected success'; exit 1; }
 
 # wait for at least 3 restarts
 for ((secs=0; secs<$MAX_SECS; secs++)); do
@@ -44,6 +51,6 @@ fi
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 154398dd662e8a68c4c0b7823eb47403d5229515..ca13c5dec5cab036070318298af3db78e9e98300 100755 (executable)
@@ -6,16 +6,18 @@ systemd-analyze log-level debug
 systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple1' true
 test -f /run/simple1
 
-! systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false
+systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false \
+    && { echo 'unexpected success'; exit 1; }
 test -f /run/simple2
 
 systemd-run --unit=exec1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec1' sleep 1
 test -f /run/exec1
 
-! systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false'
+systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false' \
+    && { echo 'unexpected success'; exit 1; }
 test -f /run/exec2
 
-cat > /tmp/forking1.sh <<EOF
+cat >/tmp/forking1.sh <<EOF
 #!/usr/bin/env bash
 
 set -eux
@@ -31,7 +33,7 @@ chmod +x /tmp/forking1.sh
 systemd-run --unit=forking1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking1' /tmp/forking1.sh
 test -f /run/forking1
 
-cat > /tmp/forking2.sh <<EOF
+cat >/tmp/forking2.sh <<EOF
 #!/usr/bin/env bash
 
 set -eux
@@ -44,13 +46,15 @@ systemd-notify MAINPID=\$MAINPID
 EOF
 chmod +x /tmp/forking2.sh
 
-! systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh
+systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh \
+    && { echo 'unexpected success'; exit 1; }
 test -f /run/forking2
 
 systemd-run --unit=oneshot1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot1' true
 test -f /run/oneshot1
 
-! systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false
+systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false \
+    && { echo 'unexpected success'; exit 1; }
 test -f /run/oneshot2
 
 systemd-run --unit=dbus1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus1' \
@@ -58,10 +62,10 @@ systemd-run --unit=dbus1.service --wait -p StandardOutput=tty -p StandardError=t
     || :
 test -f /run/dbus1
 
-systemd-run --unit=dbus2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus2' true
+systemd-run --unit=dbus2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus2' true
 test -f /run/dbus2
 
-cat > /tmp/notify1.sh <<EOF
+cat >/tmp/notify1.sh <<EOF
 #!/usr/bin/env bash
 
 set -eux
@@ -73,17 +77,19 @@ chmod +x /tmp/notify1.sh
 systemd-run --unit=notify1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify1' /tmp/notify1.sh
 test -f /run/notify1
 
-! systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true
+systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true \
+    && { echo 'unexpected success'; exit 1; }
 test -f /run/notify2
 
 systemd-run --unit=idle1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle1' true
 test -f /run/idle1
 
-! systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false
+systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false \
+     && { echo 'unexpected success'; exit 1; }
 test -f /run/idle2
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index ec84868a21271cbc07591c636b359c286925cdb3..f3c0ca4fd223dccc9827f4557a1a28cc88f0f0b1 100755 (executable)
@@ -34,9 +34,10 @@ test -e /home/testuser/works.txt
 runas testuser systemd-run --wait --user --unit=test-protect-home-read-only \
     -p PrivateUsers=yes -p ProtectHome=read-only \
     -P bash -c '
-        test -e /home/testuser/works.txt
-        ! touch /home/testuser/blocked.txt
-    '
+        test -e /home/testuser/works.txt || exit 10
+        touch /home/testuser/blocked.txt && exit 11
+    ' \
+        && { echo 'unexpected success'; exit 1; }
 test ! -e /home/testuser/blocked.txt
 
 # Check that tmpfs hides the whole directory
@@ -57,12 +58,13 @@ runas testuser systemd-run --wait --user --unit=test-protect-home-yes \
 # namespace (no CAP_SETGID in the parent namespace to write the additional
 # mapping of the user supplied group and thus cannot change groups to an
 # unmapped group ID)
-runas testuser systemd-run --wait --user --unit=test-group-fail \
+runas testuser systemd-run --wait --user --unit=test-group-fail \
     -p PrivateUsers=yes -p Group=daemon \
-    -P true
+    -P true \
+    && { echo 'unexpected success'; exit 1; }
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 97541634d05b8a816f234f1d4e79422c8bf175cb..0badb7112591ec322c92349280fce5814e3df789 100755 (executable)
@@ -6,14 +6,14 @@ systemd-analyze log-level debug
 systemd-run -p LogNamespace=foobar echo "hello world"
 
 journalctl --namespace=foobar --sync
-journalctl --namespace=foobar > /tmp/hello-world
-journalctl /tmp/no-hello-world
+journalctl -o cat --namespace=foobar >/tmp/hello-world
+journalctl -o cat >/tmp/no-hello-world
 
-grep "hello world" /tmp/hello-world
-! grep "hello world" /tmp/no-hello-world
+grep "^hello world$" /tmp/hello-world
+grep "^hello world$" /tmp/no-hello-world && { echo 'unexpected success'; exit 1; }
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 00bbdf507e62f79b4a4c2878dacbeebfe50fe2bd..d3f0f710434f54314155e8c1e27893580ce45ce2 100755 (executable)
@@ -4,22 +4,21 @@ set -o pipefail
 
 # Check if homectl is installed, and if it isn't bail out early instead of failing
 if ! test -x /usr/bin/homectl ; then
-        echo OK > /testok
+        echo OK >/testok
         exit 0
 fi
 
 inspect() {
-        # As updating disk-size-related attributes can take some time on
-        # some filesystems, let's drop these fields before comparing the
-        # outputs to avoid unexpected fails. To see the full outputs of both
-        # homectl & userdbctl (for debugging purposes) drop the fields just
-        # before the comparison.
-        homectl inspect $1 | tee /tmp/a
-        userdbctl user $1 | tee /tmp/b
-
-        local PATTERN='/^\s*Disk (Size|Free|Floor|Ceiling):/d'
-        diff <(sed -r "$PATTERN" /tmp/a) <(sed -r "$PATTERN" /tmp/b)
-        rm /tmp/a /tmp/b
+    # As updating disk-size-related attributes can take some time on some
+    # filesystems, let's drop these fields before comparing the outputs to
+    # avoid unexpected fails. To see the full outputs of both homectl &
+    # userdbctl (for debugging purposes) drop the fields just before the
+    # comparison.
+    homectl inspect $1 | tee /tmp/a
+    userdbctl user $1 | tee /tmp/b
+
+    diff -I '/^\s*Disk (Size|Free|Floor|Ceiling):/' /tmp/{a,b}
+    rm /tmp/{a,b}
 }
 
 systemd-analyze log-level debug
@@ -66,16 +65,20 @@ inspect test-user
 PASSWORD=xEhErW0ndafV4s homectl deactivate test-user
 inspect test-user
 
-! PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
+PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
+PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
+    && { echo 'unexpected success'; exit 1; }
 PASSWORD=xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz
 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
 PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz
-! PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
+PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
+PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
+    && { echo 'unexpected success'; exit 1; }
 
 homectl remove test-user
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 8c34289c529602223d99fe854fb6d9e1232d28c7..b008f52e9521e33cd2c8988b026efa298e240fcd 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
 
 sleep infinity &
-echo $! > /leakedtestpid
+echo $! >/leakedtestpid
 wait $!
index 50034cf3d9a5e9af2c6ccfd1cfbcf60a79d21ebc..f8529083a2b23fdfcc7359ac157d218dc261063b 100755 (executable)
@@ -20,6 +20,6 @@ ps -p "$leaked_pid" && exit 42
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 03231e71b183b3f1f76fac1d1bd641ad9b98404e..ea84b1d72325d25ae214eb67651dcacebd3fb76a 100755 (executable)
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 set -ex
 
-cat > /run/systemd/system/testservice-48.target <<EOF
+cat >/run/systemd/system/testservice-48.target <<EOF
 [Unit]
 Wants=testservice-48.service
 EOF
@@ -23,7 +23,7 @@ systemctl start testservice-48.target
 # May 07 23:12:20 systemd-testsuite testsuite-48.sh[53]: ef53
 sleep 3.1
 
-cat > /run/systemd/system/testservice-48.service <<EOF
+cat >/run/systemd/system/testservice-48.service <<EOF
 [Service]
 ExecStart=/bin/sleep infinity
 EOF
@@ -39,7 +39,7 @@ systemctl daemon-reload
 
 sleep 3.1
 
-cat > /run/systemd/system/testservice-48.service <<EOF
+cat >/run/systemd/system/testservice-48.service <<EOF
 [Service]
 ExecStart=/bin/sleep infinity
 EOF
@@ -61,7 +61,7 @@ systemctl daemon-reload
 
 sleep 3.1
 
-cat > /run/systemd/system/testservice-48.target <<EOF
+cat >/run/systemd/system/testservice-48.target <<EOF
 [Unit]
 Conflicts=shutdown.target
 Wants=testservice-48.service
@@ -71,7 +71,7 @@ systemctl daemon-reload
 
 systemctl start testservice-48.target
 
-cat > /run/systemd/system/testservice-48.service <<EOF
+cat >/run/systemd/system/testservice-48.service <<EOF
 [Service]
 ExecStart=/bin/sleep infinity
 EOF
@@ -80,6 +80,6 @@ systemctl restart testservice-48.target
 
 systemctl is-active testservice-48.service
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 07bb20d99c67f5f39e77f62099bc9216e6ad85df..f92280f884bedabca0dbaeb22caf512af91f8f95 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 set -ex
 
-echo "MARKER_FIXED" > /run/testservice-49-fixed
+echo "MARKER_FIXED" >/run/testservice-49-fixed
 mkdir -p /run/inaccessible
 
 systemctl start testsuite-49-namespaced.service
@@ -11,7 +11,7 @@ set +e
 systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-fixed /run/inaccessible/testfile_fixed && exit 1
 set -e
 
-echo "MARKER_RUNTIME" > /run/testservice-49-runtime
+echo "MARKER_RUNTIME" >/run/testservice-49-runtime
 
 systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime
 
@@ -38,6 +38,6 @@ set +e
 systemctl is-active testsuite-49-non-namespaced.service && exit 1
 set -e
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index ae4e520ee0339e81cbe2c3fa3ba6ec264aa7b11e..b3c120d9a6491d9324ff478d89b0880db28b3685 100755 (executable)
@@ -207,7 +207,7 @@ grep -F "squashfs" ${image_dir}/result/c | grep -q -F -v "nosuid"
 
 # Adding a new mounts at runtime works if the unit is in the active state,
 # so use Type=notify to make sure there's no race condition in the test
-cat > /run/systemd/system/testservice-50d.service <<EOF
+cat >/run/systemd/system/testservice-50d.service <<EOF
 [Service]
 RuntimeMaxSec=300
 Type=notify
index aabc56f3481fa6885cc8c44b69921ae5c8ed519b..d145d7e33ec498628fa08d2d4758ea3b39fca54e 100755 (executable)
@@ -10,22 +10,24 @@ systemd-run -p LoadCredential=passwd:/etc/passwd \
             -p DynamicUser=1 \
             --wait \
             --pipe \
-            cat '${CREDENTIALS_DIRECTORY}/passwd' '${CREDENTIALS_DIRECTORY}/shadow' '${CREDENTIALS_DIRECTORY}/dog' > /tmp/ts54-concat
+            cat '${CREDENTIALS_DIRECTORY}/passwd' '${CREDENTIALS_DIRECTORY}/shadow' '${CREDENTIALS_DIRECTORY}/dog' >/tmp/ts54-concat
 ( cat /etc/passwd /etc/shadow && echo -n wuff ) | cmp /tmp/ts54-concat
 rm /tmp/ts54-concat
 
 # Verify that the creds are immutable
-systemd-run -p LoadCredential=passwd:/etc/passwd \
+systemd-run -p LoadCredential=passwd:/etc/passwd \
             -p DynamicUser=1 \
             --wait \
-            touch '${CREDENTIALS_DIRECTORY}/passwd'
-! systemd-run -p LoadCredential=passwd:/etc/passwd \
+            touch '${CREDENTIALS_DIRECTORY}/passwd' \
+    && { echo 'unexpected success'; exit 1; }
+systemd-run -p LoadCredential=passwd:/etc/passwd \
             -p DynamicUser=1 \
             --wait \
-            rm '${CREDENTIALS_DIRECTORY}/passwd'
+            rm '${CREDENTIALS_DIRECTORY}/passwd' \
+    && { echo 'unexpected success'; exit 1; }
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index f7896ada4274c3d53a5138b345acd121db6d66dd..d73f4b1e7ae21b76e9a5000e345c1116a61b6bf4 100755 (executable)
@@ -6,19 +6,19 @@ systemd-analyze log-level debug
 systemd-analyze log-target console
 
 # Loose checks to ensure the environment has the necessary features for systemd-oomd
-[[ -e /proc/pressure ]] || echo "no PSI" >> /skipped
+[[ -e /proc/pressure ]] || echo "no PSI" >>/skipped
 cgroup_type=$(stat -fc %T /sys/fs/cgroup/)
 if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then
-    echo "no cgroup2" >> /skipped
+    echo "no cgroup2" >>/skipped
 fi
 if [ ! -f /usr/lib/systemd/systemd-oomd ] && [ ! -f /lib/systemd/systemd-oomd ]; then
-    echo "no oomd" >> /skipped
+    echo "no oomd" >>/skipped
 fi
 [[ -e /skipped ]] && exit 0 || true
 
 rm -rf /etc/systemd/system/testsuite-55-testbloat.service.d
 
-echo "DefaultMemoryPressureDurationSec=5s" >> /etc/systemd/oomd.conf
+echo "DefaultMemoryPressureDurationSec=5s" >>/etc/systemd/oomd.conf
 
 systemctl start testsuite-55-testchill.service
 systemctl start testsuite-55-testbloat.service
@@ -47,8 +47,8 @@ if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then
     sleep 120 # wait for systemd-oomd kill cool down and elevated memory pressure to come down
 
     mkdir -p /etc/systemd/system/testsuite-55-testbloat.service.d/
-    echo "[Service]" > /etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
-    echo "ManagedOOMPreference=avoid" >> /etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
+    echo "[Service]" >/etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
+    echo "ManagedOOMPreference=avoid" >>/etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
 
     systemctl daemon-reload
     systemctl start testsuite-55-testchill.service
@@ -71,6 +71,6 @@ fi
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0
index 9de03e1dea4f73e873d77c58e08af663b47eb479..079da072015a666c9e20c90332c77a22d3c6e511 100755 (executable)
@@ -29,11 +29,13 @@ systemd-run --wait --unit=one -p ExitType=cgroup /tmp/test56-exit-cgroup.sh
 systemd-run --wait --unit=two -p ExitType=cgroup -p ExecCondition=true /tmp/test56-exit-cgroup.sh
 
 # false exec condition: systemd-run should exit immediately with status code: 1
-! systemd-run --wait --unit=three -p ExitType=cgroup -p ExecCondition=false /tmp/test56-exit-cgroup.sh
+systemd-run --wait --unit=three -p ExitType=cgroup -p ExecCondition=false /tmp/test56-exit-cgroup.sh \
+    && { echo 'unexpected success'; exit 1; }
 
 # service should exit uncleanly
 (sleep 1; systemctl kill --signal 9 four) &
-! systemd-run --wait --unit=four -p ExitType=cgroup /tmp/test56-exit-cgroup.sh
+systemd-run --wait --unit=four -p ExitType=cgroup /tmp/test56-exit-cgroup.sh \
+    && { echo 'unexpected success'; exit 1; }
 
 
 # Multiple level process tree, parent process exits quickly
@@ -55,7 +57,8 @@ systemd-run --wait --unit=five -p ExitType=cgroup /tmp/test56-exit-cgroup-parent
 
 # service should exit uncleanly
 (sleep 1; systemctl kill --signal 9 six) &
-! systemd-run --wait --unit=six -p ExitType=cgroup /tmp/test56-exit-cgroup-parentless.sh
+systemd-run --wait --unit=six -p ExitType=cgroup /tmp/test56-exit-cgroup-parentless.sh \
+    && { echo 'unexpected success'; exit 1; }
 
 
 # Multiple level process tree, parent process exits uncleanly but last process exits cleanly
@@ -85,10 +88,11 @@ EOF
 chmod +x /tmp/test56-exit-cgroup-unclean.sh
 
 # service should exit uncleanly after 1 second
-! systemd-run --wait --unit=eight -p ExitType=cgroup /tmp/test56-exit-cgroup-unclean.sh
+systemd-run --wait --unit=eight -p ExitType=cgroup /tmp/test56-exit-cgroup-unclean.sh \
+    && { echo 'unexpected success'; exit 1; }
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo OK >/testok
 
 exit 0