torture: Add testing of RCU's Rust bindings to torture.sh
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 12 Mar 2025 22:54:48 +0000 (15:54 -0700)
committerJoel Fernandes <joelagnelf@nvidia.com>
Fri, 16 May 2025 15:12:54 +0000 (11:12 -0400)
This commit adds a --do-rcu-rust parameter to torture.sh, which invokes
a rust_doctests_kernel kunit run.  Note that kunit wants a clean source
tree, so this runs "make mrproper", which might come as a surprise to
some users.  Should there be a --mrproper parameter to torture.sh to make
the user explicitly ask for it?

Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
tools/testing/selftests/rcutorture/bin/torture.sh

index 475f758f62167e53b179f4defc959bcef2e20ce0..e03fdaca89b35561c93d198524d27cf9ab93713f 100755 (executable)
@@ -59,6 +59,7 @@ do_clocksourcewd=yes
 do_rt=yes
 do_rcutasksflavors=yes
 do_srcu_lockdep=yes
+do_rcu_rust=no
 
 # doyesno - Helper function for yes/no arguments
 function doyesno () {
@@ -89,6 +90,7 @@ usage () {
        echo "       --do-rcutorture / --do-no-rcutorture / --no-rcutorture"
        echo "       --do-refscale / --do-no-refscale / --no-refscale"
        echo "       --do-rt / --do-no-rt / --no-rt"
+       echo "       --do-rcu-rust / --do-no-rcu-rust / --no-rcu-rust"
        echo "       --do-scftorture / --do-no-scftorture / --no-scftorture"
        echo "       --do-srcu-lockdep / --do-no-srcu-lockdep / --no-srcu-lockdep"
        echo "       --duration [ <minutes> | <hours>h | <days>d ]"
@@ -191,6 +193,9 @@ do
        --do-rt|--do-no-rt|--no-rt)
                do_rt=`doyesno "$1" --do-rt`
                ;;
+       --do-rcu-rust|--do-no-rcu-rust|--no-rcu-rust)
+               do_rcu_rust=`doyesno "$1" --do-rcu-rust`
+               ;;
        --do-scftorture|--do-no-scftorture|--no-scftorture)
                do_scftorture=`doyesno "$1" --do-scftorture`
                ;;
@@ -485,6 +490,46 @@ then
        torture_set "rcurttorture-exp" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --kconfig "CONFIG_PREEMPT_RT=y CONFIG_EXPERT=y CONFIG_HZ_PERIODIC=n CONFIG_NO_HZ_FULL=y CONFIG_RCU_NOCB_CPU=y" --trust-make
 fi
 
+if test "$do_rcu_rust" = "yes"
+then
+       echo " --- do-rcu-rust:" Start `date` | tee -a $T/log
+       rrdir="tools/testing/selftests/rcutorture/res/$ds/results-rcu-rust"
+       mkdir -p "$rrdir"
+       echo " --- make LLVM=1 rustavailable " | tee -a $rrdir/log > $rrdir/rustavailable.out
+       make LLVM=1 rustavailable > $T/rustavailable.out 2>&1
+       retcode=$?
+       echo $retcode > $rrdir/rustavailable.exitcode
+       cat $T/rustavailable.out | tee -a $rrdir/log >> $rrdir/rustavailable.out 2>&1
+       buildphase=rustavailable
+       if test "$retcode" -eq 0
+       then
+               echo " --- Running 'make mrproper' in order to run kunit." | tee -a $rrdir/log > $rrdir/mrproper.out
+               make mrproper > $rrdir/mrproper.out 2>&1
+               retcode=$?
+               echo $retcode > $rrdir/mrproper.exitcode
+               buildphase=mrproper
+       fi
+       if test "$retcode" -eq 0
+       then
+               echo " --- Running rust_doctests_kernel." | tee -a $rrdir/log > $rrdir/rust_doctests_kernel.out
+               ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --make_options CLIPPY=1 --arch arm64 --kconfig_add CONFIG_SMP=y --kconfig_add CONFIG_WERROR=y --kconfig_add CONFIG_RUST=y rust_doctests_kernel >> $rrdir/rust_doctests_kernel.out 2>&1
+               # @@@ Remove "--arch arm64" in order to test on native architecture?
+               # @@@ Analyze $rrdir/rust_doctests_kernel.out contents?
+               retcode=$?
+               echo $retcode > $rrdir/rust_doctests_kernel.exitcode
+               buildphase=rust_doctests_kernel
+       fi
+       if test "$retcode" -eq 0
+       then
+               echo "rcu-rust($retcode)" $rrdir >> $T/successes
+               echo Success >> $rrdir/log
+       else
+               echo "rcu-rust($retcode)" $rrdir >> $T/failures
+               echo " --- rcu-rust Test summary:" >> $rrdir/log
+               echo " --- Summary: Exit code $retcode from $buildphase, see $rrdir/$buildphase.out" >> $rrdir/log
+       fi
+fi
+
 if test "$do_srcu_lockdep" = "yes"
 then
        echo " --- do-srcu-lockdep:" Start `date` | tee -a $T/log