您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tst_brkm函数代码示例

51自学网 2021-06-03 08:59:40
  C++
这篇教程C++ tst_brkm函数代码示例写得很实用,希望能帮到您。

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

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

示例1: main

int main(int argc, char *argv[]){	int fblocks = 1;	/* Iterations. Default 1 */	int bufsize = BUFSIZE;	int count, ret;	int offset;	int fd, newfd;	int i, l_fail = 0, fail_count = 0, total = 0;	int failed = 0;	int shmsz = MMAP_GRANULARITY;	int pagemask = ~(sysconf(_SC_PAGE_SIZE) - 1);	char *buf0, *buf1, *buf2;	caddr_t shm_base;	/* Options */	while ((i = getopt(argc, argv, "b:")) != -1) {		switch (i) {		case 'b':			if ((fblocks = atoi(optarg)) <= 0) {				fprintf(stderr, "fblocks must be > 0/n");				prg_usage();			}			break;		default:			prg_usage();		}	}	setup();	/* Open file and fill, allocate for buffer */	if ((fd = open(filename, O_DIRECT | O_RDWR | O_CREAT, 0666)) < 0) {		tst_brkm(TBROK, cleanup, "open failed for %s: %s",			 filename, strerror(errno));	}	if ((buf0 = valloc(bufsize)) == NULL) {		tst_brkm(TBROK, cleanup, "valloc() buf0 failed: %s",			 strerror(errno));	}	for (i = 1; i < fblocks; i++) {		fillbuf(buf0, bufsize, (char)i);		if (write(fd, buf0, bufsize) < 0) {			tst_brkm(TBROK, cleanup, "write failed for %s: %s",				 filename, strerror(errno));		}	}	close(fd);	if ((buf2 = valloc(bufsize)) == NULL) {		tst_brkm(TBROK, cleanup, "valloc() buf2 failed: %s",			 strerror(errno));	}	if ((fd = open(filename, O_DIRECT | O_RDWR)) < 0) {		tst_brkm(TBROK, cleanup, "open failed for %s: %s",			 filename, strerror(errno));	}	/* Test-1: Negative Offset */	offset = -1;	count = bufsize;	errno = 0;	ret = lseek(fd, offset, SEEK_SET);	if ((ret >= 0) || (errno != EINVAL)) {		tst_resm(TFAIL, "lseek allows negative offset. returns %d:%s",			 ret, strerror(errno));		failed = TRUE;		fail_count++;	} else		tst_resm(TPASS, "Negative Offset");	total++;	/* Test-2: Removed */	tst_resm(TPASS, "removed");	/* Test-3: Odd count of read and write */	offset = 0;	count = 1;	lseek(fd, 0, SEEK_SET);	if (write(fd, buf2, 4096) == -1) {		tst_resm(TFAIL, "can't write to file %d", ret);	}	switch (fs_type) {	case TST_NFS_MAGIC:	case TST_BTRFS_MAGIC:		tst_resm(TCONF, "%s supports odd count IO",			 tst_fs_type_name(fs_type));	break;	default:		ret = runtest_f(fd, buf2, offset, count, EINVAL, 3, "odd count");		testcheck_end(ret, &failed, &fail_count,					"Odd count of read and write");	}	total++;	/* Test-4: Read beyond the file size */	offset = bufsize * (fblocks + 10);	count = bufsize;	if (lseek(fd, offset, SEEK_SET) < 0) {		tst_resm(TFAIL, "lseek failed: %s", strerror(errno));		failed = TRUE;//.........这里部分代码省略.........
开发者ID:kraj,项目名称:ltp,代码行数:101,


示例2: alarmfunc

void alarmfunc(int sig){	/* for some reason tst_brkm doesn't seem to work in a signal handler */	tst_brkm(TFAIL, cleanup, "one or more children did't die in 60 second "	    "time limit");}
开发者ID:shubmit,项目名称:shub-ltp,代码行数:6,


示例3: main

intmain(int ac, char **av){	int lc;			/* loop counter */	int fflag;		/* functionality flag variable */	char *msg;		/* message returned from parse_opts */	/* Parse standard options given to run the test. */	msg = parse_opts(ac, av, (option_t *) NULL, NULL);	if (msg != (char *) NULL) {		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);		tst_exit();	}	/* Perform global setup for test */	setup();	/* Check looping state if -i option given */	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* Reset Tst_count in case we are looping. */		Tst_count=0;		/*		 * Call mknod() to creat a node on a directory without		 * set group-ID (sgid) bit set.		 */		TEST(mknod(node_name, MODE_RWX, 0));			/* Check return code from mknod(2) */		if (TEST_RETURN == -1) {			tst_resm(TFAIL,				 "mknod(%s, %#o, 0)  failed, errno=%d : %s",				 node_name, MODE_RWX, TEST_ERRNO,				 strerror(TEST_ERRNO));			continue;		}		/*		 * Perform functional verification if test executed		 * without (-f) option.		 */		if (STD_FUNCTIONAL_TEST) {			/* Set the functionality flag */			fflag = 1;			/* Check for node's creation */	 		if (stat(node_name, &buf) < 0) {				tst_resm(TFAIL,					 "stat() of %s failed, errno:%d",					 node_name, TEST_ERRNO);				/* unset flag as functionality fails */				fflag = 0;			}			/* Verify mode permissions of node */			if (buf.st_mode & S_ISGID) {				tst_resm(TFAIL, "%s: Incorrect modes, setgid "					 "bit set", node_name);				/* unset flag as functionality fails */				fflag = 0;			}			/* Verify group ID */			if (buf.st_gid != mygid) {				tst_resm(TFAIL, "%s: Incorrect group",					 node_name);				/* unset flag as functionality fails */				fflag = 0;			}			if (fflag) {				tst_resm(TPASS, "Functionality of mknod(%s, "					 "%#o, 0) successful",			 		 node_name, MODE_RWX);			}		} else {			tst_resm(TPASS, "call succeeded");		}		/* Remove the node for the next go `round */		if (unlink(node_name) == -1) {			tst_resm(TWARN, /				 "unlink(%s) failed, errno:%d %s",				 node_name, errno, strerror(errno));		}   	}	/* Change the directory back to temporary directory */	chdir("..");	/*	 * Invoke cleanup() to delete the test directories created	 * in the setup() and exit main().	 */	cleanup();	/*NOTREACHED*/	return(0);}	/* End main */
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:97,


示例4: main

int main(int ac, char **av){	int lc;	char *msg;	pid_t c_pid;	int status, e_code;	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	}#ifdef UCLINUX#define PIPE_NAME	"msgsnd06"	maybe_run_child(&do_child, "d", &msg_q_1);#endif	setup();		/* global setup */	if (sync_pipe_create(sync_pipes, PIPE_NAME) == -1)		tst_brkm(TBROK, cleanup, "sync_pipe_create failed");	/* 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;		msgkey = getipckey();		/* create a message queue with read/write permission */		if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW))		    == -1) {			tst_brkm(TBROK, cleanup, "Can't create message queue");		}		/* initialize the message buffer */		init_buf(&msg_buf, MSGTYPE, MSGSIZE);		/* write messages to the queue until it is full */		while (msgsnd(msg_q_1, &msg_buf, MSGSIZE, IPC_NOWAIT) != -1) {			msg_buf.mtype += 1;		}		/*		 * fork a child that will attempt to write a message		 * to the queue without IPC_NOWAIT		 */		if ((c_pid = FORK_OR_VFORK()) == -1) {			tst_brkm(TBROK, cleanup, "could not fork");		}		if (c_pid == 0) {	/* child */#ifdef UCLINUX			if (self_exec(av[0], "d", msg_q_1) < 0) {				tst_brkm(TBROK, cleanup, "could not self_exec");			}#else			do_child();#endif		} else {	/* parent */			if (sync_pipe_wait(sync_pipes) == -1)				tst_brkm(TBROK, cleanup,					 "sync_pipe_wait failed");			if (sync_pipe_close(sync_pipes, PIPE_NAME) == -1)				tst_brkm(TBROK, cleanup,					 "sync_pipe_close failed");			/* After son has been created, give it a chance to execute the			 * msgsnd command before we continue. Without this sleep, on SMP machine			 * the father rm_queue could be executed before the son msgsnd.			 */			sleep(2);			/* remove the queue */			rm_queue(msg_q_1);			/* wait for the child to finish */			wait(&status);			/* make sure the child returned a good exit status */			e_code = status >> 8;			if (e_code != 0) {				tst_resm(TFAIL, "Failures reported above");			}		}	}	cleanup();	tst_exit();}
开发者ID:GOEUM,项目名称:ltp,代码行数:91,


示例5: main

int main(int ac, char **av){	int lc;	int i;	int fildes;		/* file descriptor of test file */	size_t nbytes;		/* no. of bytes to be written */	off_t offset;		/* offset position in the specified file */	char *test_desc;	/* test specific error message */	tst_parse_opts(ac, av, NULL, NULL);	setup();	for (lc = 0; TEST_LOOPING(lc); lc++) {		tst_count = 0;		/* loop through the test cases */		for (i = 0; Test_cases[i].desc != NULL; i++) {			fildes = Test_cases[i].fd;			test_desc = Test_cases[i].desc;			nbytes = Test_cases[i].nb;			offset = Test_cases[i].offst;			if (fildes == 1) {				fildes = pfd[0];			} else if (fildes == 2) {				fildes = fd1;			}			/*			 * Call pread() with the specified file descriptor,			 * no. of bytes to be read from specified offset.			 * and verify that call should fail with appropriate			 * errno set.			 */			TEST(pread(fildes, read_buf[0], nbytes, offset));			/* Check for the return code of pread() */			if (TEST_RETURN != -1) {				tst_brkm(TFAIL, cleanup, "pread() returned "					 "%ld, expected -1, errno:%d",					 TEST_RETURN, Test_cases[i].exp_errno);			}			/*			 * Verify whether expected errno is set.			 */			if (TEST_ERRNO == Test_cases[i].exp_errno) {				tst_resm(TPASS, "pread() fails, %s, errno:%d",					 test_desc, TEST_ERRNO);			} else {				tst_resm(TFAIL, "pread() fails, %s, unexpected "					 "errno:%d, expected:%d", test_desc,					 TEST_ERRNO, Test_cases[i].exp_errno);			}		}	}	cleanup();	tst_exit();}
开发者ID:kraj,项目名称:ltp,代码行数:63,


示例6: main

//.........这里部分代码省略.........#include <sys/types.h>#include <sys/stat.h>#include <errno.h>#include <fcntl.h>#if HAVE_NUMAIF_H#include <numaif.h>#endif#include <signal.h>#include <stdio.h>#include <unistd.h>#include "test.h"#include "mem.h"char *TCID = "ksm02";int TST_TOTAL = 1;static int merge_across_nodes;#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H /	&& HAVE_MPOL_CONSTANTSoption_t ksm_options[] = {	{"n:", &opt_num, &opt_numstr},	{"s:", &opt_size, &opt_sizestr},	{"u:", &opt_unit, &opt_unitstr},	{NULL, NULL, NULL}};int main(int argc, char *argv[]){	int lc;	int size = 128, num = 3, unit = 1;	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };	unsigned int node;	tst_parse_opts(argc, argv, ksm_options, ksm_usage);	node = get_a_numa_node(tst_exit);	set_node(nmask, node);	setup();	for (lc = 0; TEST_LOOPING(lc); lc++) {		tst_count = 0;		check_ksm_options(&size, &num, &unit);		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) {			if (errno != ENOSYS)				tst_brkm(TBROK | TERRNO, cleanup,					 "set_mempolicy");			else				tst_brkm(TCONF, cleanup,					 "set_mempolicy syscall is not "					 "implemented on your system.");		}		create_same_memory(size, num, unit);		write_cpusets(node);		create_same_memory(size, num, unit);	}	cleanup();	tst_exit();}void cleanup(void){	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)		FILE_PRINTF(PATH_KSM "merge_across_nodes",				 "%d", merge_across_nodes);	restore_max_page_sharing();	umount_mem(CPATH, CPATH_NEW);}void setup(void){	tst_require_root();	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");	save_max_page_sharing();	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, cleanup);	TEST_PAUSE;	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);}#else /* no NUMA */int main(void){	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");}
开发者ID:1587,项目名称:ltp,代码行数:101,


示例7: main

/*********************************************************************** * Main ***********************************************************************/intmain(int ac, char **av){    int lc;		/* loop counter */    const char *msg;		/* message returned from parse_opts */    struct stat fbuf, lbuf;    int cnt;    char lname[255];    /***************************************************************     * parse standard options     ***************************************************************/    if ( (msg=parse_opts(ac, av, options, &help)) != (char *) NULL ) {	tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	tst_exit();    }    if ( Nflag ) {	if ( sscanf(Noptlinks, "%i", &nlinks) != 1 ) {	    tst_brkm(TBROK, cleanup, "-N option invalid, must be numeric");	}    }     /***************************************************************     * perform global setup for test     ***************************************************************/    setup();    /***************************************************************     * check looping state if -c option given     ***************************************************************/    for (lc=0; TEST_LOOPING(lc); lc++) {	/* reset Tst_count in case we are looping. */	Tst_count=0;	for(cnt=1; cnt < nlinks; cnt++) {		    sprintf(lname, "%s%d", Basename, cnt);            /*	     *  Call link(2)	     */	    TEST(link(Fname, lname));		    /* check return code */	    if ( TEST_RETURN == -1 ) {	        tst_resm(TFAIL, "link(%s, %s) Failed, errno=%d : %s",		     Fname, lname, TEST_ERRNO, strerror(TEST_ERRNO));	    } 	}	    	/***************************************************************	 * only perform functional verification if flag set (-f not given)	 ***************************************************************/	if ( STD_FUNCTIONAL_TEST ) {	    stat(Fname, &fbuf);	    for(cnt=1; cnt < nlinks; cnt++) {                sprintf(lname, "%s%d", Basename, cnt);		stat(lname, &lbuf);		if ( fbuf.st_nlink <= 1 || lbuf.st_nlink <= 1 ||			(fbuf.st_nlink != lbuf.st_nlink) ) {		    tst_resm(TFAIL,			"link(%s, %s[1-%d]) ret %d for %d files, stat values do not match %d %d",			Fname, Basename, nlinks, TEST_RETURN, nlinks,			fbuf.st_nlink, lbuf.st_nlink);		    break;		}	    }	    if ( cnt >= nlinks ) {		tst_resm(TPASS,		    "link(%s, %s[1-%d]) ret %d for %d files, stat linkcounts match %d",		    Fname, Basename, nlinks, TEST_RETURN, nlinks,		    fbuf.st_nlink);	    }	} 	else	    Tst_count++;#ifdef CRAY/* * IRIX (xfs) systems do not have the 1000 link limit. * I tried 100000 links on 2/97 without error on IRIX 6.4. */	/*	 * Now check that one more link will put you over the top	 */        sprintf(lname, "%s%d", Basename, cnt);        /*         *  Call link(2)         */        TEST(link(Fname, lname));        /* check return code *///.........这里部分代码省略.........
开发者ID:hallco978,项目名称:msys,代码行数:101,


示例8: check_functionality

/* * check_functionality - check various conditions to make sure they *			 are correct. */void check_functionality(int i){	void *orig_add;	int *shared;	int fail = 0;	struct shmid_ds buf;	shared = (int *)addr;	/* stat the shared memory ID */	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {		tst_brkm(TBROK, cleanup, "couldn't stat shared memory");	}	/* check the number of attaches */	if (buf.shm_nattch != 1) {		tst_resm(TFAIL, "# of attaches is incorrect");		return;	}	/* check the size of the segment */	if (buf.shm_segsz != INT_SIZE) {		tst_resm(TFAIL, "segment size is incorrect");		return;	}	/* check for specific conditions depending on the type of attach */	switch (i) {	case 0:		/*		 * Check the functionality of the first call by simply		 * "writing" a value to the shared memory space.		 * If this fails the program will get a SIGSEGV, dump		 * core and exit.		 */		*shared = CASE0;		break;	case 1:		/*		 * Check the functionality of the second call by writing		 * a value to the shared memory space and then checking		 * that the original address given was rounded down as		 * specified in the man page.		 */		*shared = CASE1;		orig_add = addr + ((unsigned long)TC[1].offset % SHMLBA);		if (orig_add != base_addr + TC[1].offset) {			tst_resm(TFAIL, "shared memory address is not "				 "correct");			fail = 1;		}		break;	case 2:		/*		 * This time the shared memory is read only.  Read the value		 * and check that it is equal to the value set in case #2,		 * because shared memory is persistent.		 */		if (*shared != CASE1) {			tst_resm(TFAIL, "shared memory value isn't correct");			fail = 1;		}		break;	}	if (!fail) {		tst_resm(TPASS, "conditions and functionality are correct");	}}
开发者ID:Mellanox,项目名称:arc_ltp,代码行数:76,


示例9: main

int main(int ac, char **av){	int lc;			/* loop counter */	char *msg;		/* message returned from parse_opts */	pid_t pid, fake_pid;	int exno, status, fake_status, nsig;	/* parse standard options */	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	}#ifdef UCLINUX	maybe_run_child(&do_child, "");#endif	setup();		/* global setup */	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;		status = 1;		exno = 1;		pid = FORK_OR_VFORK();		if (pid < 0) {			tst_brkm(TBROK, cleanup, "Fork failed");		} else if (pid == 0) {#ifdef UCLINUX			if (self_exec(av[0], "") < 0) {				tst_brkm(TBROK, cleanup,					 "self_exec of child failed");			}#else			do_child();#endif		} else {			fake_pid = FORK_OR_VFORK();			if (fake_pid < 0) {				tst_brkm(TBROK, cleanup, "Second fork failed");			} else if (fake_pid == 0) {#ifdef UCLINUX				if (self_exec(av[0], "") < 0) {					tst_brkm(TBROK, cleanup,						 "second self_exec "						 "of child failed");				}#else				do_child();#endif			}			kill(fake_pid, TEST_SIG);			waitpid(fake_pid, &fake_status, 0);			TEST(kill(fake_pid, TEST_SIG));			kill(pid, TEST_SIG);			waitpid(pid, &status, 0);		}		if (TEST_RETURN != -1) {			tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s "				 "Expected a return value of -1 got %ld",				 TCID, TEST_ERRNO, strerror(TEST_ERRNO),				 TEST_RETURN);		 }		if (STD_FUNCTIONAL_TEST) {			/*			 * Check to see if the errno was set to the expected			 * value of 3 : ESRCH			 */			nsig = WTERMSIG(status);			TEST_ERROR_LOG(TEST_ERRNO);			if (TEST_ERRNO == ESRCH) {				tst_resm(TPASS, "errno set to %d : %s, as "					 "expected", TEST_ERRNO,					 strerror(TEST_ERRNO));			} else {				tst_resm(TFAIL, "errno set to %d : %s expected "					 "%d : %s", TEST_ERRNO,					 strerror(TEST_ERRNO), 3, strerror(3));			}		}	}	cleanup();	tst_exit();}
开发者ID:joyforu,项目名称:android-ltp-ndk,代码行数:89,


示例10: main

intmain(int ac, char **av){    int lc;		/* loop counter */    const 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);        /***************************************************************     * perform global setup for test     ***************************************************************/    setup();        /* set the expected errnos... */    TEST_EXP_ENOS(exp_enos);        /***************************************************************     * check looping state if -c option given     ***************************************************************/    for (lc=0; TEST_LOOPING(lc); lc++) {		/* reset Tst_count in case we are looping. */	Tst_count=0;	        if (write(fd, s, READ_BLOCK_SIZE) == -1) {	    tst_brkm(TBROK, cleanup,		     "write(%s, %s, %d) Failed, errno=%d : %s",		     fname, s, READ_BLOCK_SIZE, errno, strerror(errno));        }        offset+=READ_BLOCK_SIZE;        if (lseek(fd, (long)(offset-READ_BLOCK_SIZE), 0) == -1) {	    tst_brkm(TBROK, cleanup,		     "lseek(%s, %ld, 0) Failed, errno=%d : %s",		     fname, (long)(offset-READ_BLOCK_SIZE), errno, strerror(errno));        }	/* 	 * Call read(2)	 */	TEST(read(fd, s, READ_BLOCK_SIZE));		/* check return code */	if ( TEST_RETURN == -1 ) {	    TEST_ERROR_LOG(TEST_ERRNO);	    tst_resm(TFAIL, "read(fd, s, READ_BLOCK_SIZE) Failed, errno=%d : %s",		     TEST_ERRNO, strerror(TEST_ERRNO));	} else {	    /***************************************************************	     * only perform functional verification if flag set (-f not given)	     ***************************************************************/	    if ( STD_FUNCTIONAL_TEST ) {		/* No Verification test, yet... */		tst_resm(TPASS, "read(pfds) returned %d", TEST_RETURN);	    } 	}	    }	/* End for TEST_LOOPING */        /***************************************************************     * cleanup and exit     ***************************************************************/    cleanup();    return 0;}	/* End main */
开发者ID:ARMtools,项目名称:newlib-cygwin,代码行数:68,


示例11: main

int main(int ac, char **av){	int lc;	const char *msg;	char read_buf[BUF_SIZE];	/* buffer to hold data read from file */	int nread = 0, count, err_flg = 0;	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	for (lc = 0; TEST_LOOPING(lc); lc++) {		tst_count = 0;		setup();		TEST(msync(addr, page_sz, MS_ASYNC));		if (TEST_RETURN == -1) {			tst_resm(TFAIL | TERRNO, "msync failed");			continue;		}		if (STD_FUNCTIONAL_TEST) {			if (lseek(fildes, (off_t) 100, SEEK_SET) != 100)				tst_brkm(TBROK | TERRNO, cleanup,					 "lseek failed");			/*			 * Seeking to specified offset. successful.			 * Now, read the data (256 bytes) and compare			 * them with the expected.			 */			nread = read(fildes, read_buf, sizeof(read_buf));			if (nread != BUF_SIZE)				tst_brkm(TBROK, cleanup, "read failed");			else {				/*				 * Check whether read data (from mapped				 * file) contains the expected data				 * which was initialised in the setup.				 */				for (count = 0; count < nread; count++)					if (read_buf[count] != 1)						err_flg++;			}			if (err_flg != 0)				tst_resm(TFAIL,					 "data read from file doesn't match");			else				tst_resm(TPASS,					 "Functionality of msync() successful");		} else			tst_resm(TPASS, "call succeeded");		cleanup();	}	tst_exit();}
开发者ID:sozong,项目名称:ltp,代码行数:61,


示例12: main

int main(int ac, char **av){	int lc;	char *msg;	pid_t cpid;		/* Child process id */	int status;		/* child exit status */	/* Parse standard options given to run the test. */	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);#ifdef UCLINUX	maybe_run_child(&do_child, "dddd", &timereq.tv_sec, &timereq.tv_nsec,			&timerem.tv_sec, &timerem.tv_nsec);#endif	setup();	/* set the expected errnos... */	TEST_EXP_ENOS(exp_enos);	for (lc = 0; TEST_LOOPING(lc); lc++) {		Tst_count = 0;		/*		 * Creat a child process and suspend its		 * execution using nanosleep()		 */		if ((cpid = FORK_OR_VFORK()) == -1) {			tst_brkm(TBROK, cleanup, "fork() failed");		}		if (cpid == 0) {	/* Child process */#ifdef UCLINUX			if (self_exec(av[0], "dddd",				      timereq.tv_sec, timereq.tv_nsec,				      timerem.tv_sec, timerem.tv_nsec) < 0) {				tst_brkm(TBROK, cleanup, "self_exec failed");			}#else			do_child();#endif		}		/* wait for child to time slot for execution */		sleep(1);		/* Now send signal to child */		if (kill(cpid, SIGINT) < 0) {			tst_brkm(TBROK, cleanup,				 "kill() fails send signal to child");		}		/* Wait for child to execute */		wait(&status);		if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {			tst_resm(TPASS, "nanosleep() failed, interrupted"					" by signal (%d) as expected", EINTR);		} else {			tst_resm(TFAIL, "child process exited abnormally; "					"status = %d", status);		}	}	cleanup();	tst_exit();}
开发者ID:shubmit,项目名称:shub-ltp,代码行数:68,


示例13: main

int main(int ac, char **av){	int lc;	char *msg;	int i;	char *comp_string;	comp_string = NULL;	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	setup();	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* reset tst_count in case we are looping */		tst_count = 0;		for (i = 0; i < TST_TOTAL; ++i) {			osnamelth = SIZE(osname);			switch (i) {			case 0:				comp_string = buf.sysname;				break;			case 1:				comp_string = buf.release;				break;			case 2:				comp_string = buf.version;				break;			}			TEST(sysctl(TC[i].name, TC[i].size, TC[i].oldval,				    TC[i].oldlen, TC[i].newval, TC[i].newlen));			if (TEST_RETURN != 0) {				if (TEST_ERRNO == ENOSYS) {					tst_resm(TCONF,						 "You may need to make CONFIG_SYSCTL_SYSCALL=y"						 " to your kernel config.");				} else {					tst_resm(TFAIL,						 "sysctl(2) failed unexpectedly "						 "errno:%d", TEST_ERRNO);				}				continue;			}			if (!STD_FUNCTIONAL_TEST) {				tst_resm(TPASS, "call succeeded");				continue;			}			if (strcmp(TC[i].oldval, comp_string) != 0) {				tst_resm(TFAIL, "strings don't match - %s : %s",					 TC[i].oldval, comp_string);			} else {				tst_resm(TPASS, "%s is correct", TC[i].desc);			}			if (TC[i].cleanup) {				(void)TC[i].cleanup();			}		}	}	cleanup();	tst_exit();}
开发者ID:dacongy,项目名称:ltp,代码行数:71,


