/* * * 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 * shmat01.c * * DESCRIPTION * shmat01 - test that shmat() works correctly * * ALGORITHM * create a shared memory resouce with read/write permissions * loop if that option was specified * call shmat() with the TEST() macro using three valid conditions * check the return code * if failure, issue a FAIL message. * otherwise, * if doing functionality testing * check for the correct conditions after the call * if correct, * issue a PASS message * otherwise * issue a FAIL message * call cleanup * * USAGE: * shmat01 [-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 "ipcshm.h" char *TCID = "shmat01"; int TST_TOTAL = 3; extern int Tst_count; #define CASE0 10 /* values to write into the shared */ #define CASE1 20 /* memory location. */ #ifdef __ia64__ #define UNALIGNED 0x5ff00eee /* an address not evenly divisible by */ #elif defined __XTENSA__ /* SHMLBA which defaults to 0x8048e8b */ /* TASK_SIZE on Xtensa is only 0x40000000 */ #define UNALIGNED 0x28ffeeee #elif defined __arm__ #define UNALIGNED 0x28ffeeee #else #define UNALIGNED 0x5fffeeee #endif int shm_id_1 = -1; void *addr; /* for result of shmat-call */ struct test_case_t { int *shmid; void *addr; int flags; } TC[] = { /* a straight forward read/write attach */ {&shm_id_1, 0, 0}, /* an attach using non aligned memory */ {&shm_id_1, (void *)UNALIGNED, SHM_RND}, /* a read only attach */ {&shm_id_1, 0, SHM_RDONLY} }; 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