[DTrace-devel] [PATCH v2 2/2] tests, actions: fix tst.symmod.sh

Eugene Loh eugene.loh at oracle.com
Tue Feb 13 03:56:53 UTC 2024


The comment about never using shuf does not belong in the commit message.

The indentation in the file is with tabs, so that style should be preserved.

Instead of inflooping (in flooping?), how about "infinitely looping".  
(I do find some occurrences of "inflooping" on the internet, but might 
as well be less slangy?)

Anyhow, instead of the shuffle approach, how about "awk 'NF == 4' 
/proc/kallsyms" to a temp file and use that?

But even that won't be enough.  Once you allow "any" symbol from 
/proc/kallsyms, you risk encountering symbols that DTrace doesn't know 
about.  Stuff like __ksymtab* and __kstrtab* and others.  I think we 
filter that stuff out in dt_modsym_addsym().  The same filtering is done 
in test/unittest/consumer/tst.symbols.c.  It's the headache one saves by 
going after a specific symbol like ksys_write.

On 2/12/24 11:21, Nick Alcock wrote:
> This test needed adjusting for /proc/kallsyms support, which means we can't
> handle built-in modules any more: so gain a bit of function to make up for
> it by picking a random modular symbol instead of always using ksys_write.
>
> This exposed another bug: when a modular symbol is picked, it doesn't strip
> off the []s from the module name, causing a spurious test failure.
>
> (This is the first time I have ever had reason to use shuf(1).)
>
> Signed-off-by: Nick Alcock<nick.alcock at oracle.com>
> ---
>   test/unittest/actions/symmod/tst.symmod.sh | 20 +++++++++++++-------
>   1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/test/unittest/actions/symmod/tst.symmod.sh b/test/unittest/actions/symmod/tst.symmod.sh
> index 340baf53e7bb..0625ae01f366 100755
> --- a/test/unittest/actions/symmod/tst.symmod.sh
> +++ b/test/unittest/actions/symmod/tst.symmod.sh
> @@ -1,20 +1,26 @@
>   #!/bin/bash
>   #
>   # Oracle Linux DTrace.
> -# Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2021, 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
>   
> -# pick a test symbol from /proc/kallmodsyms
> -read ADD NAM MOD <<< `awk '/ksys_write/  {print $1, $4, $5}' /proc/kallmodsyms`
> +# Skip on a non-modular kernel, rather than inflooping.
>   
> -# a blank module means the module is vmlinux
> -if [ x$MOD == x ]; then
> -	MOD=vmlinux
> -fi
> +[[ ! -e /proc/modules ]] && exit 67
> +
> +# pick a test symbol from /proc/kallsyms: if we get no module, keep trying,
> +# because a blank module might be vmlinux or might be built-in.  (We cannot
> +# validate these given only /proc/kallsyms: the test would need to scan
> +# vmlinux.ranges as well.)
> +MOD=
> +while [[ -z $MOD ]]; do
> +    read ADD NAM MOD <<< `shuf /proc/kallsyms | head -1 | awk '{print $1, $3, gensub(/[[\]]/,"","g", $4)}'`
> +    [[ -z $MOD ]] && continue;
> +done
>   
>   # add the module to the name
>   NAM=$MOD'`'$NAM
> -- 2.43.0.272.gce700b77fd



More information about the DTrace-devel mailing list