示例14: main

int main(int ac, char **av){	struct stat stat_buf;	/* stat(2) struct contents */	int lc;			/* loop counter */	char *msg;		/* message returned from parse_opts */	off_t file_length;	/* test file length */	/* Parse standard options given to run the test. */	msg = parse_opts(ac, av, NULL, NULL);	if (msg != 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 truncate(2) to truncate a test file to a		 * specified length.		 */		TEST(truncate(TESTFILE, TRUNC_LEN));		if (TEST_RETURN == -1) {			TEST_ERROR_LOG(TEST_ERRNO);			tst_resm(TFAIL,				 "truncate(%s, %d) Failed, errno=%d : %s",				 TESTFILE, TRUNC_LEN, TEST_ERRNO,				 strerror(TEST_ERRNO));		} else {			/*			 * Perform functional verification if test			 * executed without (-f) option.			 */			if (STD_FUNCTIONAL_TEST) {				/*				 * Get the testfile information using				 * stat(2).				 */				if (stat(TESTFILE, &stat_buf) < 0) {					tst_brkm(TFAIL, cleanup, "stat(2) of "						 "%s failed, error:%d",						 TESTFILE, errno);				 }				stat_buf.st_mode &= ~S_IFREG;				file_length = stat_buf.st_size;				/*				 * Check for expected size of testfile after				 * truncate(2) on it.				 */				if (file_length != TRUNC_LEN) {					tst_resm(TFAIL, "%s: Incorrect file "						 "size %"PRId64", Expected %d",						 TESTFILE, (int64_t)file_length,						 TRUNC_LEN);				} else {					tst_resm(TPASS, "Functionality of "						 "truncate(%s, %d) successful",						 TESTFILE, TRUNC_LEN);				}			} else {				tst_resm(TPASS, "%s call succeeded", TCID);			}		}		Tst_count++;	/* incr TEST_LOOP counter */	}	cleanup();	tst_exit();}
开发者ID:piet-delaney,项目名称:android-ltp-ndk,代码行数:78,


示例15: main

intmain(int ac, char **av){    int lc;		/* loop counter */    const 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, NULL, "OPTION PARSING ERROR - %s", msg);	tst_exit();    }    /***************************************************************     * perform global setup for test     ***************************************************************/    setup();    /* set the expected errnos... */    TEST_EXP_ENOS(exp_enos);    /***************************************************************     * check looping state if -c option given     ***************************************************************/    for (lc=0; TEST_LOOPING(lc); lc++) {	/* reset Tst_count in case we are looping. */	Tst_count=0;        /*         *  Call lseek(2)         */	TEST( lseek(-1, (long)1, SEEK_SET) );		/* check return code */	if ( TEST_RETURN == -1 ) {	    if ( STD_FUNCTIONAL_TEST ) {		if ( TEST_ERRNO == EBADF )	            tst_resm(TPASS,			"lseek(-1, 1, SEEK_SET) Failed, errno=%d : %s",		        TEST_ERRNO, strerror(TEST_ERRNO));		else	            tst_resm(TFAIL,			"lseek(-1, 1, SEEK_SET) Failed, errno=%d : %s, expected %d(EBADF)",		        TEST_ERRNO, strerror(TEST_ERRNO), EBADF);			    }	    else		Tst_count++;	} else {	    	    tst_resm(TFAIL, "lseek(-1, 1, SEEK_SET) returned %d", 		TEST_RETURN);	}    }	/* End for TEST_LOOPING */    /***************************************************************     * cleanup and exit     ***************************************************************/    cleanup();    return 0;}	/* End main */
开发者ID:hallco978,项目名称:msys,代码行数:68,


示例16: main

