当前位置: 首页>>代码示例>>C++>>正文


C++ TEST_EXP_ENOS函数代码示例

本文整理汇总了C++中TEST_EXP_ENOS函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_EXP_ENOS函数的具体用法?C++ TEST_EXP_ENOS怎么用?C++ TEST_EXP_ENOS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TEST_EXP_ENOS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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();
}
开发者ID:dacongy,项目名称:ltp,代码行数:41,代码来源:statfs03.c

示例2: setup2

/*
 * 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");
	}
}
开发者ID:barajas,项目名称:Intel-GLTP,代码行数:44,代码来源:hugeshmget03.c

示例3: main

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*/}
开发者ID:ystk,项目名称:debian-ltp,代码行数:41,代码来源:close02.c

示例4: setup

/*
 * 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());

}
开发者ID:dacongy,项目名称:ltp,代码行数:25,代码来源:write04.c

示例5: setup

/*
 * 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();
}
开发者ID:8l,项目名称:rose,代码行数:24,代码来源:syscall_tst.117.semget.03.c

示例6: setup

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;

}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:21,代码来源:writev01.c

示例7: main

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();
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:21,代码来源:msync04.c

示例8: setup

/*
 * 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;
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:25,代码来源:setregid04.c

示例9: setup

/*
 * 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;

}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:24,代码来源:setdomainname02.c

示例10: setup

/* 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() */
开发者ID:ystk,项目名称:debian-ltp,代码行数:22,代码来源:clock_settime03.c

示例11: setup

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
}
开发者ID:MohdVara,项目名称:ltp,代码行数:40,代码来源:msync03.c

示例12: setup

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;
}
开发者ID:jp-coughlin,项目名称:ltp,代码行数:40,代码来源:mkdir03.c

示例13: main

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();

}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:40,代码来源:time01.c

示例14: setup

/*
 * 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");
	}
}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:43,代码来源:semctl02.c

示例15: setup

/*
 * 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;
}
开发者ID:shubmit,项目名称:shub-ltp,代码行数:44,代码来源:setreuid05.c


注:本文中的TEST_EXP_ENOS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。