OS = linux

ROOT = UNDEFINED

CIMSERVER_PATH = /usr/sbin/

include mak/commands.mak

create_providerlinks:
	@make createlink OBJECT=/usr/share/Pegasus/test/lib/libSampleInstanceProvider.so.1 LINKNAME=/usr/lib/Pegasus/providers/libSampleInstanceProvider.so
	@make createlink OBJECT=/usr/share/Pegasus/test/lib/libSampleMethodProvider.so.1 LINKNAME=/usr/lib/Pegasus/providers/libSampleMethodProvider.so
	@make createlink OBJECT=/usr/share/Pegasus/test/lib/libFamilyProvider.so.1 LINKNAME=/usr/lib/Pegasus/providers/libFamilyProvider.so
	@make createlink OBJECT=/usr/share/Pegasus/test/lib/libIndicationStressTestConsumer.so.1 LINKNAME=/usr/lib/Pegasus/providers/libIndicationStressTestConsumer.so
	@make createlink OBJECT=/usr/share/Pegasus/test/lib/libIndicationStressTestProvider.so.1 LINKNAME=/usr/lib/Pegasus/providers/libIndicationStressTestProvider.so
	@if [ -e /selinux/enforce ] ; then chcon system_u:object_r:shlib_t /usr/share/Pegasus/test/lib/* >/dev/null 2>&1 ||:; restorecon -R /usr/lib/Pegasus/providers/ >/dev/null 2>&1 ||:; fi

remove_providerlinks:
	rm -f /usr/lib/Pegasus/providers/libSampleInstanceProvider.so
	rm -f /usr/lib/Pegasus/providers/libSampleMethodProvider.so
	rm -f /usr/lib/Pegasus/providers/libFamilyProvider.so
	rm -f /usr/lib/Pegasus/providers/libIndicationStressTestConsumer.so
	rm -f /usr/lib/Pegasus/providers/libIndicationStressTestProvider.so

prestarttests:
	@make -s prestarttests_internal

prestarttests_internal:
	./bin/TestAbstract
	./bin/TestArray
	./bin/TestBase64
	./bin/TestClassDecl
	./bin/TestDateTime
	./bin/TestFlavor
	./bin/TestFormatter
	./bin/TestHashTable
	./bin/TestInstanceDecl
	./bin/TestLogger
	./bin/TestMethod
	./bin/TestObject
	./bin/TestOperationContext
	./bin/TestParamValue
	./bin/TestParameter
	./bin/TestProperty
	./bin/TestQualifier
	./bin/TestQualifierDecl
	./bin/TestQualifierList
	./bin/TestQueue
	./bin/TestReference
	./bin/TestResolve
	./bin/TestResponseHandler
	./bin/TestScope
	./bin/TestStack
	./bin/TestStopwatch
	./bin/TestStrToInstName
	./bin/TestString
	./bin/TestTimeValue
	./bin/TestToMof
	./bin/TestValidateClass
	./bin/TestValue
	./bin/TracerTest
	./bin/TestIPC

poststarttests:
	@make -s poststarttests_internal

poststarttests_internal:
	/usr/share/Pegasus/test/bin/TestClient -local
	/usr/share/Pegasus/test/bin/OSTestClient
	/usr/share/Pegasus/test/bin/TestPegClientInvokeMethod2
	/usr/share/Pegasus/test/bin/TestIndicationStressTest setup WQL
	/usr/share/Pegasus/test/bin/TestIndicationStressTest run 100 1
	/usr/share/Pegasus/test/bin/TestIndicationStressTest cleanup

tests:
	@make -i cimstop
	@make prestarttests
	@make setupTEST
	@make runTestSuite CIMSERVER_CONFIG_OPTIONS="" TESTSUITE_CMDS="make@@poststarttests" || { make unsetupTEST; exit 1; }
	@make runTestSuite CIMSERVER_CONFIG_OPTIONS="enableHttpConnection=false enableHttpsConnection=false" TESTSUITE_CMDS="/usr/share/Pegasus/test/bin/TestClient@@-local" || { make unsetupTEST; exit 1; }
	@make unsetupTEST

setupTEST:
ifeq ($(wildcard /var/lib/Pegasus/repository.bak),)
	@make -i cimstop
	@mv /var/lib/Pegasus/repository /var/lib/Pegasus/repository.bak
	@mv /var/lib/Pegasus/testrepository /var/lib/Pegasus/repository
	@make cimstart
	@make create_providerlinks
else
	@echo "Setup Aborted: /var/lib/Pegasus/repository.bak already exists"
endif

unsetupTEST:
ifneq ($(wildcard /var/lib/Pegasus/repository/tog-pegasus-testrepository),)
	@make -i cimstop
	@mv /var/lib/Pegasus/repository /var/lib/Pegasus/testrepository
	@mv /var/lib/Pegasus/repository.bak /var/lib/Pegasus/repository
endif
	@make remove_providerlinks

