pm-qa: change result message for tests

- change the result message for each subtest, so that it won't interfere with lava log
  parsing. Report total pass and fail count for tests.
- bug: https://bugs.launchpad.net/linaro-power-qa/+bug/1156614
- change permission in cputopology scripts for execution

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
diff --git a/Makefile b/Makefile
index 52aa60d..731619d 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@
 #	@(cd suspend; $(MAKE) check)
 	@(cd thermal; $(MAKE) check)
 #	@(cd powertop; $(MAKE) check)
+	@(cd cputopology; $(MAKE) check)
 
 uncheck:
 	@(cd cpufreq; $(MAKE) uncheck)
diff --git a/cpufreq/cpufreq_01.sh b/cpufreq/cpufreq_01.sh
index f4fc178..dd93c29 100755
--- a/cpufreq/cpufreq_01.sh
+++ b/cpufreq/cpufreq_01.sh
@@ -30,3 +30,4 @@
 FILES="scaling_available_frequencies scaling_cur_freq scaling_setspeed"
 
 for_each_cpu check_cpufreq_files $FILES
+test_status_show
diff --git a/cpufreq/cpufreq_02.sh b/cpufreq/cpufreq_02.sh
index aeecd45..1ec725f 100755
--- a/cpufreq/cpufreq_02.sh
+++ b/cpufreq/cpufreq_02.sh
@@ -30,3 +30,4 @@
 FILES="scaling_available_governors scaling_governor"
 
 for_each_cpu check_cpufreq_files $FILES
+test_status_show
diff --git a/cpufreq/cpufreq_03.sh b/cpufreq/cpufreq_03.sh
index 65aed52..ae32fee 100755
--- a/cpufreq/cpufreq_03.sh
+++ b/cpufreq/cpufreq_03.sh
@@ -49,3 +49,4 @@
 fi
 
 for_each_cpu for_each_governor check_governor || exit 1
+test_status_show
diff --git a/cpufreq/cpufreq_04.sh b/cpufreq/cpufreq_04.sh
index f044164..3edf83f 100755
--- a/cpufreq/cpufreq_04.sh
+++ b/cpufreq/cpufreq_04.sh
@@ -57,3 +57,4 @@
 else
     for_each_cpu for_each_frequency check_frequency || exit 1
 fi
+test_status_show
diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh
index f4cc997..a0b82f4 100755
--- a/cpufreq/cpufreq_05.sh
+++ b/cpufreq/cpufreq_05.sh
@@ -98,3 +98,4 @@
 fi
 
 restore_governors
+test_status_show
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh
index cb45e4b..08f7a6d 100755
--- a/cpufreq/cpufreq_06.sh
+++ b/cpufreq/cpufreq_06.sh
@@ -121,3 +121,4 @@
 
 restore_frequencies
 restore_governors
+test_status_show
diff --git a/cpufreq/cpufreq_07.sh b/cpufreq/cpufreq_07.sh
index 354ed46..516e0a7 100755
--- a/cpufreq/cpufreq_07.sh
+++ b/cpufreq/cpufreq_07.sh
@@ -95,3 +95,4 @@
 for_each_cpu check_ondemand
 
 restore_governors
+test_status_show
diff --git a/cpufreq/cpufreq_08.sh b/cpufreq/cpufreq_08.sh
index 328b4f5..d78c191 100755
--- a/cpufreq/cpufreq_08.sh
+++ b/cpufreq/cpufreq_08.sh
@@ -82,3 +82,4 @@
 for_each_cpu check_userspace
 
 restore_governors
+test_status_show
diff --git a/cpufreq/cpufreq_09.sh b/cpufreq/cpufreq_09.sh
index c1d1a7b..3ffccec 100755
--- a/cpufreq/cpufreq_09.sh
+++ b/cpufreq/cpufreq_09.sh
@@ -78,3 +78,4 @@
 for_each_cpu check_powersave
 
 restore_governors
+test_status_show
diff --git a/cpuhotplug/1_sanity_check.sh b/cpuhotplug/1_sanity_check.sh
index 50ebbcc..e091879 100755
--- a/cpuhotplug/1_sanity_check.sh
+++ b/cpuhotplug/1_sanity_check.sh
@@ -37,3 +37,4 @@
 }
 
 check "all cpu are online" "sanity_check"
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_01.sh b/cpuhotplug/cpuhotplug_01.sh
index 83fc17a..a1dfe93 100755
--- a/cpuhotplug/cpuhotplug_01.sh
+++ b/cpuhotplug/cpuhotplug_01.sh
@@ -34,3 +34,4 @@
 done
 
 for_each_cpu check_cpuhotplug_files online
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_02.sh b/cpuhotplug/cpuhotplug_02.sh
index 4273f65..2c582cf 100755
--- a/cpuhotplug/cpuhotplug_02.sh
+++ b/cpuhotplug/cpuhotplug_02.sh
@@ -58,3 +58,4 @@
 }
 
 for_each_cpu check_state
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_03.sh b/cpuhotplug/cpuhotplug_03.sh
index 51cde18..d4816ca 100755
--- a/cpuhotplug/cpuhotplug_03.sh
+++ b/cpuhotplug/cpuhotplug_03.sh
@@ -48,4 +48,5 @@
     return 0
 }
 
-for_each_cpu check_affinity_fails
\ No newline at end of file
+for_each_cpu check_affinity_fails
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_04.sh b/cpuhotplug/cpuhotplug_04.sh
index 753cf55..67098e1 100755
--- a/cpuhotplug/cpuhotplug_04.sh
+++ b/cpuhotplug/cpuhotplug_04.sh
@@ -69,3 +69,4 @@
 }
 
 for_each_cpu check_task_migrate
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_05.sh b/cpuhotplug/cpuhotplug_05.sh
index 12df3c4..98371d4 100755
--- a/cpuhotplug/cpuhotplug_05.sh
+++ b/cpuhotplug/cpuhotplug_05.sh
@@ -47,3 +47,4 @@
 }
 
 for_each_cpu check_procinfo
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_06.sh b/cpuhotplug/cpuhotplug_06.sh
index ce4ffeb..1f2641d 100755
--- a/cpuhotplug/cpuhotplug_06.sh
+++ b/cpuhotplug/cpuhotplug_06.sh
@@ -47,3 +47,4 @@
 }
 
 for_each_cpu check_procinfo
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_07.sh b/cpuhotplug/cpuhotplug_07.sh
index 72d9744..6486dd7 100755
--- a/cpuhotplug/cpuhotplug_07.sh
+++ b/cpuhotplug/cpuhotplug_07.sh
@@ -64,3 +64,4 @@
 }
 
 for_each_cpu check_notification
+test_status_show
diff --git a/cpuhotplug/cpuhotplug_08.sh b/cpuhotplug/cpuhotplug_08.sh
index e996f11..d413595 100755
--- a/cpuhotplug/cpuhotplug_08.sh
+++ b/cpuhotplug/cpuhotplug_08.sh
@@ -47,3 +47,4 @@
 }
 
 for i in $(seq 1 50); do random_stress || break; done
+test_status_show
diff --git a/cpuhotplug/z_sanity_check.sh b/cpuhotplug/z_sanity_check.sh
index 43051ac..c39413e 100755
--- a/cpuhotplug/z_sanity_check.sh
+++ b/cpuhotplug/z_sanity_check.sh
@@ -37,3 +37,4 @@
 }
 
 check "all cpu are back online" "sanity_check"
+test_status_show
diff --git a/cpuidle/cpuidle_01.sh b/cpuidle/cpuidle_01.sh
index 8fe2f5d..ec7b911 100755
--- a/cpuidle/cpuidle_01.sh
+++ b/cpuidle/cpuidle_01.sh
@@ -58,3 +58,4 @@
 check_cpuidle_files
 
 for_each_cpu check_cpuidle_state_files
