[LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test

Cyril Hrubis chrubis@suse.cz
Thu Mar 17 18:19:00 CET 2016


Hi!
> +# enable the nop_test_refuse can cause an
> +# 'write error: Invalid argument'. So don't
> +# test it.
> +option_files=${option_files/test_nop_refuse/}
> +trace_options=( $option_files )
> +
> +NR_TRACE_OPTIONS=${#trace_options[*]}

This does not work even in bash because the trace_options is never
casted to array so it just returns 0.

The portable way is plain old wc:

NR=$(echo $trace_options |wc -w)

>  for ((; ; ))
>  {

Please fix these bash style loops as well.

> @@ -25,7 +31,6 @@ for ((; ; ))
>  	{
>  		num=`date +%N`
>  		num=`printf 1%s $num`
> -
>  		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
>  		{

And here.

>  			n=$(( ( $num >> $i ) % 2 ))
> @@ -34,9 +39,9 @@ for ((; ; ))
>  			else
>  				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
>  			fi
> +			[ $? -ne 0 ] && echo "setup trace option ${trace_options[$i]} failed"

Shouldn't this check be just after the echo rather than here?

>  		}
>  	}
>  
>  	sleep 1
>  }
> -
> -- 
> 1.8.3.1
> 
> 
> -- 
> Mailing list info: http://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list