[PATCH 02/03]: Test sched_smt_power_saving with valid and invalid values

Signed-off-by: poornima nayak <[email protected]>

diff -uprN
ltp-full-20090228_orig/testcases/kernel/power_management/test_sched_smt.sh 
ltp-full-20090228/testcases/kernel/power_management/test_sched_smt.sh
---
ltp-full-20090228_orig/testcases/kernel/power_management/test_sched_smt.sh      
1969-12-31 18:00:00.000000000 -0600
+++
ltp-full-20090228/testcases/kernel/power_management/test_sched_smt.sh
2009-03-06 08:50:18.000000000 -0600
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+. pm_include.sh
+
+valid_input="0 1"
+invalid_input="a 2 abcefg x1999 xffff -1 -00000
200000000000000000000000000000000000000000000000000000000000000000000000000000 
ox324 -0xfffffffffffffffffffff"
+test_file="/sys/devices/system/cpu/sched_smt_power_savings"
+if [ ! -f ${test_file} ] ; then
+       echo "MISSING_FILE: missing file ${test_file}"
+       exit $MISSING_FILE
+fi
+
+function check_input() {
+       validity_check=${2:-valid}
+       if [ "${validity_check}" = "invalid" ] ; then
+               PASS="Testcase FAIL - Able to execute"
+               FAIL="Testcase PASS - Unable to execute"
+       else
+               PASS="Testcase PASS"
+               FAIL="Testcase FAIL"
+       fi
+       for input in ${1}
+       do
+               echo ${input} > ${test_file} 2>/dev/null
+               return_value=$?
+               output=$(cat ${test_file})
+               if [ "${return_value}" = "0" -a "${input}" = "${output}" ] ; 
then
+                       echo "${0}: ${PASS}: echo ${input} > ${test_file}"
+                       if [ "${validity_check}" = "invalid" ] ; then
+                               RC=1
+                       fi
+               else
+                       echo "${0}: ${FAIL}: echo ${input} > ${test_file}"
+                       if [ "${validity_check}" = "valid" ] ; then
+                               RC=1
+                       fi
+               fi
+       done
+}
+echo "${0}: ---Valid test cases---"
+check_input "${valid_input}"
+echo "${0}: ---Invalid test cases---"
+check_input "${invalid_input}" invalid
+exit $RC


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to