int main(int ac, char **av){    int lc;			/* loop counter */    char *msg;		/* message returned from parse_opts */    int i, red, wtstatus;    int pipefd[2];		/* fds for pipe read/write */    char rebuf[BUFSIZ];    int Acnt = 0, Bcnt = 0;	/* count 'A' and 'B' */    int fork_1, fork_2;	/* ret values in parent */    /* parse standard options */    if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *)NULL) {        tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);        /*NOTREACHED*/    }    setup();    for (lc = 0; TEST_LOOPING(lc); lc++) {        /* reset Tst_count in case we are looping */        Tst_count = 0;        TEST(pipe(pipefd));        if (TEST_RETURN == -1) {            tst_resm(TFAIL, "pipe() call failed");            continue;        }        if (!STD_FUNCTIONAL_TEST) {            tst_resm(TWARN, "-f option should not be used");            tst_resm(TPASS, "call succeeded");            continue;        }        if ((fork_1 = FORK_OR_VFORK()) == -1) {            tst_brkm(TBROK, cleanup, "fork() #1 failed");            /*NOTREACHED*/        }        if (fork_1 == 0) {	/* 1st child */            if (close(pipefd[0]) != 0) {                tst_resm(TWARN, "pipefd[0] close failed, "                         "errno = %d", errno);                exit(1);            }            for (i = 0; i < PIPEWRTCNT / 2; ++i) {                if (write(pipefd[1], "A", 1) != 1) {                    tst_resm(TWARN, "write to pipe failed");                    exit(1);                }            }            exit(0);        }        /* parent */        waitpid(fork_1, &wtstatus, 0);        if (WEXITSTATUS(wtstatus) != 0) {            tst_brkm(TBROK, cleanup, "problem detected in child, "                     "wait status %d, errno = %d", wtstatus, errno);        }        if ((fork_2 = FORK_OR_VFORK()) == -1) {            tst_brkm(TBROK, cleanup, "fork() #2 failed");            /*NOTREACHED*/        }        if (fork_2 == 0) {	/* 2nd child */            if (close(pipefd[0]) != 0) {                tst_resm(TWARN, "pipefd[0] close "                         "failed, errno = %d", errno);                exit(1);            }            for (i = 0; i < PIPEWRTCNT / 2; ++i) {                if (write(pipefd[1], "B", 1) != 1) {                    tst_resm(TWARN, "write to pipe failed");                    exit(1);                }            }            exit(0);        }        /* parent */        waitpid(fork_2, &wtstatus, 0);        if (WEXITSTATUS(wtstatus) != 0) {            tst_brkm(TBROK, cleanup, "problem detected in child, "                     "wait status %d, errno = %d", wtstatus, errno);        }        if (close(pipefd[1]) != 0) {            tst_brkm(TBROK, cleanup, "pipefd[1] close failed, "                     "errno = %d", errno);            /*NOTREACHED*/        }//.........这里部分代码省略.........
开发者ID:ystk,项目名称:debian-ltp,代码行数:101,


示例17: main

int main(int ac, char **av){	int lc;	char *msg;	int i;	/* Disable test if the version of the kernel is less than 2.6.16 */	if ((tst_kvercmp(2, 6, 16)) < 0) {		tst_resm(TWARN, "This test can only run on kernels that are ");		tst_resm(TWARN, "2.6.16 and higher");		exit(0);	}	/***************************************************************	 * parse standard options	 ***************************************************************/	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	/***************************************************************	 * perform global setup for test	 ***************************************************************/	setup();	/***************************************************************	 * check looping state if -c option given	 ***************************************************************/	for (lc = 0; TEST_LOOPING(lc); lc++) {		setup_every_copy();		Tst_count = 0;		/*		 * Call openat		 */		for (i = 0; i < TST_TOTAL; i++) {			TEST(myopenat			     (fds[i], filenames[i], O_CREAT | O_WRONLY, 0600));			/* check return code */			if (TEST_ERRNO == expected_errno[i]) {				/***************************************************************				 * only perform functional verification if flag set (-f not given)				 ***************************************************************/				if (STD_FUNCTIONAL_TEST) {					/* No Verification test, yet... */					tst_resm(TPASS,						 "openat() returned the expected errno %d: %s",						 TEST_ERRNO,						 strerror(TEST_ERRNO));				}			} else {				TEST_ERROR_LOG(TEST_ERRNO);				tst_resm(TFAIL,					 "openat() Failed, errno=%d : %s",					 TEST_ERRNO, strerror(TEST_ERRNO));			}		}	}	/***************************************************************	 * cleanup and exit	 ***************************************************************/	cleanup();	return (0);}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:69,


示例18: main

int main(int ac, char **av){	int lc;			/* loop counter */	char *msg;		/* message returned from parse_opts */	struct passwd *nobody;	pid_t pid;	struct sched_param param;	int status;	/* parse standard options */	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *)NULL) {		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);	 /*NOTREACHED*/}	setup();	TEST_EXP_ENOS(exp_enos);	/* check looping state if -i option is given */	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* reset Tst_count in case we are looping */		Tst_count = 0;		if ((pid = FORK_OR_VFORK()) == -1) {			tst_brkm(TBROK, cleanup, "fork failed");		}		if (pid == 0) {	/* child */			param.sched_priority = 1;			nobody = my_getpwnam(user1name);			if (seteuid(nobody->pw_uid) == -1) {				tst_brkm(TBROK, cleanup, "seteuid() failed");			}			TEST(sched_setscheduler(pid, SCHED_FIFO, &param));			if (TEST_ERRNO) {				TEST_ERROR_LOG(TEST_ERRNO);			}			if (TEST_RETURN != -1) {				tst_resm(TFAIL, "sched_setscheduler(2) passed "					 "with non root priveledges");			} else if (TEST_ERRNO != EPERM) {				tst_resm(TFAIL, "Expected EPERM, got %d",					 TEST_ERRNO);			} else {				tst_resm(TPASS, "got EPERM");			}		} else {	/* parent */			/* let the child carry on */			wait(&status);			if (WIFEXITED(status) != 0) {	/* Exit with errors */				exit(WEXITSTATUS(status));			} else {				exit(0);			}		}		if (seteuid(0) == -1) {			tst_brkm(TBROK, cleanup, "seteuid(0) failed");		}	}	cleanup();	 /*NOTREACHED*/ return 0;}
开发者ID:ystk,项目名称:debian-ltp,代码行数:71,


示例19: main

int main(int ac, char **av){	int lc;			/* loop counter */	char *msg;		/* message returned from parse_opts */	int status;		/* child process exit status */	int rval;		/* return value for wait() */	/* Parse standard options given to run the test. */	msg = parse_opts(ac, av, (option_t *) NULL, NULL);	if (msg != (char *)NULL) {		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);	}#ifdef UCLINUX	maybe_run_child(&do_child_uclinux, "");#endif	/* Perform global setup for test */	setup();	/* set the expected errnos... */	TEST_EXP_ENOS(exp_enos);	/* Check looping state if -i option given */	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* Reset Tst_count in case we are looping. */		Tst_count = 0;		/* Creat a new process using fork() */		if ((cpid = FORK_OR_VFORK()) == -1) {			tst_brkm(TBROK, cleanup, "fork() failed");		}		if (cpid == 0) {	/* Child process */#ifdef UCLINUX			if (self_exec(av[0], "") < 0) {				tst_brkm(TBROK, cleanup, "self_exec failed");			}#else			do_child();#endif		}		/* Parent process */		/* sleep to ensure the child executes */		sleep(1);		/*		 * Send the SIGINT signal now, so that child		 * returns from pause and resumes execution.		 */		kill(cpid, SIGINT);		/* Sleep to ensure the signal sent is effected */		sleep(1);		/*		 * In case pause() doesn't return witin 2 seconds,		 * set the alarm to send SIGKILL for the child.		 */		signal(SIGALRM, kill_handle);		alarm(2);		/* wait for child to exit */		wait(&status);		TEST_ERROR_LOG(status >> 8);		/* Reset the timer in case pause() returned */		alarm(0);		/*		 * Verify that, wait() returned due to normal		 * or abnormal termination of child due to		 * receipt of signal SIGKILL.		 * Receipt of SIGKILL indicates that pause()		 * didn't returned after receipt of SIGINT.		 */		if (WTERMSIG(status) == SIGKILL) {			rval = wait(&status);			if ((rval == -1) && (errno == ECHILD)) {				tst_resm(TFAIL, "pause() didn't return "					 "as expected");			}		}	}			/* End for TEST_LOOPING */	/* Call cleanup() to undo setup done for the test. */	cleanup();	return 0;}				/* End main */
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:92,