+test_status_show
diff --git a/cpuidle/cpuidle_02.sh b/cpuidle/cpuidle_02.sh
index 1b155c1..491107b 100755
--- a/cpuidle/cpuidle_02.sh
+++ b/cpuidle/cpuidle_02.sh
@@ -35,3 +35,4 @@
 fi
 
 check "cpuidle program runs successfully (120 secs)" "./$CPUIDLE_KILLER"
+test_status_show
diff --git a/cpuidle/cpuidle_03.sh b/cpuidle/cpuidle_03.sh
index 22bca10..25cca1b 100755
--- a/cpuidle/cpuidle_03.sh
+++ b/cpuidle/cpuidle_03.sh
@@ -58,3 +58,4 @@
 
 for_each_cpu check_cpuidle_kill
 restore_cpus
+test_status_show
diff --git a/cpuidle/cpuidle_sanity.sh b/cpuidle/cpuidle_sanity.sh
index a8336fa..568c129 100755
--- a/cpuidle/cpuidle_sanity.sh
+++ b/cpuidle/cpuidle_sanity.sh
@@ -33,3 +33,4 @@
 }
 
 check_cpuidle_sysfs_entry
+test_status_show
diff --git a/cputopology/cputopology_01.sh b/cputopology/cputopology_01.sh
old mode 100644
new mode 100755
index c7cbc26..60a11e3
--- a/cputopology/cputopology_01.sh
+++ b/cputopology/cputopology_01.sh
@@ -23,7 +23,7 @@
 #       - initial API and implementation
 #
 
-# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#sched_mc_02
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cputopology_01
 
 source ../include/functions.sh
 
@@ -36,3 +36,4 @@
 }
 
 for_each_cpu check_physical_package_id || exit 1
+test_status_show
diff --git a/cputopology/cputopology_02.sh b/cputopology/cputopology_02.sh
old mode 100644
new mode 100755
index 6520ce5..7c9a46d
--- a/cputopology/cputopology_02.sh
+++ b/cputopology/cputopology_02.sh
@@ -23,7 +23,7 @@
 #       - initial API and implementation
 #
 
-# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#sched_mc_03
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cputopology_02
 
 source ../include/functions.sh
 
@@ -31,3 +31,4 @@
 thread_siblings thread_siblings_list"
 
 for_each_cpu check_topology_files $FILES
+test_status_show
diff --git a/include/functions.sh b/include/functions.sh
index 7ee809b..fa9a370 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -30,6 +30,17 @@
 PREFIX=$TEST_NAME
 INC=0
 CPU=
+pass_count=0
+fail_count=0
+
+test_status_show() {
+    echo "-------- total = $(($pass_count + $fail_count))"
+    echo "-------- pass = $pass_count"
+    # report failure only if it is there
+    if [ $fail_count -ne 0 ] ; then
+      echo "-------- fail = $fail_count"
+    fi
+}
 
 log_begin() {
     printf "%-76s" "$TEST_NAME.$INC$CPU: $@... "
@@ -216,11 +227,13 @@
 
     $func $@
     if [ $? != 0 ]; then
-	log_end "fail"
+	log_end "Err"
+	fail_count=$(($fail_count + 1))
 	return 1
     fi
 
-    log_end "pass"
+    log_end "Ok"
+    pass_count=$(($pass_count + 1))
 
     return 0
 }
diff --git a/powertop/powertop_01.sh b/powertop/powertop_01.sh
index cf243f1..c66b725 100755
--- a/powertop/powertop_01.sh
+++ b/powertop/powertop_01.sh
@@ -56,3 +56,4 @@
 }
 
 run_powertop
+test_status_show
diff --git a/powertop/powertop_sanity.sh b/powertop/powertop_sanity.sh
index 3ae3065..060f85c 100755
--- a/powertop/powertop_sanity.sh
+++ b/powertop/powertop_sanity.sh
@@ -33,3 +33,4 @@
 }
 
 check_powertop
+test_status_show
diff --git a/suspend/suspend_01.sh b/suspend/suspend_01.sh
index e591dc9..6f36302 100755
--- a/suspend/suspend_01.sh
+++ b/suspend/suspend_01.sh
@@ -45,4 +45,5 @@
 fi
 
 restore_trace
+test_status_show
 rm -f "$LOGFILE"
diff --git a/suspend/suspend_02.sh b/suspend/suspend_02.sh
index 5e41d08..ceb6398 100755
--- a/suspend/suspend_02.sh
+++ b/suspend/suspend_02.sh
@@ -45,5 +45,6 @@
 fi
 
 restore_trace
+test_status_show
 rm -f "$LOGFILE"
 
diff --git a/suspend/suspend_03.sh b/suspend/suspend_03.sh
index b71966c..de81627 100755
--- a/suspend/suspend_03.sh
+++ b/suspend/suspend_03.sh
@@ -46,4 +46,5 @@
 fi
 
 restore_trace
+test_status_show
 rm -f "$LOGFILE"
diff --git a/suspend/suspend_04.sh b/suspend/suspend_04.sh
index 8947afd..0eb70dd 100755
--- a/suspend/suspend_04.sh
+++ b/suspend/suspend_04.sh
@@ -70,4 +70,5 @@
 fi
 
 restore_trace
+test_status_show
 rm -f "$LOGFILE"
diff --git a/suspend/suspend_05.sh b/suspend/suspend_05.sh
index a87490c..55396e5 100755
--- a/suspend/suspend_05.sh
+++ b/suspend/suspend_05.sh
@@ -90,4 +90,5 @@
 fi
 
 restore_trace
+test_status_show
 rm -f "$LOGFILE"
diff --git a/thermal/thermal_01.sh b/thermal/thermal_01.sh
index 390fbde..5a74296 100755
--- a/thermal/thermal_01.sh
+++ b/thermal/thermal_01.sh
@@ -83,3 +83,4 @@
 check_thermal_zone_trip_level
 
 check_thermal_zone_bindings
+test_status_show
diff --git a/thermal/thermal_02.sh b/thermal/thermal_02.sh
index d2cb32e..a78618c 100755
--- a/thermal/thermal_02.sh
+++ b/thermal/thermal_02.sh
@@ -63,3 +63,4 @@
 for_each_cooling_device check_cooling_device_attributes
 
 for_each_cooling_device check_cooling_device_states
+test_status_show
diff --git a/thermal/thermal_03.sh b/thermal/thermal_03.sh
index f2cfb81..92e9569 100755
--- a/thermal/thermal_03.sh
+++ b/thermal/thermal_03.sh
@@ -61,3 +61,4 @@
 trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
 
 for_each_thermal_zone check_temperature_change
+test_status_show
diff --git a/thermal/thermal_04.sh b/thermal/thermal_04.sh
index 7fe53e2..58aac43 100755
--- a/thermal/thermal_04.sh
+++ b/thermal/thermal_04.sh
@@ -81,3 +81,4 @@
 trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
 
 for_each_cooling_device verify_cooling_device_temp_change
+test_status_show
diff --git a/thermal/thermal_05.sh b/thermal/thermal_05.sh
index e7e2710..3dcaa8d 100755
--- a/thermal/thermal_05.sh
+++ b/thermal/thermal_05.sh
@@ -72,3 +72,4 @@
     echo $prev_state_val > $dirpath/cur_state
 }
 for_each_cooling_device verify_cpufreq_cooling_device_action
+test_status_show
diff --git a/thermal/thermal_06.sh b/thermal/thermal_06.sh
index b0a9442..e170028 100755
--- a/thermal/thermal_06.sh
+++ b/thermal/thermal_06.sh
@@ -103,3 +103,4 @@
 trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
 
 for_each_thermal_zone check_trip_point_change
+test_status_show
diff --git a/thermal/thermal_sanity.sh b/thermal/thermal_sanity.sh
index 7d4ca6c..37e4c88 100755
--- a/thermal/thermal_sanity.sh
+++ b/thermal/thermal_sanity.sh
@@ -31,3 +31,4 @@
 }
 
 check_thermal_zone
+test_status_show