tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c
Extension
.c
Size
4308 bytes
Lines
182
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

static void dummy_emit(const char *buf, bool force) {}

void test_prog_tests_framework_expected_msgs(void)
{
	struct expected_msgs msgs;
	int i, j, error_cnt;
	const struct {
		const char *name;
		const char *log;
		const char *expected;
		struct expect_msg *pats;
	} cases[] = {
		{
			.name = "simple-ok",
			.log = "aaabbbccc",
			.pats = (struct expect_msg[]) {
				{ .substr = "aaa" },
				{ .substr = "ccc" },
				{}
			}
		},
		{
			.name = "simple-fail",
			.log = "aaabbbddd",
			.expected = "MATCHED    SUBSTR: 'aaa'\n"
				    "EXPECTED   SUBSTR: 'ccc'\n",
			.pats = (struct expect_msg[]) {
				{ .substr = "aaa" },
				{ .substr = "ccc" },
				{}
			}
		},
		{
			.name = "negative-ok-mid",
			.log = "aaabbbccc",
			.pats = (struct expect_msg[]) {
				{ .substr = "aaa" },
				{ .substr = "foo", .negative = true },
				{ .substr = "bar", .negative = true },
				{ .substr = "ccc" },
				{}
			}
		},
		{
			.name = "negative-ok-tail",
			.log = "aaabbbccc",
			.pats = (struct expect_msg[]) {
				{ .substr = "aaa" },
				{ .substr = "foo", .negative = true },
				{}
			}
		},
		{
			.name = "negative-ok-head",
			.log = "aaabbbccc",
			.pats = (struct expect_msg[]) {
				{ .substr = "foo", .negative = true },
				{ .substr = "ccc" },
				{}
			}
		},
		{
			.name = "negative-fail-head",
			.log = "aaabbbccc",
			.expected = "UNEXPECTED SUBSTR: 'aaa'\n",
			.pats = (struct expect_msg[]) {
				{ .substr = "aaa", .negative = true },
				{ .substr = "bbb" },
				{}
			}
		},
		{
			.name = "negative-fail-tail",
			.log = "aaabbbccc",
			.expected = "UNEXPECTED SUBSTR: 'ccc'\n",
			.pats = (struct expect_msg[]) {
				{ .substr = "bbb" },
				{ .substr = "ccc", .negative = true },
				{}
			}
		},
		{
			.name = "negative-fail-mid-1",
			.log = "aaabbbccc",
			.expected = "UNEXPECTED SUBSTR: 'bbb'\n",
			.pats = (struct expect_msg[]) {
				{ .substr = "aaa" },
				{ .substr = "bbb", .negative = true },
				{ .substr = "ccc" },
				{}

Annotation

Implementation Notes