#1 Add CI tests using the standard test interface
Closed 5 years ago by zbyszek. Opened 6 years ago by esakaiev.
git://fedorapeople.org/~esakaiev/systemd systemd_tests  into  master

Adding systemd tests to the systemd_tests branch
esakaiev • 6 years ago  
Removing .gitignore form the master branch
esakaiev • 6 years ago  
.gitignore
file removed

tests/README.md
file added
+3
@@ -0,0 +1,3 @@

+ # About

+ 

+ This project contains code to test [systemd](https://github.com/systemd/systemd/)

tests/activate/runtest.sh
file added
+71
@@ -0,0 +1,71 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of activate

+ #   Description: Test for sactivate

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-activate.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-activate.sh /usr/bin/test-activate.sh"

+         rlRun "cp test-activate.service /etc/systemd/system/"

+ 

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "systemd activate related test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok /usr/bin/test-activate.sh /etc/systemd/system/test-activate.service"

+        rlRun "systemctl daemon-reload"

+ 

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/activate/test-activate.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test active Service

+ 

+ [Service]

+ Type=simple

+ ExecStart=/usr/bin/systemd-socket-activate  -l 2000 --inetd -a cat

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/activate/test-activate.sh
file added
+26
@@ -0,0 +1,26 @@

+ #!/bin/bash

+ set -x

+ set -e

+ set -o pipefail

+ 

+ if ! type "nc" > /dev/null; then

+     echo "Skipping test as netcat package does not exist ."

+     touch /tmp/testok

+     exit 0

+ fi

+ 

+ echo "Starting test activate socket ..."

+ 

+ systemctl stop test-activate.service

+ systemctl start test-activate.service

+ 

+ # TCP

+ test="echo hello | nc localhost 2000"

+ 

+ printf hello | nc localhost 2000 > /tmp/test-active

+ [[ $(cat /tmp/test-active) == "hello" ]]

+ 

+ touch /tmp/testok

+ 

+ systemctl stop test-activate.service

+ rm /tmp/test-active

tests/basic/runtest.sh
file added
+55
@@ -0,0 +1,55 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of basic systemd test

+ #   Description: Basic systemd setup

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Basic systemd setup"

+ 

+      	rlRun "systemctl --state=failed --no-legend --no-pager > /tmp/failed ; echo OK > /tmp/testok"

+         rlAssertNotGrep "failed" "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+          rlRun "rm /tmp/testok /tmp/failed"

+      rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/dockerfile
file added
+15
@@ -0,0 +1,15 @@

+ FROM fedora:26

+ MAINTAINER "you" your@email.here

+ ENV container docker

+ RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \

+ rm -f /lib/systemd/system/multi-user.target.wants/*;\

+ rm -f /etc/systemd/system/*.wants/*;\

+ rm -f /lib/systemd/system/local-fs.target.wants/*; \

+ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \

+ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \

+ rm -f /lib/systemd/system/basic.target.wants/*;\

+ rm -f /lib/systemd/system/anaconda.target.wants/*;

+ VOLUME [ "/sys/fs/cgroup" ]

+ CMD ["/usr/sbin/init"]

+ 

+ 

tests/dropin/a.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=A

+ Requires=b.service

+ Before=b.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/b.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=B

+ Wants=f.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/c.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=C

+ Requires=a.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/d.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=D:Cyclic

+ After=b.service

+ Before=a.service

+ Requires=a.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/e.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=E:Cyclic

+ After=b.service

+ Before=a.service

+ Wants=a.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/f.service
file added
+5
@@ -0,0 +1,5 @@

+ [Unit]

+ Description=F

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/g.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=G

+ Conflicts=e.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/h.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=H

+ Wants=g.service

+ 

+ [Service]

+ ExecStart=/bin/true

tests/dropin/runtest.sh
file added
+66
@@ -0,0 +1,66 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of dropin

+ #   Description: Test for dropins

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/test/TEST-05-RLIMITS

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+     rlAssertRpm $PACKAGE

+ 

+         # import the test scripts in the rootfs and plug them in systemd"

+         rlRun  "cp testsuite.service /etc/systemd/system/"

+         rlRun  "cp test-dropin.sh /usr/bin/"

+ 

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Resource dropin test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /usr/bin/test-dropin.sh /etc/systemd/system/testsuite.service"

+        rlRun "rm /tmp/testok"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/dropin/test-dropin.sh
file added
+274
@@ -0,0 +1,274 @@

+ #! /bin/bash

+ 

+ set -e

+ set -x

+ 

+ _clear_service () {

+         systemctl stop $1.service 2>/dev/null || :

+         rm -f  /{etc,run,usr/lib}/systemd/system/$1.service

+         rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d

+         rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}

+ }

+ 

+ clear_services () {

+         for u in $*; do

+                 _clear_service $u

+         done

+         systemctl daemon-reload

+ }

+ 

+ create_service () {

+         clear_services $1

+ 

+         cat >/etc/systemd/system/$1.service<<EOF

+ [Unit]

+ Description=$1 unit

+ 

+ [Service]

+ ExecStart=/bin/sleep 100000

+ EOF

+         mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d

+         mkdir -p /etc/systemd/system/$1.service.{wants,requires}

+         mkdir -p /run/systemd/system/$1.service.{wants,requires}

+         mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires}

+ }

+ 

+ create_services () {

+         for u in $*; do

+                 create_service $u

+         done

+ }

+ 

+ check_ok () {

+         [ $# -eq 3 ] || return

+ 

+         x="$(systemctl show --value -p $2 $1)"

+         case "$x" in

+         *$3*)      return 0 ;;

+         *)         return 1

+         esac

+ }

+ 

+ check_ko () {

+         ! check_ok "$@"

+ }

+ 

+ test_basic_dropins () {

+         echo "Testing basic dropins..."

+ 

+         echo "*** test a wants b wants c"

+         create_services a b c

+         ln -s ../b.service /etc/systemd/system/a.service.wants/

+         ln -s ../c.service /etc/systemd/system/b.service.wants/

+         check_ok a Wants b.service

+         check_ok b Wants c.service

+ 

+         echo "*** test a wants,requires b"

+         create_services a b c

+         ln -s ../b.service /etc/systemd/system/a.service.wants/

+         ln -s ../b.service /etc/systemd/system/a.service.requires/

+         check_ok a Wants b.service

+         check_ok a Requires b.service

+ 

+         echo "*** test a wants nonexistent"

+         create_service a

+         ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/

+         check_ok a Wants nonexistent.service

+         systemctl start a

+         systemctl stop  a

+ 

+         echo "*** test a requires nonexistent"

+         ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/

+         systemctl daemon-reload

+         check_ok a Requires nonexistent.service

+ 

+         # 'b' is already loaded when 'c' pulls it in via a dropin.

+         echo "*** test a,c require b"

+         create_services a b c

+         ln -sf ../b.service /etc/systemd/system/a.service.requires/

+         ln -sf ../b.service /etc/systemd/system/c.service.requires/

+         systemctl start a

+         check_ok c Requires b.service

+         systemctl stop a b

+ 

+         # 'b'  is already loaded when 'c' pulls it in via an alias dropin.

+         echo "*** test a wants alias"

+         create_services a b c

+         ln -sf c.service /etc/systemd/system/c1.service

+         ln -sf ../c.service  /etc/systemd/system/a.service.wants/

+         ln -sf ../c1.service /etc/systemd/system/b.service.wants/

+         systemctl start a

+         check_ok a Wants c.service

+         check_ok b Wants c.service

+         systemctl stop a c

+ 

+         clear_services a b c

+ }

+ 

+ test_template_dropins () {

+         echo "Testing template dropins..."

+ 

+         create_services foo bar@ yup@

+ 

+         ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service

+         check_ok foo Wants bar@1.service

+ 

+         clear_services foo bar@ yup@

+ }

+ 

+ test_alias_dropins () {

+         echo "Testing alias dropins..."

+ 

+         echo "*** test a wants b1 alias of b"

+         create_services a b

+         ln -sf b.service /etc/systemd/system/b1.service

+         ln -sf ../b1.service /etc/systemd/system/a.service.wants/

+         check_ok a Wants b.service

+         systemctl start a

+         systemctl --quiet is-active b

+         systemctl stop a b

+         rm /etc/systemd/system/b1.service

+         clear_services a b

+ 

+         # A weird behavior: the dependencies for 'a' may vary. It can be

+         # changed by loading an alias...

+         #

+         # [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore

+         # part of the names set so all its specific dropins are loaded.

+         #

+         # [2] 'a' is already loaded. 'a1' is simply only merged into 'a' so

+         # none of its dropins are loaded ('y' is missing from the deps).

+         echo "*** test 2"

+         create_services a x y

+         mkdir -p /etc/systemd/system/a1.service.wants/

+         ln -sf a.service /etc/systemd/system/a1.service

+         ln -sf ../x.service /etc/systemd/system/a.service.wants/

+         ln -sf ../y.service /etc/systemd/system/a1.service.wants/

+         check_ok a1 Wants x.service # see [1]

+         check_ok a1 Wants y.service

+         systemctl start a

+         check_ok a1 Wants x.service # see [2]

+         check_ko a1 Wants y.service

+         systemctl stop a x y

+         rm /etc/systemd/system/a1.service

+ 

+         clear_services a x y

+ }

+ 

+ test_masked_dropins () {

+         echo "Testing masked dropins..."

+ 

+         create_services a b

+ 

+         # 'b' is masked for both deps

+         echo "*** test a wants,requires b is masked"

+         ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service

+         ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service

+         check_ko a Wants b.service

+         check_ko a Requires b.service

+ 

+         # 'a' wants 'b' and 'b' is masked at a lower level

+         echo "*** test a wants b, mask override"

+         ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service

+         ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service

+         check_ok a Wants b.service

+ 

+         # 'a' wants 'b' and 'b' is masked at a higher level

+         echo "*** test a wants b, mask"

+         ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service

+         ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service

+         check_ko a Wants b.service

+ 

+         # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep

+         echo "*** test a wants b, b1, and one is masked"

+         create_services a b

+         ln -sf b.service /etc/systemd/system/b1.service

+         ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service

+         ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service

+         systemctl cat a

+         systemctl show -p Wants,Requires a

+         systemctl cat b1

+         systemctl show -p Wants,Requires b1

+         check_ok a Wants b.service

+         check_ko a Wants b1.service # the alias does not show up in the list of units

+         rm /etc/systemd/system/b1.service

+ 

+         # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep

+         echo "*** test a wants b, alias dep is masked"

+         create_services a b

+         ln -sf b.service /etc/systemd/system/b1.service

+         ln -sf /dev/null /etc/systemd/system/a.service.wants/b1.service

+         ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service

+         check_ok a Wants b.service

+         check_ko a Wants b1.service # the alias does not show up in the list of units

+         rm /etc/systemd/system/b1.service

+ 

+         # 'a' has Wants=b.service but also has a masking

+         # dropin 'b': 'b' should still be pulled in.

+         echo "*** test a wants b both ways"

+         create_services a b

+         ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service

+         cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF

+ [Unit]

+ Wants=b.service

+ EOF

+         check_ok a Wants b.service

+ 

+         # mask a dropin that points to an nonexistent unit.

+         echo "*** test a wants nonexistent is masked"

+         create_services a

+         ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service

+         ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/

+         check_ko a Requires nonexistent.service

+ 

+         # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is

+         # masked at a higher level.

+         echo "*** test a wants b is masked"

+         create_services a b c

+         ln -sf ../b.service /etc/systemd/system/a.service.requires/

+         ln -sf ../b.service /run/systemd/system/c.service.requires/

+         ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service

+         systemctl start a

+         check_ko c Requires b.service

+         systemctl stop a b

+ 

+         # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is

+         # masked at a lower level.

+         echo "*** test a requires b is masked"

+         create_services a b c

+         ln -sf ../b.service /etc/systemd/system/a.service.requires/

+         ln -sf ../b.service /etc/systemd/system/c.service.requires/

+         ln -sf /dev/null /run/systemd/system/c.service.requires/b.service

+         systemctl start a

+         check_ok c Requires b.service

+         systemctl stop a b

+ 

+         # 'a' requires 2 aliases of 'b' and one of them is a mask.

+         echo "*** test a requires alias of b, other alias masked"

+         create_services a b

+         ln -sf b.service /etc/systemd/system/b1.service

+         ln -sf b.service /etc/systemd/system/b2.service

+         ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.service

+         ln -sf ../b1.service /run/systemd/system/a.service.requires/

+         ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/

+         check_ok a Requires b

+ 

+         # Same as above but now 'b' is masked.

+         echo "*** test a requires alias of b, b dep masked"

+         create_services a b

+         ln -sf b.service /etc/systemd/system/b1.service

+         ln -sf b.service /etc/systemd/system/b2.service

+         ln -sf ../b1.service /run/systemd/system/a.service.requires/

+         ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/

+         ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service

+         check_ok a Requires b

+ 

+         clear_services a b

+ }

+ 

+ test_basic_dropins

+ test_template_dropins

+ test_alias_dropins

+ test_masked_dropins

+ 

+ touch /tmp/testok

tests/dropin/testsuite.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-dropin.sh

+ Type=oneshot

tests/execute/exec-capabilityambientset-merge-nfsnobody.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test for AmbientCapabilities

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(grep "CapAmb:" /proc/self/status); test "$$c" = "CapAmb:	0000000000003000"'

+ Type=oneshot

+ User=nfsnobody

+ AmbientCapabilities=CAP_NET_ADMIN

+ AmbientCapabilities=CAP_NET_RAW

tests/execute/exec-capabilityambientset-merge.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test for AmbientCapabilities

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(grep "CapAmb:" /proc/self/status); test "$$c" = "CapAmb:	0000000000003000"'

+ Type=oneshot

+ User=nobody

+ AmbientCapabilities=CAP_NET_ADMIN

+ AmbientCapabilities=CAP_NET_RAW

tests/execute/exec-capabilityambientset-nfsnobody.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for AmbientCapabilities

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(grep "CapAmb:" /proc/self/status); test "$$c" = "CapAmb:	0000000000003000"'

+ Type=oneshot

+ User=nfsnobody

+ AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW

tests/execute/exec-capabilityambientset.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for AmbientCapabilities

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(grep "CapAmb:" /proc/self/status); test "$$c" = "CapAmb:	0000000000003000"'

+ Type=oneshot

+ User=nobody

+ AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW

tests/execute/exec-capabilityboundingset-invert.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for CapabilityBoundingSet

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(capsh --print | grep "^Bounding set .*cap_chown"); test -z "$$c"'

+ Type=oneshot

+ CapabilityBoundingSet=~CAP_CHOWN

tests/execute/exec-capabilityboundingset-merge.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for CapabilityBoundingSet

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(capsh --print | grep "Bounding set "); test "$$c" = "Bounding set =cap_chown,cap_fowner,cap_kill"'

+ Type=oneshot

+ CapabilityBoundingSet=CAP_FOWNER

+ CapabilityBoundingSet=CAP_KILL CAP_CHOWN

tests/execute/exec-capabilityboundingset-reset.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for CapabilityBoundingSet

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(capsh --print | grep "Bounding set "); test "$$c" = "Bounding set ="'

+ Type=oneshot

+ CapabilityBoundingSet=CAP_FOWNER CAP_KILL

+ CapabilityBoundingSet=

tests/execute/exec-capabilityboundingset-simple.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for CapabilityBoundingSet

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(capsh --print | grep "Bounding set "); test "$$c" = "Bounding set =cap_fowner,cap_kill"'

+ Type=oneshot

+ CapabilityBoundingSet=CAP_FOWNER CAP_KILL

tests/execute/exec-dynamicuser-fixeduser-one-supplementarygroup.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test DynamicUser with User= and SupplementaryGroups=

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "1" && test "$$(id -g)" = "1" && test "$$(id -u)" = "1"'

+ Type=oneshot

+ User=1

+ DynamicUser=yes

+ SupplementaryGroups=1

tests/execute/exec-dynamicuser-fixeduser.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test DynamicUser with User=

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "1" && test "$$(id -g)" = "1" && test "$$(id -u)" = "1"'

+ Type=oneshot

+ User=1

+ DynamicUser=yes

tests/execute/exec-dynamicuser-state-dir.service
file added
+19
@@ -0,0 +1,19 @@

+ [Unit]

+ Description=Test DynamicUser= with StateDirectory=

+ 

+ [Service]

+ ExecStart=/usr/bin/test -w /var/lib/waldo

+ ExecStart=/usr/bin/test -w /var/lib/quux/pief

+ ExecStart=/bin/touch /var/lib/waldo/yay

+ ExecStart=/bin/touch /var/lib/quux/pief/yayyay

+ ExecStart=/usr/bin/test -f /var/lib/waldo/yay

+ ExecStart=/usr/bin/test -f /var/lib/quux/pief/yayyay

+ ExecStart=/usr/bin/test -f /var/lib/private/waldo/yay

+ ExecStart=/usr/bin/test -f /var/lib/private/quux/pief/yayyay

+ 

+ # Make sure that /var/lib/private/waldo is really the only writable directory besides the obvious candidates

+ ExecStart=/bin/sh -x -c 'test $$(find / -type d -writable 2> /dev/null | egrep -v -e \'^(/var/tmp$$|/tmp$$|/proc/|/dev/mqueue$$|/dev/shm$$)\' | sort -u | tr -d '\\\\n') = /var/lib/private/quux/pief/var/lib/private/waldo'

+ 

+ Type=oneshot

+ DynamicUser=yes

+ StateDirectory=waldo quux/pief

tests/execute/exec-dynamicuser-supplementarygroups.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test DynamicUser with SupplementaryGroups=

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G | cut -d " " --complement -f 1)" = "1 2 3"'

+ Type=oneshot

+ DynamicUser=yes

+ SupplementaryGroups=1 2 3

tests/execute/exec-environment-empty.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for Environment

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$${VAR1-unset}" = "unset" && test "$${VAR2-unset}" = "unset" && test "$${VAR3-unset}" = "unset"'

+ Type=oneshot

+ Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"

+ Environment=

tests/execute/exec-environment-multiple.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for Environment

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = foobar'

+ Type=oneshot

+ Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"

+ Environment="VAR3=foobar"

tests/execute/exec-environment.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Environment

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6"'

+ Type=oneshot

+ Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"

tests/execute/exec-environmentfile.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for EnvironmentFile

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "$$word 5 6"'

+ Type=oneshot

+ EnvironmentFile=/tmp/test-exec_environmentfile.conf

tests/execute/exec-group-nfsnobody.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Group

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -n -g)" = "nfsnobody"'

+ Type=oneshot

+ Group=nfsnobody

tests/execute/exec-group.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Group

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -n -g)" = "nobody"'

+ Type=oneshot

+ Group=nobody

tests/execute/exec-ignoresigpipe-no.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for IgnoreSIGPIPE=no

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'kill -PIPE 0'

+ Type=oneshot

+ IgnoreSIGPIPE=no

tests/execute/exec-ignoresigpipe-yes.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for IgnoreSIGPIPE=yes

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'kill -PIPE 0'

+ Type=oneshot

+ IgnoreSIGPIPE=yes

tests/execute/exec-inaccessiblepaths-mount-propagation.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test to make sure that InaccessiblePaths= disconnect mount propagation

+ 

+ [Service]

+ InaccessiblePaths=-/i-dont-exist

+ ExecStart=/bin/sh -x -c 'd=$$(mktemp -d -p /tmp); trap "umount \'$$d\' && rmdir \'$$d\'" EXIT; mount -t tmpfs tmpfs "$$d"; grep "$$d" /proc/self/mountinfo && ! grep "$$d" /proc/$${PPID}/mountinfo && ! grep "$$d" /proc/1/mountinfo'

+ Type=oneshot

tests/execute/exec-inaccessiblepaths-proc.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test to make sure that mount namespace setup works properly with the 'InaccessiblePaths=/proc' option

+ 

+ [Service]

+ InaccessiblePaths=/proc

+ ExecStart=/bin/sh -x -c 'test "$$(stat -c %%a /proc)" = "0"'

+ Type=oneshot

tests/execute/exec-ioschedulingclass-best-effort.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for IOSchedulingClass=best-effort

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(LC_ALL=C ionice); test "$${c%%:*}" = "best-effort"'

+ Type=oneshot

+ IOSchedulingClass=best-effort

tests/execute/exec-ioschedulingclass-idle.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for IOSchedulingClass=idle

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(LC_ALL=C ionice); test "$${c%%:*}" = "idle"'

+ Type=oneshot

+ IOSchedulingClass=idle

tests/execute/exec-ioschedulingclass-none.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for IOSchedulingClass=none

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(LC_ALL=C ionice); test "$${c%%:*}" = "none"'

+ Type=oneshot

+ IOSchedulingClass=none

tests/execute/exec-ioschedulingclass-realtime.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for IOSchedulingClass=realtime

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(LC_ALL=C ionice); test "$${c%%:*}" = "realtime"'

+ Type=oneshot

+ IOSchedulingClass=realtime

tests/execute/exec-oomscoreadjust-negative.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for OOMScoreAdjust

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(cat /proc/self/oom_score_adj); test "$$c" -eq -100'

+ Type=oneshot

+ OOMScoreAdjust=-100

tests/execute/exec-oomscoreadjust-positive.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for OOMScoreAdjust

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(cat /proc/self/oom_score_adj); test "$$c" -eq 100'

+ Type=oneshot

+ OOMScoreAdjust=100

tests/execute/exec-passenvironment-absent.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PassEnvironment with variables absent from the execution environment

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$${VAR1-unset}" = "unset" && test "$${VAR2-unset}" = "unset" && test "$${VAR3-unset}" = "unset"'

+ Type=oneshot

+ PassEnvironment=VAR1 VAR2 VAR3

tests/execute/exec-passenvironment-empty.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for PassEnvironment and erasing the variable list

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$${VAR1-unset}" = "unset" && test "$${VAR2-unset}" = "unset" && test "$${VAR3-unset}" = "unset"'

+ Type=oneshot

+ PassEnvironment=VAR1 VAR2 VAR3

+ PassEnvironment=

tests/execute/exec-passenvironment-repeated.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for PassEnvironment with a variable name repeated

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6"'

+ Type=oneshot

+ PassEnvironment=VAR1 VAR2

+ PassEnvironment=VAR1 VAR3

tests/execute/exec-passenvironment.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PassEnvironment

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6"'

+ Type=oneshot

+ PassEnvironment=VAR1 VAR2 VAR3

tests/execute/exec-personality-aarch64.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Personality=aarch64

+ 

+ [Service]

+ ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "aarch64")'

+ Type=oneshot

+ Personality=aarch64

tests/execute/exec-personality-ppc64.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Personality=ppc64

+ 

+ [Service]

+ ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "ppc64")'

+ Type=oneshot

+ Personality=ppc64

tests/execute/exec-personality-ppc64le.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Personality=ppc64le

+ 

+ [Service]

+ ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "ppc64le")'

+ Type=oneshot

+ Personality=ppc64le

tests/execute/exec-personality-s390.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Personality=s390

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(uname -m); test "$$c" = "s390"'

+ Type=oneshot

+ Personality=s390

tests/execute/exec-personality-x86-64.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Personality=x86-64

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(uname -m); test "$$c" = "x86_64"'

+ Type=oneshot

+ Personality=x86-64

tests/execute/exec-personality-x86.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Personality=x86

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'c=$$(uname -m); test "$$c" = "i686"'

+ Type=oneshot

+ Personality=x86

tests/execute/exec-privatedevices-no-capability-mknod.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test CAP_MKNOD capability for PrivateDevices=no

+ 

+ [Service]

+ PrivateDevices=no

+ ExecStart=/bin/sh -x -c 'capsh --print | grep cap_mknod'

+ Type=oneshot

tests/execute/exec-privatedevices-no-capability-sys-rawio.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test CAP_SYS_RAWIO capability for PrivateDevices=no

+ 

+ [Service]

+ PrivateDevices=no

+ ExecStart=/bin/sh -x -c 'capsh --print | grep cap_sys_rawio'

+ Type=oneshot

tests/execute/exec-privatedevices-no.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PrivateDev=no

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test -c /dev/kmsg'

+ Type=oneshot

+ PrivateDevices=no

tests/execute/exec-privatedevices-yes-capability-mknod.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test CAP_MKNOD capability for PrivateDevices=yes

+ 

+ [Service]

+ PrivateDevices=yes

+ ExecStart=/bin/sh -x -c '! capsh --print | grep cap_mknod'

+ Type=oneshot

tests/execute/exec-privatedevices-yes-capability-sys-rawio.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test CAP_SYS_RAWIO capability for PrivateDevices=yes

+ 

+ [Service]

+ PrivateDevices=yes

+ ExecStart=/bin/sh -x -c '! capsh --print | grep cap_sys_rawio'

+ Type=oneshot

tests/execute/exec-privatedevices-yes.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PrivateDev=yes

+ 

+ [Service]

+ ExecStart=/bin/sh -c 'test ! -c /dev/kmsg'

+ Type=oneshot

+ PrivateDevices=yes

tests/execute/exec-privatenetwork-yes.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PrivateNetwork

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'i=$$(ip link | grep ": " | grep -v ": lo:"); test -z "$$i"'

+ Type=oneshot

+ PrivateNetwork=yes

tests/execute/exec-privatetmp-no.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PrivateTmp=no

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test -f /tmp/test-exec_privatetmp'

+ Type=oneshot

+ PrivateTmp=no

tests/execute/exec-privatetmp-yes.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for PrivateTmp=yes

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test ! -f /tmp/test-exec_privatetmp'

+ Type=oneshot

+ PrivateTmp=yes

tests/execute/exec-protectkernelmodules-no-capabilities.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test CAP_SYS_MODULE ProtectKernelModules=no

+ 

+ [Service]

+ ProtectKernelModules=no

+ ExecStart=/bin/sh -x -c 'capsh --print | grep cap_sys_module'

+ Type=oneshot

tests/execute/exec-protectkernelmodules-yes-capabilities.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test CAP_SYS_MODULE for ProtectKernelModules=yes

+ 

+ [Service]

+ ProtectKernelModules=yes

+ ExecStart=/bin/sh -x -c '! capsh --print | grep cap_sys_module'

+ Type=oneshot

tests/execute/exec-protectkernelmodules-yes-mount-propagation.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test to make sure that passing ProtectKernelModules=yes disconnect mount propagation

+ 

+ [Service]

+ ProtectKernelModules=yes

+ ExecStart=/bin/sh -x -c 'd=$$(mktemp -d -p /tmp); trap "umount \'$$d\' && rmdir \'$$d\'" EXIT; mount -t tmpfs tmpfs "$$d"; grep "$$d" /proc/self/mountinfo && ! grep "$$d" /proc/$${PPID}/mountinfo && ! grep "$$d" /proc/1/mountinfo'

+ Type=oneshot

tests/execute/exec-read-only-path-succeed.service
file added
+8
@@ -0,0 +1,8 @@

+ [Service]

+ Type=oneshot

+ # This should work, as we explicitly disable the effect of ReadOnlyPaths=

+ ExecStart=+/bin/touch /tmp/thisisasimpletest

+ # This should also work, as we do not disable the effect of ReadOnlyPaths= but invert the exit code

+ ExecStart=/bin/sh -x -c '! /bin/touch /tmp/thisisasimpletest'

+ ExecStart=+/bin/rm /tmp/thisisasimpletest

+ ReadOnlyPaths=/tmp

tests/execute/exec-readonlypaths-mount-propagation.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test to make sure that passing ReadOnlyPaths= disconnect mount propagation

+ 

+ [Service]

+ ReadOnlyPaths=-/i-dont-exist

+ ExecStart=/bin/sh -x -c 'd=$$(mktemp -d -p /tmp); trap "umount \'$$d\' && rmdir \'$$d\'" EXIT; mount -t tmpfs tmpfs "$$d"; grep "$$d" /proc/self/mountinfo && ! grep "$$d" /proc/$${PPID}/mountinfo && ! grep "$$d" /proc/1/mountinfo'

+ Type=oneshot

tests/execute/exec-readonlypaths.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for ReadOnlyPaths=

+ 

+ [Service]

+ ReadOnlyPaths=/etc -/i-dont-exist /usr

+ ExecStart=/bin/sh -x -c 'test ! -w /etc && test ! -w /usr && test ! -e /i-dont-exist && test -w /var'

+ Type=oneshot

tests/execute/exec-readwritepaths-mount-propagation.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test to make sure that passing ReadWritePaths= disconnect mount propagation

+ 

+ [Service]

+ ReadWritePaths=-/i-dont-exist

+ ExecStart=/bin/sh -x -c 'd=$$(mktemp -d -p /tmp); trap "umount \'$$d\' && rmdir \'$$d\'" EXIT; mount -t tmpfs tmpfs "$$d"; grep "$$d" /proc/self/mountinfo && ! grep "$$d" /proc/$${PPID}/mountinfo && ! grep "$$d" /proc/1/mountinfo'

+ Type=oneshot

tests/execute/exec-restrict-address-families.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test RestrictAddressFamilies=~AF_INET AF_INET6

+ 

+ [Service]

+ ExecStart=/bin/sh -c '/usr/bin/nc -l 8000'

+ RestrictAddressFamilies=~AF_INET AF_INET6

+ Type=simple

tests/execute/exec-restrict-namespaces-mnt-blacklist.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test RestrictNamespaces=~mnt

+ 

+ [Service]

+ RestrictNamespaces=~mnt

+ ExecStart=/bin/sh -x -c 'unshare -m'

+ Type=oneshot

tests/execute/exec-restrict-namespaces-mnt.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test RestrictNamespaces=mnt

+ 

+ [Service]

+ RestrictNamespaces=mnt

+ ExecStart=/bin/sh -x -c 'unshare -m'

+ Type=oneshot

tests/execute/exec-restrict-namespaces-no.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test RestrictNamespaces=no

+ 

+ [Service]

+ RestrictNamespaces=no

+ ExecStart=/bin/sh -x -c 'unshare -m -u -i -n -p -f'

+ Type=oneshot

tests/execute/exec-restrict-namespaces-yes.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test RestrictNamespaces=yes

+ 

+ [Service]

+ RestrictNamespaces=yes

+ ExecStart=/bin/sh -x -c 'unshare -m'

+ Type=oneshot

tests/execute/exec-restrict-realtime.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for RestrictRealtime

+ 

+ [Service]

+ ExecStart=/usr/bin/chrt --rr 99 /bin/true

+ Type=oneshot

+ RestrictRealtime=true

tests/execute/exec-runtimedirectory-mode.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for RuntimeDirectoryMode

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'mode=$$(stat -c %%a /run/test-exec_runtimedirectory-mode); test "$$mode" = "750"'

+ Type=oneshot

+ RuntimeDirectory=test-exec_runtimedirectory-mode

+ RuntimeDirectoryMode=0750

tests/execute/exec-runtimedirectory-owner-nfsnobody.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test for RuntimeDirectory owner (must not be the default group of the user if Group is set)

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G /run/test-exec_runtimedirectory-owner); test "$$group" = "nfsnobody"'

+ Type=oneshot

+ Group=nfsnobody

+ User=root

+ RuntimeDirectory=test-exec_runtimedirectory-owner

tests/execute/exec-runtimedirectory-owner.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test for RuntimeDirectory owner (must not be the default group of the user if Group is set)

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G /run/test-exec_runtimedirectory-owner); test "$$group" = "nobody"'

+ Type=oneshot

+ Group=nobody

+ User=root

+ RuntimeDirectory=test-exec_runtimedirectory-owner

tests/execute/exec-runtimedirectory.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for RuntimeDirectory

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test -d /run/test-exec_runtimedirectory'

+ Type=oneshot

+ RuntimeDirectory=test-exec_runtimedirectory

tests/execute/exec-spec-interpolation.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=https://github.com/systemd/systemd/issues/2637

+ 

+ [Service]

+ Type=oneshot

+ ExecStart=/bin/sh -x -c "perl -e 'exit(!(qq{%%U} eq qq{\\x25U}))'"

tests/execute/exec-stdin-data.service
file added
+19
@@ -0,0 +1,19 @@

+ [Unit]

+ Description=Test for StandardInputText= and StandardInputData=

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'd=$$(mktemp -d -p /tmp); echo -e "this is a test\nand this is more\nsomething encoded!\nsomething   in multiple lines\nand some more\nand a more bas64 data\nsomething with strange\nembedded\tcharacters\nand something with a exec-stdin-data.service specifier" > $d/text ; cmp $d/text ; rm -rf $d'

+ Type=oneshot

+ StandardInput=data

+ StandardInputText=this is a test

+ StandardInputText=and this is more

+ StandardInputData=c29tZXRoaW5nIGVuY29kZWQhCg==

+ StandardInputText=something \

+  in multiple lines

+ StandardInputText=\

+ and some more

+ StandardInputData=YW5kIGEgbW9y \

+     ZSBiYXM2NCBk\

+ YXRhCg==

+ StandardInputText=something with strange\nembedded\tcharacters

+ StandardInputText=and something with a %n specifier

tests/execute/exec-stdio-file.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for StandardInput=file:

+ 

+ [Service]

+ ExecStart=/usr/bin/cmp /usr/bin/cmp

+ Type=oneshot

+ StandardInput=file:/usr/bin/cmp

tests/execute/exec-supplementarygroups-multiple-groups-default-group-user.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Supplementary Group with multiple groups without Group and User

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "0 1 2 3" && test "$$(id -g)" = "0" && test "$$(id -u)" = "0"'

+ Type=oneshot

+ SupplementaryGroups=1 2 3

tests/execute/exec-supplementarygroups-multiple-groups-withgid.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for Supplementary Group with multiple groups and Group=1

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "1 2 3" && test "$$(id -g)" = "1" && test "$$(id -u)" = "0"'

+ Type=oneshot

+ Group=1

+ SupplementaryGroups=1 2 3

tests/execute/exec-supplementarygroups-multiple-groups-withuid.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for Supplementary Group with multiple groups and Uid=1

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "1 2 3" && test "$$(id -g)" = "1" && test "$$(id -u)" = "1"'

+ Type=oneshot

+ User=1

+ SupplementaryGroups=1 2 3

tests/execute/exec-supplementarygroups-single-group-user.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test for Supplementary Group with only one group and uid 1

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "1" && test "$$(id -g)" = "1" && test "$$(id -u)" = "1"'

+ Type=oneshot

+ User=1

+ Group=1

+ SupplementaryGroups=1

tests/execute/exec-supplementarygroups-single-group.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for Supplementary Group with only one group

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "1" && test "$$(id -g)" = "1" && test "$$(id -u)" = "0"'

+ Type=oneshot

+ Group=1

+ SupplementaryGroups=1

tests/execute/exec-supplementarygroups.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for Supplementary Group

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$(id -G)" = "0 1"'

+ Type=oneshot

+ SupplementaryGroups=1

tests/execute/exec-systemcallerrornumber.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for SystemCallErrorNumber

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'uname -a'

+ Type=oneshot

+ SystemCallFilter=~uname

+ SystemCallErrorNumber=EACCES

tests/execute/exec-systemcallfilter-failing.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test for SystemCallFilter

+ 

+ [Service]

+ ExecStart=/bin/echo "This should not be seen"

+ Type=oneshot

+ SystemCallFilter=ioperm

+ SystemCallFilter=~ioperm

+ SystemCallFilter=ioperm

tests/execute/exec-systemcallfilter-failing2.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for SystemCallFilter

+ 

+ [Service]

+ ExecStart=/bin/echo "This should not be seen"

+ Type=oneshot

+ SystemCallFilter=~write open execve exit_group close mmap munmap fstat DONOTEXIST

tests/execute/exec-systemcallfilter-not-failing.service
file added
+10
@@ -0,0 +1,10 @@

+ [Unit]

+ Description=Test for SystemCallFilter

+ 

+ [Service]

+ ExecStart=/bin/echo "Foo bar"

+ Type=oneshot

+ SystemCallFilter=~read write open execve ioperm

+ SystemCallFilter=ioctl

+ SystemCallFilter=read write open execve

+ SystemCallFilter=~ioperm

tests/execute/exec-systemcallfilter-not-failing2.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for SystemCallFilter

+ 

+ [Service]

+ ExecStart=/bin/echo "Foo bar"

+ Type=oneshot

+ SystemCallFilter=

tests/execute/exec-systemcallfilter-system-user-nfsnobody.service
file added
+11
@@ -0,0 +1,11 @@

+ [Unit]

+ Description=Test for SystemCallFilter in system mode with User set

+ 

+ [Service]

+ ExecStart=/bin/echo "Foo bar"

+ Type=oneshot

+ User=nfsnobody

+ SystemCallFilter=~read write open execve ioperm

+ SystemCallFilter=ioctl

+ SystemCallFilter=read write open execve

+ SystemCallFilter=~ioperm

tests/execute/exec-systemcallfilter-system-user.service
file added
+11
@@ -0,0 +1,11 @@

+ [Unit]

+ Description=Test for SystemCallFilter in system mode with User set

+ 

+ [Service]

+ ExecStart=/bin/echo "Foo bar"

+ Type=oneshot

+ User=nobody

+ SystemCallFilter=~read write open execve ioperm

+ SystemCallFilter=ioctl

+ SystemCallFilter=read write open execve

+ SystemCallFilter=~ioperm

tests/execute/exec-umask-0177.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for UMask

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'touch /tmp/test-exec-umask; mode=$$(stat -c %%a /tmp/test-exec-umask); test "$$mode" = "600"'

+ Type=oneshot

+ UMask=0177

+ PrivateTmp=yes

tests/execute/exec-umask-default.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for UMask default

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'touch /tmp/test-exec-umask; mode=$$(stat -c %%a /tmp/test-exec-umask); test "$$mode" = "644"'

+ Type=oneshot

+ PrivateTmp=yes

tests/execute/exec-unset-environment.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test for UnsetEnvironment

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$FOO" = "bar" && test "$${QUUX-X}" = "X" && test "$$VAR3" = "value3" && test "$${VAR4-X}" = "X" && test "$$VAR5" = "value5" && test "$${X%b-X}" = "X"'

+ Type=oneshot

+ Environment=FOO=bar QUUX=waldo VAR3=value3 VAR4=value4 VAR5=value5 X%b=%U

+ UnsetEnvironment=QUUX=waldo VAR3=somethingelse VAR4 X%b=%U

tests/execute/exec-user-nfsnobody.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for User

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$USER" = "nfsnobody"'

+ Type=oneshot

+ User=nfsnobody

tests/execute/exec-user.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for User

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$USER" = "nobody"'

+ Type=oneshot

+ User=nobody

tests/execute/exec-workingdirectory.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Test for WorkingDirectory

+ 

+ [Service]

+ ExecStart=/bin/sh -x -c 'test "$$PWD" = "/tmp/test-exec_workingdirectory"'

+ Type=oneshot

+ WorkingDirectory=/tmp/test-exec_workingdirectory

tests/execute/runtest.sh
file added
+74
@@ -0,0 +1,74 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of systemd.exec

+ #   Description: Test for Execution environment configuration

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/src/test/test-execute.c

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+ 	rlRun  "cp *.service /etc/systemd/system/"

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-execute.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-execute.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "execute unit test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+        rlRun "rm /tmp/testok"

+        rlRun "rm /usr/bin/test-execute.sh"

+        rlRun "rm /etc/systemd/system/exec-*.service"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/execute/test-execute.sh
file added
+520
@@ -0,0 +1,520 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ result=0

+ 

+ function is_inaccessible_available() {

+     files='/run/systemd/inaccessible/reg

+            /run/systemd/inaccessible/dir

+            /run/systemd/inaccessible/chr

+            /run/systemd/inaccessible/blk

+            /run/systemd/inaccessible/fifo

+            /run/systemd/inaccessible/sock'

+ 

+     local ret='0'

+ 

+     for file in $files

+     do

+         if [ ! -r $file ]

+         then

+             ret='-1'

+             echo $ret

+         fi

+     done

+ 

+     echo $ret

+ }

+ 

+ test_exec_workingdirectory() {

+     mkdir -m 0755 -p "/tmp/test-exec_workingdirectory"

+ 

+     systemctl start exec-workingdirectory.service

+     [[ $? -eq 0 ]]

+ 

+     rm -rf "/tmp/test-exec_workingdirectory"

+ }

+ 

+ test_exec_privatedevices() {

+ 

+     if is_inaccessible_available "0"

+     then

+ 

+         systemctl start exec-privatedevices-yes.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-privatedevices-no.service

+         [[ $? -eq 0 ]]

+     fi

+ }

+ 

+ test_exec_privatedevices_capabilities() {

+ 

+     if is_inaccessible_available "0"

+     then

+ 

+         systemctl start exec-privatedevices-yes-capability-mknod.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-privatedevices-no-capability-mknod.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-privatedevices-yes-capability-sys-rawio.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-privatedevices-no-capability-sys-rawio.service

+         [[ $? -eq 0 ]]

+ 

+     fi

+ }

+ 

+ test_exec_protectkernelmodules() {

+ 

+     if is_inaccessible_available "0"

+     then

+ 

+         if [ `which capsh` != "" ]; then

+ 

+             systemctl start exec-protectkernelmodules-no-capabilities.service

+             [[ $? -eq 0 ]]

+             systemctl start exec-protectkernelmodules-yes-capabilities.service

+             [[ $? -eq 0 ]]

+             systemctl start exec-protectkernelmodules-yes-mount-propagation.service

+             [[ $? -eq 0 ]]

+ 

+         fi

+     fi

+ }

+ 

+ test_exec_readwritepaths() {

+ 

+     systemctl start exec-readwritepaths-mount-propagation.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_inaccessiblepaths() {

+ 

+     systemctl start exec-inaccessiblepaths-mount-propagation.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_inaccessiblepaths_proc() {

+ 

+     if is_inaccessible_available "0"

+     then

+ 

+         systemctl start exec-inaccessiblepaths-proc.service

+         [[ $? -eq 0 ]]

+     fi

+ }

+ 

+ test_exec_user() {

+ 

+     if grep -q "nobody" /etc/group

+     then

+ 

+         systemctl start exec-user.service

+         [[ $? -eq 0 ]]

+ 

+     elif grep -q "nfsnobody" /etc/group

+     then

+         systemctl start exec-user-nfsnobody.service

+         [[ $? -eq 0 ]]

+     else

+         echo "Skipping test_exec_user, could not find nobody/nfsnobody user"

+     fi

+ }

+ 

+ test_exec_group() {

+ 

+     if grep -q "nobody" /etc/group

+     then

+         systemctl start exec-group.service

+         [[ $? -eq 0 ]]

+ 

+     elif grep -q "nfsnobody" /etc/group

+     then

+         systemctl start exec-group-nfsnobody.service

+         [[ $? -eq 0 ]]

+ 

+     else

+         echo "Skipping test_exec_group, could not find nobody/nfsnobody group"

+     fi

+ }

+ 

+ test_exec_privatetmp() {

+     touch "/tmp/test-exec_privatetmp"

+ 

+     systemctl start exec-privatetmp-yes.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-privatetmp-no.service

+     [[ $? -eq 0 ]]

+ 

+     unlink "/tmp/test-exec_privatetmp"

+ }

+ 

+ test_exec_supplementary_groups() {

+ 

+     systemctl start exec-supplementarygroups.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-supplementarygroups-single-group.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-supplementarygroups-single-group-user.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-supplementarygroups-multiple-groups-default-group-user.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-supplementarygroups-multiple-groups-withgid.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-supplementarygroups-multiple-groups-withuid.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_environment() {

+ 

+     systemctl start exec-environment.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-environment-multiple.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-environment-empty.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_environmentfile() {

+     echo "VAR1='word1 word2'"      >  "/tmp/test-exec_environmentfile.conf"

+     echo "VAR2='word3'"            >> "/tmp/test-exec_environmentfile.conf"

+     echo "# comment1"              >> "/tmp/test-exec_environmentfile.conf"

+     echo "# comment2"              >> "/tmp/test-exec_environmentfile.conf"

+     echo "# comment3"              >> "/tmp/test-exec_environmentfile.conf"

+     echo "# line without an equal" >> "/tmp/test-exec_environmentfile.conf"

+     echo "VAR3='$word 5 6'"        >> "/tmp/test-exec_environmentfile.conf"

+ 

+     systemctl start exec-environmentfile.service

+     [[ $? -eq 0 ]]

+ 

+     unlink "/tmp/test-exec_environmentfile.conf"

+ }

+ 

+ test_exec_umask() {

+ 

+     systemctl start exec-umask-default.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-umask-0177.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_runtimedirectory() {

+ 

+     systemctl start exec-runtimedirectory.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-runtimedirectory-mode.service

+     [[ $? -eq 0 ]]

+ 

+     if grep -q "nobody" /etc/group

+     then

+         systemctl start exec-runtimedirectory-owner.service

+         [[ $? -eq 0 ]]

+     elif grep -q "nfsnobody" /etc/group

+     then

+         systemctl start exec-runtimedirectory-owner-nfsnobody.service

+         [[ $? -eq 0 ]]

+     else

+         echo "Skipping test_exec_runtimedirectory, could not find nobody/nfsnobody group"

+     fi

+ }

+ 

+ test_exec_capabilityboundingset() {

+ 

+     if [ `which capsh` != "" ]; then

+ 

+         systemctl start exec-capabilityboundingset-simple.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-capabilityboundingset-reset.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-capabilityboundingset-merge.service

+         [[ $? -eq 0 ]]

+ 

+         systemctl start exec-capabilityboundingset-invert.service

+         [[ $? -eq 0 ]]

+ 

+     fi

+ }

+ 

+ test_exec_privatenetwork() {

+ 

+     if [ `which ip` != "" ]; then

+ 

+         systemctl start exec-privatenetwork-yes.service

+         [[ $? -eq 0 ]]

+     fi

+ }

+ 

+ test_exec_oomscoreadjust() {

+ 

+     systemctl start exec-oomscoreadjust-positive.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-oomscoreadjust-negative.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_ioschedulingclass() {

+ 

+     systemctl start exec-ioschedulingclass-none.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-ioschedulingclass-idle.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-ioschedulingclass-realtime.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-ioschedulingclass-best-effort.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_spec_interpolation() {

+ 

+     systemctl start exec-spec-interpolation.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_read_only_path_suceed() {

+ 

+     systemctl start exec-read-only-path-succeed.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_restrict_realtime_fail() {

+ 

+     set +e

+ 

+     systemctl start exec-restrict-realtime.service > /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-restrict-realtime.service failed."

+         result=1

+     else

+         rlLogDebug "exec-restrict-realtime.service passed."

+     fi

+ 

+     set -e

+ }

+ 

+ test_exec_restrict_namespaces() {

+ 

+     systemctl start exec-restrict-namespaces-no.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-restrict-namespaces-mnt.service

+     [[ $? -eq 0 ]]

+ 

+     set +e

+ 

+     systemctl start exec-restrict-namespaces-yes.service > /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-restrict-namespaces-yes.service failed."

+         result=1

+     else

+         rlLogDebug "exec-restrict-namespaces-yes.service passed."

+     fi

+ 

+     systemctl start exec-restrict-namespaces-mnt-blacklist.service > /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-restrict-namespaces-mnt-blacklist.service failed."

+         result=1

+     else

+         rlLogDebug "exec-restrict-namespaces-mnt-blacklist.service passed."

+     fi

+ 

+     set -e

+ }

+ 

+ test_exec_systemcallerrornumber() {

+ 

+     set +e

+ 

+     systemctl start exec-systemcallerrornumber.service > /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-systemcallerrornumber.service failed."

+         result=1

+     else

+         rlLogDebug "exec-systemcallerrornumber.service passed."

+     fi

+ 

+     set -e

+ }

+ 

+ test_exec_systemcallfilter() {

+ 

+     set +e

+ 

+     systemctl start exec-systemcallfilter-not-failing.service

+ 

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-systemcallfilter-not-failing2.service

+ 

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-systemcallfilter-failing.service > /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-systemcallfilter-failing.service failed."

+         result=1

+     else

+         rlLogDebug "exec-systemcallfilter-failing.service passed."

+     fi

+ 

+     systemctl start exec-systemcallfilter-failing2.service > /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-systemcallfilter-failing2.service failed."

+         result=1

+     else

+         rlLogDebug "exec-systemcallfilter-failing2.service passed."

+     fi

+ 

+     set -e

+ }

+ 

+ 

+ test_exec_restrict_address_families() {

+ 

+     set +e

+ 

+     systemctl start exec-restrict-address-families.service

+ 

+     sleep 1

+ 

+     systemctl status exec-restrict-address-families.service #> /dev/null 2>&1

+ 

+     if [ $? -eq 0 ]

+     then

+         rlLogError "exec-restrict-address-families.service failed."

+         result=1

+     else

+         rlLogDebug "exec-restrict-address-families.service passed."

+     fi

+ 

+     set -e

+ }

+ 

+ test_exec_personality() {

+ 

+     arch=$(uname --hardware-platform)

+     byte_order=$(echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6)

+ 

+     if [ $(arch) == "x86_64" ]

+     then

+         systemctl start exec-personality-x86-64.service

+     elif [ $(arch) == "s390" ]

+     then

+         systemctl start exec-personality-s390.service

+     elif [ $(arch) == "powerpc64" ]

+     then

+         # little endian

+         if [ $(byte_order) == "1" ]

+         then

+             systemctl start exec-personality-ppc64.service

+         else

+             systemctl start exec-personality-ppc64le.service

+         fi

+     elif [ $(arch) == "aarch64" ]

+     then

+         systemctl start exec-personality-aarch64.service

+     elif [ $(arch) == "i386" ]

+     then

+         systemctl start exec-personality-x86.service

+     fi

+ }

+ 

+ test_exec_dynamic_user() {

+     systemctl start exec-dynamicuser-fixeduser.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-dynamicuser-fixeduser-one-supplementarygroup.service

+     [[ $? -eq 0 ]]

+ 

+     systemctl start exec-dynamicuser-supplementarygroups.service

+     [[ $? -eq 0 ]]

+ 

+   #  systemctl start exec-dynamicuser-state-dir.service

+   #  [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_unset_environment() {

+     systemctl start exec-unset-environment.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_stdin_data() {

+     systemctl start exec-stdin-data.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_stdio_file() {

+     systemctl start exec-stdio-file.service

+     [[ $? -eq 0 ]]

+ }

+ 

+ test_exec_dynamic_user

+ test_exec_workingdirectory

+ test_exec_privatedevices

+ test_exec_privatedevices_capabilities

+ test_exec_protectkernelmodules

+ test_exec_readwritepaths

+ test_exec_inaccessiblepaths

+ test_exec_user

+ test_exec_group

+ test_exec_privatetmp

+ test_exec_supplementary_groups

+ test_exec_environment

+ test_exec_environmentfile

+ test_exec_umask

+ test_exec_runtimedirectory

+ test_exec_capabilityboundingset

+ test_exec_privatenetwork

+ test_exec_oomscoreadjust

+ test_exec_ioschedulingclass

+ test_exec_spec_interpolation

+ test_exec_read_only_path_suceed

+ test_exec_restrict_realtime_fail

+ test_exec_restrict_namespaces

+ test_exec_systemcallerrornumber

+ test_exec_systemcallfilter

+ test_exec_restrict_address_families

+ test_exec_personality

+ #test_exec_unset_environment

+ #test_exec_stdin_data

+ #test_exec_stdio_file

+ 

+ if [ $result -eq 0 ]

+ then

+     touch /tmp/testok

+ fi

tests/hostnamectl/runtest.sh
file added
+62
@@ -0,0 +1,62 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/systemd/Sanity/hostnamectl

+ #   Description: Test for hostnamectl

+ #   Author: Branislav Blaskovic <bblaskov@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2015 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/wily/systemd/wily/view/head:/debian/tests/hostnamed

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlRun "ORIG_HOST=`cat /etc/hostname`"

+         rlRun -s "hostnamectl"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlLog "status test"

+         rlAssertGrep "Static hostname: $ORIG_HOST" "$rlRun_LOG"

+ 

+         rlLog "set-hostname test"

+         rlRun "hostnamectl set-hostname testhostname"

+         rlAssertGrep "testhostname" "/etc/hostname"

+         rlRun -s "hostnamectl"

+         rlAssertGrep "Static hostname: testhostname" "$rlRun_LOG"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "hostnamectl set-hostname $ORIG_HOST"

+         rlRun -s "hostnamectl"

+         rlAssertGrep "Static hostname: $ORIG_HOST" "$rlRun_LOG"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/issue-1981/runtest.sh
file added
+69
@@ -0,0 +1,69 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of https://github.com/systemd/systemd/issues/1981

+ #   Description: Test for timer segfault

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/test/TEST-07-ISSUE-1981

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-segfault.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-segfault.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Timer segfault test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+        rlRun "rm /tmp/testok /usr/bin/test-segfault.sh"

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/issue-1981/test-segfault.sh
file added
+36
@@ -0,0 +1,36 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ 

+ >/tmp/failed

+ 

+ cat <<'EOL' >/lib/systemd/system/my.service

+ [Service]

+ Type=oneshot

+ ExecStart=/bin/echo Timer runs me

+ EOL

+ 

+ cat <<'EOL' >/lib/systemd/system/my.timer

+ [Timer]

+ OnBootSec=10s

+ OnUnitInactiveSec=1h

+ EOL

+ 

+ systemctl unmask my.timer

+ 

+ systemctl start my.timer

+ 

+ mkdir -p /etc/systemd/system/my.timer.d/

+ cat <<'EOL' >/etc/systemd/system/my.timer.d/override.conf

+ [Timer]

+ OnBootSec=10s

+ OnUnitInactiveSec=1h

+ EOL

+ 

+ systemctl daemon-reload

+ 

+ systemctl mask my.timer

+ 

+ touch /tmp/testok

+ rm /tmp/failed

tests/issue-2467/runtest.sh
file added
+84
@@ -0,0 +1,84 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of https://github.com/systemd/systemd/issues/2467

+ #   Description: Don't start services every few ms if condition fails

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/test/TEST-07-ISSUE-2467

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+           # setup the testsuite service

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ Type=oneshot

+ ExecStart=/bin/sh -e -x -c 'rm -f /tmp/nonexistent; systemctl start test.socket; echo a | nc -U /run/test.ctl; >/tmp/testok'

+ TimeoutStartSec=10s

+ EOF"

+ 

+        rlRun -s "cat  >/etc/systemd/system/test.socket <<'EOF'

+ [Socket]

+ ListenStream=/run/test.ctl

+ EOF"

+ 

+         rlRun -s "cat > /etc/systemd/system/test.service <<'EOF'

+ [Unit]

+ Requires=test.socket

+ ConditionPathExistsGlob=/tmp/nonexistent

+ 

+ [Service]

+ ExecStart=/bin/true

+ EOF"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Don't start services every few ms if condition fails "

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service" 1

+         rlAssertNotExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+        rlRun "rm /etc/systemd/system/testsuite.service"

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/issue-3166/runtest.sh
file added
+96
@@ -0,0 +1,96 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of https://github.com/systemd/systemd/issues/3166

+ #   Description: Service doesn't enter the "failed" state

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/issues/3166

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         # setup the testsuite service

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/test-fail-on-restart.sh

+ Type=oneshot

+ EOF"

+ 

+         rlRun -s "cat >/etc/systemd/system/fail-on-restart.service <<EOF

+ [Unit]

+ Description=Fail on restart

+ 

+ [Service]

+ Type=simple

+ ExecStart=/bin/false

+ Restart=always

+ EOF"

+ 

+ 

+         rlRun -s "cat >/usr/bin/test-fail-on-restart.sh <<'EOF'

+ #!/bin/bash -x

+ 

+ systemctl start fail-on-restart.service

+ active_state=$(systemctl show --property ActiveState fail-on-restart.service)

+ while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do

+     sleep 1

+     active_state=$(systemctl show --property ActiveState fail-on-restart.service)

+ done

+ systemctl is-failed fail-on-restart.service || exit 1

+ touch /tmp/oktestok

+ EOF"

+ 

+         rlRun "chmod 0755 /usr/bin/test-fail-on-restart.sh"

+ 

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Service doesn't enter the failed state"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service" 1

+         rlAssertNotExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+        rlRun "rm /etc/systemd/system/testsuite.service /usr/bin/test-fail-on-restart.sh /etc/systemd/system/fail-on-restart.service"

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/jobs/hello-after-sleep.target
file added
+5
@@ -0,0 +1,5 @@

+ [Unit]

+ Description=Sleep for a minute, then say hello.

+ Wants=sleep.service hello.service

+ After=sleep.service

+ Before=hello.service

tests/jobs/hello.service
file added
+5
@@ -0,0 +1,5 @@

+ [Unit]

+ Description=Hello World

+ 

+ [Service]

+ ExecStart=/bin/echo "Hello World"

tests/jobs/runtest.sh
file added
+75
@@ -0,0 +1,75 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of jobs

+ #   Description: Test for jobs

+ #   Author: Susant Sahani<susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/test/TEST-05-JOBS

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+     rlAssertRpm $PACKAGE

+ 

+     # setup the testsuite service

+          rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-jobs.sh

+ Type=oneshot

+ EOF"

+          rlRun "cp hello.service sleep.service hello-after-sleep.target unstoppable.service /etc/systemd/system/"

+          rlRun "cp test-jobs.sh /usr/bin"

+          rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "status jobs test"

+ 

+         rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+ 

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok"

+        rlRun "rm  /etc/systemd/system/testsuite.service /etc/systemd/system/hello.service /etc/systemd/system/sleep.service "

+              "/etc/systemd/system/hello-after-sleep.target /etc/systemd/system/unstoppable.service /usr/bin/test-jobs.sh /tmp/testok"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/jobs/sleep.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Sleep for 1 minute

+ 

+ [Service]

+ Type=oneshot

+ ExecStart=/bin/sleep 60

tests/jobs/test-jobs.sh
file added
+80
@@ -0,0 +1,80 @@

+ #!/bin/bash -x

+ 

+ # Test merging of a --job-mode=ignore-dependencies job into a previously

+ # installed job.

+ 

+ systemctl start --no-block hello-after-sleep.target

+ 

+ systemctl list-jobs > /root/list-jobs.txt

+ while ! grep 'sleep\.service.*running' /root/list-jobs.txt; do

+     systemctl list-jobs > /root/list-jobs.txt

+ done

+ 

+ grep 'hello\.service.*waiting' /root/list-jobs.txt || exit 1

+ 

+ # This is supposed to finish quickly, not wait for sleep to finish.

+ START_SEC=$(date -u '+%s')

+ systemctl start --job-mode=ignore-dependencies hello

+ END_SEC=$(date -u '+%s')

+ ELAPSED=$(($END_SEC-$START_SEC))

+ 

+ [ "$ELAPSED" -lt 3 ] || exit 1

+ 

+ # sleep should still be running, hello not.

+ systemctl list-jobs > /root/list-jobs.txt

+ grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1

+ grep 'hello\.service' /root/list-jobs.txt && exit 1

+ systemctl stop sleep.service hello-after-sleep.target || exit 1

+ 

+ # Test for a crash when enqueuing a JOB_NOP when other job already exists

+ systemctl start --no-block hello-after-sleep.target || exit 1

+ # hello.service should still be waiting, so these try-restarts will collapse

+ # into NOPs.

+ systemctl try-restart --job-mode=fail hello.service || exit 1

+ systemctl try-restart hello.service || exit 1

+ systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1

+ 

+ # TODO: add more job queueing/merging tests here.

+ 

+ # Test for irreversible jobs

+ systemctl start unstoppable.service || exit 1

+ 

+ # This is expected to fail with 'job cancelled'

+ systemctl stop unstoppable.service && exit 1

+ # But this should succeed

+ systemctl stop --job-mode=replace-irreversibly unstoppable.service || exit 1

+ 

+ # We're going to shutdown soon. Let's see if it succeeds when

+ # there's an active service that tries to be unstoppable.

+ # Shutdown of the container/VM will hang if not.

+ systemctl start unstoppable.service || exit 1

+ 

+ # Test waiting for a started unit(s) to terminate again

+ 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

+ [Unit]

+ Description=Wait for 5 seconds and fail

+ [Service]

+ ExecStart=/bin/sh -ec 'sleep 5; false'

+ EOF

+ 

+ # wait2 succeeds

+ START_SEC=$(date -u '+%s')

+ systemctl start --wait wait2.service || exit 1

+ END_SEC=$(date -u '+%s')

+ ELAPSED=$(($END_SEC-$START_SEC))

+ [[ "$ELAPSED" -ge 2 ]] && [[ "$ELAPSED" -le 4 ]] || exit 1

+ 

+ # wait5fail fails, so systemctl should fail

+ START_SEC=$(date -u '+%s')

+ ! systemctl start --wait wait2.service wait5fail.service || exit 1

+ END_SEC=$(date -u '+%s')

+ ELAPSED=$(($END_SEC-$START_SEC))

+ [[ "$ELAPSED" -ge 5 ]] && [[ "$ELAPSED" -le 7 ]] || exit 1

+ 

+ touch /tmp/testok

tests/jobs/unstoppable.service
file added
+5
@@ -0,0 +1,5 @@

+ [Service]

+ Type=oneshot

+ RemainAfterExit=yes

+ ExecStart=/bin/echo "I'm unstoppable!"

+ ExecStop=/bin/systemctl start --no-block unstoppable.service

tests/journal/runtest.sh
file added
+85
@@ -0,0 +1,85 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of journald

+ #   Description: Test for journal

+ #   Author: Susant Sahani<susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/test/TEST-04-JOURNAL

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+     rlAssertRpm $PACKAGE

+ 

+         rlRun -s "cat >/etc/systemd/system/forever-print-hola.service <<EOF

+ [Unit]

+ Description=ForeverPrintHola service

+ 

+ [Service]

+ Type=simple

+ ExecStart=/bin/sh -x -c 'while :; do printf "Hola\n" || touch /i-lose-my-logs; sleep 1; done'

+ EOF"

+ 

+ rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-journal.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp -v test-journal.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "status journald test"

+ 

+ 	rlLog "starting forever-print-hola.service"

+      	rlRun "systemctl start forever-print-hola.service"

+ 

+         rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+ 

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok"

+        rlRun "rm /etc/systemd/system/forever-print-hola.service /etc/systemd/system/testsuite.service /usr/bin/test-journal.sh"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/journal/test-journal.sh
file added
+70
@@ -0,0 +1,70 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ # Test stdout stream

+ 

+ # Skip empty lines

+ ID=$(journalctl --new-id128 | sed -n 2p)

+ >/tmp/expected

+ printf $'\n\n\n' | systemd-cat -t "$ID" --level-prefix false

+ journalctl --sync

+ journalctl -b -o cat -t "$ID" >/tmp/output

+ cmp /tmp/expected /tmp/output

+ 

+ ID=$(journalctl --new-id128 | sed -n 2p)

+ >/tmp/expected

+ printf $'<5>\n<6>\n<7>\n' | systemd-cat -t "$ID" --level-prefix true

+ journalctl --sync

+ journalctl -b -o cat -t "$ID" >/tmp/output

+ cmp /tmp/expected /tmp/output

+ 

+ # Remove trailing spaces

+ ID=$(journalctl --new-id128 | sed -n 2p)

+ printf "Trailing spaces\n">/tmp/expected

+ printf $'<5>Trailing spaces \t \n' | systemd-cat -t "$ID" --level-prefix true

+ journalctl --sync

+ journalctl -b -o cat -t "$ID" >/tmp/output

+ cmp /tmp/expected /tmp/output

+ 

+ ID=$(journalctl --new-id128 | sed -n 2p)

+ printf "Trailing spaces\n">/tmp/expected

+ printf $'Trailing spaces \t \n' | systemd-cat -t "$ID" --level-prefix false

+ journalctl --sync

+ journalctl -b -o cat -t "$ID" >/tmp/output

+ cmp /tmp/expected /tmp/output

+ 

+ # Don't remove leading spaces

+ ID=$(journalctl --new-id128 | sed -n 2p)

+ printf $' \t Leading spaces\n'>/tmp/expected

+ printf $'<5> \t Leading spaces\n' | systemd-cat -t "$ID" --level-prefix true

+ journalctl --sync

+ journalctl -b -o cat -t "$ID" >/tmp/output

+ cmp /tmp/expected /tmp/output

+ 

+ ID=$(journalctl --new-id128 | sed -n 2p)

+ printf $' \t Leading spaces\n'>/tmp/expected

+ printf $' \t Leading spaces\n' | systemd-cat -t "$ID" --level-prefix false

+ journalctl --sync

+ journalctl -b -o cat -t "$ID" >/tmp/output

+ cmp /tmp/expected /tmp/output

+ 

+ # Don't lose streams on restart

+ systemctl start forever-print-hola

+ sleep 3

+ systemctl restart systemd-journald

+ sleep 3

+ systemctl stop forever-print-hola

+ [[ ! -f "/i-lose-my-logs" ]]

+ 

+ # https://github.com/systemd/systemd/issues/4408

+ rm -f /i-lose-my-logs

+ systemctl start forever-print-hola

+ sleep 3

+ systemctl kill --signal=SIGKILL systemd-journald

+ sleep 3

+ [[ ! -f "/i-lose-my-logs" ]]

+ 

+ touch /tmp/testok

tests/killmode/runtest.sh
file added
+105
@@ -0,0 +1,105 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/systemd/Sanity/KillMode

+ #   Description: This test tests KillMode options for services

+ #   Author: Branislav Blaskovic <bblaskov@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2015 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ function cleanup_cgroup()

+ {

+     expect=$1

+     while read pid

+     do

+         rlRun "ps $pid" $expect

+         # cleanup

+         kill -9 $pid

+     done < /var/tmp/killmode.procs

+ }

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlRun "cp -v trapka* /usr/bin/"

+         rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+         rlRun "pushd $TmpDir"

+ 

+         rlLog "Prepare tester.service with KillMode=none"

+ # Prepare files

+ cat >/usr/lib/systemd/system/tester.service <<EOF

+ [Unit]

+ Description=tester

+ 

+ [Service]

+ ExecStart=/usr/bin/tester

+ KillMode=none

+ EOF

+ 

+         rlRun "echo '#!/bin/bash' > /usr/bin/tester"

+         rlRun "echo \"sleep 1h\" >> /usr/bin/tester"

+         rlRun "chmod +x /usr/bin/tester"

+ 

+         rlRun "systemctl daemon-reload"

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "KillMode none"

+         rlRun "systemctl start tester.service"

+         cp /sys/fs/cgroup/systemd/system.slice/tester.service/cgroup.procs /var/tmp/killmode.procs

+         rlRun "systemctl status tester.service -l"

+         rlRun "systemctl stop tester.service"

+         cleanup_cgroup 0

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "KillMode mixed"

+         rlLog "Prepare tester.service with KillMode=mixed"

+         rlRun "sed -i \"s/KillMode=none/KillMode=mixed/\" /usr/lib/systemd/system/tester.service"

+         rlRun "sed -i \"s,/usr/bin/tester,/usr/bin/trapka,\" /usr/lib/systemd/system/tester.service"

+             cat /usr/lib/systemd/system/tester.service

+         rlRun "systemctl daemon-reload"

+ 

+         rlRun "systemctl start tester.service"

+ 

+         cp /sys/fs/cgroup/systemd/system.slice/tester.service/cgroup.procs /var/tmp/killmode.procs

+         rlRun "systemctl status tester.service -l"

+         rlRun "systemctl stop tester.service"

+         rlRun -s "journalctl -u tester.service --no-pager"

+         rlAssertGrep "Main process got SIGTERM" "$rlRun_LOG"

+         rlAssertNotGrep "Sub process got SIGTERM" "$rlRun_LOG"

+         cleanup_cgroup 1

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "popd"

+         rlRun "rm /usr/lib/systemd/system/tester.service /usr/bin/tester /usr/bin/trapka /usr/bin/trapka.sub /var/tmp/killmode.procs"

+         rlRun "systemctl daemon-reload"

+         rlRun "rm -r $TmpDir" 0 "Removing tmp directory"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ rlGetTestState

tests/killmode/trapka
file added
+20
@@ -0,0 +1,20 @@

+ #!/bin/bash

+ 

+ function catchit()

+ {

+     echo 'Main process got SIGTERM'

+     exit 0

+ }

+ 

+ for i in `seq 1 5`

+ do

+     /usr/bin/trapka.sub &

+ done

+ 

+ trap "catchit" SIGTERM

+ 

+ 

+ while :

+ do

+     sleep 0.1

+ done

tests/killmode/trapka.sub
file added
+14
@@ -0,0 +1,14 @@

+ #!/bin/bash

+ 

+ function catchit()

+ {

+     echo 'Sub process got SIGTERM'

+     exit 0

+ }

+ 

+ trap "catchit" SIGTERM

+ 

+ while :

+ do

+     sleep 0.1

+ done

tests/link/runtest.sh
file added
+69
@@ -0,0 +1,69 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of systemd link

+ #   Description: Test for systemd.link — Network device configuration

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-link.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-link.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "systemd link Network device configuration"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok /usr/bin/test-link.sh /etc/systemd/system/testsuite.service"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/link/test-link.sh
file added
+67
@@ -0,0 +1,67 @@

+ #!/bin/bash

+ set -x

+ set -e

+ set -o pipefail

+ 

+ if ! type "ip" > /dev/null; then

+     echo "Skipping test as iproute package does not exist, skipping test."

+     touch /tmp/testok

+     exit 0

+ fi

+ 

+ ip link add name test99 type veth peer name test99-guest

+ ip link set dev test99 addr 00:01:02:aa:bb:cc

+ ip link set dev test99 up

+ 

+ cat >/etc/systemd/network/00-test.link <<EOF

+ 

+ [Match]

+ MACAddress=00:01:02:aa:bb:cc

+ 

+ [Link]

+ AutoNegotiation=0

+ BitsPerSecond=1000k

+ MTUBytes=1280

+ TCPSegmentationOffload=on

+ GenericSegmentationOffload=on

+ UDPSegmentationOffload=on

+ GenericReceiveOffload=on

+ EOF

+ 

+ udevadm test-builtin net_setup_link /sys/class/net/test99

+ 

+ [[ "$(cat /sys/class/net/test99/speed)" == "10000" ]]

+ [[ "$(cat /sys/class/net/test99/mtu)"   == "1280" ]]

+ 

+ [[ "$(ethtool -k test99 | grep tcp-segmentation-offload)" == "tcp-segmentation-offload: on" ]]

+ [[ "$(ethtool -k test99 | grep udp-fragmentation-offload)" == "udp-fragmentation-offload: on" ]]

+ [[ "$(ethtool -k test99 | grep generic-segmentation-offload)" == "generic-segmentation-offload: on" ]]

+ [[ "$(ethtool -k test99 | grep generic-receive-offload)" == "generic-receive-offload: on" ]]

+ 

+ ip link del test99

+ rm /etc/systemd/network/00-test.link

+ 

+ cat >/etc/systemd/network/00-test.link <<EOF

+ 

+ [Match]

+ MACAddress=00:01:02:aa:bb:cc

+ 

+ [Link]

+ MACAddress=00:01:02:aa:bb:cd

+ Alias=testalias99

+ AutoNegotiation=0

+ 

+ EOF

+ 

+ ip link add name test99 type dummy

+ ip link set dev test99 addr 00:01:02:aa:bb:cc

+ 

+ udevadm test-builtin net_setup_link /sys/class/net/test99

+ 

+ [[ "$(cat /sys/class/net/test99/ifalias)" == "testalias99" ]]

+ [[ "$(cat /sys/class/net/test99/address)" == "00:01:02:aa:bb:cd" ]]

+ 

+ ip link del test99

+ rm /etc/systemd/network/00-test.link

+ 

+ touch /tmp/testok

tests/localectl/runtest.sh
file added
+66
@@ -0,0 +1,66 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/systemd/Sanity/localectl

+ #   Description: Test for localectl

+ #   Author: Branislav Blaskovic <bblaskov@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2015 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlFileBackup "/etc/locale.conf"

+         rlFileBackup "/etc/vconsole.conf"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun -s "localectl"

+         rlAssertGrep "System Locale:" "$rlRun_LOG"

+ 

+         rlRun "localectl set-locale LANG=C LC_CTYPE=en_US.UTF-8" 0 "Set some locale"

+         rlRun -s "localectl"

+         rlAssertGrep "LANG=C" "$rlRun_LOG"

+         rlAssertGrep "LC_CTYPE=en_US.UTF-8" "$rlRun_LOG"

+ 

+         rlRun "localectl set-locale LANG=C LC_CTYPE=sk_SK.UTF-8" 0 "Set some locale"

+         rlRun -s "localectl"

+         rlAssertGrep "LC_CTYPE=sk_SK.UTF-8" "$rlRun_LOG"

+ 

+         rlRun "localectl set-x11-keymap et pc101" 0 "Set X11 default keyboard mapping"

+         rlRun -s "localectl"

+         rlAssertGrep "X11 Layout: et" "$rlRun_LOG"

+         rlAssertGrep "X11 Model: pc101" "$rlRun_LOG"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "localectl set-x11-keymap us"

+         rlFileRestore

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ rlGetTestState

tests/loginctl/runtest.sh
file added
+129
@@ -0,0 +1,129 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/systemd/Sanity/loginctl

+ #   Description: loginctl test

+ #   Author: Branislav Blaskovic <bblaskov@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2016 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ USER=systemdtester

+ SESSION_NUM=3

+ export SYSTEMD_PAGER=

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+         rlRun "chmod 600 ssh/id_rsa"

+         rlRun "useradd $USER"

+         rlRun "rsync -rav ssh/ /home/$USER/.ssh"

+         rlRun "cp -v ssh/id_rsa* $TmpDir/"

+         rlRun "chown -R ${USER}.${USER} /home/$USER/"

+         rlRun "restorecon -v -R /home/$USER"

+         rlRun "find /home/$USER"

+         rlRun "pushd $TmpDir"

+         rlServiceStart sshd

+     rlPhaseEnd

+ 

+     #

+     # BASICS

+     #

+     rlPhaseStartTest "basics"

+         rlRun "loginctl --help"

+         rlRun "loginctl"

+         for action in list-seats list-sessions list-users seat-status session-status show-seat show-session show-user user-status

+         do

+             rlRun "loginctl $action"

+         done

+     rlPhaseEnd

+ 

+     #

+     # ADVANCED - setup

+     #

+     rlPhaseStartTest "setup advanced"

+         for i in `seq 1 $SESSION_NUM`

+         do

+             ssh -i $TmpDir/id_rsa -o StrictHostKeyChecking=no $USER@localhost 'sleep 1h' &

+             sshPid=$!

+             sleep 2

+             rlRun "ps $sshPid" 0 "ssh connection for $USER is up and running"

+         done

+     rlPhaseEnd

+ 

+     #

+     # ADVANCED - testing

+     #

+     rlPhaseStartTest "advanced"

+         rlLog "list-sessions check"

+         rlRun -s "loginctl list-sessions"

+         rlAssertGrep "$USER" $rlRun_LOG

+ 

+         rlLog

+         rlLog "list-users check"

+         rlRun -s "loginctl list-users"

+         rlAssertGrep "$(id -u root) root"  $rlRun_LOG

+         rlAssertGrep "$(id -u $USER) $USER"  $rlRun_LOG

+ 

+         rlLog

+         rlLog "show-user check"

+         rlRun -s "loginctl show-user $USER"

+         rlAssertGrep "^UID=$(id -u $USER)$"  $rlRun_LOG

+         rlAssertGrep "^GID=$(id -g $USER)$"  $rlRun_LOG

+         rlAssertGrep "^Name=$USER$"  $rlRun_LOG

+ 

+         rlLog

+         rlLog "show-session check"

+         for session in $(loginctl list-sessions | grep $USER | awk '{print $1}')

+         do

+             rlRun -s "loginctl show-session $session"

+             rlAssertGrep "^Id=$session$"  $rlRun_LOG

+             rlAssertGrep "^User=$(id -u $USER)$"  $rlRun_LOG

+             rlAssertGrep "^Name=$USER$"  $rlRun_LOG

+             rlAssertGrep "^Service=sshd$"  $rlRun_LOG

+             rlAssertGrep "^Class=user$"  $rlRun_LOG

+             rlAssertGrep "^Active=yes$"  $rlRun_LOG

+             rlAssertGrep "^State=active$"  $rlRun_LOG

+         done

+     rlPhaseEnd

+ 

+     #

+     # ADVANCED - cleanup

+     #

+     rlPhaseStartTest "cleanup advanced"

+         rlRun "pkill -u $USER"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlServiceRestore sshd

+         rlRun "userdel -r $USER"

+         rlRun "popd"

+         rlRun "rm -r $TmpDir" 0 "Removing tmp directory"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/loginctl/ssh/authorized_keys
file added
+1
@@ -0,0 +1,1 @@

+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGixjcJuXWin0/yN58GW95iQpd7NR9SrwyIVqi5q9z6pauwZSIzEIgcAcfPBm6WVINt1sj0o3vhd134Kdjc/Xvrt5WaIppJTSQNdZpSoAT9Tn5BThYTrjh9DgKrwmC8biDSbBL+fnorbeo9UPXDBFRcZO+fjoT0ENXRZqDulH1gzQqe+0KIIwgo/Ks6VXAjar+OgBhrGuAnn8a6B2PGEK8jdS1oAFZChIGMoRuU/rAgI2ag3hxu44snnD7NjiIzota627l+6mk+oWXW9NoUXCcE6XJ8+lGOXEUFpjxNApGA/ZgjnA5kRVCIGupfasJNQ9AF5ksXzhB9PRfawQmLhJZ test@fedoraci.redhat.com

tests/loginctl/ssh/id_rsa
file added
+27
@@ -0,0 +1,27 @@

+ -----BEGIN RSA PRIVATE KEY-----

+ MIIEpAIBAAKCAQEAxosY3Cbl1op9P8jefBlveYkKXezUfUq8MiFaouavc+qWrsGU

+ iMxCIHAHHzwZullSDbdbI9KN74Xdd+CnY3P1767eVmiKaSU0kDXWaUqAE/U5+QU4

+ WE644fQ4Cq8JgvG4g0mwS/n56K23qPVD1wwRUXGTvn46E9BDV0Wag7pR9YM0Knvt

+ CiCMIKPyrOlVwI2q/joAYaxrgJ5/GugdjxhCvI3UtaABWQoSBjKEblP6wICNmoN4

+ cbuOLJ5w+zY4iM6LWutu5fuppPqFl1vTaFFwnBOlyfPpRjlxFBaY8TQKRgP2YI5w

+ OZEVQiBrqX2rCTUPQBeZLF84QfT0X2sEJi4SWQIDAQABAoIBABSf7n0wLUAUMt6l

+ ZzdNDR969PC84XYChXpPrLKvdBp+jBirU1rCnTvxZ0v/WkzZaoSyP22BOe1f4pnJ

+ ZJoYObwkVkRzp600iDlS3mshqhxopRURTcEerGYMkKXLeRl5Msmwpfe+iA97vFB4

+ 6gs03bewLMDlK/NS9yvhtyNn/4uZXnfZMiZ9oZwe3vMjnDp50lVg3XLcqyV9cg4/

+ 7EsbDzO16uBsYVlEf8PU02LhHR7ZiDI24T1BfVe5au+5DR3+Z1k+d1DmEshRjfdA

+ cTlTbbpJNm8t632Cxp4Zzs+92oZBdrwqykax5Z94NMbp4uMK28MurzqjsD4DjDmz

+ UWReX2ECgYEA/B4I+MaUqOJ2KL9yE51dzxr5CNAVyGSGT4Mlu0Zc+2pwJ2q+YbcA

+ DJDvdKnYa5Acaomynu1M6VJVeLy7ibqf8FPYofPT+9LAPL98dUfrkBEt55E7KWR9

+ R52r/m6Czfb1lvoVTh7wfRILZd0EqzrAG2NHtDStj4jr7+QgrU9SUbMCgYEAyZnZ

+ KJ5nLvv61ZWHhswFkBxKL66wSC4fHzWd44YfqqNyQt0b6qBQrQD4ya/bhZBne13c

+ c68L4F6xjk/G6OZqkbcjBiBHbYFxs03a1mObdYkh4WcveVw8KDnvYeXJ0Vy+d44f

+ 2PLDBtbRx4/BuwiZsqhgf9dlcU6zzO7Sy979TcMCgYBsnVvsIVEmOPoCsAerX55s

+ fQhQvaTEwloCo1N8DOI+BirvMFN4sWg6Aa7Hqexs2pcDZvMm+MCrvCbKbzS0L0x8

+ MwMfMnZfBPqAsVYjCKr5VA1ct/qu6HX4hnr0kBOWPBCtzGulTjr5Bu8WIVPDmPnu

+ UqUvg4pKTginPra9M3EZdQKBgQCcs55NaVrw9WIStKjkiR9l1eeASruxT1BXlPiG

+ CxIANA2zlWSGqlgrMY8wTiZHGmilRt79eLm1jEVdRftpuvhpDT4HG/4JS02Svth0

+ PnZvFMmmB+up3JzR875zjQajWwCds3ZjzsbzQPVMthwzAktdyG1B0a6DNVai25w0

+ Zb7kuwKBgQD7ddf3xvdvZm3Ia0m6uesu734l79dC6qgMoU3hsVd0Po+wSzhN/nzT

+ 38uAyDJyztrmtWqecuXp66bmvhdDeAN8qyJI5vAN4aMOkPMBUCYMmOF0SAfydapI

+ SOZgpo3U7DzavtCb81w8debz1AQ1H/7zU/mLfhINb2zWrsVk8TJ99w==

+ -----END RSA PRIVATE KEY-----

tests/loginctl/ssh/id_rsa.pub
file added
+1
@@ -0,0 +1,1 @@

+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGixjcJuXWin0/yN58GW95iQpd7NR9SrwyIVqi5q9z6pauwZSIzEIgcAcfPBm6WVINt1sj0o3vhd134Kdjc/Xvrt5WaIppJTSQNdZpSoAT9Tn5BThYTrjh9DgKrwmC8biDSbBL+fnorbeo9UPXDBFRcZO+fjoT0ENXRZqDulH1gzQqe+0KIIwgo/Ks6VXAjar+OgBhrGuAnn8a6B2PGEK8jdS1oAFZChIGMoRuU/rAgI2ag3hxu44snnD7NjiIzota627l+6mk+oWXW9NoUXCcE6XJ8+lGOXEUFpjxNApGA/ZgjnA5kRVCIGupfasJNQ9AF5ksXzhB9PRfawQmLhJZ test@fedoraci.redhat.com

tests/modules-load/modules-load.sh
file added
+12
@@ -0,0 +1,12 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ /usr/lib/systemd/systemd-modules-load /etc/modules-load.d/virtio-net.conf

+ modinfo virtio_net

+ 

+ [[ "$?" == "0" ]]

+ 

+ touch /tmp/testok

tests/modules-load/runtest.sh
file added
+63
@@ -0,0 +1,63 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of modules-load

+ #   Description: Test for modules-load

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+ 	rlRun  "cat >/etc/modules-load.d/virtio-net.conf <<EOF

+ virtio-net

+ EOF"

+         rlRun "cp modules-load.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "modules load related test"

+ 

+ 	rlLog "Loading Module"

+         rlRun "/usr/bin/modules-load.sh"

+         rlAssertExists "/tmp/testok"

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok"

+        rlRun "rm /etc/modules-load.d/virtio-net.conf /usr/bin/modules-load.sh"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/network/networkd-test.py
file added
+1006
The added file is too large to be shown here, see it at: tests/network/networkd-test.py
tests/network/runtest.sh
file added
+68
@@ -0,0 +1,68 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of systemd networkd

+ #   Description: Test for systemd.network — Network device configuration

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-network.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-network.sh networkd-test.py /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "systemd-networkd test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok /usr/bin/test-network.sh /usr/bin/networkd-test.py /etc/systemd/system/testsuite.service"

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/network/test-network.sh
file added
+482
@@ -0,0 +1,482 @@

+ #!/bin/bash

+ set -x

+ set -e

+ set -o pipefail

+ 

+ if ! type "ip" > /dev/null; then

+     echo "Skipping test as iproute package does not exist ."

+     touch /tmp/testok

+     exit 0

+ fi

+ 

+ # Netdev Kind test

+ # bond bridge gre gretap ip6gre	ip6tnl ip6gretap ipip ipvlan macvlan macvtap

+ # sit tap tun veth vlan vti vti6 vxlan geneve vrf vcan

+ 

+ # Test creation of netdevs does not require .network file support

+ # Create indepedent

+ 

+ # Bridge

+ cat >/etc/systemd/network/25-bridge.netdev <<EOF

+ [NetDev]

+ Name=bridge99

+ Kind=bridge

+ 

+ [Bridge]

+ HelloTimeSec=9

+ MaxAgeSec=9

+ ForwardDelaySec=9

+ AgeingTimeSec=9

+ Priority=9

+ MulticastQuerier= true

+ MulticastSnooping=true

+ STP=true

+ 

+ EOF

+ 

+ # Bond

+ cat >/etc/systemd/network/25-bond.netdev <<EOF

+ [NetDev]

+ Name=bond99

+ Kind=bond

+ 

+ [Bond]

+ Mode=802.3ad

+ TransmitHashPolicy=layer3+4

+ MIIMonitorSec=1s

+ LACPTransmitRate=fast

+ UpDelaySec=2s

+ DownDelaySec=2s

+ ResendIGMP=4

+ MinLinks=1

+ 

+ EOF

+ 

+ # Veth pair

+ cat >/etc/systemd/network/25-veth.netdev <<EOF

+ [NetDev]

+ Name=veth99

+ Kind=veth

+ 

+ [Peer]

+ Name=veth-peer

+ EOF

+ 

+ # dummy

+ cat >/etc/systemd/network/25-dummy.netdev <<EOF

+ [NetDev]

+ Name=dummy99

+ Kind=dummy

+ MACAddress=12:34:56:78:9a:bc

+ EOF

+ 

+ # VRF

+ cat >/etc/systemd/network/25-vrf.netdev <<EOF

+ [NetDev]

+ Name=vrf99

+ Kind=vrf

+ 

+ [VRF]

+ TableId=42

+ EOF

+ 

+ # Tap

+ cat >/etc/systemd/network/25-tap.netdev <<EOF

+ [NetDev]

+ Name=tap99

+ Kind=tap

+ 

+ [Tap]

+ MultiQueue=true

+ PacketInfo=true

+ EOF

+ 

+ # Tun

+ cat >/etc/systemd/network/25-tun.netdev <<EOF

+ [NetDev]

+ Name=tun99

+ Kind=tun

+ 

+ [Tun]

+ MultiQueue=true

+ PacketInfo=true

+ EOF

+ 

+ #  Virtual Can

+ cat >/etc/systemd/network/25-vcan.netdev <<EOF

+ [NetDev]

+ Name=vcan99

+ Kind=vcan

+ 

+ EOF

+ 

+ systemctl stop systemd-networkd

+ systemctl start systemd-networkd

+ 

+ sleep 3

+ 

+ [[ -L /sys/class/net/tap99 ]]

+ [[ -L /sys/class/net/tun99 ]]

+ [[ -L /sys/class/net/bridge99 ]]

+ [[ -L /sys/class/net/veth99 ]]

+ [[ -L /sys/class/net/bond99 ]]

+ [[ -L /sys/class/net/dummy99 ]]

+ [[ -L /sys/class/net/vrf99 ]]

+ [[ -L /sys/class/net/vcan99 ]]

+ 

+ 

+ # Bridge property test

+ 

+ read HelloTimeSec <  /sys/devices/virtual/net/bridge99/bridge/hello_time

+ [[ "$HelloTimeSec" == "900" ]]

+ 

+ read MaxAgeSec <  /sys/devices/virtual/net/bridge99/bridge/max_age

+ [[ "$MaxAgeSec" == "900" ]]

+ 

+ read ForwardDelaySec <  /sys/devices/virtual/net/bridge99/bridge/forward_delay

+ [[ "$ForwardDelaySec" == "900" ]]

+ 

+ read AgeingTimeSec <  /sys/devices/virtual/net/bridge99/bridge/ageing_time

+ [[ "$AgeingTimeSec" == "900" ]]

+ 

+ read Priority <  /sys/devices/virtual/net/bridge99/bridge/priority

+ [[ "$Priority" == "9" ]]

+ 

+ read MulticastQuerier <  /sys/devices/virtual/net/bridge99/bridge/multicast_querier

+ [[ "$MulticastQuerier" == "1" ]]

+ 

+ read MulticastSnooping <  /sys/devices/virtual/net/bridge99/bridge/multicast_snooping

+ [[ "$MulticastSnooping" == "1" ]]

+ 

+ read STP <  /sys/devices/virtual/net/bridge99/bridge/stp_state

+ [[ "$STP" == "1" ]]

+ 

+ 

+ # Bonding property test

+ read Mode < /sys/devices/virtual/net/bond99/bonding/mode

+ [[ "$Mode" == "802.3ad 4" ]]

+ 

+ read TransmitHashPolicy < /sys/devices/virtual/net/bond99/bonding/xmit_hash_policy

+ [[ "$TransmitHashPolicy" == "layer3+4 1" ]]

+ 

+ read MIIMonitorSec < /sys/devices/virtual/net/bond99/bonding/miimon

+ [[ "$MIIMonitorSec" == "1000" ]]

+ 

+ read LACPTransmitRate < /sys/devices/virtual/net/bond99/bonding/lacp_rate

+ [[ "$LACPTransmitRate" == "fast 1" ]]

+ 

+ read UpDelaySec < /sys/devices/virtual/net/bond99/bonding/updelay

+ [[ "$UpDelaySec" == "2000" ]]

+ 

+ read DownDelaySec < /sys/devices/virtual/net/bond99/bonding/downdelay

+ [[ "$DownDelaySec" == "2000" ]]

+ 

+ read ResendIGMP < /sys/devices/virtual/net/bond99/bonding/resend_igmp

+ [[ "$ResendIGMP" == "4" ]]

+ 

+ read MinLinks < /sys/devices/virtual/net/bond99/bonding/min_links

+ [[ "$MinLinks" == "1" ]]

+ 

+ # Tap and tun property test

+ read TapFlags < /sys/devices/virtual/net/tap99/tun_flags

+ [[ "$TapFlags" == "0x902" ]]

+ 

+ read TunFlags < /sys/devices/virtual/net/tun99/tun_flags

+ [[ "$TunFlags" == "0x901" ]]

+ 

+ ip link del bridge99

+ ip link del tap99

+ ip link del tun99

+ ip link del veth99

+ ip link del bond99

+ ip link del dummy99

+ ip link del vrf99

+ ip link del vcan99

+ 

+ rm /etc/systemd/network/25-veth.netdev

+ rm /etc/systemd/network/25-bond.netdev

+ rm /etc/systemd/network/25-dummy.netdev

+ rm /etc/systemd/network/25-vcan.netdev

+ rm /etc/systemd/network/25-vrf.netdev

+ rm /etc/systemd/network/25-bridge.netdev

+ rm /etc/systemd/network/25-tap.netdev

+ rm /etc/systemd/network/25-tun.netdev

+ 

+ # Test netdev which require a .network file support

+ 

+ # VLAN

+ cat >/etc/systemd/network/25-vlan1.netdev <<EOF

+ [NetDev]

+ Name=vlan99

+ Kind=vlan

+ 

+ [VLAN]

+ Id=99

+ EOF

+ 

+ # MacVTap

+ cat >/etc/systemd/network/25-macvtap.netdev <<EOF

+ [NetDev]

+ Name=macvtap99

+ Kind=macvtap

+ EOF

+ 

+ # MacVLan

+ cat >/etc/systemd/network/25-macvlan.netdev <<EOF

+ [NetDev]

+ Name=macvlan99

+ Kind=macvlan

+ EOF

+ 

+ # IPIP tunnel

+ cat >/etc/systemd/network/25-ipip.netdev <<EOF

+ [NetDev]

+ Name=ipiptun99

+ Kind=ipip

+ MTUBytes=1480

+ 

+ [Tunnel]

+ Local=192.168.223.238

+ Remote=192.169.224.239

+ TTL=64

+ EOF

+ 

+ # ip6tnl tunnel

+ cat >/etc/systemd/network/25-ip6tnl.netdev <<EOF

+ [NetDev]

+ Name=ip6tnl99

+ Kind=ip6tnl

+ 

+ [Tunnel]

+ Mode=ip6ip6

+ Local=2a00:ffde:4567:edde::4987

+ Remote=2001:473:fece:cafe::5179

+ 

+ EOF

+ 

+ # ip6gretap tunnel

+ cat >/etc/systemd/network/25-ip6gre.netdev <<EOF

+ [NetDev]

+ Name=ip6gretap99

+ Kind=ip6gretap

+ 

+ [Tunnel]

+ Local=2a00:ffde:4567:edde::4987

+ Remote=2001:473:fece:cafe::5179

+ 

+ EOF

+ 

+ # sit tunnel

+ cat >/etc/systemd/network/25-sit.netdev <<EOF

+ [NetDev]

+ Name=sittun99

+ Kind=sit

+ 

+ [Tunnel]

+ Local=10.65.223.238

+ Remote=10.65.223.239

+ EOF

+ 

+ # gre tunnel

+ cat >/etc/systemd/network/25-gre.netdev <<EOF

+ [NetDev]

+ Name=gretun99

+ Kind=gre

+ 

+ [Tunnel]

+ Local=10.65.223.238

+ Remote=10.65.223.239

+ EOF

+ 

+ # greptapl tunnel

+ cat >/etc/systemd/network/25-gretap.netdev <<EOF

+ [NetDev]

+ Name=gretap99

+ Kind=gretap

+ 

+ [Tunnel]

+ Local=10.65.223.238

+ Remote=10.65.223.239

+ EOF

+ 

+ # vti tunnel

+ cat >/etc/systemd/network/25-vti.netdev <<EOF

+ [NetDev]

+ Name=vtitun99

+ Kind=vti

+ 

+ [Tunnel]

+ Local=10.65.223.238

+ Remote=10.65.223.239

+ EOF

+ 

+ # vti6 tunnel

+ cat >/etc/systemd/network/25-vti6.netdev <<EOF

+ [NetDev]

+ Name=vti6tun99

+ Kind=vti6

+ 

+ [Tunnel]

+ Local=2a00:ffde:4567:edde::4987

+ Remote=2001:473:fece:cafe::5179

+ 

+ EOF

+ 

+ # VXLAN

+ cat >/etc/systemd/network/25-vxlan.netdev <<EOF

+ [NetDev]

+ Name=vxlan99

+ Kind=vxlan

+ 

+ [VXLAN]

+ Id=999

+ 

+ EOF

+ 

+ # IP Vlan

+ cat >/etc/systemd/network/25-ipvlan.netdev <<EOF

+ [NetDev]

+ Name=ipvlan99

+ Kind=ipvlan

+ 

+ [IPVLAN]

+ Mode=L2

+ EOF

+ 

+ 

+ # Create .network files

+ cat >/etc/systemd/network/test1.network <<EOF

+ [Match]

+ Name=test1

+ 

+ [Network]

+ Tunnel=ipiptun99

+ Tunnel=sittun99

+ Tunnel=gretap99

+ Tunnel=vtitun99

+ Tunnel=ip6tnl99

+ 

+ EOF

+ 

+ cat >/etc/systemd/network/test2.network <<EOF

+ [Match]

+ Name=test2

+ 

+ [Network]

+ VLAN=vlan99

+ EOF

+ 

+ cat >/etc/systemd/network/test3.network <<EOF

+ [Match]

+ Name=test3

+ 

+ [Network]

+ IPVLAN=ipvlan99

+ 

+ EOF

+ 

+ cat >/etc/systemd/network/test4.network <<EOF

+ [Match]

+ Name=test4

+ 

+ [Network]

+ MACVLAN=macvlan99

+ MACVTAP=macvtap99

+ 

+ EOF

+ 

+ cat >/etc/systemd/network/test5.network <<EOF

+ [Match]

+ Name=test5

+ 

+ [Network]

+ VXLAN=vxlan99

+ 

+ EOF

+ 

+ ip link add test1 type veth peer name peer1

+ ip link add test2 type veth peer name peer2

+ ip link add test3 type veth peer name peer3

+ ip link add test4 type veth peer name peer4

+ ip link add test5 type veth peer name peer5

+ 

+ systemctl stop systemd-networkd

+ systemctl start systemd-networkd

+ 

+ sleep 2

+ 

+ # verify all netdevs are created

+ [[ -L /sys/class/net/ipiptun99 ]]

+ [[ -L /sys/class/net/sittun99 ]]

+ [[ -L /sys/class/net/gretap99 ]]

+ [[ -L /sys/class/net/vtitun99 ]]

+ [[ -L /sys/class/net/ip6tnl99 ]]

+ [[ -L /sys/class/net/vxlan99 ]]

+ [[ -L /sys/class/net/vlan99 ]]

+ [[ -L /sys/class/net/macvtap99 ]]

+ [[ -L /sys/class/net/macvlan99 ]]

+ [[ -L /sys/class/net/ipvlan99 ]]

+ 

+ # netdev property test.

+ 

+ [[ "$(ip -d link show vlan99 | grep id |  awk '{print $5}')" == "99" ]]

+ [[ "$(ip -d link show vxlan99 | grep id | awk '{print $3}')" == "999" ]]

+ 

+ # Perform cleanup

+ # Remove netdevs

+ ip link del vlan99

+ ip link del ipiptun99

+ ip link del sittun99

+ ip link del gretap99

+ ip link del vtitun99

+ ip link del ip6tnl99

+ ip link del macvtap99

+ ip link del macvlan99

+ ip link del vxlan99

+ ip link del ipvlan99

+ 

+ # Remove confs

+ rm /etc/systemd/network/25-vlan1.netdev

+ rm /etc/systemd/network/25-ipip.netdev

+ rm /etc/systemd/network/25-ip6tnl.netdev

+ rm /etc/systemd/network/25-sit.netdev

+ rm /etc/systemd/network/25-gre.netdev

+ rm /etc/systemd/network/25-gretap.netdev

+ rm /etc/systemd/network/25-vti.netdev

+ rm /etc/systemd/network/25-vxlan.netdev

+ rm /etc/systemd/network/25-vti6.netdev

+ rm /etc/systemd/network/25-ip6gre.netdev

+ rm /etc/systemd/network/25-ipvlan.netdev

+ rm /etc/systemd/network/25-macvtap.netdev

+ rm /etc/systemd/network/25-macvlan.netdev

+ 

+ rm /etc/systemd/network/test1.network

+ rm /etc/systemd/network/test2.network

+ rm /etc/systemd/network/test3.network

+ rm /etc/systemd/network/test4.network

+ rm /etc/systemd/network/test5.network

+ 

+ ip link del test1

+ ip link del test2

+ ip link del test3

+ ip link del test4

+ ip link del test5

+ 

+ systemctl stop systemd-networkd

+ 

+ # DHCP

+ if ! type "python3" > /dev/null; then

+     echo "Skipping DHCP test as python3 package does not exist ."

+     touch /tmp/testok

+     exit 0

+ fi

+ 

+ /usr/bin/python3 /usr/bin/networkd-test.py

+ 

+ return_code=$?

+ 

+ if [ $return_code != "0" ]; then

+    exit $return_code

+ fi

+ 

+ touch /tmp/testok

tests/path/path-changed.path
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test PathChanged

+ 

+ [Path]

+ PathChanged=/tmp/test-path_changed

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/path-changed.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-directorynotempty.path
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test DirectoryNotEmpty

+ 

+ [Path]

+ DirectoryNotEmpty=/tmp/test-path_directorynotempty/

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/path-directorynotempty.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-exists.path
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test PathExists

+ 

+ [Path]

+ PathExists=/tmp/test-path_exists

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/path-exists.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-existsglob.path
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test PathExistsGlob

+ 

+ [Path]

+ PathExistsGlob=/tmp/test-path_existsglob*

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/path-existsglob.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-makedirectory.path
file added
+10
@@ -0,0 +1,10 @@

+ [Unit]

+ Description=Test MakeDirectory & DirectoryMode

+ 

+ [Path]

+ DirectoryNotEmpty=/tmp/test-path_makedirectory/

+ MakeDirectory=yes

+ DirectoryMode=0744

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/path-makedirectory.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-modified.path
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Test PathModified

+ 

+ [Path]

+ PathModified=/tmp/test-path_modified

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/path-modified.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-mycustomunit.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test Path Unit=

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-service.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Service Test for Path units

+ 

+ [Service]

+ ExecStart=/bin/true

+ Type=oneshot

tests/path/path-unit.path
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Test Path Unit=

+ 

+ [Path]

+ PathExists=/tmp/test-path_unit

+ Unit=path-mycustomunit.service

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/path/runtest.sh
file added
+73
@@ -0,0 +1,73 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of path units

+ #   Description: Test for path units

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/src/test/test-path.c

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+ 	rlRun  "cp *.path *.service /etc/systemd/system/"

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-path.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-path.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Path unit test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+        rlRun "rm /tmp/testok"

+        rlRun "rm /usr/bin/test-path.sh /etc/systemd/system/path-changed.path /etc/systemd/system/path-directorynotempty.service /etc/systemd/system/path-exists.path /etc/systemd/system/path-makedirectory.service  /etc/systemd/system/path-mycustomunit.service /etc/systemd/system/path-changed.service /etc/systemd/system/path-existsglob.path /etc/systemd/system/path-exists.service /etc/systemd/system/path-modified.path /etc/systemd/system/path-service.service /etc/systemd/system/path-directorynotempty.path /etc/systemd/system/path-existsglob.service /etc/systemd/system/path-makedirectory.path /etc/systemd/system/path-modified.service /etc/systemd/system/path-unit.path"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/path/test-path.sh
file added
+115
@@ -0,0 +1,115 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ test_path_exists() {

+     local test_path='/tmp/test-path_exists'

+ 

+     systemctl start path-exists.path

+ 

+     [[ ! -f $test_path ]]

+ 

+     systemctl stop path-exists.service path-exists.path

+ }

+ 

+ test_path_existsglob() {

+     local test_path='/tmp/test-path_existsglobFOOBAR'

+ 

+     systemctl start path-existsglob.path

+ 

+     [[ ! -f $test_path ]]

+ 

+     systemctl stop path-existsglob.service path-existsglob.path

+ }

+ 

+ test_path_changed() {

+     local test_path='/tmp/test-path_changed'

+ 

+     touch $test_path

+ 

+     systemctl start path-changed.path

+ 

+     exec 3<>$test_path

+ 

+     exec 3>&-

+ 

+     systemctl stop path-changed.service path-changed.path

+ }

+ 

+ test_path_modified() {

+     local test_path='/tmp/test-path_modified'

+ 

+     touch $test_path

+ 

+     systemctl start path-modified.path

+ 

+     exec 3<>$test_path

+ 

+     echo "test" >&3

+ 

+     exec 3>&-

+ 

+     systemctl stop path-modified.service path-modified.path

+ }

+ 

+ test_path_unit() {

+     local test_path='/tmp/test-path_unit'

+ 

+     systemctl start path-mycustomunit.service

+ 

+     [[ ! -f $test_path ]]

+ 

+     systemctl stop path-mycustomunit.service

+ }

+ 

+ test_path_directorynotempty() {

+     local test_path='/tmp/test-path_directorynotempty/'

+ 

+     [ ! -f $test_path ]

+ 

+     systemctl start  path-directorynotempty.path

+ 

+     # MakeDirectory default to no

+     [[ ! -f $test_path ]]

+ 

+     mkdir -p $test_path

+     touch "$test_path/testfile"

+ 

+     rm -rf $test_path

+ 

+     systemctl stop path-directorynotempty.path path-directorynotempty.service

+ }

+ 

+ test_path_makedirectory_directorymode() {

+     local test_path='/tmp/test-path_makedirectory/'

+     local mode='744'

+ 

+     [[ ! -d $test_path ]]

+ 

+     systemctl start path-makedirectory.path

+ 

+     # Check if the directory has been created

+     [[ -d $test_path ]]

+ 

+     # Check the mode we specified with DirectoryMode=0744

+ 

+     test_mode="$(stat -c "%a" $test_path)"

+ 

+     [[ $test_mode == $mode ]]

+ 

+     rm -rf $test_path

+ 

+     systemctl stop path-makedirectory.path path-makedirectory.service

+ }

+ 

+ test_path_exists

+ test_path_existsglob

+ test_path_changed

+ test_path_modified

+ test_path_unit

+ test_path_directorynotempty

+ test_path_makedirectory_directorymode

+ 

+ touch /tmp/testok

tests/rlimits/runtest.sh
file added
+82
@@ -0,0 +1,82 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of rlimits

+ #   Description: Test for resource limits

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/tree/master/test/TEST-05-RLIMITS

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 	rlRun  "cp /etc/systemd/system.conf /tmp/system.conf"

+ 

+ 	rlRun  "cat >/etc/systemd/system.conf <<EOF

+ [Manager]

+ DefaultLimitNOFILE=10000:16384

+ EOF"

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-rlimits.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp -v test-rlimits.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Resource limits-related test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlAssertEquals "DefaultLimitNOFILESoft=10000" "$(systemctl show -p DefaultLimitNOFILESoft)"  "DefaultLimitNOFILESoft=10000"

+        rlAssertEquals "DefaultLimitNOFILE=16384"     "$(systemctl show -p DefaultLimitNOFILE)"  "DefaultLimitNOFILE=16384"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "mv /tmp/system.conf /etc/systemd/system.conf"

+        rlRun "rm /tmp/testok"

+        rlRun "rm /usr/bin/test-rlimits.sh"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/rlimits/test-rlimits.sh
file added
+13
@@ -0,0 +1,13 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ [[ "$(systemctl show -p LimitNOFILESoft testsuite.service)" = "LimitNOFILESoft=10000" ]]

+ [[ "$(systemctl show -p LimitNOFILE testsuite.service)" = "LimitNOFILE=16384" ]]

+ 

+ [[ "$(ulimit -n -S)" = "10000" ]]

+ [[ "$(ulimit -n -H)" = "16384" ]]

+ 

+ touch /tmp/testok

tests/sched/runtest.sh
file added
+74
@@ -0,0 +1,74 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of sched-prio

+ #   Description: Test for sched-prio

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Inspiration from https://github.com/systemd/systemd/blob/master/src/test/test-sched-prio.c

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 	rlRun  "cp sched_idle_bad.service sched_idle_ok.service sched_rr_bad.service sched_rr_change.service sched_rr_ok.service /etc/systemd/system"

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-sched.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-sched.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "Resource sched-prio test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /etc/systemd/system/sched_idle_bad.service /etc/systemd/system/sched_idle_ok.service /etc/systemd/system/sched_rr_bad.service /etc/systemd/system/sched_rr_change.service /etc/systemd/system/sched_rr_ok.service /etc/systemd/system/testsuite.service"

+ 

+        rlRun "rm /tmp/testok"

+        rlRun "rm /usr/bin/test-sched.sh"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/sched/sched_idle_bad.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Bad sched priority for Idle

+ 

+ [Service]

+ ExecStart=/bin/true

+ CPUSchedulingPriority=1

tests/sched/sched_idle_ok.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Sched idle with prio 0

+ 

+ [Service]

+ ExecStart=/bin/true

+ CPUSchedulingPriority=0

tests/sched/sched_rr_bad.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=Bad sched priority for RR

+ 

+ [Service]

+ ExecStart=/bin/true

+ CPUSchedulingPolicy=rr

+ CPUSchedulingPriority=0

+ CPUSchedulingPriority=100

tests/sched/sched_rr_change.service
file added
+9
@@ -0,0 +1,9 @@

+ [Unit]

+ Description=Change prio

+ 

+ [Service]

+ ExecStart=/bin/true

+ CPUSchedulingPolicy=rr

+ CPUSchedulingPriority=1

+ CPUSchedulingPriority=2

+ CPUSchedulingPriority=99

tests/sched/sched_rr_ok.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=Default prio for RR

+ 

+ [Service]

+ ExecStart=/bin/true

+ CPUSchedulingPolicy=rr

tests/sched/test-sched.sh
file added
+22
@@ -0,0 +1,22 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ [[ "$(systemctl show -p CPUSchedulingPolicy sched_idle_ok.service)" = "CPUSchedulingPolicy=0" ]]

+ [[ "$(systemctl show -p CPUSchedulingPriority sched_idle_ok.service)" = "CPUSchedulingPriority=0" ]]

+ 

+ [[ "$(systemctl show -p CPUSchedulingPolicy sched_idle_bad.service)" = "CPUSchedulingPolicy=0" ]]

+ [[ "$(systemctl show -p CPUSchedulingPriority sched_idle_bad.service)" = "CPUSchedulingPriority=0" ]]

+ 

+ [[ "$(systemctl show -p CPUSchedulingPolicy sched_rr_ok.service)" = "CPUSchedulingPolicy=2" ]]

+ [[ "$(systemctl show -p CPUSchedulingPriority sched_rr_ok.service)" = "CPUSchedulingPriority=1" ]]

+ 

+ [[ "$(systemctl show -p CPUSchedulingPolicy sched_rr_bad.service)" = "CPUSchedulingPolicy=2" ]]

+ [[ "$(systemctl show -p CPUSchedulingPriority sched_rr_bad.service)" = "CPUSchedulingPriority=1" ]]

+ 

+ [[ "$(systemctl show -p CPUSchedulingPolicy sched_rr_change.service)" = "CPUSchedulingPolicy=2" ]]

+ [[ "$(systemctl show -p CPUSchedulingPriority sched_rr_change.service)" = "CPUSchedulingPriority=99" ]]

+ 

+ touch /tmp/testok

tests/socket/runtest.sh
file added
+71
@@ -0,0 +1,71 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of socket

+ #   Description: Test for socket

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-socket.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-socket.sh /usr/bin/test-socket.sh"

+         rlRun "cp test-protocol.service test-protocol.socket test.service test.socket /etc/systemd/system/"

+ 

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "systemd socket related test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+ 

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /tmp/testok /usr/bin/test-socket.sh /etc/systemd/system/test.socket /etc/systemd/system/test.service /etc/systemd/system/test-protocol.socket /etc/systemd/system/test-protocol.service /etc/systemd/system/testsuite.service"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/socket/test-protocol.service
file added
+13
@@ -0,0 +1,13 @@

+ [Unit]

+ Description=Test socket Service

+ Requires=test.socket

+ 

+ [Service]

+ Type=simple

+ ExecStart=/usr/bin/python /usr/bin/test-server.py

+ StandardInput=socket

+ StandardError=journal

+ TimeoutStopSec=5

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/socket/test-protocol.socket
file added
+13
@@ -0,0 +1,13 @@

+ [Unit]

+ Description=Test Socket

+ 

+ [Socket]

+ ListenStream=127.0.0.1:9998

+ SocketProtocol=sctp

+ 

+ [Socket]

+ ListenDatagram=127.0.0.1:9998

+ SocketProtocol=udplite

+ 

+ [Install]

+ WantedBy=sockets.target

tests/socket/test-server.py
file added
+10
@@ -0,0 +1,10 @@

+ #!/usr/bin/python

+ import sys

+ import logging

+ logging.basicConfig(level=logging.INFO)

+ 

+ instance = sys.argv[1]

+ 

+ data = sys.stdin.readline().strip()

+ logging.info('test-service: at instance %s, got request: %s', instance, data)

+ sys.stdout.write(data + '\r\n')

tests/socket/test-socket.sh
file added
+61
@@ -0,0 +1,61 @@

+ #!/bin/bash

+ set -x

+ set -e

+ set -o pipefail

+ 

+ if ! type "netstat" > /dev/null; then

+     echo "Skipping test as iproute package does not exist ."

+     touch /tmp/testok

+     exit 0

+ fi

+ 

+ if ! type "lsof" > /dev/null; then

+     echo "Skipping test as lsof package does not exist ."

+     touch /tmp/testok

+     exit 0

+ fi

+ 

+ echo "Starting test socket ..."

+ 

+ systemctl stop test.socket

+ systemctl stop test-protocol.socket

+ 

+ systemctl start test.socket

+ 

+ # ListenStream=

+ [[ "$(netstat -antp | grep 9999 | awk '{print $NF}')" == "1/systemd" ]]

+ 

+ # ListenDatagram=

+ [[ "$(netstat -anup | grep 9999 | awk '{print $NF}')" == "1/systemd" ]]

+ 

+ # ListenSequentialPacket= Unix domain

+ [[ "$(netstat -lxp | grep "/var/run/test.socket" | awk '{print $6}')" == "SEQPACKET" ]]

+ [[ "$(netstat -lxp | grep "/var/run/test.socket" | awk '{print $9}')" == "1/systemd" ]]

+ 

+ [[ -p /var/run/test-fifo ]]

+ 

+ systemctl start test-protocol.socket

+ 

+ # ListenStream=sctp

+ [[ "$(netstat -antp | grep 9998 | awk '{print $NF}')" == "1/systemd" ]]

+ 

+ # ListenDatagram=udplite

+ [[ "$(lsof -p 1 | grep UDPLITE | awk '{print $NF}')" == "localhost:9998" ]]

+ 

+ # BindIPv6Only=both

+ [[ "$(netstat -antp | grep 9990 | awk '{print $NF}')" == "1/systemd" ]]

+ [[ "$(netstat -antp | grep 9990 | awk '{print $4}')"  == ":::9990"   ]]

+ 

+ # SocketUser=, SocketGroup=

+ [[ "$(ls -al /var/run/test-fifo | awk '{print $3 $4}')" == "nobodynobody" ]]

+ 

+ # vsock

+ [[ "$(systemctl status test.socket | grep vsock | sed "s/^ *//")" == "vsock:2:1234 (Stream)" ]]

+ 

+ # netlink route

+ [[ "$(systemctl status test.socket | grep route |  sed "s/^ *//")" == "route 1361 (Netlink)" ]]

+ 

+ touch /tmp/testok

+ 

+ systemctl stop test.socket

+ systemctl stop test-protocol.socket

tests/socket/test.service
file added
+13
@@ -0,0 +1,13 @@

+ [Unit]

+ Description=Test socket Service

+ Requires=test.socket

+ 

+ [Service]

+ Type=simple

+ ExecStart=/usr/bin/python /usr/bin/test-server.py

+ StandardInput=socket

+ StandardError=journal

+ TimeoutStopSec=5

+ 

+ [Install]

+ WantedBy=multi-user.target

tests/socket/test.socket
file added
+32
@@ -0,0 +1,32 @@

+ [Unit]

+ Description=Test Socket

+ 

+ [Socket]

+ ListenStream=127.0.0.1:9999

+ 

+ [Socket]

+ ListenDatagram=127.0.0.1:9999

+ 

+ [Socket]

+ ListenSequentialPacket=/var/run/test.socket

+ 

+ [Socket]

+ ListenFIFO=/var/run/test-fifo

+ FileDescriptorName=sockio-stdin

+ RemoveOnStop=true

+ SocketUser=nobody

+ SocketGroup=nobody

+ SocketMode=0666

+ 

+ [Socket]

+ ListenStream=9990

+ BindIPv6Only=both

+ 

+ [Socket]

+ ListenStream=vsock:2:1234

+ 

+ [Socket]

+ ListenNetlink=route 1361

+ 

+ [Install]

+ WantedBy=sockets.target

tests/socket/testsuite.service
file added
+7
@@ -0,0 +1,7 @@

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-socket.sh

+ Type=oneshot

tests/standard-inventory-docker
file added
+193
@@ -0,0 +1,193 @@

+ #!/usr/bin/env python

+ 

+ import argparse

+ import errno

+ import json

+ import os

+ import shutil

+ import shlex

+ import signal

+ import socket

+ import subprocess

+ import sys

+ import tempfile

+ import time

+ import traceback

+ import distutils.util

+ 

+ def main(argv):

+     parser = argparse.ArgumentParser(description="Inventory for a container image in a registry")

+     parser.add_argument("--list", action="store_true", help="Verbose output")

+     parser.add_argument('--host', help="Get host variables")

+     parser.add_argument('--docker-extra-args', help="Extra docker arguments for launching container",

+                         default=os.environ.get("TEST_DOCKER_EXTRA_ARGS", ""))

+     parser.add_argument("subjects", nargs="*", default=shlex.split(os.environ.get("TEST_SUBJECTS", "")))

+     opts = parser.parse_args()

+ 

+     try:

+         if opts.host:

+             name, data = host(opts.host, opts.docker_extra_args)

+         else:

+             data = list(opts.subjects, opts.docker_extra_args)

+         sys.stdout.write(json.dumps(data, indent=4, separators=(',', ': ')))

+     except RuntimeError as ex:

+         sys.stderr.write("{0}: {1}\n".format(os.path.basename(sys.argv[0]), str(ex)))

+         return 1

+ 

+     return 0

+ 

+ def list(subjects, docker_extra_args):

+     hosts = [ ]

+     variables = { }

+     for subject in subjects:

+         if subject.startswith("docker:"):

+             image = subject[7:]

+             name, vars = host(image, docker_extra_args)

+             if vars:

+                 hosts.append(name)

+                 variables[name] = vars

+     return { "localhost": { "hosts": hosts, "vars": { } }, "subjects": { "hosts": hosts, "vars": { } }, "_meta": { "hostvars": variables } }

+ 

+ def host(image, docker_extra_args):

+     null = open(os.devnull, 'w')

+ 

+     try:

+         tty = os.open("/dev/tty", os.O_WRONLY)

+         os.dup2(tty, 2)

+     except OSError:

+         tty = None

+         pass

+ 

+     directory = tempfile.mkdtemp(prefix="inventory-docker")

+     cidfile = os.path.join(directory, "cid")

+ 

+     # Determine if container should be kept available for diagnosis after completion

+     try:

+         diagnose = distutils.util.strtobool(os.getenv("TEST_DEBUG", "0"))

+     except ValueError:

+         diagnose = 0

+ 

+     # Check for any additional arguments to include when starting docker container

+     try:

+         extra_arg_list = shlex.split(docker_extra_args)

+     except ValueError:

+         raise RuntimeError("Could not parse DOCKER_EXTRA_ARGS")

+ 

+     sys.stderr.write("Launching Docker container for {0}\n".format(image))

+ 

+     # Make sure the docker service is running

+     cmd = [

+         "/usr/sbin/service", "docker", "start"

+     ]

+ 

+     try:

+         subprocess.check_call(cmd, stdout=sys.stderr.fileno())

+     except subprocess.CalledProcessError as ex:

+         raise RuntimeError("Could not start docker service")

+ 

+     cmd = [

+         "/usr/bin/docker", "build", "--rm", "-t", image, "."

+         ]

+ 

+     try:

+         subprocess.check_call(cmd, stdout=sys.stderr.fileno())

+     except subprocess.CalledProcessError as ex:

+         raise RuntimeError("Could not build container image: {0}".format(image))

+ 

+     # And launch the actual container

+     cmd = [ "/usr/bin/docker", "run", "--detach", "--cidfile={0}".format(cidfile), "-itd" , "--privileged", image ]

+            #  extra_arg_list + [image]

+ 

+     try:

+         subprocess.check_call(cmd, stdout=sys.stderr.fileno())

+     except subprocess.CalledProcessError as ex:

+         raise RuntimeError("Could not run container image: {0}".format(image))

+ 

+     # Read out the container environment variable

+     for x in xrange(1, 90):

+         if os.path.exists(cidfile):

+             break

+         time.sleep(1)

+     else:

+         raise RuntimeError("Could not find container file for launched container")

+ 

+     with open(cidfile, "r") as f:

+         name = f.read().strip()

+ 

+     # Now install the necessary stuff in the container :S

+     install = [

+         "/usr/bin/docker", "exec", name, "/usr/bin/yum", "-y", "install",

+         "python2", "python2-dnf", "libselinux-python"

+     ]

+     try:

+         subprocess.check_call(install, stdout=sys.stderr.fileno())

+     except subprocess.CalledProcessError as ex:

+         raise RuntimeError("Could not install Ansible dependencies in launched container")

+ 

+     # Directory to place artifacts

+     artifacts = os.environ.get("TEST_ARTIFACTS", os.path.join(os.getcwd(), "artifacts"))

+ 

+     # The variables

+     variables = {

+         "ansible_connection": "docker",

+     }

+ 

+     # Process of our parent

+     ppid = os.getppid()

+ 

+     child = os.fork()

+     if child:

+         return name, variables

+ 

+     # Daemonize and watch the processes

+     os.chdir("/")

+     os.setsid()

+     os.umask(0)

+ 

+     if tty is None:

+         tty = null.fileno()

+ 

+     # Duplicate standard input to standard output and standard error.

+     os.dup2(null.fileno(), 0)

+     os.dup2(tty, 1)

+     os.dup2(tty, 2)

+ 

+     # Now wait for the parent process to go away, then kill the VM

+     while True:

+         time.sleep(3)

+ 

+         try:

+             os.kill(ppid, 0)

+         except OSError:

+             break # Either of the processes no longer exist

+ 

+     if diagnose:

+         sys.stderr.write("\n")

+         sys.stderr.write("DIAGNOSE: docker exec -it {0} /bin/bash\n".format(name))

+         sys.stderr.write("DIAGNOSE: kill {0} # when finished\n".format(os.getpid()))

+ 

+         def _signal_handler(*args):

+             sys.stderr.write("\nDIAGNOSE ending...\n")

+ 

+         signal.signal(signal.SIGTERM, _signal_handler)

+         signal.pause()

+ 

+     # Dump the container logs

+     try:

+         os.makedirs(artifacts)

+     except OSError as exc:

+         if exc.errno != errno.EEXIST or not os.path.isdir(artifacts):

+             raise

+     log = os.path.join(artifacts, "{0}.log".format(os.path.basename(image)))

+ 

+     # Kill the container

+     with open(log, "w") as f:

+         subprocess.call(["/usr/bin/docker", "logs", name ], stdout=f.fileno())

+     subprocess.call(["/usr/bin/docker", "kill", name ], stdout=null.fileno())

+     subprocess.call(["/usr/bin/docker", "rm", "-f", name ], stdout=null)

+ 

+     shutil.rmtree(directory)

+     sys.exit(0)

+ 

+ if __name__ == '__main__':

+     sys.exit(main(sys.argv))

tests/standard-inventory-qcow2
file added
+290
@@ -0,0 +1,290 @@

+ #!/usr/bin/env python

+ 

+ import argparse

+ import errno

+ import json

+ import os

+ import shutil

+ import shlex

+ import signal

+ import socket

+ import subprocess

+ import sys

+ import tempfile

+ import time

+ import distutils.util

+ 

+ IDENTITY = """

+ -----BEGIN RSA PRIVATE KEY-----

+ MIIEpQIBAAKCAQEA1DrTSXQRF8isQQfPfK3U+eFC4zBrjur+Iy15kbHUYUeSHf5S

+ jXPYbHYqD1lHj4GJajC9okle9rykKFYZMmJKXLI6987wZ8vfucXo9/kwS6BDAJto

+ ZpZSj5sWCQ1PI0Ce8CbkazlTp5NIkjRfhXGP8mkNKMEhdNjaYceO49ilnNCIxhpb

+ eH5dH5hybmQQNmnzf+CGCCLBFmc4g3sFbWhI1ldyJzES5ZX3ahjJZYRUfnndoUM/

+ TzdkHGqZhL1EeFAsv5iV65HuYbchch4vBAn8jDMmHh8G1ixUCL3uAlosfarZLLyo

+ 3HrZ8U/llq7rXa93PXHyI/3NL/2YP3OMxE8baQIDAQABAoIBAQCxuOUwkKqzsQ9W

+ kdTWArfj3RhnKigYEX9qM+2m7TT9lbKtvUiiPc2R3k4QdmIvsXlCXLigyzJkCsqp

+ IJiPEbJV98bbuAan1Rlv92TFK36fBgC15G5D4kQXD/ce828/BSFT2C3WALamEPdn

+ v8Xx+Ixjokcrxrdeoy4VTcjB0q21J4C2wKP1wEPeMJnuTcySiWQBdAECCbeZ4Vsj

+ cmRdcvL6z8fedRPtDW7oec+IPkYoyXPktVt8WsQPYkwEVN4hZVBneJPCcuhikYkp

+ T3WGmPV0MxhUvCZ6hSG8D2mscZXRq3itXVlKJsUWfIHaAIgGomWrPuqC23rOYCdT

+ 5oSZmTvFAoGBAPs1FbbxDDd1fx1hisfXHFasV/sycT6ggP/eUXpBYCqVdxPQvqcA

+ ktplm5j04dnaQJdHZ8TPlwtL+xlWhmhFhlCFPtVpU1HzIBkp6DkSmmu0gvA/i07Z

+ pzo5Z+HRZFzruTQx6NjDtvWwiXVLwmZn2oiLeM9xSqPu55OpITifEWNjAoGBANhH

+ XwV6IvnbUWojs7uiSGsXuJOdB1YCJ+UF6xu8CqdbimaVakemVO02+cgbE6jzpUpo

+ krbDKOle4fIbUYHPeyB0NMidpDxTAPCGmiJz7BCS1fCxkzRgC+TICjmk5zpaD2md

+ HCrtzIeHNVpTE26BAjOIbo4QqOHBXk/WPen1iC3DAoGBALsD3DSj46puCMJA2ebI

+ 2EoWaDGUbgZny2GxiwrvHL7XIx1XbHg7zxhUSLBorrNW7nsxJ6m3ugUo/bjxV4LN

+ L59Gc27ByMvbqmvRbRcAKIJCkrB1Pirnkr2f+xx8nLEotGqNNYIawlzKnqr6SbGf

+ Y2wAGWKmPyEoPLMLWLYkhfdtAoGANsFa/Tf+wuMTqZuAVXCwhOxsfnKy+MNy9jiZ

+ XVwuFlDGqVIKpjkmJyhT9KVmRM/qePwgqMSgBvVOnszrxcGRmpXRBzlh6yPYiQyK

+ 2U4f5dJG97j9W7U1TaaXcCCfqdZDMKnmB7hMn8NLbqK5uLBQrltMIgt1tjIOfofv

+ BNx0raECgYEApAvjwDJ75otKz/mvL3rUf/SNpieODBOLHFQqJmF+4hrSOniHC5jf

+ f5GS5IuYtBQ1gudBYlSs9fX6T39d2avPsZjfvvSbULXi3OlzWD8sbTtvQPuCaZGI

+ Df9PUWMYZ3HRwwdsYovSOkT53fG6guy+vElUEDkrpZYczROZ6GUcx70=

+ -----END RSA PRIVATE KEY-----

+ """

+ 

+ USER_DATA = """#cloud-config

+ users:

+   - default

+   - name: root

+     groups: sudo

+     shell: /bin/bash

+     ssh_authorized_keys:

+       - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUOtNJdBEXyKxBB898rdT54ULjMGuO6v4jLXmRsdRhR5Id/lKNc9hsdioPWUePgYlqML2iSV72vKQoVhkyYkpcsjr3zvBny9+5xej3+TBLoEMAm2hmllKPmxYJDU8jQJ7wJuRrOVOnk0iSNF+FcY/yaQ0owSF02Nphx47j2KWc0IjGGlt4fl0fmHJuZBA2afN/4IYIIsEWZziDewVtaEjWV3InMRLllfdqGMllhFR+ed2hQz9PN2QcapmEvUR4UCy/mJXrke5htyFyHi8ECfyMMyYeHwbWLFQIve4CWix9qtksvKjcetnxT+WWrutdr3c9cfIj/c0v/Zg/c4zETxtp standard-test-qcow2

+ ssh_pwauth: True

+ chpasswd:

+   list: |

+     root:foobar

+   expire: False

+ runcmd:

+   - mkfs.ext4 /dev/sdb

+   - mount /dev/sdb /usr/local 

+   - sudo mount -o remount,rw /usr

+ """

+ 

+ def main(argv):

+     parser = argparse.ArgumentParser(description="Inventory for a QCow2 test image")

+     parser.add_argument("--list", action="store_true", help="Verbose output")

+     parser.add_argument('--host', help="Get host variables")

+     parser.add_argument("subjects", nargs="*", default=shlex.split(os.environ.get("TEST_SUBJECTS", "")))

+     opts = parser.parse_args()

+ 

+     try:

+         if opts.host:

+             data = host(opts.host)

+         else:

+             data = list(opts.subjects)

+         sys.stdout.write(json.dumps(data, indent=4, separators=(',', ': ')))

+     except RuntimeError as ex:

+         sys.stderr.write("{0}: {1}\n".format(os.path.basename(sys.argv[0]), str(ex)))

+         return 1

+ 

+     return 0

+ 

+ 

+ def list(subjects):

+     hosts = []

+     variables = {}

+     for subject in subjects:

+         if subject.endswith((".qcow2", ".qcow2c")):

+             vars = host(subject)

+             if vars:

+                 hosts.append(subject)

+                 variables[subject] = vars

+     return {"localhost": {"hosts": hosts, "vars": {}}, "subjects": {"hosts": hosts, "vars": {}},

+             "_meta": {"hostvars": variables}}

+ 

+ 

+ def start_qemu(image, cloudinit, log, disk_directory=None, disk_size=None, portrange=(2222, 5555)):

+     for port in xrange(*portrange):

+         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

+         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

+         try:

+             sock.bind(("127.0.0.3", port))

+ 

+             if disk_size:

+                 return subprocess.Popen(["/usr/bin/qemu-system-x86_64", "-m", "1024", image,

+                                          "-enable-kvm", "-snapshot", "-cdrom", cloudinit,

+                                          "-hdb", disk_directory,

+                                          "-net", "nic,model=virtio", "-net",

+                                          "user,hostfwd=tcp:127.0.0.3:{0}-:22".format(port),

+                                          "-device", "isa-serial,chardev=pts2", "-chardev", "file,id=pts2,path=" + log,

+                                          "-display", "none"], stdout=open(os.devnull, 'w')), port

+             else:

+                 return subprocess.Popen(["/usr/bin/qemu-system-x86_64", "-m", "1024", image,

+                                          "-enable-kvm", "-snapshot", "-cdrom", cloudinit,

+                                          "-net", "nic,model=virtio", "-net",

+                                          "user,hostfwd=tcp:127.0.0.3:{0}-:22".format(port),

+                                          "-device", "isa-serial,chardev=pts2", "-chardev", "file,id=pts2,path=" + log,

+                                          "-display", "none"], stdout=open(os.devnull, 'w')), port

+         except IOError:

+             pass

+         finally:

+             sock.close()

+     else:

+         raise RuntimeError("unable to find free local port to map SSH to")

+ 

+ 

+ def host(image):

+     null = open(os.devnull, 'w')

+ 

+     try:

+         tty = os.open("/dev/tty", os.O_WRONLY)

+         os.dup2(tty, 2)

+     except OSError:

+         tty = None

+         pass

+ 

+     # A directory for temporary stuff

+     directory = tempfile.mkdtemp(prefix="inventory-cloud")

+     identity = os.path.join(directory, "identity")

+     with open(identity, 'w') as f:

+         f.write(IDENTITY)

+     os.chmod(identity, 0o600)

+     metadata = os.path.join(directory, "meta-data")

+     with open(metadata, 'w') as f:

+         f.write("")

+     userdata = os.path.join(directory, "user-data")

+     with open(userdata, 'w') as f:

+         f.write(USER_DATA)

+ 

+     # Create additional disk

+     disk_size = None

+     disk_directory = None

+     try:

+         disk_size = os.environ.get("EXTEND_DISK_SIZE")

+         if disk_size:

+             sys.stderr.write("\nCreate additional cloud init disk DISK SIZE {}\n".format(disk_size))

+ 

+             disk_directory = "{}/atomic-host-disk2-{}".format(directory, disk_size)

+             subprocess.check_call(["qemu-img", "create", "-f", "qcow2", disk_directory, disk_size], stdout=null)

+ 

+     except KeyError:

+         sys.stderr.write("\nCouldn't create additional cloud init disk DISK SIZE\n")

+     pass

+ 

+     # Create our cloud init so we can log in

+     cloudinit = os.path.join(directory, "cloud-init.iso")

+     subprocess.check_call(["/usr/bin/genisoimage", "-input-charset", "utf-8",

+                            "-volid", "cidata", "-joliet", "-rock", "-quiet",

+                            "-output", cloudinit, userdata, metadata], stdout=null)

+ 

+     # Determine if virtual machine should be kept available for diagnosis after completion

+     try:

+         diagnose = distutils.util.strtobool(os.getenv("TEST_DEBUG", "0"))

+     except ValueError:

+         diagnose = 0

+ 

+     sys.stderr.write("Launching virtual machine for {0}\n".format(image))

+ 

+     # And launch the actual VM

+     artifacts = os.environ.get("TEST_ARTIFACTS", os.path.join(os.getcwd(), "artifacts"))

+     try:

+         os.makedirs(artifacts)

+     except OSError as exc:

+         if exc.errno != errno.EEXIST or not os.path.isdir(artifacts):

+             raise

+     log = os.path.join(artifacts, "{0}.log".format(os.path.basename(image)))

+ 

+     proc = None  # for failure detection

+     cpe = None  # for exception scoping

+     for tries in xrange(0, 5):

+         try:

+             proc, port = start_qemu(image, cloudinit, log, disk_directory=disk_directory, disk_size=disk_size)

+             break

+         except subprocess.CalledProcessError as cpe:

+             time.sleep(1)

+             continue

+     if proc is None:

+         raise RuntimeError("Could not launch VM for qcow2 image"

+                            " '{0}':{1}".format(image, cpe.output))

+ 

+     # The variables

+     variables = {"ansible_ssh_port": "{0}".format(port),

+                  "ansible_ssh_host": "127.0.0.3",

+                  "ansible_ssh_user": "root",

+                  "ansible_ssh_pass": "foobar",

+                  "ansible_ssh_private_key_file": identity,

+                  "ansible_ssh_common_args": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"}

+ 

+     # Write out a handy inventory file, for our use and for debugging

+     args = " ".join(["{0}='{1}'".format(*item) for item in variables.items()])

+     inventory = os.path.join(directory, "inventory")

+     with open(inventory, "w") as f:

+         f.write("[subjects]\nlocalhost {1}\n".format(image, args))

+ 

+     # Wait for ssh to come up

+     ping = ["/usr/bin/ansible", "--inventory", inventory, "localhost", "--module-name", "raw", "--args", "/bin/true"]

+ 

+     for tries in xrange(0, 30):

+         try:

+             (pid, ret) = os.waitpid(proc.pid, os.WNOHANG)

+             if pid != 0:

+                 raise RuntimeError("qemu failed to launch qcow2 image: {0}".format(image))

+             subprocess.check_call(ping, stdout=null, stderr=null)

+             break

+         except subprocess.CalledProcessError:

+             time.sleep(3)

+     else:

+         # Kill the qemu process

+         try:

+             os.kill(proc.pid, signal.SIGTERM)

+         except OSError:

+             pass

+         raise RuntimeError("could not access launched qcow2 image: {0}".format(image))

+ 

+     # Process of our parent

+     ppid = os.getppid()

+ 

+     child = os.fork()

+     if child:

+         return variables

+ 

+     # Daemonize and watch the processes

+     os.chdir("/")

+     os.setsid()

+     os.umask(0)

+ 

+     if tty is None:

+         tty = null.fileno()

+ 

+     # Duplicate standard input to standard output and standard error.

+     os.dup2(null.fileno(), 0)

+     os.dup2(tty, 1)

+     os.dup2(tty, 2)

+ 

+     # Now wait for the parent process to go away, then kill the VM

+     while True:

+         time.sleep(3)

+         try:

+             os.kill(ppid, 0)

+             os.kill(proc.pid, 0)

+         except OSError:

+             break  # Either of the processes no longer exist

+ 

+     if diagnose:

+         sys.stderr.write("\n")

+         sys.stderr.write("DIAGNOSE: ssh -p {0} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "

+                          "root@{1} # password: {2}\n".format(port, "127.0.0.3", "foobar"))

+         sys.stderr.write("DIAGNOSE: export ANSIBLE_INVENTORY={0}\n".format(inventory))

+         sys.stderr.write("DIAGNOSE: kill {0} # when finished\n".format(os.getpid()))

+ 

+         def _signal_handler(*args):

+             sys.stderr.write("\nDIAGNOSE ending...\n")

+ 

+         signal.signal(signal.SIGTERM, _signal_handler)

+         signal.pause()

+ 

+     # Kill the qemu process

+     try:

+         os.kill(proc.pid, signal.SIGTERM)

+     except OSError:

+         pass

+ 

+     shutil.rmtree(directory)

+     sys.exit(0)

+ 

+ 

+ if __name__ == '__main__':

+     sys.exit(main(sys.argv))

tests/tests.yml
file added
+113
@@ -0,0 +1,113 @@

+ - hosts: localhost

+   roles:

+     - role: standard-test-beakerlib

+       tags:

+         - classic

+       tests:

+         - basic

+         - hostnamectl

+         - tmpfiles

+         - killmode

+         - localectl

+         - loginctl

+         - timedatectl

+         - rlimits

+         - journal

+         - jobs

+         - dropin

+         - sched

+         - path

+         - execute

+         - activate

+         - modules-load

+         - timers

+ # disabled due BZ#1494426

+ #       - socket

+         - link

+         - issue-1981

+         - issue-2467

+         - issue-3166

+ # disabled due BZ#1493478

+ #       - network

+       required_packages:

+         - ethtool                   # link tests needs this package

+         - findutils                 # beakerlib needs find command

+         - kernel-modules-extra      # network test needs vcan module

+         - lsof                      # socket test needs this package

+         - systemd

+         - nc

+         - python                    # beakerlib-journalling requires python

+ 

+ - hosts: localhost

+   roles:

+     - role: standard-test-beakerlib

+       tags:

+         - atomic

+       tests:

+         - basic

+         - hostnamectl

+         - tmpfiles

+         - killmode

+         - localectl

+         - loginctl

+         - timedatectl

+         - rlimits

+         - journal

+         - jobs

+         - dropin

+         - sched

+         - path

+         - execute

+         - activate

+         - modules-load

+         - timers

+ # disabled due BZ#1494426

+ #       - socket

+         - link

+         - issue-1981

+         - issue-2467

+         - issue-3166

+ # disabled due BZ#1493478

+ #       - network

+       required_packages:

+         - ethtool                   # link tests needs this package

+ 

+ - hosts: localhost

+   roles:

+     - role: standard-test-beakerlib

+       tags:

+         - container

+       tests:

+         - basic

+         - hostnamectl

+         - tmpfiles

+         - killmode

+         - localectl

+         - loginctl

+         - timedatectl

+         - rlimits

+         - journal

+         - jobs

+         - dropin

+         - sched

+         - path

+         - execute

+         - activate

+         - modules-load

+         - timers

+ # disabled due BZ#1494426

+ #       - socket

+         - link

+         - issue-1981

+         - issue-2467

+         - issue-3166

+ # disabled due BZ#1493478

+ #       - network

+       required_packages:

+         - ethtool                   # link tests needs this package

+         - findutils                 # beakerlib needs find command

+         - lsof                      # socket test needs this package

+         - systemd

+         - policycoreutilsi

+         - nc

+         - python

tests/timedatectl/runtest.sh
file added
+94
@@ -0,0 +1,94 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/systemd/Sanity/timedatectl

+ #   Description: Test for timedatectl

+ #   Author: Branislav Blaskovic <bblaskov@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2015 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ yum install -y chrony

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlAssertRpm chrony

+         rlFileBackup --clean "/var/lib/chrony/drift" "/etc/chrony.keys"

+         rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+         rlRun "pushd $TmpDir"

+         rlRun -s "timedatectl"

+         sed -i "s/Timezone/Time zone/" $rlRun_LOG

+         rlRun "TZ_ORIG=$( awk '/Timezone/ {print $2}' $rlRun_LOG )"

+         [[ -z $TZ_ORIG ]] && rlRun "TZ_ORIG=$( awk '/Time zone/ {print $3}' $rlRun_LOG )"

+ 

+ 

+         rlServiceStart chronyd

+         rlServiceStart systemd-timedated

+         timedatectl set-ntp false

+         rlLog "date = `date`"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "Timezones"

+         rlAssertGrep "Local time:" "$rlRun_LOG"

+ 

+         rlRun "timedatectl set-timezone Europe/Moscow"

+         rlRun -s "timedatectl"

+         rlAssertGrep "Time[ ]*zone: Europe/Moscow" "$rlRun_LOG"

+         rlRun -s "ls -l /etc/localtime"

+         rlAssertGrep "/usr/share/zoneinfo/Europe/Moscow" "$rlRun_LOG"

+ 

+         rlRun "timedatectl set-timezone 'America/Edmonton'"

+         rlRun "date"

+         rlRun "date | grep 'M[SD]T'"

+         rlRun "timedatectl set-timezone UTC"

+         rlRun "date | grep 'UTC'"

+         rlRun "timedatectl set-timezone $TZ_ORIG"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "Timezones count"

+         count=`timedatectl list-timezones | wc -l`

+         if [[ "$count" -ge "300" ]];then

+             rlPass "count TZ = $count"

+         else

+             rlFail "only $count TZ"

+         fi

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "timedatectl set-timezone $TZ_ORIG"

+         rlRun "timedatectl set-ntp on"

+         rlServiceRestore chronyd

+         rlServiceRestore systemd-timedated

+         rlFileRestore

+         rlRun "popd"

+         rlRun "rm -r $TmpDir" 0 "Removing tmp directory"

+         rlLog "date = `date`"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/timers/runtest.sh
file added
+72
@@ -0,0 +1,72 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of timer

+ #   Description: Test for systemd timers

+ #   Author: Susant Sahani <susant@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 	rlRun  "cp timertest.timer timertest.service /etc/systemd/system"

+ 

+         rlRun -s "cat >/etc/systemd/system/testsuite.service <<EOF

+ [Unit]

+ Description=Testsuite service

+ After=multi-user.target

+ 

+ [Service]

+ ExecStart=/usr/bin/test-timers.sh

+ Type=oneshot

+ EOF"

+         rlRun "cp test-timers.sh /usr/bin/"

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlLog "systemd timer test"

+ 

+ 	rlLog "starting testsuite.service"

+      	rlRun "systemctl start testsuite.service"

+         rlAssertExists "/tmp/testok"

+        rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+        rlRun "rm /etc/systemd/system/timertest.timer /etc/systemd/system/timertest.service"

+        rlRun "rm /tmp/testok"

+        rlRun "rm /usr/bin/test-timers.sh"

+ 

+        rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

tests/timers/test-timers.sh
file added
+20
@@ -0,0 +1,20 @@

+ #!/bin/bash

+ 

+ set -x

+ set -e

+ set -o pipefail

+ 

+ systemctl stop timertest.timer

+ 

+ systemctl start timertest.timer

+ 

+ [[ "$(systemctl list-timers | grep timertest.timer |  awk '{print $9}')" == "timertest.timer" ]]

+ 

+ sleep 5

+ 

+ # test if the file exists should have created by service triggered by the timer.

+ [[ -f /tmp/timer-test ]]

+ 

+ rm /tmp/timer-test

+ 

+ touch /tmp/testok

tests/timers/timertest.service
file added
+6
@@ -0,0 +1,6 @@

+ [Unit]

+ Description=TimerTest

+ 

+ [Service]

+ Type=simple

+ ExecStart=/usr/bin/touch > /tmp/timer-test

tests/timers/timertest.timer
file added
+5
@@ -0,0 +1,5 @@

+ [Unit]

+ Description=Runs timertest every 10s

+ 

+ [Timer]

+ OnActiveSec=2s

tests/tmpfiles/runtest.sh
file added
+85
@@ -0,0 +1,85 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/systemd/Sanity/tmpfiles

+ #   Description: Test for (Systemd-tmpfiles does not set owner/group defined)

+ #   Author: Branislav Blaskovic <bblaskov@redhat.com>

+ #   Some parts based on script by: Jakub Martisko <jamartis@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2016 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="systemd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+         rlRun "pushd $TmpDir"

+ 

+         rlRun "useradd foo"

+         rlRun "groupadd bar"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "test tmpfiles: enforce ordering when executing lines"

+ 

+ cat <<\EOF > /etc/tmpfiles.d/hello.conf

+ D /run/hello  1777 foo bar -

+ f /run/hello/hello.test  1777 root bar -

+ z /run/hello/hello.test 1777 root root - -

+ EOF

+ 

+         rlRun "systemd-tmpfiles --create"

+         rlRun -s "ls -al /run/hello/"

+         rlAssertGrep "foo.*bar.*\.$" $rlRun_LOG

+         rlAssertGrep "root.*root.*hello.test$" $rlRun_LOG

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "test tmpfiles: don't follow symlinks when adjusting ACLs, fille attributes, access modes or ownership"

+ 

+ cat <<\EOF > /etc/tmpfiles.d/hello2.conf

+ D /run/hello2  1777 foo bar -

+ f /run/hello2/hello2.test  1777 root bar -

+ L+ /run/hello2/hello2.link - root bar - /run/hello2/hello2.test

+ z /run/hello2/hello2.test 1777 root root - -

+ z /run/hello2/hello2.link - foo bar - -

+ EOF

+ 

+ 

+         rlRun "systemd-tmpfiles --create"

+         rlRun -s "ls -l  /run/hello2/"

+         rlAssertGrep "root.*root.* hello2.test$" $rlRun_LOG

+         rlAssertGrep "root.*root.* hello2.link -> /run/hello2/hello2.test$" $rlRun_LOG

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "popd"

+         rlRun "userdel -r foo"

+         rlRun "groupdel bar"

+         rlRun "rm -r $TmpDir /etc/tmpfiles.d/hello*.conf" 0 "Removing tmp directory"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

no initial comment

Justification

Adds tests according to the CI wiki specifically the standard test interface in the spec.

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic and Atomic. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:

Current package includes 1 opened issue on upstreamfirst: https://upstreamfirst.fedorainfracloud.org/shadow-utils/issue/2

Test environment

Make sure you have installed packages from the spec

    # rpm -q ansible python2-dnf libselinux-python standard-test-roles \
    ansible-2.3.2.0-1.fc26.noarch \
    python2-dnf-2.6.3-11.fc26.noarch \
    libselinux-python-2.6-7.fc26.x86_64 \
    standard-test-roles-2.4-1.fc26.noarch

Run tests for Classic

    # export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
        # curl -o systemd.rpm https://kojipkgs.fedoraproject.org/packages/systemd/231/10.fc26/x86_64/systemd-231-10.fc26.x86_64.rpm
    # export TEST_SUBJECTS=$PWD/etcd.rpm
        # ansible-playbook --tags=classic tests.yml

Snip of the example test run for Classic tests:

    PLAY RECAP *********************************************************************
    localhost                  : ok=20   changed=10   unreachable=0    failed=0   

    PASS basic
    PASS hostnamectl
    PASS tmpfiles
    PASS killmode
    PASS localectl
    PASS loginctl
    PASS timedatectl
    PASS rlimits
    PASS journal
    PASS jobs
    PASS dropin
    PASS sched
    PASS path
    PASS execute
    PASS activate
    PASS modules-load
    PASS link
    PASS issue-1981
    PASS issue-2467
    PASS issue-3166

Run tests for Atomic

    # export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
        # curl -Lo atomic.qcow2 https://ftp-stud.hs-esslingen.de/pub/Mirrors/alt.fedoraproject.org/atomic/stable/Fedora-Atomic-26-20171030.0/CloudImages/x86_64/images/Fedora-Atomic-26-20171030.0.x86_64.qcow2
    # export TEST_SUBJECTS=$PWD/atomic.qcow2
    # export EXTEND_DISK_SIZE=8G
    # ansible-playbook -i standard-inventory-qcow2 --tags=atomic tests.yml

Snip of the example test run for Classic tests:

    PLAY RECAP *********************************************************************
    /home/esaka/package_testing/upstreamfirst/systemd/atomic.qcow2 : ok=20   changed=11   unreachable=0    failed=0   

    [root@localhost systemd]# qemu-system-x86_64: terminating on signal 15 from pid 8749 (python)

    PASS basic
    PASS hostnamectl
    PASS tmpfiles
    PASS killmode
    PASS localectl
    PASS loginctl
    PASS timedatectl
    PASS rlimits
    PASS journal
    PASS jobs
    PASS dropin
    PASS sched
    PASS path
    PASS execute
    PASS activate
    PASS modules-load
    PASS link
    PASS issue-1981
    PASS issue-2467
    PASS issue-3166

Hi all,

Current pull request is in progress, going to create another pull request on upstreamfirst.

Thanks,
Eduard

It's a bit scary that this is so big. Some (all?) of those tests files are copies of upstream test files. Unfortunately pagure is not accommodating today (https://pagure.io/pagure/issue/2786) so I didn't look at all the files. But I'd rather not add ~160 duplicate files from upstream, since this will be maintenance hell. Is there something preventing using the files from test/ in the upstream sources?

Created pull request for merging changes on upstreamfirst: https://upstreamfirst.fedorainfracloud.org/systemd/pull-request/10.

Regards,
Eduard

Hi all,

I have tested all tests under Fedora27-Cloud-Base openstack image and under rawhide version, loginctls tests failed. I have created PR according to it :https://upstreamfirst.fedorainfracloud.org/systemd/issue/11

Regards,
Eduard

Hi all,

I have tested systemd under Fedora27-Cloud-Base openstack image and under rawhide version for atomic tag, all tests have passed.

Regards,
Eduard

rebased onto 4af74919e11b88a323594dbb58aa2eba579ada1d

6 years ago

rebased onto 8f3f30786ab3595944ea7600710294bed1da2dc7

6 years ago

rebased onto f8e517912f11c6ee919d2d95588478208113eaf7

6 years ago

1 new commit added

  • Removing .gitignore from systemd branch
6 years ago

rebased onto a9ab449

6 years ago

I am not sure why this needs to be merged here ?

Hi @ssahani,

Think merge is needed for moving tests from upstreamfirst to the ci pipeline, https://fedoraproject.org/wiki/FedoraAtomicCI/pipeline.

Thanks,
Eduard

How we can manage two branch it's very difficult. Is it possible we checkout from upstream first or github then run this tests.

Let me ask again (since I didn't get any reply to my comment in https://src.fedoraproject.org/rpms/systemd/pull-request/1#comment-1885): why are you copying the files from upstream into the rpm? Nack to this, it's completely unmaintainable.

It's much nicer to write ansible-script so that it can pull tests from github and run the tests.
I am working on it.

It's a bit scary that this is so big. Some (all?) of those tests files are copies of upstream test files. Unfortunately pagure is not accommodating today (https://pagure.io/pagure/issue/2786) so I didn't look at all the files. But I'd rather not add ~160 duplicate files from upstream, since this will be maintenance hell. Is there something preventing using the files from test/ in the upstream sources?

A good way to avoid duplication is to make sure all the tests are shipped in systemd-tests and then from the ansible playbooks install this package and call the tests.

That sounds like a great approach.

The whole "installed tests" idea came mostly from Ubuntu, and I don't think it has seen any real use in Fedora, so there might be some rough edges, e.g. some missing test-case files. But this should all be easily fixable if there are any issues, and then this will be a much more scalable approach.

PR #4 is more viable, let's continue the discussion there.

Pull-Request has been closed by zbyszek

5 years ago
Metadata
Changes Summary 177
-0
file removed
.gitignore
+3
file added
tests/README.md
+71
file added
tests/activate/runtest.sh
+9
file added
tests/activate/test-activate.service
+26
file added
tests/activate/test-activate.sh
+55
file added
tests/basic/runtest.sh
+15
file added
tests/dockerfile
+7
file added
tests/dropin/a.service
+6
file added
tests/dropin/b.service
+6
file added
tests/dropin/c.service
+8
file added
tests/dropin/d.service
+8
file added
tests/dropin/e.service
+5
file added
tests/dropin/f.service
+6
file added
tests/dropin/g.service
+6
file added
tests/dropin/h.service
+66
file added
tests/dropin/runtest.sh
+274
file added
tests/dropin/test-dropin.sh
+7
file added
tests/dropin/testsuite.service
+9
file added
tests/execute/exec-capabilityambientset-merge-nfsnobody.service
+9
file added
tests/execute/exec-capabilityambientset-merge.service
+8
file added
tests/execute/exec-capabilityambientset-nfsnobody.service
+8
file added
tests/execute/exec-capabilityambientset.service
+7
file added
tests/execute/exec-capabilityboundingset-invert.service
+8
file added
tests/execute/exec-capabilityboundingset-merge.service
+8
file added
tests/execute/exec-capabilityboundingset-reset.service
+7
file added
tests/execute/exec-capabilityboundingset-simple.service
+9
file added
tests/execute/exec-dynamicuser-fixeduser-one-supplementarygroup.service
+8
file added
tests/execute/exec-dynamicuser-fixeduser.service
+19
file added
tests/execute/exec-dynamicuser-state-dir.service
+8
file added
tests/execute/exec-dynamicuser-supplementarygroups.service
+8
file added
tests/execute/exec-environment-empty.service
+8
file added
tests/execute/exec-environment-multiple.service
+7
file added
tests/execute/exec-environment.service
+7
file added
tests/execute/exec-environmentfile.service
+7
file added
tests/execute/exec-group-nfsnobody.service
+7
file added
tests/execute/exec-group.service
+7
file added
tests/execute/exec-ignoresigpipe-no.service
+7
file added
tests/execute/exec-ignoresigpipe-yes.service
+7
file added
tests/execute/exec-inaccessiblepaths-mount-propagation.service
+7
file added
tests/execute/exec-inaccessiblepaths-proc.service
+7
file added
tests/execute/exec-ioschedulingclass-best-effort.service
+7
file added
tests/execute/exec-ioschedulingclass-idle.service
+7
file added
tests/execute/exec-ioschedulingclass-none.service
+7
file added
tests/execute/exec-ioschedulingclass-realtime.service
+7
file added
tests/execute/exec-oomscoreadjust-negative.service
+7
file added
tests/execute/exec-oomscoreadjust-positive.service
+7
file added
tests/execute/exec-passenvironment-absent.service
+8
file added
tests/execute/exec-passenvironment-empty.service
+8
file added
tests/execute/exec-passenvironment-repeated.service
+7
file added
tests/execute/exec-passenvironment.service
+7
file added
tests/execute/exec-personality-aarch64.service
+7
file added
tests/execute/exec-personality-ppc64.service
+7
file added
tests/execute/exec-personality-ppc64le.service
+7
file added
tests/execute/exec-personality-s390.service
+7
file added
tests/execute/exec-personality-x86-64.service
+7
file added
tests/execute/exec-personality-x86.service
+7
file added
tests/execute/exec-privatedevices-no-capability-mknod.service
+7
file added
tests/execute/exec-privatedevices-no-capability-sys-rawio.service
+7
file added
tests/execute/exec-privatedevices-no.service
+7
file added
tests/execute/exec-privatedevices-yes-capability-mknod.service
+7
file added
tests/execute/exec-privatedevices-yes-capability-sys-rawio.service
+7
file added
tests/execute/exec-privatedevices-yes.service
+7
file added
tests/execute/exec-privatenetwork-yes.service
+7
file added
tests/execute/exec-privatetmp-no.service
+7
file added
tests/execute/exec-privatetmp-yes.service
+7
file added
tests/execute/exec-protectkernelmodules-no-capabilities.service
+7
file added
tests/execute/exec-protectkernelmodules-yes-capabilities.service
+7
file added
tests/execute/exec-protectkernelmodules-yes-mount-propagation.service
+8
file added
tests/execute/exec-read-only-path-succeed.service
+7
file added
tests/execute/exec-readonlypaths-mount-propagation.service
+7
file added
tests/execute/exec-readonlypaths.service
+7
file added
tests/execute/exec-readwritepaths-mount-propagation.service
+7
file added
tests/execute/exec-restrict-address-families.service
+7
file added
tests/execute/exec-restrict-namespaces-mnt-blacklist.service
+7
file added
tests/execute/exec-restrict-namespaces-mnt.service
+7
file added
tests/execute/exec-restrict-namespaces-no.service
+7
file added
tests/execute/exec-restrict-namespaces-yes.service
+7
file added
tests/execute/exec-restrict-realtime.service
+8
file added
tests/execute/exec-runtimedirectory-mode.service
+9
file added
tests/execute/exec-runtimedirectory-owner-nfsnobody.service
+9
file added
tests/execute/exec-runtimedirectory-owner.service
+7
file added
tests/execute/exec-runtimedirectory.service
+6
file added
tests/execute/exec-spec-interpolation.service
+19
file added
tests/execute/exec-stdin-data.service
+7
file added
tests/execute/exec-stdio-file.service
+7
file added
tests/execute/exec-supplementarygroups-multiple-groups-default-group-user.service
+8
file added
tests/execute/exec-supplementarygroups-multiple-groups-withgid.service
+8
file added
tests/execute/exec-supplementarygroups-multiple-groups-withuid.service
+9
file added
tests/execute/exec-supplementarygroups-single-group-user.service
+8
file added
tests/execute/exec-supplementarygroups-single-group.service
+7
file added
tests/execute/exec-supplementarygroups.service
+8
file added
tests/execute/exec-systemcallerrornumber.service
+9
file added
tests/execute/exec-systemcallfilter-failing.service
+7
file added
tests/execute/exec-systemcallfilter-failing2.service
+10
file added
tests/execute/exec-systemcallfilter-not-failing.service
+7
file added
tests/execute/exec-systemcallfilter-not-failing2.service
+11
file added
tests/execute/exec-systemcallfilter-system-user-nfsnobody.service
+11
file added
tests/execute/exec-systemcallfilter-system-user.service
+8
file added
tests/execute/exec-umask-0177.service
+7
file added
tests/execute/exec-umask-default.service
+8
file added
tests/execute/exec-unset-environment.service
+7
file added
tests/execute/exec-user-nfsnobody.service
+7
file added
tests/execute/exec-user.service
+7
file added
tests/execute/exec-workingdirectory.service
+74
file added
tests/execute/runtest.sh
+520
file added
tests/execute/test-execute.sh
+62
file added
tests/hostnamectl/runtest.sh
+69
file added
tests/issue-1981/runtest.sh
+36
file added
tests/issue-1981/test-segfault.sh
+84
file added
tests/issue-2467/runtest.sh
+96
file added
tests/issue-3166/runtest.sh
+5
file added
tests/jobs/hello-after-sleep.target
+5
file added
tests/jobs/hello.service
+75
file added
tests/jobs/runtest.sh
+6
file added
tests/jobs/sleep.service
+80
file added
tests/jobs/test-jobs.sh
+5
file added
tests/jobs/unstoppable.service
+85
file added
tests/journal/runtest.sh
+70
file added
tests/journal/test-journal.sh
+105
file added
tests/killmode/runtest.sh
+20
file added
tests/killmode/trapka
+14
file added
tests/killmode/trapka.sub
+69
file added
tests/link/runtest.sh
+67
file added
tests/link/test-link.sh
+66
file added
tests/localectl/runtest.sh
+129
file added
tests/loginctl/runtest.sh
+1
file added
tests/loginctl/ssh/authorized_keys
+27
file added
tests/loginctl/ssh/id_rsa
+1
file added
tests/loginctl/ssh/id_rsa.pub
+12
file added
tests/modules-load/modules-load.sh
+63
file added
tests/modules-load/runtest.sh
+1006
file added
tests/network/networkd-test.py
+68
file added
tests/network/runtest.sh
+482
file added
tests/network/test-network.sh
+8
file added
tests/path/path-changed.path
+6
file added
tests/path/path-changed.service
+8
file added
tests/path/path-directorynotempty.path
+6
file added
tests/path/path-directorynotempty.service
+8
file added
tests/path/path-exists.path
+6
file added
tests/path/path-exists.service
+8
file added
tests/path/path-existsglob.path
+6
file added
tests/path/path-existsglob.service
+10
file added
tests/path/path-makedirectory.path
+6
file added
tests/path/path-makedirectory.service
+8
file added
tests/path/path-modified.path
+6
file added
tests/path/path-modified.service
+6
file added
tests/path/path-mycustomunit.service
+6
file added
tests/path/path-service.service
+9
file added
tests/path/path-unit.path
+73
file added
tests/path/runtest.sh
+115
file added
tests/path/test-path.sh
+82
file added
tests/rlimits/runtest.sh
+13
file added
tests/rlimits/test-rlimits.sh
+74
file added
tests/sched/runtest.sh
+6
file added
tests/sched/sched_idle_bad.service
+6
file added
tests/sched/sched_idle_ok.service
+8
file added
tests/sched/sched_rr_bad.service
+9
file added
tests/sched/sched_rr_change.service
+6
file added
tests/sched/sched_rr_ok.service
+22
file added
tests/sched/test-sched.sh
+71
file added
tests/socket/runtest.sh
+13
file added
tests/socket/test-protocol.service
+13
file added
tests/socket/test-protocol.socket
+10
file added
tests/socket/test-server.py
+61
file added
tests/socket/test-socket.sh
+13
file added
tests/socket/test.service
+32
file added
tests/socket/test.socket
+7
file added
tests/socket/testsuite.service
+193
file added
tests/standard-inventory-docker
+290
file added
tests/standard-inventory-qcow2
+113
file added
tests/tests.yml
+94
file added
tests/timedatectl/runtest.sh
+72
file added
tests/timers/runtest.sh
+20
file added
tests/timers/test-timers.sh
+6
file added
tests/timers/timertest.service
+5
file added
tests/timers/timertest.timer
+85
file added
tests/tmpfiles/runtest.sh