Exemple #1
0
int main(int ac, char **av)
{
	int lc;
	char *msg;

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

	setup();

	/* set up the expected errnos */
	TEST_EXP_ENOS(exp_enos);

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

		tst_count = 0;

		TEST(statfs(path, &buf));

		if (TEST_RETURN != -1) {
			tst_resm(TFAIL, "call succeeded unexpectedly");

		} else {

			TEST_ERROR_LOG(TEST_ERRNO);

			if (TEST_ERRNO == EACCES) {
				tst_resm(TPASS, "expected failure - "
					 "errno = %d : %s", TEST_ERRNO,
					 strerror(TEST_ERRNO));
			} else {
				tst_resm(TFAIL, "unexpected error - %d : %s - "
					 "expected %d", TEST_ERRNO,
					 strerror(TEST_ERRNO), exp_enos[0]);
			}
		}
	}

	cleanup();
	tst_exit();
}
Exemple #2
0
/*
 * setup2() - performs all the ONE TIME setup for this test.
 */
void setup2(unsigned long huge_pages_shm_to_be_allocated) {

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	/* get an IPC resource key */
	shmkey = getipckey();

	/*
	 * Use a while loop to create the maximum number of memory segments.
	 * If the loop exceeds MAXIDS, then break the test and cleanup.
	 */
	while ((shm_id_1 = shmget(IPC_PRIVATE, huge_pages_shm_to_be_allocated, SHM_HUGETLB | IPC_CREAT |
	     IPC_EXCL | SHM_RW)) != -1) {
		shm_id_arr[num_shms++] = shm_id_1;
		if (num_shms == MAXIDS) {
			tst_brkm(TBROK, cleanup, "The maximum number of shared "
				 "memory ID's has been\n\t reached.  Please "
				 "increase the MAXIDS value in the test.");
		}
	}

	/*
	 * If the errno is other than ENOSPC, then something else is wrong.
	 */
	if (errno != ENOSPC) {
		tst_resm(TINFO, "errno = %d : %s", errno, strerror(errno));
		tst_brkm(TBROK, cleanup, "Didn't get ENOSPC in test setup");
	}
}
Exemple #3
0
int main(int ac, char **av)
{
	int lc;			/* loop counter */
	char *msg;		/* message returned from parse_opts */

	/* parse standard options */
	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *)NULL) {
		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
	 /*NOTREACHED*/}

	setup();		/* global setup */

	/* set up expected errnos */
	TEST_EXP_ENOS(exp_enos);

	/* The following loop checks looping state if -i option given */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		/* reset Tst_count in case we are looping */
		Tst_count = 0;

		TEST(close(-1));

		if (TEST_RETURN != -1) {
			tst_resm(TFAIL, "Closed a non existent fildes");
		} else {
			TEST_ERROR_LOG(TEST_ERRNO);

			if (TEST_ERRNO != EBADF) {
				tst_resm(TFAIL, "close() FAILED to set errno "
					 "to EBADF on an invalid fd, got %d",
					 errno);
			} else {
				tst_resm(TPASS, "call returned EBADF");
			}
		}
	}
	cleanup();

	return 0;
 /*NOTREACHED*/}
Exemple #4
0
/*
 * setup()
 *	performs all ONE TIME setup for this test
 */
