test.sh revision 5c7290b1956453024fc14abba2385ea9e9bccf8c
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# ex: ts=8 sw=4 sts=4 et filetype=sh
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# Requirements:
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# selinux-policy-targeted
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen# selinux-policy-devel
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
2a73e0d39a9bec82c3800071e375d27164727e71Tom Gundersen [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen # Create what will eventually be our root filesystem onto an overlay
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen cat <<EOF >$initdir/etc/systemd/system/testsuite.service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenDescription=Testsuite service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenAfter=multi-user.target
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom GundersenExecStart=/test-selinux-checks.sh
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen cat <<EOF >$initdir/etc/systemd/system/hola.service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenExecStart=/bin/echo Start Hola
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenExecReload=/bin/echo Reload Hola
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenExecStop=/bin/echo Stop Hola
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenRemainAfterExit=yes
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen cat <<EOF >$initdir/etc/systemd/system/load-systemd-test-module.service
9dc670ea766c711741f462b29572f2e5f8f3f6bcTom GundersenDescription=Load systemd-test module
9dc670ea766c711741f462b29572f2e5f8f3f6bcTom GundersenDefaultDependencies=no
9dc670ea766c711741f462b29572f2e5f8f3f6bcTom GundersenRequires=local-fs.target
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenConflicts=shutdown.target
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenAfter=local-fs.target
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenBefore=sysinit.target shutdown.target autorelabel.service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenConditionSecurity=selinux
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenConditionPathExists=|/.load-systemd-test-module
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenExecStart=/bin/sh -x -c 'echo 0 >/sys/fs/selinux/enforce && cd /systemd-test-module && make -f /usr/share/selinux/devel/Makefile load && rm /.load-systemd-test-module'
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenRemainAfterExit=yes
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen mkdir -p $initdir/etc/systemd/system/basic.target.wants
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ln -fs load-systemd-test-module.service $initdir/etc/systemd/system/basic.target.wants/load-systemd-test-module.service
977085794d2996320e345433403de75f662b0622Tom Gundersen if ! cp -ar $_modules_dir $initdir/$_modules_dir; then
977085794d2996320e345433403de75f662b0622Tom Gundersen local _policy_headers_dir=/usr/share/selinux/devel
977085794d2996320e345433403de75f662b0622Tom Gundersen if ! cp -ar $_policy_headers_dir $initdir/$_policy_headers_dir; then
977085794d2996320e345433403de75f662b0622Tom Gundersen cp systemd_test.te $initdir/systemd-test-module
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen cp systemd_test.if $initdir/systemd-test-module
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen dracut_install checkmodule semodule semodule_package m4 make /usr/libexec/selinux/hll/pp load_policy sefcontext_compile
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen # mask some services that we do not want to run in these tests
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket