Skip to content
Snippets Groups Projects
Commit e203730a authored by Kamil Dudka's avatar Kamil Dudka
Browse files

test-common-selinux.sh: check whether SELinux tests should be skipped

Closes #132
parent 2b5185dc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -5,6 +5,7 @@ EXTRA_DIST = \
test \
test-common.sh \
test-common-acl.sh \
test-common-selinux.sh \
$(top_srcdir)/test/test-config.*.in
 
DISTCLEANFILES = \
Loading
Loading
Loading
Loading
@@ -2,38 +2,6 @@
 
. ./test-common.sh
 
# -- SELINUX - BEGIN --------------------------------
# We test if the ACLs tests should be done or not
SELINUX_TESTS=0
if type "selinuxenabled" >/dev/null 2>&1 && selinuxenabled; then
SELINUX_TESTS=1
else
echo "SELinux disabled. SELinux tests will not be executed."
fi
if [ $SELINUX_TESTS = 1 ]; then
# It seems we can run the ACL tests, but was logrotate compiled WITH_ACL=yes ?
# See the Makefile, "pretest" part, for more information
if [ -f ./test.SELINUX ]; then
SELINUX_TESTS=`cat ./test.SELINUX`
if [ $SELINUX_TESTS = 0 ]; then
echo "logrotate was NOT compiled with 'WITH_SELINUX=yes'. SELINUX tests will not be executed."
fi
fi
fi
if [ $SELINUX_TESTS = 1 ]; then
# if logrotate_tmp_t, we can't continue with SELinux tests...
touch .selinuxtest
chcon --type=logrotate_tmp_t .selinuxtest 2>/dev/null
if [ $? != 0 ]; then
SELINUX_TESTS=0
echo "SELinux context 'logrotate_tmp_t' does not exist. SELinux tests will not be executed."
fi
rm -f .selinuxtest
fi
# -- SELINUX - END ----------------------------------
# we don't want any stuff left from previous runs
cleanup 1
 
Loading
Loading
@@ -149,6 +117,7 @@ cleanup 6
# ------------------------------- Test 6 -------------------------------------
preptest test.log 6 1
preptest anothertest.log 6 1
. ./test-common-selinux.sh
if [ $SELINUX_TESTS = 1 ]; then
chcon --type=logrotate_tmp_t test.log
else
Loading
Loading
@@ -226,6 +195,7 @@ cleanup 10
# ------------------------------- Test 10 ------------------------------------
preptest test.log 10 1
 
. ./test-common-selinux.sh
if [ $SELINUX_TESTS = 1 ]; then
chcon --type=logrotate_tmp_t test.log
else
Loading
Loading
@@ -1046,6 +1016,7 @@ test.log 0
EOF
 
 
. ./test-common-selinux.sh
if [ $SELINUX_TESTS = 1 ]; then
chcon --type=logrotate_tmp_t test.log
else
Loading
Loading
@@ -1054,6 +1025,7 @@ fi
 
cleanup 47
 
. ./test-common-selinux.sh
if [ $SELINUX_TESTS = 1 ]; then
 
# ------------------------------- Test 47 ------------------------------------
Loading
Loading
# We test if the SELinux tests should be done or not
if [ -z "$SELINUX_TESTS" ]; then
# not yet checked
SELINUX_TESTS=0
if type "selinuxenabled" >/dev/null 2>&1 && selinuxenabled; then
SELINUX_TESTS=1
else
echo "SELinux disabled. SELinux tests will not be executed."
fi
if [ $SELINUX_TESTS = 1 ]; then
# It seems we can run the ACL tests, but was logrotate compiled WITH_ACL=yes ?
# See the Makefile, "pretest" part, for more information
if [ -f ./test.SELINUX ]; then
SELINUX_TESTS=`cat ./test.SELINUX`
if [ $SELINUX_TESTS = 0 ]; then
echo "logrotate was NOT compiled with 'WITH_SELINUX=yes'. SELINUX tests will not be executed."
fi
fi
fi
if [ $SELINUX_TESTS = 1 ]; then
# if logrotate_tmp_t, we can't continue with SELinux tests...
touch .selinuxtest
chcon --type=logrotate_tmp_t .selinuxtest 2>/dev/null
if [ $? != 0 ]; then
SELINUX_TESTS=0
echo "SELinux context 'logrotate_tmp_t' does not exist. SELinux tests will not be executed."
fi
rm -f .selinuxtest
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment