Change the testcases use the new api commands tst_ncpus/_max
to get the CPUS onlined and configured.

Signed-off-by: Wanlong Gao <[email protected]>
---
 testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh          | 2 +-
 testcases/kernel/controllers/cpuctl/run_cpuctl_latency_test.sh    | 4 ++--
 testcases/kernel/controllers/cpuctl/run_cpuctl_stress_test.sh     | 2 +-
 testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh            | 2 +-
 testcases/kernel/controllers/cpuset/cpuset_funcs.sh               | 2 +-
 testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh    | 2 +-
 testcases/kernel/power_management/pm_include.sh                   | 8 ++------
 .../kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh   | 4 ++--
 .../kernel/sched/hyperthreading/ht_enabled/smt_smp_enabled.sh     | 4 ++--
 .../ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh        | 7 +------
 10 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh 
b/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh
index 332a5ae..55cfe82 100755
--- a/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh
+++ b/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh
@@ -68,7 +68,7 @@ cleanup
 
 mes="CPU Accounting Controller"
 cg_path="/dev/cpuacct";
-num_online_cpus=`cat /proc/cpuinfo | grep -w -i processor | wc -l`
+num_online_cpus=`tst_ncpus`
 
 #Function to create tasks equal to num_online_cpus.
 nr_tasks ()
diff --git a/testcases/kernel/controllers/cpuctl/run_cpuctl_latency_test.sh 
b/testcases/kernel/controllers/cpuctl/run_cpuctl_latency_test.sh
index d75d356..5efb9e2 100755
--- a/testcases/kernel/controllers/cpuctl/run_cpuctl_latency_test.sh
+++ b/testcases/kernel/controllers/cpuctl/run_cpuctl_latency_test.sh
@@ -99,7 +99,7 @@ calc_allowed_latency()
                sys_latency=`cat /proc/sys/kernel/sched_wakeup_granularity_ns`
                allowed_latency=`expr $sys_latency / 1000` # in microseconds
        else
-               num_cpus=`cat /proc/cpuinfo | grep -w -i processor | wc -l`
+               num_cpus=`tst_ncpus`
                log2 $num_cpus;
                ln_num_cpus=$?
                ln_num_cpus=`expr $ln_num_cpus + 1`
@@ -170,7 +170,7 @@ PWD=`pwd`
        "2")    # With group scheduling
                echo TINFO "Running cpuctl Latency Test 2"
 
-               NUM_CPUS=`cat /proc/cpuinfo | grep -w -i processor | wc -l`;
+               NUM_CPUS=`tst_ncpus`
                get_num_groups; # NUM_GROUPS is set now
                do_setup;
 
diff --git a/testcases/kernel/controllers/cpuctl/run_cpuctl_stress_test.sh 
b/testcases/kernel/controllers/cpuctl/run_cpuctl_stress_test.sh
index faf810b..9d9d6c3 100755
--- a/testcases/kernel/controllers/cpuctl/run_cpuctl_stress_test.sh
+++ b/testcases/kernel/controllers/cpuctl/run_cpuctl_stress_test.sh
@@ -64,7 +64,7 @@ SCRIPT_PID=$$;
 FILE="stress-678";             # suffix for results file
 TEST_NAME="CPUCTL NUM_GROUPS vs NUM_TASKS TEST:";
 
-NUM_CPUS=`cat /proc/cpuinfo | grep -w -i processor | wc -l`
+NUM_CPUS=`tst_ncpus`
 N=$NUM_CPUS;           # Default total num of groups (classes)
 M=10;                  # Default total num of tasks in a group
 
diff --git a/testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh 
b/testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh
index 260c97b..f213ebf 100755
--- a/testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh
+++ b/testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh
@@ -59,7 +59,7 @@ NICEVALUE=-20;                # Nice value to renice a task 
with
 SCRIPT_PID=$$;
 PWD=`pwd`
 cd $LTPROOT/testcases/bin/
-NUM_CPUS=`cat /proc/cpuinfo | grep -w -i processor | wc -l`
+NUM_CPUS=`tst_ncpus`
 
 . parameters.sh
 
diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh 
b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
index aca0aaf..66b1543 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
@@ -24,7 +24,7 @@
 ##                                                                            
