Create a global variable that will look for number of cpus
for a platform and use it in multiple functions to make the
code simplier to read.
Signed-off-by: Lisa Nguyen <lisa.nguyen(a)linaro.org>
---
Changes from v1 to v2:
- Edit the command to grab the number of cpus by
adding the -1v option, showing the cpu numbers in order
for testing per Sanjay's suggestion
cpufreq/cpufreq_05.sh | 6 +++---
cpuhotplug/cpuhotplug_sanity.sh | 1 -
include/functions.sh | 13 +++++--------
include/thermal_functions.sh | 4 ++--
4 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh
index 93fce78..1f0dd8d 100755
--- a/cpufreq/cpufreq_05.sh
+++ b/cpufreq/cpufreq_05.sh
@@ -62,7 +62,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondem
if [ -z "$supported" ]; then
log_skip "ondemand not supported"
else
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
switch_ondemand $cpu
done
check_governor $cpu 'ondemand'
@@ -72,7 +72,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "conse
if [ -z "$supported" ]; then
log_skip "conservative not supported"
else
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
switch_conservative $cpu
done
check_governor $cpu 'conservative'
@@ -82,7 +82,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "users
if [ -z "$supported" ]; then
log_skip "userspace not supported"
else
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
switch_userspace $cpu
done
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh
index d9b6af8..2ad24ff 100755
--- a/cpuhotplug/cpuhotplug_sanity.sh
+++ b/cpuhotplug/cpuhotplug_sanity.sh
@@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
- cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then
diff --git a/include/functions.sh b/include/functions.sh
index e0f08fb..7a113b6 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh})
PREFIX=$TEST_NAME
INC=0
CPU=
+cpus=$(ls -1v $CPU_PATH | grep "cpu[0-9].*")
pass_count=0
fail_count=0
skip_count=0
@@ -86,7 +87,6 @@ for_each_cpu() {
local func=$1
shift 1
- cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
for cpu in $cpus; do
INC=0
CPU=/$cpu
@@ -339,8 +339,8 @@ save_governors() {
governors_backup=
local index=0
- for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
- governors_backup[$index]=$(cat $CPU_PATH/$i/cpufreq/scaling_governor)
+ for cpu in $cpus; do
+ governors_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_governor)
index=$((index + 1))
done
}
@@ -350,9 +350,9 @@ restore_governors() {
local index=0
local oldgov=
- for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
oldgov=${governors_backup[$index]}
- echo $oldgov > $CPU_PATH/$i/cpufreq/scaling_governor
+ echo $oldgov > $CPU_PATH/$cpu/cpufreq/scaling_governor
index=$((index + 1))
done
}
@@ -361,8 +361,6 @@ save_frequencies() {
frequencies_backup=
local index=0
- local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
- local cpu=
for cpu in $cpus; do
frequencies_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_cur_freq)
@@ -374,7 +372,6 @@ restore_frequencies() {
local index=0
local oldfreq=
- local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
for cpu in $cpus; do
oldfreq=${frequencies_backup[$index]}
diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh
index a51240b..c25e1d8 100644
--- a/include/thermal_functions.sh
+++ b/include/thermal_functions.sh
@@ -184,7 +184,7 @@ check_scaling_freq() {
local index=0
local flag=0
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
if [ $before_freq_list[$index] -ne $afterf_req_list[$index] ] ; then
flag=1
fi
@@ -197,7 +197,7 @@ store_scaling_maxfreq() {
scale_freq=
local index=0
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
scale_freq[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_max_freq)
index=$((index + 1))
done
--
1.7.9.5
== Progress ==
* Enabling UEFI Fastboot on Panda - on hold (CARD-198: 0 %)
* CARD 1103: Flash support on u-boot fastboot (CARD-1103: 100%)
- fixed checkpatch.pl issues, sent v2 of patches for review
- Testing the flashing functionality
== Plans ==
* CARD-198: Start working on the activity on Panda/BBB (50%)
* CARD 1103: fastboot flash command (CARD-1103: 60%)
- Fix the issues in booting from the flashed image
- rework on the review comments, if any
== Issues ==
* None
= Progress ==
* Buildd-tending: Debian arm64 is at 84% built (DEVPLAT-226: 5%)
http://buildd.debian-ports.org/stats/graph-quarter-big.png
* binNMUed packages for arm64 debian-installer builds
* rt-app accepted in debian. Asked rt-app authors to clarify GPL2/GPL2+ licencing
* Fix and uploaded previously failed uploads: gtkgl2, exiv2 (DEVPLAT-226: 10%)
* Unblocked blender cycle with opencolorio/openimageio
* Doubled memory on 2nd buildd (but ghc builds still run out). (DEVPLAT-226: 2%)
* Built ghc manually on bigger buildd (DEVPLAT-226: 5%)
* Investigated persistently failing package builds (DEVPLAT-221: 15%)
* Fixed libfm, rrdtool breakge (DEVPLAT-221: 10%)
* Found rdeps of mpi-defaults. Did 15 binnmus +giveback to transition: (DEVPLAT-221: 10%)
* Worked on openjade (crufty codebase need autofoo updates). (DEVPLAT-226: 20%)
* Wrote card for official debian bootstrap
* Investigated gcc-4.9 failure. Bug filed (DEVPLAT-226: 5%)
* Tracked notmuch failure down to gdb/ptrace/kernel issue. Bug filed. (DEVPLAT-221: 10%)
* Made current list/set of binaries to prime official new buildds with
* GSOC catch-up with student after hols
* BUilt updated cross-binutils packages - uploaded (DEVPLAT-220: 5%)
* Worked on breakage in current cross-gcc packages for upcoming sprint: (DEVPLAT-220: 5%)
== Plans ==
* Get cross-toolchain packages into buildable state
* Add multiarch builds to sbuild
* Fix/NMU remaining packages in SCC http://people.debian.org/~wookey/bootstrap/blockerlist
== Issues ==
Wookey
--
Principal hats: Linaro, Emdebian, Wookware, Balloonboard, ARM
http://wookware.org/
Create a global variable that will look for number of cpus
for a platform and use it in multiple functions to make the
code simplier to read.
Signed-off-by: Lisa Nguyen <lisa.nguyen(a)linaro.org>
---
cpufreq/cpufreq_05.sh | 6 +++---
cpuhotplug/cpuhotplug_sanity.sh | 1 -
include/functions.sh | 13 +++++--------
include/thermal_functions.sh | 4 ++--
4 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh
index 93fce78..1f0dd8d 100755
--- a/cpufreq/cpufreq_05.sh
+++ b/cpufreq/cpufreq_05.sh
@@ -62,7 +62,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondem
if [ -z "$supported" ]; then
log_skip "ondemand not supported"
else
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
switch_ondemand $cpu
done
check_governor $cpu 'ondemand'
@@ -72,7 +72,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "conse
if [ -z "$supported" ]; then
log_skip "conservative not supported"
else
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
switch_conservative $cpu
done
check_governor $cpu 'conservative'
@@ -82,7 +82,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "users
if [ -z "$supported" ]; then
log_skip "userspace not supported"
else
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
switch_userspace $cpu
done
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh
index d9b6af8..2ad24ff 100755
--- a/cpuhotplug/cpuhotplug_sanity.sh
+++ b/cpuhotplug/cpuhotplug_sanity.sh
@@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
- cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then
diff --git a/include/functions.sh b/include/functions.sh
index e0f08fb..74b2294 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh})
PREFIX=$TEST_NAME
INC=0
CPU=
+cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
pass_count=0
fail_count=0
skip_count=0
@@ -86,7 +87,6 @@ for_each_cpu() {
local func=$1
shift 1
- cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
for cpu in $cpus; do
INC=0
CPU=/$cpu
@@ -339,8 +339,8 @@ save_governors() {
governors_backup=
local index=0
- for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
- governors_backup[$index]=$(cat $CPU_PATH/$i/cpufreq/scaling_governor)
+ for cpu in $cpus; do
+ governors_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_governor)
index=$((index + 1))
done
}
@@ -350,9 +350,9 @@ restore_governors() {
local index=0
local oldgov=
- for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
oldgov=${governors_backup[$index]}
- echo $oldgov > $CPU_PATH/$i/cpufreq/scaling_governor
+ echo $oldgov > $CPU_PATH/$cpu/cpufreq/scaling_governor
index=$((index + 1))
done
}
@@ -361,8 +361,6 @@ save_frequencies() {
frequencies_backup=
local index=0
- local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
- local cpu=
for cpu in $cpus; do
frequencies_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_cur_freq)
@@ -374,7 +372,6 @@ restore_frequencies() {
local index=0
local oldfreq=
- local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
for cpu in $cpus; do
oldfreq=${frequencies_backup[$index]}
diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh
index a51240b..c25e1d8 100644
--- a/include/thermal_functions.sh
+++ b/include/thermal_functions.sh
@@ -184,7 +184,7 @@ check_scaling_freq() {
local index=0
local flag=0
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
if [ $before_freq_list[$index] -ne $afterf_req_list[$index] ] ; then
flag=1
fi
@@ -197,7 +197,7 @@ store_scaling_maxfreq() {
scale_freq=
local index=0
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do
+ for cpu in $cpus; do
scale_freq[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_max_freq)
index=$((index + 1))
done
--
1.7.9.5
Remove the pass and fail count variables from the check()
function as all the pass/fail/skip counts are done inside
the log_end() function.
Signed-off-by: Lisa Nguyen <lisa.nguyen(a)linaro.org>
---
Note: This was supposed to be part of the refactored
pass/skip/fail code, but it got overlooked.
include/functions.sh | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/functions.sh b/include/functions.sh
index 82d8139..e0f08fb 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -265,13 +265,11 @@ check() {
$func $@
if [ $? -ne 0 ]; then
- log_end "Err"
- fail_count=$(($fail_count + 1))
- return 1
+ log_end "Err"
+ return 1
fi
log_end "Ok"
- pass_count=$(($pass_count + 1))
return 0
}
--
1.7.9.5
== Progress ==
* Integrate VPS into the build (CARD-789, 20%)
* Setup Juno build based on master snapshot from 29th July (CARD-789, 20%)
* Visa Documentation and submission (20%)
== Plans ==
* CI and LAVA for SWG - ARMv7 TEE testing (CARD-1109)
Regards,
Vishal