void setup(void)
{

	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -i option.
	 * You want to make sure you do this before you create your temporary
	 * directory.
	 */
	TEST_PAUSE;

	/* Create a unique temporary directory and chdir() to it. */
	tst_tmpdir();

	/* create a temporary filename */
	sprintf(fifo, "%s.%d", fifo, getpid());

}
Exemple #5
0
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void setup(void)
{
	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified */
	TEST_PAUSE;

	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	/* get an IPC resource key */
	semkey = getipckey();
}
Exemple #6
0
void setup(void)
{

	tst_sig(FORK, sighandler, cleanup);

	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	tst_tmpdir();

	strcpy(name, DATA_FILE);
	sprintf(f_name, "%s.%d", name, getpid());

	bad_addr = mmap(0, 1, PROT_NONE,
			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
	if (bad_addr == MAP_FAILED)
		tst_brkm(TBROK | TERRNO, cleanup, "mmap failed");
	wr_iovec[7].iov_base = bad_addr;

}
Exemple #7
0
int main(int ac, char **av)
{
	TEST_EXP_ENOS(exp_enos);

	tst_count = 0;

	setup();

	TEST(msync(addr, page_sz, INV_SYNC));

	if (TEST_RETURN != -1)
		tst_resm(TFAIL, "msync succeeded unexpectedly");
	else if (TEST_ERRNO == EINVAL)
		tst_resm(TPASS, "msync failed with EINVAL as expected");
	else
		tst_resm(TFAIL | TTERRNO, "msync failed unexpectedly");

	cleanup();

	tst_exit();
}
/*
 * setup()
 *	performs all ONE TIME setup for this test
 */
void setup(void)
{
	struct group *junk;

	tst_require_root(NULL);

	tst_sig(FORK, DEF_HANDLER, cleanup);

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

	SAFE_GETGROUP(root);
	SAFE_GETGROUP(users);
	SAFE_GETGROUP(daemon);
	SAFE_GETGROUP(bin);

	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -c option.
	 */
	TEST_PAUSE;
}
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void setup(void)
{

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_EXP_ENOS(exp_enos);

	/* Check whether we are root */
	if (geteuid() != 0) {
		tst_brkm(TBROK, NULL, "Test must be run as root");
	}

	/* Save current domainname */
	if ((getdomainname(old_domain_name, MAX_NAME_LEN)) < 0) {
		tst_brkm(TBROK, NULL, "getdomainname() failed while"
			 " getting current domain name");
	}

	TEST_PAUSE;

}
Exemple #10
0
/* setup() - performs all ONE TIME setup for this test */
static void
setup()
{
	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Check whether we are root*/
	if (geteuid() != 0)
		tst_brkm(TBROK, tst_exit, "Test must be run as root");

	if (syscall(__NR_clock_gettime, CLOCK_REALTIME, &saved) < 0)
		tst_brkm(TBROK, tst_exit, "Clock gettime failed");

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);
	spec.tv_sec = 1;
	spec.tv_nsec = 0;

	/* Pause if that option was specified */
	TEST_PAUSE;
}	/* End setup() */
Exemple #11
0
static void setup(void)
{
	size_t nwrite = 0;
	char write_buf[BUF_SIZE];
	struct rlimit rl;

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_EXP_ENOS(exp_enos);

	tst_tmpdir();

	TEST_PAUSE;

	page_sz = (size_t)sysconf(_SC_PAGESIZE);

	fd = SAFE_OPEN(cleanup, TEMPFILE, O_RDWR | O_CREAT, 0666);

	memset(write_buf, 'a', BUF_SIZE);
	while (nwrite < page_sz) {
		SAFE_WRITE(cleanup, 1, fd, write_buf, BUF_SIZE);
		nwrite += BUF_SIZE;
	}

	addr1 = SAFE_MMAP(cleanup, 0, page_sz, PROT_READ | PROT_WRITE,
			  MAP_SHARED | MAP_LOCKED, fd, 0);

	/* addr2 is not a multiple of PAGESIZE */
	addr2 = addr1 + 1;

	/* addr3 is outside the address space of the process */
	if (getrlimit(RLIMIT_DATA, &rl) < 0)
		tst_brkm(TBROK | TERRNO, NULL, "getrlimit failed");
	addr3 = (char *)rl.rlim_max;

#if !defined(UCLINUX)
	/* memory pointed to by addr4 was not mapped */
	addr4 = get_high_address();
#endif
}
Exemple #12
0
static void setup(void)
{
    int i;
    const char *fs_type;

    tst_require_root(NULL);

    tst_sig(NOFORK, DEF_HANDLER, cleanup);

    TEST_EXP_ENOS(exp_enos);

    TEST_PAUSE;

    tst_tmpdir();

    fs_type = tst_dev_fs_type();
    device = tst_acquire_device(cleanup);

    if (!device)
        tst_brkm(TCONF, cleanup, "Failed to acquire device");

    memset(long_dir, 'a', PATH_MAX+1);

    SAFE_TOUCH(cleanup, TST_EEXIST, MODE, NULL);

    SAFE_TOUCH(cleanup, "tst_enotdir", MODE, NULL);

    SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
    SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
    for (i = 0; i < 43; i++)
        strcat(loop_dir, "/test_eloop");

    tst_mkfs(cleanup, device, fs_type, NULL);
    SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
    if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
        tst_brkm(TBROK | TERRNO, cleanup,
                 "mount device:%s failed", device);
    }
    mount_flag = 1;
}
Exemple #13
0
int main(int ac, char **av)
{
	int lc;
	char *msg;

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

	setup();

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

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

		Tst_count = 0;

		/*
		 * Call time(2)
		 */
		TEST(time(0));

		/* check return code */
		if (TEST_RETURN == -1) {
			TEST_ERROR_LOG(TEST_ERRNO);
			tst_resm(TFAIL, "time(0) Failed, errno=%d : %s",
				 TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			if (STD_FUNCTIONAL_TEST) {
				/* No Verification test, yet... */
				tst_resm(TPASS, "time(0) returned %ld",
					 TEST_RETURN);
			}
		}
	}

	cleanup();
	tst_exit();

}
Exemple #14
0
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void
setup(void)
{
	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified */
	TEST_PAUSE;

	 /* Switch to nobody user for correct error code collection */
        if (geteuid() != 0) {
                tst_brkm(TBROK, tst_exit, "Test must be run as root");
        }
        ltpuser = getpwnam(nobody_uid);
        if (setuid(ltpuser->pw_uid) == -1) {
                tst_resm(TINFO, "setuid failed to "
                         "to set the effective uid to %d",
                         ltpuser->pw_uid);
                perror("setuid");
        }


	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	/* get an IPC resource key */
	semkey = getipckey();

	/* create a semaphore set without read or alter permissions */
	if ((sem_id_1 = semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL)) == -1) {
		tst_brkm(TBROK, cleanup, "couldn't create semaphore in setup");
	}
}
Exemple #15
0
/*
 * setup()
 *	performs all ONE TIME setup for this test
 */