##
 
################################################################################
 
-NR_CPUS="`cat /proc/cpuinfo | grep "processor" | wc -l`"
+NR_CPUS=`tst_ncpus`
 if [ -f "/sys/devices/system/node/has_high_memory" ]; then
        N_NODES="`cat /sys/devices/system/node/has_high_memory`"
 else
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh 
b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh
index aca0aaf..66b1543 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh
@@ -24,7 +24,7 @@
 ##                                                                            
##
 
################################################################################
 
-NR_CPUS="`cat /proc/cpuinfo | grep "processor" | wc -l`"
+NR_CPUS=`tst_ncpus`
 if [ -f "/sys/devices/system/node/has_high_memory" ]; then
        N_NODES="`cat /sys/devices/system/node/has_high_memory`"
 else
diff --git a/testcases/kernel/power_management/pm_include.sh 
b/testcases/kernel/power_management/pm_include.sh
index 7e1dd3c..18662c3 100755
--- a/testcases/kernel/power_management/pm_include.sh
+++ b/testcases/kernel/power_management/pm_include.sh
@@ -21,15 +21,11 @@ check_config_options() {
        fi
 }
 
-no_of_cpus() {
-       echo $(cat /proc/cpuinfo | grep processor | wc -l)
-}
-
 get_topology() {
        declare -a cpus
        declare -a phyid
 
-       total_cpus=$(no_of_cpus)
+       total_cpus=`tst_ncpus`
        (( total_cpus-=1 ))
        for cpu in $(seq 0 "${total_cpus}" )
        do
@@ -48,7 +44,7 @@ get_topology() {
 }
 
 check_cpufreq() {
-       total_cpus=$(no_of_cpus)
+       total_cpus=`tst_ncpus`
        (( total_cpus-=1 ))
 
        for cpu in $(seq 0 "${total_cpus}" )
diff --git 
a/testcases/kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh 
b/testcases/kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh
index 0a33f51..92e5550 100755
--- a/testcases/kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh
+++ b/testcases/kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh
@@ -53,8 +53,8 @@ else
        exit $TFAILCNT
 fi
 
-no_of_processor=`cat /proc/cpuinfo | grep -c processor`
-no_of_cpu=`ls /sys/devices/system/cpu/ | grep -c cpu[0-9]`
+no_of_processor=`tst_ncpus`
+no_of_cpu=`tst_ncpus_max`
 
 if [ $no_of_processor -lt $no_of_cpu ];then
 
diff --git 
a/testcases/kernel/sched/hyperthreading/ht_enabled/smt_smp_enabled.sh 
b/testcases/kernel/sched/hyperthreading/ht_enabled/smt_smp_enabled.sh
index e234ea4..f4e23b5 100755
--- a/testcases/kernel/sched/hyperthreading/ht_enabled/smt_smp_enabled.sh
+++ b/testcases/kernel/sched/hyperthreading/ht_enabled/smt_smp_enabled.sh
@@ -50,8 +50,8 @@ else
        exit $TFAILCNT
 fi
 
-no_of_processor=`cat /proc/cpuinfo | grep -c processor`
-no_of_cpu=`ls /sys/devices/system/cpu/ | grep -c cpu[0-9]`
+no_of_processor=`tst_ncpus`
+no_of_cpu=`tst_ncpus_max`
 
 if [ $no_of_processor -lt $no_of_cpu ];then
        test_op="Enable:/sys/devices/system/cpu/cpuX/online"
diff --git 
a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
 
b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
index 4b14999..bd7dcc4 100755
--- 
a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
+++ 
b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
@@ -17,12 +17,7 @@ LOOP=200
 
 # Use up to 10% of free memory
 free_mem=`cat /proc/meminfo | grep '^MemFree' | awk '{ print $2 }'`
-cpus=`cat /proc/cpuinfo | egrep "^processor.*:" | wc -l`
-
-# The Non-SMP ARM Platform could not find the "processor" from the "cpuinfo".
-if [ $cpus -eq 0 ]; then
-        cpus=1
-fi
+cpus=`tst_ncpus`
 
 step=$(( $free_mem / 10 / $LOOP / $cpus ))
 
-- 
1.8.0.rc2.4.g42e55a5


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to