pm-qa: run sanity check before running test cases

run sanity test for each functionality if present.
If functionality enabled, then run all respective
test cases. This patch also adds sanity checks for
cpuidle and sched_mc.

Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org>
diff --git a/Test.mk b/Test.mk
index 1d69d7a..76f79b5 100644
--- a/Test.mk
+++ b/Test.mk
@@ -21,15 +21,22 @@
 #     Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation)
 #       - initial API and implementation
 #
-
-TST=$(wildcard *.sh)
+SNT=$(wildcard *sanity.sh)
+TST=$(wildcard *[^(sanity)].sh)
 LOG=$(TST:.sh=.log)
 CFLAGS?=-g -Wall -pthread
 CC?=gcc
 SRC=$(wildcard *.c)
 EXEC=$(SRC:%.c=%)
 
-check: uncheck $(EXEC) $(LOG)
+check: run_tests
+
+SANITY_STATUS:= $(shell if test $(SNT) && test -f $(SNT); then \
+		./$(SNT); if test "$$?" -eq 0; then echo 0; else \
+		echo 1; fi; else echo 1; fi)
+
+ifeq "$(SANITY_STATUS)" "1"
+run_tests: uncheck $(EXEC) $(LOG)
 
 %.log: %.sh
 	@echo "###"
@@ -38,6 +45,10 @@
 	@echo -n "### "; grep "URL :" ./$< | awk '/http/{print $$NF}'
 	@echo "###"
 	@./$< 2> $@
+else
+run_tests: $(SNT)
+	@cat $(<:.sh=.txt)
+endif
 
 clean:
 	rm -f *.o $(EXEC)