void setup(void)
{

	tst_sig(FORK, DEF_HANDLER, cleanup);

	if (getpwnam("nobody") == NULL) {
		tst_brkm(TBROK, NULL, "nobody must be a valid user.");
		tst_exit();
	 }

	if (getpwnam("daemon") == NULL) {
		tst_brkm(TBROK, NULL, "daemon must be a valid user.");
		tst_exit();
	 }

	if (getuid() != 0) {
		tst_resm(TBROK, "Must be run as root");
		tst_exit();
	 }

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

	nobody = *(getpwnam("nobody"));
	nobody_pw_uid = nobody.pw_uid;

	daemonpw = *(getpwnam("daemon"));
	daemon_pw_uid = daemonpw.pw_uid;

	root = *(getpwnam("root"));
	root_pw_uid = root.pw_uid;

	bin = *(getpwnam("bin"));
	bin_pw_uid = bin.pw_uid;

	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -c option.
	 */
	TEST_PAUSE;
}
Exemple #16
0
int main(int ac, char **av)
{
	int lc;
	char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
	}

	setup();

	TEST_EXP_ENOS(exp_enos);

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

		/* reset Tst_count in case we are looping */
		Tst_count = 0;

		TEST(creat(fname, MODE));

		if (TEST_RETURN != -1) {
			tst_resm(TFAIL, "call succeeded unexpectedly");
			continue;
		}

		TEST_ERROR_LOG(TEST_ERRNO);

		if (TEST_ERRNO == EMFILE) {
			tst_resm(TPASS, "call failed with expected error - "
				 "EMFILE");
		} else {
			tst_resm(TFAIL | TTERRNO, "Expected EMFILE");
		}

		remove_files(ifile);
	}
	cleanup();

	tst_exit();
}
Exemple #17
0
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void setup(void)
{
	int sem_q;

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	/*
	 * Use a while loop to create the maximum number of semaphore sets.
	 * If the loop exceeds MAXIDS, then break the test and cleanup.
	 */
	while ((sem_q = semget(IPC_PRIVATE, PSEMS, IPC_CREAT | IPC_EXCL)) != -1) {
		sem_id_arr[num_sems++] = sem_q;
		if (num_sems == MAXIDS) {
			tst_brkm(TBROK, cleanup, "The maximum number of "
				 "semaphore ID's has been\n\t reached.  Please "
				 "increase the MAXIDS value in the test.");
		}
	}

	/*
	 * If the errno is other than ENOSPC, then something else is wrong.
	 */

	if (errno != ENOSPC) {
		tst_brkm(TBROK, cleanup, "Didn't get ENOSPC in test setup"
			 " - errno = %d : %s", errno, strerror(errno));
	}
}
Exemple #18
0
static void setup(void)
{
	int fd;

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	tst_tmpdir();

	fd = SAFE_OPEN(cleanup, "test_file", O_RDWR | O_CREAT, 0777);

	FD_ZERO(&read_fds);
	FD_SET(fd, &read_fds);

	SAFE_CLOSE(cleanup, fd);

	time_buf.tv_sec = -1;
	time_buf.tv_nsec = 0;
}
Exemple #19
0
/*
 * setup()
 *	performs all ONE TIME setup for this test
 */
