Skip to content

Commit ff7d047

Browse files
committed
tests: define ALLOW_STRUCT_BY_VALUE_TEST
Modify the condition for arg_types struct-by-value test case to only run on x86_64 with gcc. Signed-off-by: Ihor Solodrai <[email protected]>
1 parent e0bea81 commit ff7d047

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

tests/arg_types.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const char *BPFTRACE_SCRIPT =
122122
str(arg0), \
123123
*(int32 *)(arg1 + 0), *(int32 *)(arg1 + 4), *(int32 *)(arg1 + 8) }\n"
124124
"test:struct_by_val_reg { arg0=%hhu arg1=%u -> arg0, arg1 }\n"
125-
#ifndef __clang__ /* bpftrace generates a bad BPF program in this case */
125+
#if ALLOW_STRUCT_BY_VALUE_TEST
126126
"test:struct_by_val_reg_pair { s.x=%llx -> arg0 }\n" /* captures first half of a struct */
127127
#endif
128128
/* bpftrace can't handle 24-byte struct-by-value case in struct_by_val_stack */
@@ -140,7 +140,7 @@ const char *BPFTRACE_OUTPUT =
140140
"test:ptrs: arg0=0x* arg1='some literal' arg2=&42\n"
141141
"test:arrs: arg0='STRING' arg1=(-100,-200,-300)\n"
142142
"test:struct_by_val_reg: arg0=1 arg1=2\n"
143-
#ifndef __clang__
143+
#if ALLOW_STRUCT_BY_VALUE_TEST
144144
"test:struct_by_val_reg_pair: s.x=3\n"
145145
#endif
146146
"test:structs_by_ref: a=(1) b=(2) c=(3,4) d=(4,5,6)\n"

tests/common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
#define __always_inline inline __attribute__((always_inline))
99
#endif
1010

11+
/* Struct-by-value USDT argument currently only works on x86_64 with gcc
12+
* See: https://github.com/bpftrace/bpftrace/issues/3798
13+
*/
14+
#if defined(__clang__) || defined(__aarch64__)
15+
#define ALLOW_STRUCT_BY_VALUE_TEST 0
16+
#else
17+
#define ALLOW_STRUCT_BY_VALUE_TEST 1
18+
#endif
19+
1120
#ifdef __cplusplus
1221
extern "C" {
1322
#endif

tests/cxx_arg_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const char *BPFTRACE_SCRIPT =
122122
str(arg0), \
123123
*(int32 *)(arg1 + 0), *(int32 *)(arg1 + 4), *(int32 *)(arg1 + 8) }\n"
124124
"test:struct_by_val_reg { arg0=%hhu arg1=%u -> arg0, arg1 }\n"
125-
#ifndef __clang__ /* bpftrace generates a bad BPF program in this case */
125+
#if ALLOW_STRUCT_BY_VALUE_TEST
126126
"test:struct_by_val_reg_pair { s.x=%llx -> arg0 }\n" /* captures first half of a struct */
127127
#endif
128128
/* bpftrace can't handle 24-byte struct-by-value case in struct_by_val_stack */
@@ -140,7 +140,7 @@ const char *BPFTRACE_OUTPUT =
140140
"test:ptrs: arg0=0x* arg1='some literal' arg2=&42\n"
141141
"test:arrs: arg0='STRING' arg1=(-100,-200,-300)\n"
142142
"test:struct_by_val_reg: arg0=1 arg1=2\n"
143-
#ifndef __clang__
143+
#if ALLOW_STRUCT_BY_VALUE_TEST
144144
"test:struct_by_val_reg_pair: s.x=3\n"
145145
#endif
146146
"test:structs_by_ref: a=(1) b=(2) c=(3,4) d=(4,5,6)\n"

0 commit comments

Comments
 (0)