Chris PeBenito dd6f82
#!/bin/bash
Chris PeBenito dd6f82
Chris PeBenito dd6f82
TYPES="strict targeted-mcs strict-mls"
Chris PeBenito dd6f82
POLVER="`checkpolicy -V |cut -f 1 -d ' '`"
Chris PeBenito dd6f82
SETFILES="/usr/sbin/setfiles"
Chris PeBenito dd6f82
SE_LINK="/usr/bin/semodule_link"
Chris PeBenito dd6f82
Chris PeBenito dd6f82
die() {
Chris PeBenito dd6f82
	if [ "$1" -eq "1" ]; then
Chris PeBenito dd6f82
		echo "failed with options: $2"
Chris PeBenito dd6f82
	fi
Chris PeBenito dd6f82
Chris PeBenito dd6f82
	exit 1
Chris PeBenito dd6f82
}
Chris PeBenito dd6f82
Chris PeBenito dd6f82
cleanup() {
Chris PeBenito dd6f82
	make bare
Chris PeBenito dd6f82
	make MONOLITHIC=n bare
Chris PeBenito dd6f82
}
Chris PeBenito dd6f82
Chris PeBenito dd6f82
do_test() {
Chris PeBenito dd6f82
	local OPTS=""
Chris PeBenito dd6f82
Chris PeBenito dd6f82
	trap cleanup SIGINT SIGQUIT
Chris PeBenito dd6f82
Chris PeBenito dd6f82
	for i in $TYPES; do
Chris PeBenito dd6f82
		# Monolithic tests
Chris PeBenito dd6f82
		OPTS="TYPE=$i MONOLITHIC=y QUIET=y DIRECT_INITRC=y"
Chris PeBenito dd6f82
		[ ! -z "$1" ] && OPTS="$OPTS DISTRO=$1"
Chris PeBenito dd6f82
		echo "**** Options: $OPTS ****"
Chris PeBenito dd6f82
		echo -ne "\33]0;mon $i $1\007"
Chris PeBenito dd6f82
		make $OPTS conf || die "$?" "$OPTS"
Chris PeBenito dd6f82
		make $OPTS || die "$?" "$OPTS"
Chris PeBenito dd6f82
		make $OPTS file_contexts || die "$?" "$OPTS"
Chris PeBenito dd6f82
		$SETFILES -q -c policy.$POLVER file_contexts || die "$?" "$OPTS"
Chris PeBenito dd6f82
		make $OPTS bare || die "$?" "$OPTS"
Chris PeBenito dd6f82
Chris PeBenito dd6f82
		# Loadable module tests
Chris PeBenito dd6f82
		OPTS="TYPE=$i MONOLITHIC=n QUIET=y DIRECT_INITRC=y"
Chris PeBenito dd6f82
		[ ! -z "$1" ] && OPTS="$OPTS DISTRO=$1"
Chris PeBenito dd6f82
		echo "**** Options: $OPTS ****"
Chris PeBenito dd6f82
		echo -ne "\33]0;mod $i $1\007"
Chris PeBenito dd6f82
		make $OPTS conf || die "$?" "$OPTS"
Chris PeBenito dd6f82
		make $OPTS base || die "$?" "$OPTS"
Chris PeBenito dd6f82
		make $OPTS -j2 modules || die "$?" "$OPTS"
Chris PeBenito dd6f82
		mv base.pp tmp
Chris PeBenito dd6f82
		############# FIXME
Chris PeBenito dd6f82
		rm dmesg.pp
Chris PeBenito dd6f82
		$SE_LINK tmp/base.pp *.pp || die "$?" "$OPTS"
Chris PeBenito dd6f82
		make $OPTS bare || die "$?" "$OPTS"
Chris PeBenito dd6f82
	done
Chris PeBenito dd6f82
}
Chris PeBenito dd6f82
Chris PeBenito dd6f82
cleanup
Chris PeBenito dd6f82
do_test
Chris PeBenito dd6f82
Chris PeBenito dd6f82
echo "Completed successfully."