Ejemplo n.º 1
0
int main(int ac, char **av)
{
	int lc;

	tst_parse_opts(ac, av, options, &help);

	if (sflag)
		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);

	setup();

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

		if (shmdt(shared) == -1) {
			tst_resm(TFAIL | TERRNO, "shmdt");
		} else {
			check_functionality();
		}

		/* reattach the shared memory segment in case we are looping */
		shared = shmat(shm_id_1, 0, 0);
		if (shared == (void *)-1)
			tst_brkm(TBROK | TERRNO, cleanup, "shmat #2: reattach");

		/* also reset pass */
		pass = 0;
	}
	cleanup();
	tst_exit();
}
Ejemplo n.º 2
0
int main(int ac, char **av)
{
	int lc;				/* loop counter */
	char *msg;			/* message returned from parse_opts */
	int i;
	void check_functionality(int);

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

	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;

		/* loop through the test cases */
		for (i=0; i<TST_TOTAL; i++) {

			/*
			 * Use TEST macro to make the call
			 */
			errno = 0;
			addr = shmat(*(TC[i].shmid), (void *)(TC[i].addr),
				   TC[i].flags);
			TEST_ERRNO = errno;
	
			if (addr == (void *)-1) {
				tst_brkm(TFAIL, cleanup, "%s call failed - "
					 "errno = %d : %s", TCID, TEST_ERRNO,
					 strerror(TEST_ERRNO));
			} else {
				if (STD_FUNCTIONAL_TEST) {
					check_functionality(i);
				} else {
					tst_resm(TPASS, "call succeeded");
				}
			}

			/*
			 * clean up things in case we are looping - in
			 * this case, detach the shared memory
			 */
			if (shmdt((const void *)addr) == -1) {
				tst_brkm(TBROK, cleanup,
					 "Couldn't detach shared memory");
			}
		}
	}

	cleanup();

	/*NOTREACHED*/
	return(0);
}
Ejemplo n.º 3
0
int main(int ac, char **av)
{
	int lc;				/* loop counter */
	char *msg;			/* message returned from parse_opts */
	void check_functionality(void);

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

        if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
             tst_brkm(TBROK, cleanup, "Test cannot be continued owning to sufficient availability of Hugepages on the system");
        else             
             huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() * hugepages_size() * 1024) / 2 ;

	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 TEST macro to make the shmdt() call
		 */

		TEST(shmdt((const void *)shared));

		if (TEST_RETURN == -1) {
			tst_resm(TFAIL, "%s call failed - errno = %d : %s",
				 TCID, TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			if (STD_FUNCTIONAL_TEST) {
				check_functionality();
			} else {
				tst_resm(TPASS, "call succeeded");
			}
		}

		/* reattach the shared memory segment in case we are looping */
		shared = (int*)shmat(shm_id_1, 0, 0);

		if (*shared == -1) {
			tst_brkm(TBROK, cleanup, "memory reattach failed");
		}

		/* also reset pass */
		pass = 0;
	}

	cleanup();

	/*NOTREACHED*/
	return 0;
}
Ejemplo n.º 4
0
int main(int ac, char **av)
{
	int lc;			/* loop counter */
	char *msg;		/* message returned from parse_opts */
	void check_functionality(void);

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

	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 TEST macro to make the call
		 */

		TEST(semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA));

		if (TEST_RETURN == -1) {
			tst_resm(TFAIL, "%s call failed - errno = %d : %s",
				 TCID, TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			/* get the semaphore ID */
			sem_id_1 = TEST_RETURN;

			if (STD_FUNCTIONAL_TEST) {
				check_functionality();
			} else {
				tst_resm(TPASS, "semaphore was created");
			}
		}

		/*
		 * remove the semaphore that was created and mark the ID
		 * as invalid.
		 */
		if (sem_id_1 != -1) {
			rm_sema(sem_id_1);
			sem_id_1 = -1;
		}
	}

	cleanup();

	 /*NOTREACHED*/ return 0;
}
Ejemplo n.º 5
0
Archivo: msgget01.c Proyecto: 1587/ltp
int main(int ac, char **av)
{
	int lc;
	void check_functionality(void);

	tst_parse_opts(ac, av, NULL, NULL);

	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 TEST macro to make the call to create the message queue
		 */

		TEST(msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RD | MSG_WR));

		if (TEST_RETURN == -1) {
			tst_resm(TFAIL, "%s call failed - errno = %d : %s",
				 TCID, TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			msg_q_1 = TEST_RETURN;
			/*
			 * write a message to the queue.
			 * read back the message.
			 * PASS the test if they are the same.
			 */
			check_functionality();
		}

		/*
		 * remove the message queue that was created and mark the ID
		 * as invalid.
		 */
		if (msg_q_1 != -1) {
			rm_queue(msg_q_1);
			msg_q_1 = -1;
		}
	}

	cleanup();
	tst_exit();
}
Ejemplo n.º 6
0
int main(int ac, char **av)
{
	int lc;
	const char *msg;
	void check_functionality(void);

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

	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 TEST macro to make the shmdt() call
		 */

		TEST(shmdt((const void *)shared));

		if (TEST_RETURN == -1) {
			tst_resm(TFAIL, "%s call failed - errno = %d : %s",
				 TCID, TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			check_functionality();
		}

		/* reattach the shared memory segment in case we are looping */
		shared = (int *)shmat(shm_id_1, 0, 0);

		if (shared == (void *)-1) {
			tst_brkm(TBROK, cleanup, "memory reattach failed");
		}

		/* also reset pass */
		pass = 0;
	}

	cleanup();

	tst_exit();
}
int main(int ac, char **av)
{
	int lc, i;

	tst_parse_opts(ac, av, options, &help);

	if (sflag)
		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);

	setup();

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

		for (i = 0; i < TST_TOTAL; i++) {
			addr = shmat(*(TC[i].shmid), TC[i].addr, TC[i].flags);
			if (addr == (void *)-1) {
				tst_brkm(TFAIL | TERRNO, cleanup, "shmat");
			} else {
				check_functionality(i);
			}

			/*
			 * addr in TC[0] will be used to generate an unaligned
			 * address for TC[1]
			 */
			if (i == 0 && addr != (void *)-1)
				TC[1].addr = (void *)(((unsigned long)addr &
						       ~(SHMLBA - 1)) + SHMLBA -
						      1);
			if (shmdt(addr) == -1)
				tst_brkm(TBROK | TERRNO, cleanup, "shmdt");
		}
	}
	cleanup();
	tst_exit();
}
Ejemplo n.º 8
0
int main(int ac, char **av)
{
	int lc;			/* loop counter */
	char *msg;		/* message returned from parse_opts */
	void check_functionality(void);
	int r_val;

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

	setup();		/* global setup */

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

		/* get the name of the test dirctory */
		if ((temp_dir = (getcwd(temp_dir, 0))) == NULL)
			tst_brkm(TBROK, cleanup, "getcwd failed");

		/*
		 * create a new directory and open it
		 */

		if ((r_val = mkdir(TEST_DIR, MODES)) == -1)
			tst_brkm(TBROK, cleanup, "mkdir failed");

		if ((fd = open(TEST_DIR, O_RDONLY)) == -1)
			tst_brkm(TBROK, cleanup, "open of directory failed");

		TEST(fchdir(fd));

		if (TEST_RETURN == -1)
			tst_brkm(TFAIL|TTERRNO, cleanup, "fchdir call failed");
		else {
			if (STD_FUNCTIONAL_TEST)
				check_functionality();
			else
				tst_resm(TPASS, "call succeeded");
		}

		/*
		 * clean up things in case we are looping
		 */

		/*
		 * NOTE: in case of failure here, we need to use "tst_resm()"
		 * and not "tst_brkm()".  This is because if we get to this
		 * point, we have already set a PASS or FAIL for the test
		 * and "tst_brkm()" won't report as we might expect.
		 */

		/* chdir back to our temporary work directory */
		if ((r_val = chdir("..")) == -1)
			tst_resm(TBROK|TERRNO, "chdir failed");

		if ((r_val = rmdir(TEST_DIR)) == -1)
			tst_resm(TBROK|TERRNO, "rmdir failed");

		free(temp_dir);
		temp_dir = NULL;
	}

	cleanup();

	tst_exit();
}