void setup(void)
{
	/* capture signals */
	tst_sig(FORK, DEF_HANDLER, cleanup);

	if (getpwnam("nobody") == NULL) {
		tst_brkm(TBROK, NULL, "nobody must be a valid user.");
		tst_exit();
	 /*NOTREACHED*/}

	/* Check that the test process id is super/root  */
	if (geteuid() != 0) {
		tst_brkm(TBROK, NULL, "Must be root for this test!");
		tst_exit();
	}

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

	nobody = *(getpwnam("nobody"));
	nobody_pw_uid = nobody.pw_uid;

	root = *(getgrnam("root"));
	root_gr_gid = root.gr_gid;

	users = *(getgrnam("users"));
	users_gr_gid = users.gr_gid;

	sys = *(getgrnam("sys"));
	sys_gr_gid = sys.gr_gid;

	bin = *(getgrnam("bin"));
	bin_gr_gid = bin.gr_gid;

	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -c option.
	 */
	TEST_PAUSE;
}
Exemple #20
0
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void
setup(void)
{
	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified */
	TEST_PAUSE;

	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	/* get an IPC resource key */
	shmkey = getipckey();

	shmkey2 = shmkey + 1;

	if ((shm_id_1 = shmget(shmkey, SHM_SIZE, IPC_CREAT | IPC_EXCL |
	     SHM_RW)) == -1) {
		tst_brkm(TBROK, cleanup, "couldn't create shared memory "
			 "segment in setup()");
	}

	/* Make sure shm_nonexisting_key is a nonexisting key */
	while(1) {
		while(-1 != shmget(shm_nonexisting_key,1,SHM_RD)) {
			shm_nonexisting_key--;
		}
		if(errno == ENOENT)
			break;
	}
}
Exemple #21
0
int main(int ac, char **av)
{
	int i;
	int lc;
	const char *msg;

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

	setup();

	TEST_EXP_ENOS(exp_enos);

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;
		for (i = 0; i < TST_TOTAL; i++)
			read_verify(&TC[i]);
	}
	cleanup();
	tst_exit();
}
/* setup() - performs all ONE TIME setup for this test */
void setup()
{
	/*
	 * Initialize scheduling parameter structure to use with
	 * sched_setscheduler()
	 */
	struct sched_param p = { 1 };

	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified */
	TEST_PAUSE;

	/* Change scheduling policy to SCHED_RR */
	if ((sched_setscheduler(0, SCHED_RR, &p)) == -1) {
		tst_brkm(TBROK, cleanup, "sched_setscheduler() failed");
	}
}				/* End setup() */
Exemple #23
0
/*
 * setup()
 *	performs all ONE TIME setup for this test
 */
