tools/testing/selftests/user_events/dyn_test.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/user_events/dyn_test.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/user_events/dyn_test.c
Extension
.c
Size
6284 bytes
Lines
297
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

if (errno == EADDRINUSE) {
			/* Name is in use, with different fields */
			*match = false;
			ret = 0;
		}

		goto cleanup;
	}

	*match = true;
	ret = 0;
cleanup:
	unreg_event(fd, check, 31);
	unreg_event(fd, check, 30);

	close(fd);

	wait_for_delete();

	return ret;
}

#define TEST_MATCH(x, y) \
do { \
	bool match; \
	ASSERT_NE(-1, check_match(&self->check, x, y, &match)); \
	ASSERT_EQ(true, match); \
} while (0)

#define TEST_NMATCH(x, y) \
do { \
	bool match; \
	ASSERT_NE(-1, check_match(&self->check, x, y, &match)); \
	ASSERT_EQ(false, match); \
} while (0)

#define TEST_PARSE(x) ASSERT_NE(-1, parse(&self->check, x))

#define TEST_NPARSE(x) ASSERT_EQ(-1, parse(&self->check, x))

FIXTURE(user) {
	int check;
	bool umount;
};

FIXTURE_SETUP(user) {
	USER_EVENT_FIXTURE_SETUP(return, self->umount);
}

FIXTURE_TEARDOWN(user) {
	USER_EVENT_FIXTURE_TEARDOWN(self->umount);

	wait_for_delete();
}

TEST_F(user, basic_types) {
	/* All should work */
	TEST_PARSE("u:__test_event u64 a");
	TEST_PARSE("u:__test_event u32 a");
	TEST_PARSE("u:__test_event u16 a");
	TEST_PARSE("u:__test_event u8 a");
	TEST_PARSE("u:__test_event char a");
	TEST_PARSE("u:__test_event unsigned char a");
	TEST_PARSE("u:__test_event int a");
	TEST_PARSE("u:__test_event unsigned int a");
	TEST_PARSE("u:__test_event short a");
	TEST_PARSE("u:__test_event unsigned short a");
	TEST_PARSE("u:__test_event char[20] a");
	TEST_PARSE("u:__test_event unsigned char[20] a");
	TEST_PARSE("u:__test_event char[0x14] a");
	TEST_PARSE("u:__test_event unsigned char[0x14] a");
	/* Bad size format should fail */
	TEST_NPARSE("u:__test_event char[aa] a");
	/* Large size should fail */
	TEST_NPARSE("u:__test_event char[9999] a");
	/* Long size string should fail */
	TEST_NPARSE("u:__test_event char[0x0000000000001] a");
}

TEST_F(user, loc_types) {
	/* All should work */
	TEST_PARSE("u:__test_event __data_loc char[] a");
	TEST_PARSE("u:__test_event __data_loc unsigned char[] a");
	TEST_PARSE("u:__test_event __rel_loc char[] a");
	TEST_PARSE("u:__test_event __rel_loc unsigned char[] a");
}

TEST_F(user, size_types) {
	/* Should work */
	TEST_PARSE("u:__test_event struct custom a 20");

Annotation

Implementation Notes