Skip to content

Commit

Permalink
Change "variable.tracepoint arg casts in predicates" runtime test
Browse files Browse the repository at this point in the history
The test currently checks on '@' output only and generates wait
tracepoint by calling "sleep 1 || wait $!", which on my fedora
does not add 'struct rusage' argument.

Adding simple wait4_ru.c program to testprogs that calls wait4
with 'struct rusage' argument and generates the proper argument
for the test.

Changing bpftrace invocation to run wait4_ru via -c option, so
we are sure we will get the single count.
  • Loading branch information
olsajiri authored and fbs committed Nov 12, 2019
1 parent 352e983 commit 9aae057
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/runtime/variable
Expand Up @@ -37,7 +37,6 @@ TIMEOUT 5
AFTER dd if=/dev/random bs=3 count=1

NAME tracepoint arg casts in predicates
RUN bpftrace -v -e 'tracepoint:syscalls:sys_enter_wait4 /args->ru/ { @ru[tid] = args->ru; } tracepoint:syscalls:sys_exit_wait4 /@ru[tid]/ { @++; exit(); }'
EXPECT @
RUN bpftrace -v -e 'tracepoint:syscalls:sys_enter_wait4 /args->ru/ { @ru[tid] = args->ru; } tracepoint:syscalls:sys_exit_wait4 /@ru[tid]/ { @++; exit(); }' -c ./testprogs/wait4_ru
EXPECT @: 1
TIMEOUT 5
AFTER sleep 1 || wait $!
21 changes: 21 additions & 0 deletions tests/testprogs/wait4_ru.c
@@ -0,0 +1,21 @@
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <stdlib.h>

int main(void)
{
struct rusage rusage;
pid_t pid;

pid = fork();
if (pid == 0) {
exit(0);
}

wait4(pid, NULL, 0, &rusage);
return 0;
}

0 comments on commit 9aae057

Please sign in to comment.