ipc tests by GQ

This commit is contained in:
Ben Gras
2009-09-21 14:53:53 +00:00
parent 75d3db4911
commit a4d1b17453
98 changed files with 19446 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
# Makefile for the tests
CC = exec cc
CFLAGS = -Wall -D_MINIX -D_POSIX_SOURCE -I../lib/
PROG = semget01 semget02 semget03 semget05 semget06
all: $(PROG)
$(PROG): tst_res.o libipc.o tst_sig.o parse_opts.o tst_tmpdir.o rmobj.o
$(CC) $(CFLAGS) -o $@ $@.c tst_res.o libipc.o tst_sig.o parse_opts.o tst_tmpdir.o rmobj.o
rmobj.o: ../lib/rmobj.c
$(CC) $(CFLAGS) -c -o rmobj.o ../lib/rmobj.c
tst_res.o: ../lib/tst_res.c
$(CC) $(CFLAGS) -c -o tst_res.o ../lib/tst_res.c
tst_sig.o: ../lib/tst_sig.c
$(CC) $(CFLAGS) -c -o tst_sig.o ../lib/tst_sig.c
tst_tmpdir.o: ../lib/tst_tmpdir.c
$(CC) $(CFLAGS) -c -o tst_tmpdir.o ../lib/tst_tmpdir.c
parse_opts.o: ../lib/parse_opts.c
$(CC) $(CFLAGS) -c -o parse_opts.o ../lib/parse_opts.c
libipc.o: ../lib/libipc.c
$(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c
clean:
/usr/bin/rm -f *.o $(PROG)
test:
sh ./test.sh
semget01: semget01.c
semget02: semget02.c
semget03: semget03.c
semget05: semget05.c
semget06: semget06.c
+198
View File
@@ -0,0 +1,198 @@
/*
*
* Copyright (c) International Business Machines Corp., 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* NAME
* semget01.c
*
* DESCRIPTION
* semget01 - test that semget() correclty creates a semaphore set
*
* ALGORITHM
* loop if that option was specified
* call semget() to create the semaphore set
* check the return code
* if failure, issue a FAIL message.
* otherwise,
* if doing functionality testing
* stat the semaphore set
* if the number of primitive semaphores is correct and
* the semaphore uid == the process uid
* then,
* issue a PASS message
* otherwise
* issue a FAIL message
* call cleanup
*
* USAGE: <for command-line>
* semget01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
* where, -c n : Run n copies concurrently.
* -f : Turn off functionality Testing.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
* none
*/
#include "ipcsem.h"
#include "usctest.h"
char *TCID = "semget01";
int TST_TOTAL = 1;
extern int Tst_count;
int sem_id_1 = -1;
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);
}
/*
* check_functionality() - check the functionality of the tested system call.
*/
void
check_functionality(void)
{
struct semid_ds semary;
union semun un_arg; /* union defined in ipcsem.h */
/* STAT the semaphore */
un_arg.buf = &semary;
if (semctl(sem_id_1, 0, IPC_STAT, un_arg) == -1) {
tst_brkm(TBROK, cleanup, "Could not stat the semaphore");
return;
}
if (un_arg.buf->sem_nsems != PSEMS) {
tst_resm(TFAIL, "# of semaphores in set != # given to create");
return;
}
if (un_arg.buf->sem_perm.cuid != geteuid()) {
tst_resm(TFAIL, "semaphore uid != process uid");
return;
}
tst_resm(TPASS, "basic semaphore values are okay");
}
/*
* setup() - performs all the ONE TIME setup for this test.
*/
void
setup(void)
{
/* capture signals */
tst_sig(NOFORK, DEF_HANDLER, cleanup);
/* 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();
}
/*
* cleanup() - performs all the ONE TIME cleanup for this test at completion
* or premature exit.
*/
void
cleanup(void)
{
/* if it exists, remove the semaphore resouce */
rm_sema(sem_id_1);
/* Remove the temporary directory */
tst_rmdir();
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit();
}
+196
View File
@@ -0,0 +1,196 @@
/*
*
* Copyright (c) International Business Machines Corp., 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* NAME
* semget02.c
*
* DESCRIPTION
* semget02 - test for EACCES and EEXIST errors
*
* ALGORITHM
* create a semaphore set without read or alter permissions
* loop if that option was specified
* call semget() using two different invalid cases
* check the errno value
* issue a PASS message if we get EACCES or EEXIST
* otherwise, the tests fails
* issue a FAIL message
* call cleanup
*
* USAGE: <for command-line>
* semget02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
* where, -c n : Run n copies concurrently.
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
* none
*/
#include <pwd.h>
#include "../lib/ipcsem.h"
char *TCID = "semget02";
int TST_TOTAL = 2;
extern int Tst_count;
int exp_enos[] = {EACCES, EEXIST, 0};
char nobody_uid[] = "nobody";
struct passwd *ltpuser;
int sem_id_1 = -1;
struct test_case_t {
int flags;
int error;
} TC [] = {
/* EACCES - the semaphore has no read or alter permissions */
{SEM_RA, EACCES},
/* EEXIST - the semaphore id exists and semget() was called with */
/* IPC_CREAT and IPC_EXCL */
{IPC_CREAT | IPC_EXCL, EEXIST}
};
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, 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;
for (i=0; i<TST_TOTAL; i++) {
/* use the TEST macro to make the call */
TEST(semget(semkey, PSEMS, TC[i].flags));
if (TEST_RETURN != -1) {
sem_id_1 = TEST_RETURN;
tst_resm(TFAIL, "call succeeded");
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",
TEST_ERRNO, strerror(TEST_ERRNO));
}
}
}
cleanup();
/*NOTREACHED*/
return(0);
}
/*
* setup() - performs all the ONE TIME setup for this test.
*/
void
setup(void)
{
/* Switch to nobody user for correct error code collection */
if (geteuid() != 0) {
tst_brkm(TBROK, tst_exit, "Test must be run as root");
}
/* 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();
ltpuser = getpwnam(nobody_uid);
if (seteuid(ltpuser->pw_uid) == -1) {
tst_resm(TINFO, "setreuid failed to "
"to set the effective uid to %d",
ltpuser->pw_uid);
perror("setreuid");
}
/* 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");
}
}
/*
* cleanup() - performs all the ONE TIME cleanup for this test at completion
* or premature exit.
*/
void
cleanup(void)
{
/* if it exists, remove the semaphore resource */
rm_sema(sem_id_1);
/* Remove the temporary directory */
tst_rmdir();
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit();
}
+159
View File
@@ -0,0 +1,159 @@
/*
*
* Copyright (c) International Business Machines Corp., 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* NAME
* semget03.c
*
* DESCRIPTION
* semget03 - test for ENOENT error
*
* ALGORITHM
* loop if that option was specified
* call semget() with a valid key but with no associated semaphore set
* and IPC_CREAT is not asserted
* check the errno value
* issue a PASS message if we get ENOENT
* otherwise, the tests fails
* issue a FAIL message
* call cleanup
*
* USAGE: <for command-line>
* semget03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
* where, -c n : Run n copies concurrently.
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
* none
*/
#include "../lib/ipcsem.h"
char *TCID = "semget03";
int TST_TOTAL = 1;
extern int Tst_count;
int exp_enos[] = {ENOENT, 0}; /* 0 terminated list of expected errnos */
int sem_id_1 = -1;
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);
}
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, PSEMS, SEM_RA));
if (TEST_RETURN != -1) {
sem_id_1 = TEST_RETURN;
tst_resm(TFAIL, "call succeeded when error expected");
continue;
}
TEST_ERROR_LOG(TEST_ERRNO);
switch(TEST_ERRNO) {
case ENOENT:
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);
}
/*
* 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();
}
/*
* cleanup() - performs all the ONE TIME cleanup for this test at completion
* or premature exit.
*/
void
cleanup(void)
{
/* if it exists, remove the semaphore resource */
rm_sema(sem_id_1);
/* Remove the temporary directory */
tst_rmdir();
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit();
}
+217
View File
@@ -0,0 +1,217 @@
/*
*
* Copyright (c) International Business Machines Corp., 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* NAME
* semget05.c
*
* DESCRIPTION
* semget05 - test for ENOSPC error
*
* ALGORITHM
* create semaphore sets in a loop until the system limit is reached
* loop if that option was specified
* attempt to create yet another semaphore set
* check the errno value
* issue a PASS message if we get ENOSPC
* otherwise, the tests fails
* issue a FAIL message
* call cleanup
*
* USAGE: <for command-line>
* semget05 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
* where, -c n : Run n copies concurrently.
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
* 03/2001 - Written by Wayne Boyer
* 07/2006 - Changes By Michael Reed
* - Changed the value of MAXIDS for the specific machine by reading
* the system limit for SEMMNI - The maximum number of sempahore sets
*
* RESTRICTIONS
* none
*/
#include "../lib/ipcsem.h"
char *TCID = "semget05";
int TST_TOTAL = 1;
extern int Tst_count;
/*
* The MAXIDS value is somewhat arbitrary and may need to be increased
* depending on the system being tested.
*/
int MAXIDS=2048;
int exp_enos[] = {ENOSPC, 0}; /* 0 terminated list of expected errnos */
int *sem_id_arr;
int num_sems = 0; /* count the semaphores created */
int main(int ac, char **av)
{
int lc,getmaxid; /* 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;
}
}
}
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);
}
/*
* setup() - performs all the ONE TIME setup for this test.
*/
void
setup(void)
{
int sem_q;
/* 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();
/*
* 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(semkey + num_sems, 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));
}
}
/*
* cleanup() - performs all the ONE TIME cleanup for this test at completion
* or premature exit.
*/
void
cleanup(void)
{
int i;
/* remove the semaphore resources that were created */
for (i=0; i<num_sems; i++) {
rm_sema(sem_id_arr[i]);
}
/* Remove the temporary directory */
tst_rmdir();
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit();
}
+170
View File
@@ -0,0 +1,170 @@
/*
*
* Copyright (c) International Business Machines Corp., 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* NAME
* semget06.c
*
* DESCRIPTION
* semget06 - test for EINVAL error
*
* ALGORITHM
* loop if that option was specified
* call semget() using two different invalid cases - too many and too
* few primitive semaphores
* check the errno value
* issue a PASS message if we get EINVAL
* otherwise, the tests fails
* issue a FAIL message
* call cleanup
*
* USAGE: <for command-line>
* semget06 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
* where, -c n : Run n copies concurrently.
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
* none
*/
#include "../lib/ipcsem.h"
char *TCID = "semget06";
int TST_TOTAL = 2;
extern int Tst_count;
#define LARGENUM 1024 * 32
#define SMALLNUM -1
int exp_enos[] = {EINVAL, 0}; /* 0 terminated list of expected errnos */
int sem_id_1 = -1;
int num_sems[] = {LARGENUM, SMALLNUM};
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, 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++) {
TEST(semget(semkey, num_sems[i],
IPC_CREAT | IPC_EXCL | SEM_RA));
if (TEST_RETURN != -1) {
sem_id_1 = TEST_RETURN;
tst_resm(TFAIL, "call succeeded");
continue;
}
TEST_ERROR_LOG(TEST_ERRNO);
switch(TEST_ERRNO) {
case EINVAL:
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);
}
/*
* 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();
}
/*
* cleanup() - performs all the ONE TIME cleanup for this test at completion
* or premature exit.
*/
void
cleanup(void)
{
/* if it exists, remove the semaphore resource */
rm_sema(sem_id_1);
/* Remove the temporary directory */
tst_rmdir();
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit();
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
./semget01
./semget02
./semget03
./semget05
./semget06