diff --git a/tests/stress/cpu/cpu_calc_power.sh b/tests/stress/cpu/cpu_calc_power.sh index d87b32eeeb125edd23fa82d788d428c698397207..6960cf805f1e05bc62ab5692ee92b3b9a1700c87 100644 --- a/tests/stress/cpu/cpu_calc_power.sh +++ b/tests/stress/cpu/cpu_calc_power.sh @@ -30,10 +30,10 @@ function cpu_calc_power_test() { else echo "warning: No cpu is online." && test_skip fi - cpuload_monitor_on_usr $cpu_used_nums & check_cmd "stress-ng" - run_cmd "stress-ng --cpu $cpu_used_nums --cpu-method all --verify --timeout=$RUNTIME" + run_cmd "stress-ng --cpu $cpu_used_nums --cpu-method all --verify --timeout=$RUNTIME" & + cpuload_monitor_on_usr $cpu_used_nums & wait echo "Check cpu load log" diff --git a/tests/stress/cpu/cpu_stress.sh b/tests/stress/cpu/cpu_stress.sh index 02d64426a77c8e94c861e3e35f770c3b5f1c7aac..9bbb3ce9709c6ace21a89077fc58fc21d19c0b0b 100644 --- a/tests/stress/cpu/cpu_stress.sh +++ b/tests/stress/cpu/cpu_stress.sh @@ -25,7 +25,7 @@ function cpuload_monitor_on_usr() { local has_cpu_on_off_during_stress=${2:-"false"} local count=0 local cur_name - local usr_ratio + local usr_ratio min_ratio=100 check_cmd "mpstat" echo "==================[CPULOAD monitor $(($RUNTIME - 10 ))s]===================" >> $CPU_LOAD_RESULTS_LOG @@ -36,6 +36,9 @@ function cpuload_monitor_on_usr() { fi while read line;do usr_ratio="$(echo "$line"|awk '{print $3}')" + if [ $(echo "$usr_ratio > 10"|bc) -eq 1 ];then + [ $(echo "$usr_ratio > $min_ratio"|bc) -eq 1 ] || min_ratio=$usr_ratio + fi if "$has_cpu_on_off_during_stress";then if [ $(echo "$usr_ratio > 20"|bc) -eq 1 ];then ((count++)) @@ -53,7 +56,8 @@ function cpuload_monitor_on_usr() { all_average="$(grep all $CPU_LOAD_LOG|awk '{print $3}')" error_num="$(echo "scale=3;($cpu_nums - $count)/$cpu_nums"|bc)" if [ $count -ge $cpu_nums ] || [ $(echo "$error_num < 0.05"|bc) -eq 1 ] || [ $(top -H -b -n1|grep -w stress-ng-cpu|wc -l) -ge $cpu_nums ] \ - || (! $has_cpu_on_off_during_stress && [ $(echo "$all_average > 90"|bc) -eq 1 ]) || ( $has_cpu_on_off_during_stress && [ $(echo "$all_average > 20"|bc) -eq 1 ]) ;then + || (! $has_cpu_on_off_during_stress && [ $(echo "$all_average > 90"|bc) -eq 1 ]) || ( $has_cpu_on_off_during_stress && [ $(echo "$all_average > 20"|bc) -eq 1 ]) \ + || (! $has_cpu_on_off_during_stress && [ $(echo "$min_ratio > 20"|bc) -eq 1 ]);then echo -e "[CPU FULL lOAD(100.00%),AVERAGE(>20% or 90%),Deviation 5%]: count($count)--->cpu used($cpu_nums)\n$cur_name" >> $CPU_LOAD_RESULTS_LOG echo "Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle" >> $CPU_LOAD_RESULTS_LOG cat $CPU_LOAD_LOG >> $CPU_LOAD_RESULTS_LOG