void setup(void)
{

	tst_sig(FORK, DEF_HANDLER, cleanup);

	if (getpwnam("nobody") == NULL) {
		tst_brkm(TBROK, NULL, "nobody must be a valid user.");
		tst_exit();
	 }

	if (getpwnam("bin") == NULL) {
		tst_brkm(TBROK, NULL, "bin must be a valid user.");
		tst_exit();
	 }

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

	root = *(getpwnam("root"));
	root_pw_uid = root.pw_uid;

	nobody = *(getpwnam("nobody"));
	nobody_pw_uid = nobody.pw_uid;

	bin = *(getpwnam("bin"));
	bin_pw_uid = bin.pw_uid;

	/* Check that the test process id is nobody */
	if (geteuid() != nobody.pw_uid) {
/*		tst_brkm(TBROK, NULL, "Must be nobody for this test!");
		tst_exit();*/
		setuid(nobody.pw_uid);
	}

	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -c option.
	 */
	TEST_PAUSE;
}
Exemple #24
0
static void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_require_root(NULL);

	ltpuser = SAFE_GETPWNAM(cleanup, nobody_uid);

	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	/* Initialize longmodname to LONGMODNAMECHAR character */
	memset(longmodname, LONGMODNAMECHAR, MODULE_NAME_LEN - 1);

	/* Get unique module name for each child process */
	if (sprintf(modname, "%s_%d", BASEMODNAME, getpid()) <= 0)
		tst_brkm(TBROK, NULL, "Failed to initialize module name");

	tdat[2].modname = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
				    MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
}
Exemple #25
0
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void setup(void)
{
	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified */
	TEST_PAUSE;

	/* Switch to nobody user for correct error code collection */
	if (geteuid() != 0) {
		tst_brkm(TBROK, tst_exit, "Test must be run as root");
	}
	ltpuser = getpwnam(nobody_uid);
	if (setuid(ltpuser->pw_uid) == -1) {
		tst_resm(TINFO, "setuid failed to "
			 "to set the effective uid to %d", ltpuser->pw_uid);
		perror("setuid");
	}

	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	msgkey = getipckey();

	/*
	 * Create the message queue without specifying permissions.
	 */
	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL)) == -1) {
		tst_brkm(TBROK, cleanup, "Could not create message queue"
			 " - errno = %d : %s", errno, strerror(errno));
	}
}
Exemple #26
0
int main(int ac, char **av)
{
	int lc;
	int i;
	char *msg;

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

	setup();

	TEST_EXP_ENOS(exp_enos);

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

		for (i = 0; i < TST_TOTAL; i++) {
			TEST(chroot(TC[i].dir));

			if (TEST_RETURN != -1) {
				tst_resm(TFAIL, "call succeeded unexpectedly");
				continue;
			}

			if (TEST_ERRNO == TC[i].error) {
				tst_resm(TPASS | TTERRNO, "failed as expected");
			} else {
				tst_resm(TFAIL | TTERRNO,
					 "didn't fail as expected (expected errno "
					 "= %d : %s)",
					 TC[i].error, strerror(TC[i].error));
			}
		}
	}

	cleanup();
	tst_exit();
}
Exemple #27
0
/***************************************************************
 * setup() - performs all ONE TIME setup for this test.
 ***************************************************************/
void setup()
{

	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	/* create a temporary directory and go to it */
	tst_tmpdir();

	/* Indicate which errnos are expected */
	TEST_EXP_ENOS(exp_enos);

	/*
	 *  Attempt to get some memory to work with.
	 */

	if ((dp = (char *)malloc((unsigned)BUFSIZ + 1)) == NULL) {
		tst_brkm(TBROK | TERRNO, cleanup, "malloc() failed");
	}

}
Exemple #28
0
/*
 * setup() - performs all the ONE TIME setup for this test.
 */
void setup(void)
{

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	/* Switch to nobody user for correct error code collection */
	if (geteuid() != 0) {
		tst_brkm(TBROK, NULL, "Test must be run as root");
	}
	ltpuser = getpwnam(nobody_uid);
	if (setuid(ltpuser->pw_uid) == -1) {
		tst_resm(TINFO, "setuid failed to "
			 "to set the effective uid to %d", ltpuser->pw_uid);
		perror("setuid");
	}

	/*
	 * Create a temporary directory and cd into it.
	 * This helps to ensure that a unique msgkey is created.
	 * See ../lib/libipc.c for more information.
	 */
	tst_tmpdir();

	msgkey = getipckey();

	/* create a message queue without write permission */
	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RD)) == -1) {
		tst_brkm(TBROK, cleanup, "Can't create message queue");
	}

	/* initialize the message buffer with something trivial */
	msg_buf.mtype = MSGTYPE;
	msg_buf.mtext[0] = 'a';
}
Exemple #29
0
/* setup() - performs all ONE TIME setup for this test */
void setup()
{

	/* capture signals */
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified */
	TEST_PAUSE;

	/*
	 * Save current capability data.
	 * header.version must be _LINUX_CAPABILITY_VERSION
	 */
	header.version = _LINUX_CAPABILITY_VERSION;
	if ((capget(&header, &data)) == -1) {
		tst_brkm(TBROK|TERRNO, tst_exit, "capget() failed");
	}

}				/* End setup() */
/*
 * setup()
 *	performs all ONE TIME setup for this test
 */
void setup(void)
{
	/* capture signals */
	tst_sig(FORK, DEF_HANDLER, cleanup);

	/* Set up the expected error numbers for -e option */
	TEST_EXP_ENOS(exp_enos);

	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -i option.
	 * You want to make sure you do this before you create your temporary
	 * directory.
	 */
	TEST_PAUSE;

	/* Create a unique temporary directory and chdir() to it. */
	tst_tmpdir();

	/* create a temporary filename */
	sprintf(fifo+strlen(fifo), ".%d", getpid());

}