Beispiel #1
0
void testoom(int mempolicy, int lite, int retcode, int allow_sigkill)
{
	int ksm_run_orig;

	set_global_mempolicy(mempolicy);

	tst_res(TINFO, "start normal OOM testing.");
	oom(NORMAL, lite, retcode, allow_sigkill);

	tst_res(TINFO, "start OOM testing for mlocked pages.");
	oom(MLOCK, lite, retcode, allow_sigkill);

	/*
	 * Skip oom(KSM) if lite == 1, since limit_in_bytes may vary from
	 * run to run, which isn't reliable for oom03 cgroup test.
	 */
	if (access(PATH_KSM, F_OK) == -1 || lite == 1) {
		tst_res(TINFO, "KSM is not configed or lite == 1, "
			 "skip OOM test for KSM pags");
	} else {
		tst_res(TINFO, "start OOM testing for KSM pages.");
		SAFE_FILE_SCANF(PATH_KSM "run", "%d", &ksm_run_orig);
		SAFE_FILE_PRINTF(PATH_KSM "run", "1");
		oom(KSM, lite, retcode, allow_sigkill);
		SAFE_FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
	}
}
Beispiel #2
0
static void cleanup(void)
{
	if (opt_shmid && shmid != -1)
		SAFE_SHMCTL(shmid, IPC_RMID, NULL);

	if (!opt_shmid && fd != -1) {
		SAFE_CLOSE(fd);
		SAFE_UNLINK(TEST_FILE);
	}

	if (mounted)
		tst_umount(MOUNT_DIR);

	if (restore_nr_hgpgs) {
		tst_res(TINFO, "restore nr_hugepages to %ld.", nr_hugepages);
		SAFE_FILE_PRINTF(path, "%ld", nr_hugepages);
	}

	if (restore_shmmax)
		SAFE_FILE_PRINTF(PATH_SHMMAX, "%llu", shmmax);

	if (restore_overcomm_hgpgs) {
		tst_res(TINFO, "restore nr_overcommit_hugepages to %ld.",
			nr_overcommit_hugepages);
		SAFE_FILE_PRINTF(pathover, "%ld", nr_overcommit_hugepages);
	}
}
Beispiel #3
0
static void setup(void)
{
	int fd;
	tst_require_root(NULL);

	fd = open(boost, O_RDWR);
	if (fd == -1) {
		tst_brkm(TCONF, NULL,
			"acpi-cpufreq not loaded or overclock not supported");
	}
	close(fd);

	tst_sig(FORK, DEF_HANDLER, cleanup);

	SAFE_FILE_SCANF(NULL, boost, "%d", &boost_value);

	SAFE_FILE_SCANF(NULL, up_limit, "%d", &threshold);

	/* change cpu0 scaling governor */
	SAFE_FILE_SCANF(NULL, governor, "%s", governor_name);
	SAFE_FILE_PRINTF(cleanup, governor, "%s", "userspace");

	/* use only cpu0 */
	cpu_set_t set;
	CPU_ZERO(&set);
	CPU_SET(0, &set);
	if (sched_setaffinity(0, sizeof(cpu_set_t), &set) < 0)
		tst_brkm(TBROK | TERRNO, cleanup, "failed to set CPU0");

	SAFE_FILE_PRINTF(cleanup, up_limit, "11");
}
Beispiel #4
0
void setup(void)
{
	tst_require_root(NULL);

	if (access(PATH_THP, F_OK) == -1)
		tst_brkm(TCONF, NULL, "THP is not enabled");

	SAFE_FILE_SCANF(NULL, PATH_KHPD "scan_sleep_millisecs",
			"%d", &pre_thp_scan_sleep_millisecs);
	/* set 0 to khugepaged/scan_sleep_millisecs to run khugepaged 100% */
	SAFE_FILE_PRINTF(NULL, PATH_KHPD "scan_sleep_millisecs", "0");

	SAFE_FILE_SCANF(NULL, PATH_KHPD "alloc_sleep_millisecs",
			"%d", &pre_thp_alloc_sleep_millisecs);
	/*
	 * set 0 to khugepaged/alloc_sleep_millisecs to make sure khugepaged
	 * don't stop if there's a hugepage allcation failure.
	 */
	SAFE_FILE_PRINTF(NULL, PATH_KHPD "alloc_sleep_millisecs", "0");

	SAFE_FILE_SCANF(NULL, PATH_THP "enabled", "%[^\n]", pre_thp_enabled);
	/* open khugepaged as 'always' mode */
	SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "always");

	tst_sig(FORK, DEF_HANDLER, NULL);
	TEST_PAUSE;
}
Beispiel #5
0
static void do_test(void)
{
	int i;

	if (!SAFE_FORK()) {
		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", 1);
		SAFE_SETSID();

		if (SAFE_FORK())
			pause();

		SAFE_KILL(getppid(), SIGKILL);
		usleep(1000);

		// The child has gone, the grandchild runs with kref == 1
		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", 0);
		SAFE_SETSID();

		// runs with the freed ag/tg
		for (i = 0; i < LOOPS; i++)
			usleep(10);

		TST_CHECKPOINT_WAKE(0);

		exit(0);
	}

	SAFE_WAIT(NULL); // destroy the child's ag/tg

	TST_CHECKPOINT_WAIT(0);

	tst_res(TPASS, "Bug not reproduced");
}
Beispiel #6
0
void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	char *abs_path = tst_get_tmpdir();

	SAFE_ASPRINTF(cleanup, &testfile3, "%s/fstatattestfile3.txt", abs_path);
	free(abs_path);

	SAFE_MKDIR(cleanup, pathname, 0700);

	fds[0] = SAFE_OPEN(cleanup, pathname, O_DIRECTORY);
	fds[1] = fds[4] = fds[0];

	SAFE_FILE_PRINTF(cleanup, testfile, testfile);
	SAFE_FILE_PRINTF(cleanup, testfile2, testfile2);

	fds[2] =  SAFE_OPEN(cleanup, testfile3, O_CREAT | O_RDWR, 0600);

	fds[3] = 100;
	fds[5] = AT_FDCWD;

	filenames[0] = filenames[2] = filenames[3] = filenames[4] =
	    filenames[5] = testfile;
	filenames[1] = testfile3;

	TEST_PAUSE;
}
Beispiel #7
0
int main(int argc, char *argv[])
{
    char *msg;
    int lc;
    int swap_acc_on = 1;

    msg = parse_opts(argc, argv, NULL, NULL);
    if (msg != NULL)
        tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

#if __WORDSIZE == 32
    tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
#endif

    setup();

    for (lc = 0; TEST_LOOPING(lc); lc++) {
        tst_count = 0;

        tst_resm(TINFO, "OOM on CPUSET & MEMCG...");
        testoom(0, 0);

        /*
         * Under NUMA system, the migration of cpuset's memory
         * is in charge of cpuset.memory_migrate, we can write
         * 1 to cpuset.memory_migrate to enable the migration.
         */
        if (is_numa(cleanup)) {
            write_cpuset_files(CPATH_NEW, "memory_migrate", "1");
            tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
                     "cpuset.memory_migrate=1");
            testoom(0, 0);
        }

        if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
            if (errno == ENOENT) {
                tst_resm(TCONF,
                         "memcg swap accounting is disabled");
                swap_acc_on = 0;
            } else
                tst_brkm(TBROK|TERRNO, cleanup, "access");
        }

        if (swap_acc_on) {
            tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
                     "special memswap limitation:");
            SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "%ld", TESTMEM);
            testoom(0, 0);

            tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
                     "disabled memswap limitation:");
            SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "-1");
            testoom(0, 0);
        }
    }

    cleanup();
    tst_exit();
}
Beispiel #8
0
static void setup(void)
{
	check_hugepage();
	hugepagesize = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
	init_sys_sz_paths();

	if (opt_sysfs) {
		path = path_sys_sz_huge;
		pathover = path_sys_sz_over;
	} else {
		path = PATH_PROC_HUGE;
		pathover = PATH_PROC_OVER;
	}

	if (opt_alloc) {
		size = atoi(opt_alloc);
		length = (size + size * 0.5) * 2;
	}

	if (opt_shmid) {
		SAFE_FILE_SCANF(PATH_SHMMAX, "%llu", &shmmax);
		if (shmmax < (unsigned long long)(length / 2 * hugepagesize)) {
			restore_shmmax = 1;
			SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld",
					(length / 2 * hugepagesize));
		}
	}

	SAFE_FILE_SCANF(path, "%ld", &nr_hugepages);
	tst_res(TINFO, "original nr_hugepages is %ld", nr_hugepages);

	/* Reset. */
	SAFE_FILE_PRINTF(path, "%ld", size);
	restore_nr_hgpgs = 1;

	if (access(pathover, F_OK)) {
		tst_brk(TCONF, "file %s does not exist in the system",
			pathover);
	}

	SAFE_FILE_SCANF(pathover, "%ld", &nr_overcommit_hugepages);
	tst_res(TINFO, "original nr_overcommit_hugepages is %ld",
		nr_overcommit_hugepages);

	/* Reset. */
	SAFE_FILE_PRINTF(pathover, "%ld", size);
	restore_overcomm_hgpgs = 1;

	SAFE_MKDIR(MOUNT_DIR, 0700);
	SAFE_MOUNT(NULL, MOUNT_DIR, "hugetlbfs", 0, NULL);
	mounted = 1;

	if (opt_shmid) {
		/* Use /proc/meminfo to generate an IPC key. */
		key = ftok(PATH_MEMINFO, strlen(PATH_MEMINFO));
		if (key == -1)
			tst_brk(TBROK | TERRNO, "ftok");
	}
}
Beispiel #9
0
static void cleanup(void)
{
	SAFE_FILE_PRINTF(NULL, boost, "%d", boost_value);

	if (governor[0] != '\0')
		SAFE_FILE_PRINTF(NULL, governor, "%s", governor_name);

	if (threshold)
		SAFE_FILE_PRINTF(NULL, up_limit, "%d", threshold);

	TEST_CLEANUP;
}
Beispiel #10
0
static void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	fd2 = SAFE_OPEN(cleanup, ".", O_DIRECTORY);

	SAFE_FILE_PRINTF(cleanup, "test_file", "A");

	fd3 = SAFE_OPEN(cleanup, "test_file", O_RDWR);