示例20: main

int main(int ac, char **av){    int lc;    char *msg;    TST_TOTAL = (sizeof(args) / sizeof(args[0])) - 1;    /***************************************************************     * parse standard options     ***************************************************************/    if ((msg = parse_opts(ac, av, options, &help)) != NULL)        tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);    if (!lflag) {        path = strdup("/tmp");    }    /***************************************************************     * perform global setup for test     ***************************************************************/    setup();    /* set the expected errnos... */    TEST_EXP_ENOS(exp_enos);    /***************************************************************     * check looping state if -c option given     ***************************************************************/    for (lc = 0; TEST_LOOPING(lc); lc++) {        tst_count = 0;        for (i = 0; i < TST_TOTAL; i++) {            errno = -4;            /*             * Call pathconf(2)             */            TEST(pathconf(path, args[i].value));            /*             * A test case can only fail if -1 is returned and the errno             * was set.  If the errno remains unchanged, the             * system call did not fail.             */            if (TEST_RETURN == -1 && errno != -4) {                tst_resm(TFAIL,                         "pathconf(%s, %s) Failed, errno=%d : %s",                         path, args[i].define_tag, TEST_ERRNO,                         strerror(TEST_ERRNO));            } else {                /***************************************************************                 * only perform functional verification if flag set (-f not given)                 ***************************************************************/                if (STD_FUNCTIONAL_TEST) {                    /* No Verification test, yet... */                    tst_resm(TPASS,                             "pathconf(%s, %s) returned %ld",                             path, args[i].define_tag,                             TEST_RETURN);                }            }        }    }    /***************************************************************     * cleanup and exit     ***************************************************************/    cleanup();    tst_exit();}
开发者ID:nloopa,项目名称:Linux-Test-Project,代码行数:73,


示例21: main

int main(int argc, char **argv){	int lc;	tst_parse_opts(argc, argv, NULL, NULL);	setup();	pass = 0;	for (lc = 0; TEST_LOOPING(lc); lc++) {		int i, pid;		tst_count = 0;		if ((pid = FORK_OR_VFORK()) == -1) {			tst_brkm(TBROK, cleanup, "fork failed");		} else if (pid == 0) {	/* child */			for (i = 0; i < TST_TOTAL; i++) {				/* Set the real or effective user id */				TEST(SETREUID(cleanup, *test_data[i].real_uid,					      *test_data[i].eff_uid));				if (TEST_RETURN == *test_data[i].exp_ret) {					if (TEST_RETURN == neg_one) {						if (TEST_ERRNO != EPERM) {							tst_resm(TFAIL,								 "setreuid(%d, %d) "								 "did not set errno "								 "value as expected.",								 *test_data								 [i].real_uid,								 *test_data								 [i].eff_uid);							continue;						}						tst_resm(TPASS,							 "setreuid(%d, %d) "							 "failed as expected.",							 *test_data[i].real_uid,							 *test_data[i].eff_uid);					} else {						tst_resm(TPASS,							 "setreuid(%d, %d) "							 "succeeded as expected.",							 *test_data[i].real_uid,							 *test_data[i].eff_uid);					}				} else {					tst_resm(TFAIL, "setreuid(%d, %d) "						 "did not return as expected.",						 *test_data[i].real_uid,						 *test_data[i].eff_uid);				}				if (TEST_RETURN == -1) {				}				uid_verify(test_data[i].exp_real_usr,					   test_data[i].exp_eff_usr,					   test_data[i].test_msg);			}			tst_exit();		} else {	/* parent */			tst_record_childstatus(cleanup, pid);		}	}	cleanup();	tst_exit();}
开发者ID:AbhiramiP,项目名称:ltp,代码行数:69,


示例22: main

int main(int ac, char **av){	int lc;	char *msg;	char *node_name;	/* ptr. for node name created */	char *test_desc;	/* test specific error message */	int ind;		/* counter to test different test conditions */	msg = parse_opts(ac, av, NULL, NULL);	if (msg != NULL) {		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);	}	/*	 * Invoke setup function to call individual test setup functions	 * for the test which run as root/super-user.	 */	setup();	/* set the expected errnos... */	TEST_EXP_ENOS(exp_enos);	for (lc = 0; TEST_LOOPING(lc); lc++) {		tst_count = 0;		for (ind = 0; Test_cases[ind].desc != NULL; ind++) {			node_name = Test_cases[ind].pathname;			test_desc = Test_cases[ind].desc;#if !defined(UCLINUX)			if (node_name == High_address_node) {				node_name = get_high_address();			}#endif			/*			 * Call mknod(2) to test different test conditions.			 * verify that it fails with -1 return value and			 * sets appropriate errno.			 */			TEST(mknod(node_name, MODE_RWX, 0));			/* Check return code from mknod(2) */			if (TEST_RETURN != -1) {				tst_resm(TFAIL,					 "mknod() returned %ld, expected "					 "-1, errno:%d", TEST_RETURN,					 Test_cases[ind].exp_errno);				continue;			}			TEST_ERROR_LOG(TEST_ERRNO);			if (TEST_ERRNO == Test_cases[ind].exp_errno) {				tst_resm(TPASS, "mknod() fails, %s, errno:%d",					 test_desc, TEST_ERRNO);			} else {				tst_resm(TFAIL, "mknod() fails, %s, errno:%d, "					 "expected errno:%d", test_desc,					 TEST_ERRNO, Test_cases[ind].exp_errno);			}		}	}	/*	 * Invoke cleanup() to delete the test directories created	 * in the setup().	 */	cleanup();	tst_exit();}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:75,


示例23: main

int main(int ac, char **av){	int lc;			/* loop counter */	char *msg;		/* message returned from parse_opts */	int i;	/*	 * parse standard options	 */	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *)NULL) {		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);	}	/*	 * perform global setup for test	 */	setup();	/* set the expected errnos... */	TEST_EXP_ENOS(exp_enos);	/*	 * check looping state if -i option given	 */	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* reset Tst_count in case we are looping. */		Tst_count = 0;		/* loop through the test cases */		for (i = 0; i < TST_TOTAL; i++) {			TEST(rename(TC[i].fd1, TC[i].fd2));			if (TEST_RETURN != -1) {				tst_resm(TFAIL, "call succeeded unexpectedly");				continue;			}			TEST_ERROR_LOG(TEST_ERRNO);			if (TEST_ERRNO == TC[i].error) {				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), TC[i].error);			}		}	}			/* End for TEST_LOOPING */	/*	 * cleanup and exit	 */	cleanup();	 /*NOTREACHED*/ return 0;}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:61,


示例24: main

int main(int ac, char **av){	int lc,getmaxid=0;				/* loop counter */	char *msg;			/* message returned from parse_opts */	FILE *fp;	/* parse standard options */	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);	}	/* Set the MAXIDS for the specific machine by reading the system limit           for SEMMNI - The maximum number of sempahore sets                  */	if((fp = fopen("/proc/sys/kernel/sem", "r")) != NULL) 	  {	    for(lc= 0; lc < 4; lc++)	      {		if(lc == 3)		  {		    if(getmaxid > MAXIDS)		      MAXIDS=getmaxid;		  }	      }	  }	if(fp) 		fclose(fp);	sem_id_arr = (int*)malloc(sizeof(int)*MAXIDS);	setup();			/* global setup */		/* 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;		/* use the TEST macro to make the call */			TEST(semget(semkey + num_sems, PSEMS,			    IPC_CREAT | IPC_EXCL | SEM_RA));		/*	printf("rc = %ld /n",	TEST_RETURN); */		if (TEST_RETURN != -1) {			tst_resm(TFAIL, "call succeeded when error expected");			continue;		}			TEST_ERROR_LOG(TEST_ERRNO);		switch(TEST_ERRNO) {		case ENOSPC:			tst_resm(TPASS, "expected failure - errno "				 "= %d : %s", TEST_ERRNO, strerror(TEST_ERRNO));			break;		default:			tst_resm(TFAIL, "unexpected error - %d : %s",				 TEST_ERRNO, strerror(TEST_ERRNO));			break;		}	}	cleanup();	/*NOTREACHED*/	return(0);}
开发者ID:AgamAgarwal,项目名称:minix,代码行数:67,


