1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. 4f08c3bdfSopenharmony_ci# Author: Xiao Yang <yangx.jy@cn.fujitsu.com> 5f08c3bdfSopenharmony_ci# 6f08c3bdfSopenharmony_ci# This is a regression test for invalid value of sysctl_sched_time_avg. 7f08c3bdfSopenharmony_ci# System will hang if user set sysctl_sched_time_avg to 0 on buggy kernel. 8f08c3bdfSopenharmony_ci# 9f08c3bdfSopenharmony_ci# The kernel bug has been fixed in kernel: 10f08c3bdfSopenharmony_ci# '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")' 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ciTST_TESTFUNC=sysctl_test 13f08c3bdfSopenharmony_ciTST_NEEDS_ROOT=1 14f08c3bdfSopenharmony_ciTST_NEEDS_CMDS="sysctl" 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_cisysctl_test() 17f08c3bdfSopenharmony_ci{ 18f08c3bdfSopenharmony_ci # With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms 19f08c3bdfSopenharmony_ci local dir="/proc/sys/kernel/" 20f08c3bdfSopenharmony_ci [ -e "$dir""sched_time_avg_ms" ] && local name="sched_time_avg_ms" 21f08c3bdfSopenharmony_ci [ -e "$dir""sched_time_avg" ] && local name="sched_time_avg" 22f08c3bdfSopenharmony_ci [ -z "$name" ] && tst_brk TCONF \ 23f08c3bdfSopenharmony_ci "sched_time_avg(_ms) was not supported" 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_ci local orig_value=$(cat "$dir""$name") 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci sysctl -w "kernel.""$name"=0 >/dev/null 2>&1 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci local test_value=$(cat "$dir""$name") 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci if [ ${test_value} -eq ${orig_value} ]; then 32f08c3bdfSopenharmony_ci tst_res TPASS "Setting $name failed" 33f08c3bdfSopenharmony_ci else 34f08c3bdfSopenharmony_ci tst_res TFAIL "Setting $name succeeded" 35f08c3bdfSopenharmony_ci sysctl -w "kernel.""$name"=${orig_value} >/dev/null 2>&1 36f08c3bdfSopenharmony_ci fi 37f08c3bdfSopenharmony_ci} 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci. tst_test.sh 40f08c3bdfSopenharmony_citst_run 41