#if !defined(UCLINUX)
	outside_buf = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
				MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#endif

	addr4 = SAFE_MEMALIGN(cleanup, getpagesize(), (4096 * 10));
	addr5 = addr4 + 1;

	fs_type = tst_fs_type(cleanup, ".");
	if (fs_type != TST_TMPFS_MAGIC)
		fd4 = SAFE_OPEN(cleanup, "test_file", O_RDWR | O_DIRECT);
}
Beispiel #11
0
void setup(void)
{
	long mem_total, hpage_size;

	tst_require_root();

	mem_total = read_meminfo("MemTotal:");
	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &orig_shmmax);
	SAFE_FILE_PRINTF(NULL, PATH_SHMMAX, "%ld", (long)SIZE);
	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &new_shmmax);

	if (mem_total < 2L*1024*1024)
		tst_brkm(TCONF,	NULL, "Needed > 2GB RAM, have: %ld", mem_total);

	if (new_shmmax < SIZE)
		tst_brkm(TCONF,	NULL, "shmmax too low, have: %ld", new_shmmax);

	orig_hugepages = get_sys_tune("nr_hugepages");
	hpage_size = read_meminfo("Hugepagesize:") * 1024;

	hugepages = (orig_hugepages * hpage_size + SIZE) / hpage_size;
	set_sys_tune("nr_hugepages", hugepages, 1);

	TEST_PAUSE;
}
Beispiel #12
0
static void client_run(void)
{
	void *res = NULL;
	long clnt_time = 0;
	int i;
	for (i = 0; i < clients_num; ++i) {
		pthread_join(thread_ids[i], &res);
		if (res) {
			tst_brkm(TBROK, cleanup, "client[%d] failed: %s",
				i, strerror((intptr_t)res));
		}
	}

	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_end);
	clnt_time = (tv_client_end.tv_sec - tv_client_start.tv_sec) * 1000 +
		(tv_client_end.tv_nsec - tv_client_start.tv_nsec) / 1000000;

	tst_resm(TINFO, "total time '%ld' ms", clnt_time);

	/* ask server to terminate */
	client_msg[0] = start_fin_byte;
	int cfd = client_connect_send(client_msg, client_msg_size);
	if (cfd != -1) {
		shutdown(cfd, SHUT_WR);
		SAFE_CLOSE(NULL, cfd);
	}
	/* the script tcp_fastopen_run.sh will remove it */
	SAFE_FILE_PRINTF(cleanup, rpath, "%ld", clnt_time);
}
Beispiel #13
0
void setup(void)
{
	if ((tst_kvercmp(2, 6, 17)) < 0) {
		tst_brkm(TCONF, cleanup, "This test can only run on kernels "
			"that are 2.6.17 or higher");
	}

	TEST_PAUSE;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	SAFE_FILE_PRINTF(cleanup, TEST_FILE, STR);
	rdfd = SAFE_OPEN(cleanup, TEST_FILE, O_RDONLY);

	wrfd = SAFE_OPEN(cleanup, TEST_FILE2,
		O_WRONLY | O_CREAT, 0644);

	appendfd = SAFE_OPEN(cleanup, TEST_FILE3,
		O_RDWR | O_CREAT | O_APPEND, 0644);

	SAFE_PIPE(cleanup, pipes);

	SAFE_WRITE(cleanup, 1, pipes[1], STR, sizeof(STR) - 1);
}
Beispiel #14
0
void setup(void)
{
	tst_require_root(NULL);

	if (tst_kvercmp(2, 6, 32) < 0)
		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
	if (access(PATH_KSM, F_OK) == -1)
		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");

	/*
	 * kernel commit 90bd6fd introduced a new KSM sysfs knob
	 * /sys/kernel/mm/ksm/merge_across_nodes, setting it to '0'
	 * will prevent KSM pages being merged across numa nodes,
	 * which will cause the case fail, so we need to make sure
	 * it is enabled before testing.
	 */
	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0) {
		SAFE_FILE_SCANF(NULL, PATH_KSM "merge_across_nodes",
				"%d", &merge_across_nodes);
		SAFE_FILE_PRINTF(NULL, PATH_KSM "merge_across_nodes", "1");
	}

	tst_sig(FORK, DEF_HANDLER, NULL);
	TEST_PAUSE;
}
Beispiel #15
0
int main(int argc, char *argv[])
{
	const char *msg;
	int lc;

	msg = parse_opts(argc, argv, NULL, NULL);
	if (msg != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

#if __WORDSIZE == 32
	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
#endif

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;

		SAFE_FILE_PRINTF(cleanup, MEMCG_PATH_NEW "/tasks",
				 "%d", getpid());
		SAFE_FILE_PRINTF(cleanup, MEMCG_LIMIT, "%ld", TESTMEM);

		testoom(0, 0, ENOMEM, 1);

		if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
			if (errno == ENOENT)
				tst_resm(TCONF,
					 "memcg swap accounting is disabled");
			else
				tst_brkm(TBROK | TERRNO, cleanup, "access");
		} else {
			SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT,
					 "%ld", TESTMEM);
			testoom(0, 1, ENOMEM, 1);
		}

		/* OOM for MEMCG with mempolicy */
		if (is_numa(cleanup)) {
			tst_resm(TINFO, "OOM on MEMCG & mempolicy...");
			testoom(MPOL_BIND, 0, ENOMEM, 1);
			testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1);
			testoom(MPOL_PREFERRED, 0, ENOMEM, 1);
		}
	}
	cleanup();
	tst_exit();
}
Beispiel #16
0
static void cleanup(void)
{
	if (ovl_mounted)
		SAFE_UMOUNT(OVL_MNT);

	if (orig_bdi_limit)
		SAFE_FILE_PRINTF(sys_bdi_ra_path, "%d", orig_bdi_limit);
}
Beispiel #17
0
void cleanup(void)
{
    SAFE_FILE_PRINTF(NULL, PATH_KHPD "scan_sleep_millisecs",
                     "%d", pre_thp_scan_sleep_millisecs);

    SAFE_FILE_PRINTF(NULL, PATH_KHPD "alloc_sleep_millisecs",
                     "%d", pre_thp_alloc_sleep_millisecs);

    if (strcmp(pre_thp_enabled, "[always] madvise never") == 0)
        SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "always");
    else if (strcmp(pre_thp_enabled, "always [madvise] never") == 0)
        SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "madvise");
    else
        SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "never");

    TEST_CLEANUP;
}
Beispiel #18
0
static void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	SAFE_FILE_PRINTF(cleanup, FNAME, "File content\n");
}
Beispiel #19
0
static void setup(void)
{
	SAFE_MKDIR(MOUNT_NAME, 0755);
	SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, "none", MS_BIND, NULL);
	mount_created = 1;
	SAFE_CHDIR(MOUNT_NAME);
	SAFE_MKDIR(DIR_NAME, 0755);

	sprintf(fname, "tfile_%d", getpid());
	SAFE_FILE_PRINTF(fname, "1");
}
Beispiel #20
0
static void test_run(void)
{
	int cur_freq, max_freq;
	SAFE_FILE_SCANF(cleanup, maxspeed, "%d", &max_freq);
	set_speed(max_freq);

	/* Enable boost */
	if (boost_value == 0)
		SAFE_FILE_PRINTF(cleanup, boost, "1");
	cur_freq = load_cpu(30);
	tst_resm((cur_freq >= max_freq) ? TPASS : TFAIL,
		"compare current speed %d and max speed %d",
		cur_freq, max_freq);

	/* Disable boost */
	SAFE_FILE_PRINTF(cleanup, boost, "0");
	cur_freq = load_cpu(30);
	tst_resm((cur_freq < max_freq) ? TPASS : TFAIL,
		"compare current speed %d and max speed %d",
		cur_freq, max_freq);
}
Beispiel #21
0
void setup(void)
{
	TEST_PAUSE;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	SAFE_FILE_PRINTF(cleanup, TEST_FILE, "test file");

	SAFE_SYMLINK(cleanup, TEST_FILE, SFILE);
}
Beispiel #22
0
static void do_cleanup(void)
{
	free(client_msg);
	free(server_msg);

	tcp.cleanup();

	if (tfo_cfg_changed) {
		SAFE_FILE_SCANF(NULL, tfo_cfg, "%d", &tfo_cfg_value);
		tfo_cfg_value &= ~tfo_bit_num;
		tfo_cfg_value |= !tfo_support << (tfo_bit_num - 1);
		tst_resm(TINFO, "unset '%s' back to '%d'",
			tfo_cfg, tfo_cfg_value);
		SAFE_FILE_PRINTF(NULL, tfo_cfg, "%d", tfo_cfg_value);
	}

	if (tw_reuse_changed) {
		SAFE_FILE_PRINTF(NULL, tcp_tw_reuse, "0");
		tst_resm(TINFO, "unset '%s' back to '0'", tcp_tw_reuse);
	}
}
Beispiel #23
0
void cleanup(void)
{
	SAFE_FILE_PRINTF(NULL, PATH_KHPD "scan_sleep_millisecs",
			 "%d", pre_thp_scan_sleep_millisecs);

	SAFE_FILE_PRINTF(NULL, PATH_KHPD "alloc_sleep_millisecs",
			 "%d", pre_thp_alloc_sleep_millisecs);

	/*
	 * The value of transparent_hugepage/enabled is speical,
	 * we need to recover the previous value one by one for
	 * the three mode: always, madvise, never.
	 */
	if (strcmp(pre_thp_enabled, "[always] madvise never") == 0)
		SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "always");
	else if (strcmp(pre_thp_enabled, "always [madvise] never") == 0)
		SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "madvise");
	else
		SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "never");

	TEST_CLEANUP;
}
Beispiel #24
0
static void set_speed(int freq)
{
	int set_freq;
	SAFE_FILE_SCANF(cleanup, setspeed, "%d", &set_freq);

	if (set_freq != freq) {
		tst_resm(TINFO, "change speed from %d to %d...",
			set_freq, freq);
		SAFE_FILE_PRINTF(cleanup, setspeed, "%d", freq);
	} else {
		tst_resm(TINFO, "set speed is %d", set_freq);
	}
}
Beispiel #25
0
static void test_run(void)
{
	int boost_time, boost_off_time, max_freq_khz;
	SAFE_FILE_SCANF(cleanup, maxspeed, "%d", &max_freq_khz);
	tst_resm(TINFO, "maximum speed is %d KHz", max_freq_khz);

	/* Enable boost */
	if (boost_value == cdrv[id].off)
		SAFE_FILE_PRINTF(cleanup, cdrv[id].file, "%s", cdrv[id].on_str);
	tst_resm(TINFO, "load CPU0 with boost enabled");
	boost_time = load_cpu(max_freq_khz);

	/* Disable boost */
	SAFE_FILE_PRINTF(cleanup, cdrv[id].file, "%s", cdrv[id].off_str);
	tst_resm(TINFO, "load CPU0 with boost disabled");
	boost_off_time = load_cpu(max_freq_khz);

	boost_off_time *= .98;

	tst_resm((boost_time < boost_off_time) ? TPASS : TFAIL,
		"compare time spent with and without boost (-2%%)");
}
Beispiel #26
0
Datei: mem.c Projekt: Havner/ltp
void testoom(int mempolicy, int lite, int retcode, int allow_sigkill)
{
	int ksm_run_orig;

	set_global_mempolicy(mempolicy);

	tst_resm(TINFO, "start normal OOM testing.");
	oom(NORMAL, lite, retcode, allow_sigkill);

	tst_resm(TINFO, "start OOM testing for mlocked pages.");
	oom(MLOCK, lite, retcode, allow_sigkill);

	if (access(PATH_KSM, F_OK) == -1) {
		tst_resm(TINFO, "KSM configuration is not enabled, "
			 "skip OOM test for KSM pags");
	} else {
		tst_resm(TINFO, "start OOM testing for KSM pages.");
		SAFE_FILE_SCANF(cleanup, PATH_KSM "run", "%d", &ksm_run_orig);
		SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
		oom(KSM, lite, retcode, allow_sigkill);
		SAFE_FILE_PRINTF(cleanup,PATH_KSM "run", "%d", ksm_run_orig);
	}
}
Beispiel #27
0
void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	char *abs_path = tst_get_tmpdir();
	int p = getpid();

	/* Initialize test dir and file names */
	sprintf(pathname, "faccessattestdir%d", p);
	sprintf(testfile, "faccessattestfile%d.txt", p);
	sprintf(testfile2, "%s/faccessattestfile%d.txt", abs_path, p);
	sprintf(testfile3, "faccessattestdir%d/faccessattestfile%d.txt", p, p);

	free(abs_path);

	SAFE_MKDIR(cleanup, pathname, 0700);

	fds[0] = SAFE_OPEN(cleanup, pathname, O_DIRECTORY);
	fds[1] = fds[4] = fds[0];

	SAFE_FILE_PRINTF(cleanup, testfile, testfile);
	SAFE_FILE_PRINTF(cleanup, testfile2, testfile2);

	fds[2] = SAFE_OPEN(cleanup, testfile3, O_CREAT | O_RDWR, 0600);

	fds[3] = 100;
	fds[5] = AT_FDCWD;

	filenames[0] = filenames[2] = filenames[3] = filenames[4] = testfile;
	filenames[1] = testfile2;
	filenames[5] = testfile3;

	TEST_PAUSE;
}
Beispiel #28
0
void setup(void)
{
    tst_require_root(NULL);

    if (access(PATH_THP, F_OK) == -1)
        tst_brkm(TCONF, NULL, "THP is not enabled");

    if (!is_numa(NULL))
        tst_brkm(TCONF, NULL, "The case need a NUMA system.");

    SAFE_FILE_SCANF(NULL, PATH_KHPD "scan_sleep_millisecs",
                    "%d", &pre_thp_scan_sleep_millisecs);
    SAFE_FILE_PRINTF(NULL, PATH_KHPD "scan_sleep_millisecs", "0");

    SAFE_FILE_SCANF(NULL, PATH_KHPD "alloc_sleep_millisecs",
                    "%d", &pre_thp_alloc_sleep_millisecs);
    SAFE_FILE_PRINTF(NULL, PATH_KHPD "alloc_sleep_millisecs", "0");

    SAFE_FILE_SCANF(NULL, PATH_THP "enabled", "%[^\n]", pre_thp_enabled);
    SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "always");

    tst_sig(FORK, DEF_HANDLER, NULL);
    TEST_PAUSE;
}
Beispiel #29
0
static void run_pci_testcases(int bus, int slot)
{
	int i, res;
	for (i = 0; i < TST_TOTAL; ++i) {
		/* skip pci disable test-case, it is manual */
		if (i == PCI_DISABLE)
			continue;

		SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i);
		SAFE_FILE_SCANF(cleanup, dev_result, "%d", &res);

		tst_resm(res, "PCI bus %02x slot %02x : Test-case '%d'",
			bus, slot, i);
	}
}
Beispiel #30
0
static void setup(void)
{

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	UID16_CHECK((uid = geteuid()), "chown", cleanup)
	GID16_CHECK((gid = getegid()), "chown", cleanup)

	sprintf(fname, "t_%d", getpid());

	SAFE_FILE_PRINTF(cleanup, fname, "davef");
}