[DTrace-devel] [PATCH 3/4] test: -xcpu for just one CPU, loop over all CPUs in stress test (profile)

Kris Van Hees kris.van.hees at oracle.com
Tue Jan 23 05:52:59 UTC 2024


On Mon, Jan 22, 2024 at 07:57:12PM -0500, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

> ---
>  test/stress/options/tst.cpu-profile.sh   | 27 ++++++++++++++++++++++++
>  test/stress/options/tst.cpu-tick.sh      | 27 ++++++++++++++++++++++++
>  test/unittest/options/tst.cpu-profile.sh | 27 ++++++++++++++----------
>  test/unittest/options/tst.cpu-tick.sh    | 27 ++++++++++++++----------
>  4 files changed, 86 insertions(+), 22 deletions(-)
>  create mode 100755 test/stress/options/tst.cpu-profile.sh
>  create mode 100755 test/stress/options/tst.cpu-tick.sh
> 
> diff --git a/test/stress/options/tst.cpu-profile.sh b/test/stress/options/tst.cpu-profile.sh
> new file mode 100755
> index 00000000..51745f8b
> --- /dev/null
> +++ b/test/stress/options/tst.cpu-profile.sh
> @@ -0,0 +1,27 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +#
> +
> +dtrace=$1
> +
> +nerr=0
> +
> +# Loop over CPUs.
> +for cpu0 in `awk '/^processor[ 	]*: [0-9]*$/ {print $3}' /proc/cpuinfo`; do
> +	# Observe where DTrace runs.
> +	cpu=`$dtrace $dt_flags -xcpu=$cpu0 -qn 'profile-100ms { trace(cpu); exit(0); }'`
> +
> +	# Check result.
> +	echo expected cpu $cpu0 got cpu $cpu
> +	if [ `echo $cpu | wc -w` -ne 1 ]; then
> +		nerr=$(($nerr + 1))
> +	elif [ $(($cpu + 0)) != $cpu0 ]; then
> +		nerr=$(($nerr + 1))
> +	fi
> +done
> +
> +exit $nerr
> diff --git a/test/stress/options/tst.cpu-tick.sh b/test/stress/options/tst.cpu-tick.sh
> new file mode 100755
> index 00000000..0d0c04d7
> --- /dev/null
> +++ b/test/stress/options/tst.cpu-tick.sh
> @@ -0,0 +1,27 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +#
> +
> +dtrace=$1
> +
> +nerr=0
> +
> +# Loop over CPUs.
> +for cpu0 in `awk '/^processor[ 	]*: [0-9]*$/ {print $3}' /proc/cpuinfo`; do
> +	# Observe where DTrace runs.
> +	cpu=`$dtrace $dt_flags -xcpu=$cpu0 -qn 'tick-100ms { trace(cpu); exit(0); }'`
> +
> +	# Check result.
> +	echo expected cpu $cpu0 got cpu $cpu
> +	if [ `echo $cpu | wc -w` -ne 1 ]; then
> +		nerr=$(($nerr + 1))
> +	elif [ $(($cpu + 0)) != $cpu0 ]; then
> +		nerr=$(($nerr + 1))
> +	fi
> +done
> +
> +exit $nerr
> diff --git a/test/unittest/options/tst.cpu-profile.sh b/test/unittest/options/tst.cpu-profile.sh
> index 6c43a2f5..9efe12db 100755
> --- a/test/unittest/options/tst.cpu-profile.sh
> +++ b/test/unittest/options/tst.cpu-profile.sh
> @@ -8,15 +8,20 @@
>  
>  dtrace=$1
>  
> -nerr=0
> -for cpu0 in `awk '/^processor[ 	]*: [0-9]*$/ {print $3}' /proc/cpuinfo`; do
> -	cpu=`$dtrace $dt_flags -xcpu=$cpu0 -qn 'profile-100ms { trace(cpu); exit(0); }'`
> -	echo expected cpu $cpu0 got cpu $cpu
> -	if [ `echo $cpu | wc -w` -ne 1 ]; then
> -		nerr=$(($nerr + 1))
> -	elif [ $(($cpu + 0)) != $cpu0 ]; then
> -		nerr=$(($nerr + 1))
> -	fi
> -done
> +# Pick a CPU at random.
> +cpulist=( `awk '/^processor[ 	]*: [0-9]*$/ {print $3}' /proc/cpuinfo` )
> +ncpus=${#cpulist[@]}
> +cpu0=${cpulist[$((RANDOM % $ncpus))]}
>  
> -exit $nerr
> +# Observe where DTrace runs.
> +cpu=`$dtrace $dt_flags -xcpu=$cpu0 -qn 'profile-100ms { trace(cpu); exit(0); }'`
> +
> +# Check result.
> +echo expected cpu $cpu0 got cpu $cpu
> +if [ `echo $cpu | wc -w` -ne 1 ]; then
> +	exit 1
> +elif [ $(($cpu + 0)) != $cpu0 ]; then
> +	exit 1
> +fi
> +
> +exit 0
> diff --git a/test/unittest/options/tst.cpu-tick.sh b/test/unittest/options/tst.cpu-tick.sh
> index 9463f3ef..88163acc 100755
> --- a/test/unittest/options/tst.cpu-tick.sh
> +++ b/test/unittest/options/tst.cpu-tick.sh
> @@ -8,15 +8,20 @@
>  
>  dtrace=$1
>  
> -nerr=0
> -for cpu0 in `awk '/^processor[ 	]*: [0-9]*$/ {print $3}' /proc/cpuinfo`; do
> -	cpu=`$dtrace $dt_flags -xcpu=$cpu0 -qn 'tick-100ms { trace(cpu); exit(0); }'`
> -	echo expected cpu $cpu0 got cpu $cpu
> -        if [ `echo $cpu | wc -w` -ne 1 ]; then
> -		nerr=$(($nerr + 1))
> -        elif [ $(($cpu + 0)) != $cpu0 ]; then
> -		nerr=$(($nerr + 1))
> -	fi
> -done
> +# Pick a CPU at random.
> +cpulist=( `awk '/^processor[ 	]*: [0-9]*$/ {print $3}' /proc/cpuinfo` )
> +ncpus=${#cpulist[@]}
> +cpu0=${cpulist[$((RANDOM % $ncpus))]}
>  
> -exit $nerr
> +# Observe where DTrace runs.
> +cpu=`$dtrace $dt_flags -xcpu=$cpu0 -qn 'tick-100ms { trace(cpu); exit(0); }'`
> +
> +# Check result.
> +echo expected cpu $cpu0 got cpu $cpu
> +if [ `echo $cpu | wc -w` -ne 1 ]; then
> +	exit 1
> +elif [ $(($cpu + 0)) != $cpu0 ]; then
> +	exit 1
> +fi
> +
> +exit 0
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list