systemtap-static-probes-in-ruby: Add assertion to check stap command.

The assertion is to detect a stap command error not depending on Ruby, and also
to make us report an error to the rpms/systemtap easier.

You can see the upstream systemtap routine builds when an error happens on
Fedora rawhide. There may be the same error on the latest build.
https://builder.sourceware.org/buildbot/#/builders/systemtap-fedrawhide-x86_64

For example, the assertion can catch the following stap command error.

```
$ tmt -c distro=fedora-rawhide run --all provision -h virtual -i fedora-rawhide tests -n '^/systemtap-static-probes-in-ruby$'
/var/tmp/tmt/run-014
...
total: 1 warn

$ echo $?
1

$ tmt run --id run-014 report -vvv
...
                    :: [ 23:29:01 ] :: [  BEGIN   ] :: Checking stap to detect an error not depending on Ruby :: actually running 'stap -v -e 'probe begin { exit() }''
                    Pass 1: parsed user script and 586 library scripts using 314412virt/282316res/16080shr/267544data kb, in 470usr/90sys/698real ms.
                    Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using 324576virt/293092res/16744shr/277708data kb, in 30usr/10sys/37real ms.
                    Pass 3: translated to C into "/tmp/stapVBIxqm/stap_17cbdff69dacffb521a9178adb053400_1161_src.c" using 324576virt/293408res/17060shr/277708data kb, in 0usr/0sys/0real ms.
                    <command-line>: fatal error: /tmp/stapVBIxqm/stapconf_7fa4e6888ba17abb7b5cc888ef91222c_947.h: No such file or directory
                    compilation terminated.
                    <command-line>: fatal error: /tmp/stapVBIxqm/stapconf_7fa4e6888ba17abb7b5cc888ef91222c_947.h: No such file or directory
                    compilation terminated.
                    <command-line>: fatal error: /tmp/stapVBIxqm/stapconf_7fa4e6888ba17abb7b5cc888ef91222c_947.h: No such file or directory
                    make[2]: *** [/usr/src/kernels/6.13.0-0.rc3.20241220git8faabc041a00.33.fc42.x86_64/scripts/Makefile.build:194: stap_17cbdff69dacffb521a9178adb053400_1161_src.o] Error 1
                    make[2]: *** Waiting for unfinished jobs....
                    compilation terminated.
                    make[2]: *** [/usr/src/kernels/6.13.0-0.rc3.20241220git8faabc041a00.33.fc42.x86_64/scripts/Makefile.build:194: stap_17cbdff69dacffb521a9178adb053400_1161_aux_0.o] Error 1
                    make[2]: *** [/usr/src/kernels/6.13.0-0.rc3.20241220git8faabc041a00.33.fc42.x86_64/scripts/Makefile.build:194: stap_symbols.o] Error 1
                    make[1]: *** [/usr/src/kernels/6.13.0-0.rc3.20241220git8faabc041a00.33.fc42.x86_64/Makefile:2035: .] Error 2
                    make: *** [Makefile:263: __sub-make] Error 2
                    WARNING: kbuild exited with status: 2
                    Pass 4: compiled C into "stap_17cbdff69dacffb521a9178adb053400_1161.ko" in 260usr/140sys/397real ms.
                    Pass 4: compilation failed.  [man error::pass4]
                    Kernel version 6.13.0 is outside tested range 3.10 ... 6.12-rc
                    :: [ 23:29:02 ] :: [   FAIL   ] :: Checking stap to detect an error not depending on Ruby (Expected 0, got 1)
                    :: [ 23:29:02 ] :: [  FATAL   ] ::
                    :: [ 23:29:02 ] :: [   FAIL   ] ::  (Assert: expected 0, got 1)
                    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
                    ::   Duration: 125s
                    ::   Assertions: 7 good, 2 bad
                    ::   RESULT: WARN (Setup)
...
total: 1 warn

$ echo $?
1
```
This commit is contained in:
Jun Aruga 2024-12-24 00:39:22 +01:00
commit 6c902aedee

View file

@ -46,6 +46,10 @@ rlJournalStart
rlAssertExists "${_STAP_FILE}" || rlDie
rlLog "Using STAP_FILE from $(rpm -qf ${_STAP_FILE})."
rlRun "stap-prep" 0 "Prepare system for systemtap use"
# See the upstream systemtap routine builds when an error happens.
# https://builder.sourceware.org/buildbot/#/builders/systemtap-fedrawhide-x86_64
rlRun "stap -v -e 'probe begin { exit() }'" 0 \
"Checking stap to detect an error not depending on Ruby" || rlDie
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd ${TmpDir}"
_LOG_FILE="${TmpDir}/${_LOG_FILE}"