Skip to contentSkip to conversation

selftests/bpf: fix test_attach_probe map definition

PATCH Applied Andrii Nakryiko 3 participants 3 messages Jul 6, 2019 – Jul 8, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: fix test_attach_probe map definition

ef99b02b23ef ("libbpf: capture value in BTF type info for BTF-defined map defs") changed BTF-defined maps syntax, while independently merged 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests") added new test using outdated syntax of maps. This patch fixes this test after corresponding patch sets were merged.

Fixes ef99b02b23ef ("libbpf: capture value in BTF type info for BTF-defined map defs")
Fixes 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
---
 .../testing/selftests/bpf/progs/test_attach_probe.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
tools/testing/selftests/bpf/progs/test_attach_probe.c +5 -8
index 7a7c5cd728c8..63a8dfef893b 100644
@@ -6,14 +6,11 @@
 #include "bpf_helpers.h"
 
 struct {
-	int type;
-	int max_entries;
-	int *key;
-	int *value;
-} results_map SEC(".maps") = {
-	.type = BPF_MAP_TYPE_ARRAY,
-	.max_entries = 4,
-};
+	__uint(type, BPF_MAP_TYPE_ARRAY);
+	__uint(max_entries, 4);
+	__type(key, int);
+	__type(value, int);
+} results_map SEC(".maps");
 
 SEC("kprobe/sys_nanosleep")
 int handle_sys_nanosleep_entry(struct pt_regs *ctx)
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andrii Nakryiko

ef99b02b23ef ("libbpf: capture value in BTF type info for BTF-defined map defs") changed BTF-defined maps syntax, while independently merged 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests") added new test using outdated syntax of maps. This patch fixes this test after corresponding patch sets were merged.

Fixes ef99b02b23ef ("libbpf: capture value in BTF type info for BTF-defined map defs")
Fixes 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
Quoted 29 lines
---
  .../testing/selftests/bpf/progs/test_attach_probe.c | 13 +++++--------
  1 file changed, 5 insertions(+), 8 deletions(-)
tools/testing/selftests/bpf/progs/test_attach_probe.c +5 -8
index 7a7c5cd728c8..63a8dfef893b 100644
@@ -6,14 +6,11 @@
  #include "bpf_helpers.h"
 
  struct {
-	int type;
-	int max_entries;
-	int *key;
-	int *value;
-} results_map SEC(".maps") = {
-	.type = BPF_MAP_TYPE_ARRAY,
-	.max_entries = 4,
-};
+	__uint(type, BPF_MAP_TYPE_ARRAY);
+	__uint(max_entries, 4);
+	__type(key, int);
+	__type(value, int);
+} results_map SEC(".maps");
 
  SEC("kprobe/sys_nanosleep")
  int handle_sys_nanosleep_entry(struct pt_regs *ctx)
maintainer Applied
#2 lore raw
In reply to Andrii Nakryiko
Quoted 9 lines · Andrii Nakryiko

ef99b02b23ef ("libbpf: capture value in BTF type info for BTF-defined map defs") changed BTF-defined maps syntax, while independently merged 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests") added new test using outdated syntax of maps. This patch fixes this test after corresponding patch sets were merged.

Fixes ef99b02b23ef ("libbpf: capture value in BTF type info for BTF-defined map defs")
Fixes 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")

Applied, thanks!