selftests/bpf: Add test validating data section to struct convertion layout
Add a simple selftests validating datasection-to-struct layour dumping. Global variables are constructed in such a way as to cause both natural and artificial padding (through custom alignment requirement). Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20191214014341.3442258-17-andriin@fb.com
This commit is contained in:
committed by
Alexei Starovoitov
parent
dde53c1b76
commit
197448eaac
37
tools/testing/selftests/bpf/progs/test_skeleton.c
Normal file
37
tools/testing/selftests/bpf/progs/test_skeleton.c
Normal file
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) 2019 Facebook */
|
||||
|
||||
#include <linux/bpf.h>
|
||||
#include "bpf_helpers.h"
|
||||
|
||||
struct s {
|
||||
int a;
|
||||
long long b;
|
||||
} __attribute__((packed));
|
||||
|
||||
int in1 = 0;
|
||||
long long in2 = 0;
|
||||
char in3 = '\0';
|
||||
long long in4 __attribute__((aligned(64))) = 0;
|
||||
struct s in5 = {};
|
||||
|
||||
long long out2 = 0;
|
||||
char out3 = 0;
|
||||
long long out4 = 0;
|
||||
int out1 = 0;
|
||||
|
||||
|
||||
SEC("raw_tp/sys_enter")
|
||||
int handler(const void *ctx)
|
||||
{
|
||||
static volatile struct s out5;
|
||||
|
||||
out1 = in1;
|
||||
out2 = in2;
|
||||
out3 = in3;
|
||||
out4 = in4;
|
||||
out5 = in5;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
Reference in New Issue
Block a user