1#!/bin/sh 2################################################################################ 3# 4# Copyright (C) 2022 Huawei Device Co., Ltd. 5# SPDX-License-Identifier: GPL-2.0 6# 7# Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. 8# Do not use in new code. 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17# File: sched_rtg06.sh 18# 19# Description: sched RTG Stability test 20# 21# Authors: liudanning - liudanning@h-partners.com 22# 23# History: April 6 2022 - init scripts 24# 25################################################################################ 26 27source tst_oh.sh 28 29do_setup() 30{ 31 dmesg -c 32 PPID=$(ps -ef | grep "/sched_rtg06.sh" | grep -v grep | awk '{print $3}') 33} 34 35do_test() 36{ 37 stability_test randmom 38 39 stability_test ordered 40 41 stability_test all 42} 43 44stability_test() 45{ 46 sh create_process.sh 40 47 if [ "$1" == "randmom" ]; then 48 tst_res TINFO "All 40 porcesss join random rtg from 2 to 20" 49 random_rtg 50 fi 51 52 if [ "$1" == "ordered" ]; then 53 tst_res TINFO "All 40 processes join rtg from 2 to 20 one by one" 54 ordered_rtg 55 fi 56 57 if [ "$1" == "all" ]; then 58 tst_res TINFO "All 40 processes join rtg 2" 59 all_in_one_rtg 60 fi 61 sleep 60 62 tst_res TINFO "kill 40 loop processes...." 63 ps -ef | grep "sched_rtg06.sh" | grep -v "grep" | grep -v ${PPID} | cut -c 9-18 | xargs kill -9 64 tst_res TINFO "kill 40 task processes...." 65 ps -ef | grep "create_process" | grep -v "grep" | grep -v ${PPID} | cut -c 9-18 | xargs kill -9 66 sleep 5 67 tst_res TINFO "kill process successed." 68 aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility && 69 sleep 1 && 70 PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') 71 if [ $? -eq 0 ]; then 72 dmesg | grep "BUG" || 73 dmesg | grep "panic" || 74 dmesg | grep "Unable to handle kernel" || 75 dmesg | grep "WARNING:" 76 if [ $? -eq 0 ]; then 77 tst_res TFAIL "$1 test error messages found!" 78 else 79 tst_res TPASS "sched RTG Stability $1 test success." 80 fi 81 else 82 tst_res TFAIL "sched RTG Stability $1 test failed!" 83 fi 84 aa force-stop ohos.samples.ecg 85} 86 87 88 89random_rtg() 90{ 91 for i in $(seq 1 40); do 92 { 93 while true; do 94 echo $((RANDOM % 19 + 2)) > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 95 sleep 0.1 96 echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 97 sleep 0.2 98 done 99 }& 100 done 101} 102 103ordered_rtg() 104{ 105 for i in $(seq 1 40); do 106 { 107 if [ ${i} -le 20 ]; then 108 while true; do 109 echo ${i} > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 110 sleep 0.1 111 echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 112 sleep 0.2 113 done & 114 else 115 while true; do 116 echo 2 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 117 sleep 0.1 118 echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 119 sleep 0.2 120 done 121 fi 122 }& 123 done 124} 125 126all_in_one_rtg() 127{ 128 local _rtg_id=$((RANDOM % 19 + 2)) 129 for i in $(seq 1 40); do 130 { 131 while true; do 132 echo $_rtg_id > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 133 sleep 0.1 134 echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id 135 sleep 0.2 136 done 137 }& 138 done 139} 140 141do_clean() 142{ 143 rm -rf taskpid.txt 144} 145 146do_setup 147do_test 148do_clean 149tst_exit