Пример #1
0
int main(int argc, char **argv)
{
	pid_t pid;

	if (argc == 2) {
		if (!strcmp(argv[1], "hugetlbfs")) {
			unsigned long hpage_size = default_huge_page_size();

			if (!hpage_size) {
				printf("Unable to determine huge page size\n");
				abort();
			}

			hugetlbfs_test = 1;
			memfd_str = MEMFD_HUGE_STR;
			mfd_def_size = hpage_size * 2;
		} else {
			printf("Unknown option: %s\n", argv[1]);
			abort();
		}
	}

	test_create();
	test_basic();

	test_seal_write();
	test_seal_future_write();
	test_seal_shrink();
	test_seal_grow();
	test_seal_resize();

	test_share_dup("SHARE-DUP", "");
	test_share_mmap("SHARE-MMAP", "");
	test_share_open("SHARE-OPEN", "");
	test_share_fork("SHARE-FORK", "");

	/* Run test-suite in a multi-threaded environment with a shared
	 * file-table. */
	pid = spawn_idle_thread(CLONE_FILES | CLONE_FS | CLONE_VM);
	test_share_dup("SHARE-DUP", SHARED_FT_STR);
	test_share_mmap("SHARE-MMAP", SHARED_FT_STR);
	test_share_open("SHARE-OPEN", SHARED_FT_STR);
	test_share_fork("SHARE-FORK", SHARED_FT_STR);
	join_idle_thread(pid);

	printf("memfd: DONE\n");

	return 0;
}
Пример #2
0
int main(int argc, char **argv)
{
	pid_t pid;

	printf("memfd: CREATE\n");
	test_create();
	printf("memfd: BASIC\n");
	test_basic();

	printf("memfd: SEAL-WRITE\n");
	test_seal_write();
	printf("memfd: SEAL-SHRINK\n");
	test_seal_shrink();
	printf("memfd: SEAL-GROW\n");
	test_seal_grow();
	printf("memfd: SEAL-RESIZE\n");
	test_seal_resize();

	printf("memfd: SHARE-DUP\n");
	test_share_dup();
	printf("memfd: SHARE-MMAP\n");
	test_share_mmap();
	printf("memfd: SHARE-OPEN\n");
	test_share_open();
	printf("memfd: SHARE-FORK\n");
	test_share_fork();

	/* Run test-suite in a multi-threaded environment with a shared
	 * file-table. */
	pid = spawn_idle_thread(CLONE_FILES | CLONE_FS | CLONE_VM);
	printf("memfd: SHARE-DUP (shared file-table)\n");
	test_share_dup();
	printf("memfd: SHARE-MMAP (shared file-table)\n");
	test_share_mmap();
	printf("memfd: SHARE-OPEN (shared file-table)\n");
	test_share_open();
	printf("memfd: SHARE-FORK (shared file-table)\n");
	test_share_fork();
	join_idle_thread(pid);

	printf("memfd: DONE\n");

	return 0;
}