All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] commands/sysctl: Add new regression test for invalid sched_time_avg
Date: Tue, 6 Mar 2018 13:42:42 +0100	[thread overview]
Message-ID: <20180306124242.GC16934@rei.lan> (raw)
In-Reply-To: <1516695452-23224-1-git-send-email-yangx.jy@cn.fujitsu.com>

Hi!
> +TST_TESTFUNC=sysctl_test
> +TST_NEEDS_CMDS="sysctl"
> +
> +. tst_test.sh
> +
> +get_value()
> +{
> +	local value=$(sysctl -n $1)
> +	[ -z "$value" ] && tst_brk TBROK \
> +		"Failed to get the value of sched_time_avg(_ms)"
> +
> +	echo $value
> +}
> +
> +sysctl_test()
> +{
> +	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
> +	local name=$(sysctl -a 2>&1 | egrep -o \
> +		'kernel.(sched_time_avg|sched_time_avg_ms)')
> +	[ -z "$name" ] && tst_brk TCONF \
> +		"sched_time_avg(_ms) was not supported"

Can't we just do?

if [ -e /proc/sys/kernel/sched_time_avg_ms ]; then
	name=...
fi

if [ -e /proc/sys/kernel/sched_time_avg ]; then
	name=...
fi

[ -z "$name" ] ...

> +	local orig_value=$(get_value $name)
> +
> +	sysctl -w $name=0 >/dev/null 2>&1
> +
> +	# Increase the chance of exposing the problem on RHEL6
> +	sleep 3

What is this sleep good for? Do we wait here for the kernel to crash?

> +	local curr_value=$(get_value $name)
> +
> +	if [ ${curr_value} -eq ${orig_value} ]; then
> +		tst_res TPASS "Setting sched_time_avg(_ms) failed"
> +	else
> +		tst_res TFAIL "Setting sched_time_avg(_ms) succeeded"
> +		sysctl -w $name=${orig_value} >/dev/null 2>&1
> +	fi
> +}
> +
> +tst_run
> -- 
> 1.8.3.1
> 
> 
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2018-03-06 12:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23  8:17 [LTP] [PATCH] commands/sysctl: Add new regression test for invalid sched_time_avg Xiao Yang
2018-02-12  9:03 ` Xiao Yang
2018-03-02  9:19 ` Xiao Yang
2018-03-06 12:42 ` Cyril Hrubis [this message]
2018-03-07  3:51   ` Xiao Yang
2018-03-14 17:01     ` Cyril Hrubis
2018-03-15  8:22       ` [LTP] [PATCH v3] " Xiao Yang
2018-03-15 12:21         ` Cyril Hrubis
2018-03-15  8:27       ` [LTP] [PATCH] " Xiao Yang
2018-03-07  4:35   ` [LTP] [PATCH v2] " Xiao Yang
2018-03-14  1:26     ` Xiao Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180306124242.GC16934@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.