示例25: main

int main(int ac, char **av){	int lc;	int rval;	pid_t pid, pid1;	int status;	/*	 * parse standard options	 */	tst_parse_opts(ac, av, NULL, NULL);	/*	 * perform global setup for test	 */	setup();	/*	 * check looping state if -i option given	 */	for (lc = 0; TEST_LOOPING(lc); lc++) {		tst_count = 0;		/* Initialize the test directories name */		sprintf(tstdir1, "tstdir1.%d", getpid());		if ((pid = FORK_OR_VFORK()) < 0) {			tst_brkm(TBROK, cleanup, "fork #1 failed");		}		if (pid == 0) {	/* first child */			rval = setreuid(nobody_uid, nobody_uid);			if (rval < 0) {				tst_resm(TFAIL, "setreuid failed to "					 "to set the real uid to %d and "					 "effective uid to %d",					 nobody_uid, nobody_uid);				perror("setreuid");				exit(1);			}			/* create the parent directory with 0700 permits */			if (mkdir(tstdir1, PERMS) == -1) {				tst_resm(TFAIL, "mkdir(%s, %#o) Failed",					 tstdir1, PERMS);				exit(1);			}			/* create tstdir1 succeeded */			exit(0);		}		wait(&status);		if (WEXITSTATUS(status) != 0) {			tst_brkm(TFAIL, cleanup,				 "Test to check mkdir EACCES failed"				 "in create parent directory");		}		sprintf(tstdir2, "%s/tst", tstdir1);		if ((pid1 = FORK_OR_VFORK()) < 0) {			tst_brkm(TBROK, cleanup, "fork #2 failed");		}		if (pid1 == 0) {	/* second child */			rval = setreuid(bin_uid, bin_uid);			if (rval < 0) {				tst_resm(TFAIL, "setreuid failed to "					 "to set the real uid to %d and "					 "effective uid to %d",					 bin_uid, bin_uid);				perror("setreuid");				exit(1);			}			if (mkdir(tstdir2, PERMS) != -1) {				tst_resm(TFAIL, "mkdir(%s, %#o) unexpected "					 "succeeded", tstdir2, PERMS);				exit(1);			}			if (errno != EACCES) {				tst_resm(TFAIL, "Expected EACCES got %d",					 errno);				exit(1);			}			/* PASS */			exit(0);		}		waitpid(pid1, &status, 0);		if (WEXITSTATUS(status) == 0) {			tst_resm(TPASS, "Test to attempt to creat a directory "				 "in a directory having no permissions "				 "SUCCEEDED in setting errno to EACCES");		} else {			tst_resm(TFAIL, "Test to attempt to creat a directory "				 "in a directory having no permissions FAILED");			cleanup();		}	}	/*	 * cleanup and exit	 *///.........这里部分代码省略.........
开发者ID:AbhiramiP,项目名称:ltp,代码行数:101,


示例26: main

int main(int ac, char **av){	int lc;	char *msg;	pid_t c1pid, c2pid;	int wtstatus;	int bytesread;	int acnt = 0, bcnt = 0;	char rbuf[BUFSIZ];	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);#ifdef UCLINUX	maybe_run_child(&c1func, "ndd", 1, &fildes[0], &fildes[1]);	maybe_run_child(&c2func, "ndd", 2, &fildes[0], &fildes[1]);#endif	setup();	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* reset Tst_count in case we are looping */		Tst_count = 0;		if (pipe(fildes) == -1)			tst_brkm(TBROK, cleanup, "pipe() failed - errno %d",				 errno);		if ((c1pid = FORK_OR_VFORK()) == -1)			tst_brkm(TBROK, cleanup, "fork() failed - "				 "errno %d", errno);		if (c1pid == 0)#ifdef UCLINUX			if (self_exec(av[0], "ndd", 1, fildes[0], fildes[1]) <			    0) {				tst_brkm(TBROK, cleanup, "self_exec failed");			}#else			c1func();#endif		if ((c2pid = FORK_OR_VFORK()) == -1)			tst_brkm(TBROK, cleanup, "fork() failed - "				 "errno %d", errno);		if (c2pid == 0)#ifdef UCLINUX			if (self_exec(av[0], "ndd", 2, fildes[0], fildes[1]) <			    0) {				tst_brkm(TBROK, cleanup, "self_exec failed");			}#else			c2func();#endif		/* PARENT */		if (close(fildes[1]) == -1)			tst_resm(TWARN, "Could not close fildes[1] - errno %d",				 errno);		/*		 * Read a bit from the children first		 */		while ((acnt < 100) && (bcnt < 100)) {			bytesread = safe_read(fildes[0], rbuf, sizeof(rbuf));			if (bytesread < 0) {				tst_resm(TFAIL, "Unable to read from pipe, "					 "errno=%d", errno);				break;			}			switch (rbuf[1]) {			case 'A':				acnt++;				break;			case 'b':				bcnt++;				break;			default:				tst_resm(TFAIL, "Got bogus '%c' "					 "character", rbuf[1]);				break;			}		}		/*		 * Try to kill the children		 */		if (kill(c1pid, SIGKILL) == -1)			tst_resm(TFAIL, "failed to kill child 1, errno=%d",				 errno);		if (kill(c2pid, SIGKILL) == -1)			tst_resm(TFAIL, "failed to kill child 1, errno=%d",				 errno);		/*		 * Set action for the alarm		 */		if (signal(SIGALRM, alarmfunc) == SIG_ERR)			tst_resm(TWARN|TERRNO, "call to signal failed");		/*		 * Set an alarm for 60 seconds just in case the child		 * processes don't die//.........这里部分代码省略.........
开发者ID:shubmit,项目名称:shub-ltp,代码行数:101,


示例27: main

intmain(int argc, char *argv[]){	int clt_sk, svr_sk, accept_sk;	sockaddr_storage_t svr_loop, accept_loop;	sockaddr_storage_t svr_local_addr, svr_peer_addr;	sockaddr_storage_t clt_local_addr, clt_peer_addr;	socklen_t len;	int error;	int pf_class;        /* Rather than fflush() throughout the code, set stdout to	 * be unbuffered.	 */	setvbuf(stdout, NULL, _IONBF, 0);	/* Initialize the server and client addresses. */#if TEST_V6	pf_class = PF_INET6;        svr_loop.v6.sin6_family = AF_INET6;        svr_loop.v6.sin6_addr = (struct in6_addr)SCTP_IN6ADDR_ANY_INIT;        svr_loop.v6.sin6_port = htons(SCTP_TESTPORT_1);#else	pf_class = PF_INET;	svr_loop.v4.sin_family = AF_INET;	svr_loop.v4.sin_addr.s_addr = INADDR_ANY;	svr_loop.v4.sin_port = htons(SCTP_TESTPORT_1);#endif	/* Create and bind the listening server socket.  */        svr_sk = test_socket(pf_class, SOCK_STREAM, IPPROTO_SCTP);	test_bind(svr_sk, &svr_loop.sa, sizeof(svr_loop));	memset(&svr_local_addr, 0x00, sizeof(svr_local_addr));	len = sizeof(svr_local_addr);	/* Verify that getsockname() on an unconnected socket works fine. */	error = getsockname(svr_sk, (struct sockaddr *)&svr_local_addr, &len);	if (0 != error)		tst_brkm(TBROK, NULL, "getsockname: %s", strerror(errno));	tst_resm(TPASS, "getsockname on an unconnected socket");	memset(&svr_peer_addr, 0x00, sizeof(svr_peer_addr));	len = sizeof(svr_peer_addr);	/* Verify that getpeername() on an unconnected socket fails. */	error = getpeername(svr_sk, (struct sockaddr *)&svr_peer_addr, &len);	if ((-1 != error) || (ENOTCONN != errno))		tst_brkm(TBROK, NULL, "getpeername on an unconnected "			 "socket error:%d, errno:%d", error, errno);	tst_resm(TPASS, "getpeername on an unconnected socket");	/* Mark svr_sk as being able to accept new associations.  */	test_listen(svr_sk, 5);	/* Create the client socket.  */	clt_sk = test_socket(pf_class, SOCK_STREAM, IPPROTO_SCTP);	/* Do a blocking connect from clt_sk to svr_sk */#if TEST_V6	svr_loop.v6.sin6_addr = in6addr_loopback;#else	svr_loop.v4.sin_addr.s_addr = SCTP_IP_LOOPBACK;#endif	test_connect(clt_sk, &svr_loop.sa, sizeof(svr_loop));	memset(&clt_local_addr, 0x00, sizeof(clt_local_addr));	len = sizeof(clt_local_addr);	/* Get the client's local address. */	error = getsockname(clt_sk, (struct sockaddr *)&clt_local_addr, &len);	if (0 != error)		tst_brkm(TBROK, NULL, "getsockname on a connected client "			 "socket: %s", strerror(errno));	tst_resm(TPASS, "getsockname on a connected client socket");	memset(&clt_peer_addr, 0x00, sizeof(clt_peer_addr));	len = sizeof(clt_peer_addr);	/* Get the client's peer address. */	error = getpeername(clt_sk, (struct sockaddr *)&clt_peer_addr, &len);	if (0 != error)		tst_brkm(TBROK, NULL, "getpeername on a connected client "			 "socket: %s", strerror(errno));	tst_resm(TPASS, "getpeername on a connected client socket");	/* Extract the association on the listening socket as a new socket. */	len = sizeof(accept_loop);	accept_sk = test_accept(svr_sk, &accept_loop.sa, &len);	memset(&svr_local_addr, 0x00, sizeof(svr_local_addr));	len = sizeof(svr_local_addr);	/* Get the server's local address. */	error = getsockname(accept_sk, (struct sockaddr *)&svr_local_addr,				&len);	if (0 != error)		tst_brkm(TBROK, NULL, "getsockname on a connected server "			 "socket: %s", strerror(errno));	tst_resm(TPASS, "getsockname on a connected server socket");//.........这里部分代码省略.........
开发者ID:shubmit,项目名称:shub-ltp,代码行数:101,


示例28: setup

/* * setup(void) - performs all ONE TIME setup for this test. * 	Exit the test program on receipt of unexpected signals. *	Create a temporary directory used to hold test directories created *	and change the directory to it. *	Verify that pid of process executing the test is root. *	Create a test directory on temporary directory and set the ownership *	of test directory to nobody user. *	Set the effective uid/gid of the process to that of nobody user. */voidsetup(){	/* Capture unexpected signals */	tst_sig(NOFORK, DEF_HANDLER, cleanup);	/* Check that the test process id is super/root  */	if (geteuid() != 0) {		tst_brkm(TBROK, NULL, "Must be super/root for this test!"); 		tst_exit();	}	/* Pause if that option was specified */	TEST_PAUSE;	/* Make a temp dir and cd to it */	tst_tmpdir();        /* fix permissions on the tmpdir */        if (chmod(".", 0711) != 0) {                tst_brkm(TBROK, cleanup, "chmod() failed");        }	/* Save the real user id of the test process */        save_myuid = getuid();	/* Save the process id of the test process */        mypid = getpid();	/* Get the node name to be created in the test */	sprintf(node_name, TNODE, mypid);	/* Get the uid/gid of guest user - nobody */	if ((user1 = getpwnam(LTPUSER)) == NULL) {		tst_brkm(TBROK, cleanup, "%s not in /etc/passwd",			 LTPUSER);	}	user1_uid = user1->pw_uid;	group1_gid = user1->pw_gid;	/* Get effective group id of the test process */        group2_gid = getegid();	/*	 * Create a test directory under temporary directory with the	 * specified mode permissions, with uid/gid set to that of guest	 * user and the test process.	 */	if (mkdir(DIR_TEMP, MODE_RWX) < 0) {		tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", DIR_TEMP);	}	if (chown(DIR_TEMP, user1_uid, group2_gid) < 0) {		tst_brkm(TBROK, cleanup, "chown(2) of %s failed", DIR_TEMP);	}	/*	 * Verify that test directory created with expected permission modes	 * and ownerships.	 */	if (stat(DIR_TEMP, &buf) < 0) {		tst_brkm(TBROK, cleanup, "stat(2) of %s failed", DIR_TEMP);	}	/* Verify modes of test directory */	if (buf.st_mode & S_ISGID) {		tst_brkm(TBROK, cleanup,			 "%s: Incorrect modes, setgid bit set", DIR_TEMP);	}	/* Verify group ID */	if (buf.st_gid != group2_gid) {		tst_brkm(TBROK, cleanup, "%s: Incorrect group", DIR_TEMP);	}	   	/* 	 * Set the effective group id and user id of the test process 	 * to that of guest user.	 */	if (setgid(group1_gid) < 0) {		tst_brkm(TBROK, cleanup,			 "Unable to set process gid to that of ltp user");	}	if (setreuid(-1, user1_uid) < 0) {		tst_brkm(TBROK, cleanup,			 "Unable to set process uid to that of ltp user");	}	/* Save the real group ID of the current process */	mygid = getgid();//.........这里部分代码省略.........
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:101,


示例29: main

int main(int ac, char **av){	int lc;	char *msg;	int i;	char *comp_string;	/* parse standard options */	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);	}	setup();	/* check looping state if -i option is given */	for (lc = 0; TEST_LOOPING(lc); lc++) {		/* reset Tst_count in case we are looping */		Tst_count = 0;		for (i = 0; i < TST_TOTAL; ++i) {			osnamelth = SIZE(osname);			switch (i) {			case 0:				comp_string = buf.sysname;				break;			case 1:				comp_string = buf.release;				break;			case 2:				comp_string = buf.version;				break;			}			TEST(sysctl(TC[i].name, TC[i].size, TC[i].oldval,					  TC[i].oldlen, TC[i].newval,					  TC[i].newlen));			if (TEST_RETURN != 0) {				tst_resm(TFAIL, "sysctl(2) failed unexpectedly "					 "errno:%d", errno);				continue;			}			if (!STD_FUNCTIONAL_TEST) {				tst_resm(TPASS, "call succeeded");				continue;			}			if (strcmp(TC[i].oldval, comp_string) != 0) {				tst_resm(TFAIL, "strings don't match - %s : %s",					 TC[i].oldval, comp_string);			} else {				tst_resm(TPASS, "%s is correct", TC[i].desc);			}			if (TC[i].cleanup) {				(void)TC[i].cleanup();			}		}	}	cleanup();	/*NOTREACHED*/	return(0);}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:67,



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


C++ tst_kvercmp函数代码示例
C++ tst_brk函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。