##########################################################################
#   Copyright (C) International Business Machines  Corp., 2003
#
#   This program is free software;  you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
#  FILE   : Makefile
#
#  PURPOSE: The default "all" target uses the gcc compiler to compile all
#           test files in the current directory.
#
#           The "clean" target removes all files the end in ".o" (object
#           files).
#
#
#  HISTORY:
#    06/04 originated by Dustin Kirkland (k1rkland@us.ibm.com
#
##########################################################################
TOPDIR		= ../..

LOG		= run.log
CC		+= -pthread
EXE_1		= devfileperm\
		  dirperm\
		  fileperm\
		  namedpipes_fifoperm \
		  suid_sgid \
		  unixdomainsocketperm
EXE_2		= msqperm\
		  semperm\
		  shmperm



all:: $(EXE_1) $(EXE_2)

run:: all
	-groupadd  permtest1
	-groupadd  permtest2
	-useradd -g permtest1 permtest1
	-useradd -g permtest2 permtest2
	-for i in $(EXE_1); do ./$$i permtest1 &> ./$$i.$(LOG); done
	-for i in $(EXE_2); do ./$$i permtest1 permtest2 &> ./$$i.$(LOG); done
	-./procperm.sh &> ./procperm.sh.run.log
	-for i in $(EXE_1); do echo "TEST PASSED = " `grep "PASS" $$i.$(LOG) | wc -l` ", FAILED = " `grep "FAIL" $$i.$(LOG) | wc -l` >> $$i.$(LOG); done
	-for i in $(EXE_2); do echo "TEST PASSED = " `grep "PASS" $$i.$(LOG) | wc -l` ", FAILED = " `grep "FAIL" $$i.$(LOG) | wc -l` >> $$i.$(LOG); done
	echo "TEST PASSED = " `grep "PASS" procperm.sh.run.log | wc -l` ", FAILED = " `grep "FAIL" procperm.sh.run.log | wc -l` >> procperm.sh.run.log
	-userdel -r permtest1
	-userdel -r permtest2
	-groupdel permtest1
	-groupdel permtest2

rmlogs::
	rm -rf *run.log

clean::
	rm -rf $(EXE_1) $(EXE_2)

include $(TOPDIR)/rules.mk


