#!/usr/bin/bash
function _chk
{
echo "executing: $@"
eval "$@"
local rc=$?
if [ $rc -ne 0 ]; then
echo "Failed: $rc"
# Dump log for targetd
echo "journalctl -u targetd"
journalctl -u targetd
# On failure dump the audit logs
echo "ausearch ..."
ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts recent
exit 1
fi
}
SOURCE_DIR="targetd_src"
BASE=$PWD
# TODO REMOVE THIS WHEN RAWHIDE PICKS UP
# https://github.com/fedora-selinux/selinux-policy-contrib/pull/334
_chk setenforce 0
# Run the upstream setup script
_chk cd $SOURCE_DIR
_chk ./test/test.sh setup
# Pick up new changes from setup
_chk systemctl restart targetd
# Try stopping the firewall, but don't fail if this fails
systemctl stop firewalld
# Give the service a moment to start up.
_chk sleep 10
# See if the daemon is up and accepting ...
netstat -anp | grep LISTEN | grep 18700
# Go back to start directory and run unit test.
_chk cd $BASE
SRC="$BASE/$SOURCE_DIR"
_chk TARGETD_UT_CERTFILE=/etc/target/targetd_cert.pem PYTHONPATH=$SRC python3 $SRC/test/targetd_test.py -v
exit 0