public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API
Date: Wed, 4 May 2016 16:56:30 +0200	[thread overview]
Message-ID: <20160504145630.GE12244@rei.lan> (raw)
In-Reply-To: <1460966656-28328-10-git-send-email-chuhu@redhat.com>

Hi!
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
> @@ -26,20 +26,20 @@ if [ $step -eq 0 ]; then
>  	LOOP=50
>  fi
>  
> -for ((; ;))
> -{
> +while true; do
>  	new_size=1
> -	for ((i = 0; i < $LOOP; i++))
> -	{
> +	i=0;

The semicolon after i=0 is useless (and in all i=0; lines in this
patch).

...

> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
> index de6bbea..70135c1 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
> @@ -13,6 +13,9 @@
>  #                                                                             #
>  ###############################################################################
>  
> +. test.sh

No need to source test.sh for the tst_kvercmp which is a separate
binary.

> +TRACING_PATH=/sys/kernel/debug/tracing/

Shouldn't this be propagated from the main script? What's the point of
redefining it here?

>  LOOP=400
>  
>  # In kernel which is older than 2.6.32, we set global clock
> @@ -24,23 +27,23 @@ else
>          old_kernel=0
>  fi
>  
> -for ((; ;))
> -{
> -	if [ $old_kernel -eq 1 ];
> -	then
> -		for ((i = 0; i < $LOOP; i++))
> -		{
> +while true; do
> +	i=0;
> +	if [ $old_kernel -eq 1 ]; then
> +		while [ $i -lt $LOOP ]; do
>  			echo 1 > "$TRACING_PATH"/options/global-clock
>  			echo 0 > "$TRACING_PATH"/options/global-clock
> -		}
> +			i=$((i + 1))
> +		done
>  	else
> -		for ((i = 0; i < $LOOP; i++))
> -		{
> +		while [ $i -lt $LOOP ]; do
>  			echo local > "$TRACING_PATH"/trace_clock
>  			echo global > "$TRACING_PATH"/trace_clock
> -		}
> +			i=$((i + 1))
> +		done
> +
>  	fi
>  
>  	sleep 1
> -}
> +done
>  
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
> index 47d42bc..a24008a 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
> @@ -13,10 +13,11 @@
>  #                                                                             #
>  ###############################################################################
>  
> +. test.sh

You don't have to add test.sh for tst_sleep.

>  ftrace_sleep()
>  {
> -	# usleep is not a standard command?
> -	usleep 200000 2> /dev/null
> +	tst_sleep 200000us
>  	if [ $? -ne 0 ]; then
>  		sleep 1
>  	fi

You should remove the fallback to sleep 1 if the usleep wasn't found.
Ideally the whole function ftrace_sleep should be removed and you should
just call tst_sleep from the main loop.

> @@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1
>  
>  LOOP=20
>  
> -for ((; ;))
> -{
> -	for ((i = 0; i < $LOOP; i++))
> -	{
> +while true; do
> +	i=0;
> +	while [ $i -lt $LOOP ]; do
>  		cat "$TRACING_PATH"/trace_pipe > /dev/null &
>  
>  		this_pid=$!
> @@ -45,8 +45,7 @@ for ((; ;))
>  		wait $this_pid
>  		this_pid=0
>  		ftrace_sleep
> -	}
> -
> +		i=$((i + 1))
> +	done
>  	sleep 2
> -}
> -
> +done

And you should also fix the kill called by the full path in this script.
It should really be just kill not /bin/kill.

> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
> index d7e6fd3..2691991 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
> @@ -16,6 +16,8 @@
>  LOOP=200
>  
>  should_skip=0
> +rand_gen=tst_random

What's the point of assigning tst_random into a variable instead of
using it directly?

> +nr_cpus=`tst_ncpus`
>  
>  if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
>          should_skip=1
> @@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then
>  	should_skip=1
>  fi
>  
> -for ((; ;))
> -{
> +while true; do
>  	if [ $should_skip -eq 1 ]; then
>  		sleep 2
>  		continue
>  	fi
> -
> -	for ((i = 0; i < $LOOP; i++))
> -	{
> -		cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1
> -	}
> +	cpu=$($rand_gen 0 $((nr_cpus - 1)))
> +	i=0;
> +	while [ $i -lt $LOOP ]; do
> +		cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1
> +		i=$((i + 1))
> +	done
>  
>  	sleep 1
> -}
> -
> +done

...

> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
> index fbaceb8..6090a91 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
> @@ -15,12 +15,13 @@
>  
>  MAX_LATENCY=100000
>  
> -for ((; ;))
> -{
> -	for ((i = 0; i < $MAX_LATENCY; i += 400))
> -	{
> +while true; do
> +	i=0;
> +	while [ $i -lt $MAX_LATENCY ]; do
>  		echo $i > "$TRACING_PATH"/tracing_max_latency
> -	}
> +		i=$((i + 400))
> +	done
>  
>  	sleep 1
> -}
> +
> +Vdone
   ^
   Typo?

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-05-04 14:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18  8:04 [LTP] [PATCH V2 0/9] tracing: make ftrace tests to be extended Chunyu Hu
2016-04-18  8:04 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu
2016-04-18  8:04   ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu
2016-04-18  8:04     ` [LTP] [PATCH V2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu
2016-04-18  8:04       ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Chunyu Hu
2016-04-18  8:04         ` [LTP] [PATCH V2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu
2016-04-18  8:04           ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu
2016-04-18  8:04             ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Chunyu Hu
2016-04-18  8:04               ` [LTP] [PATCH V2 8/9] ftrace_stress: add two new tests Chunyu Hu
2016-04-18  8:04                 ` [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API Chunyu Hu
2016-05-04 14:56                   ` Cyril Hrubis [this message]
2016-05-04 15:42                     ` Chunyu Hu
2016-05-04 16:32                       ` Cyril Hrubis
2016-05-05  7:44                       ` Chunyu Hu
2016-05-10 14:13                         ` Cyril Hrubis
2016-05-11 11:01                           ` Chunyu Hu
2016-05-04 16:57               ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Cyril Hrubis
2016-05-04 13:34             ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis
2016-05-04 15:04               ` Chunyu Hu
2016-05-04 15:55                 ` Cyril Hrubis
2016-05-04 16:28                   ` Chunyu Hu
2016-05-04 23:40                     ` Chunyu Hu
2016-05-04 16:50         ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Cyril Hrubis
2016-05-05  0:53           ` Chunyu Hu
2016-05-10 14:25             ` Cyril Hrubis
2016-05-11 11:14               ` Chunyu Hu
2016-05-04 16:00     ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Cyril Hrubis
2016-05-05  6:24       ` Li Wang
2016-05-04 16:26   ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Cyril Hrubis
2016-05-05  6:21     ` Li Wang
2016-05-05 10:11     ` Chunyu Hu
2016-05-05 10:53       ` Chunyu Hu

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=20160504145630.GE12244@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox