alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 3 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of version 2 of the GNU General Public License as |
| 6 | * published by the Free Software Foundation. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 7 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 8 | * This program is distributed in the hope that it would be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 11 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 12 | * Further, this software is distributed without any warranty that it is |
| 13 | * free of the rightful claim of any third person regarding infringement |
| 14 | * or the like. Any license provided herein, whether implied or |
| 15 | * otherwise, applies only to this software file. Patent licenses, if |
| 16 | * any, provided herein do not apply to combinations of this program with |
| 17 | * other software, or any other product whatsoever. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 18 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write the Free Software Foundation, Inc., 59 |
| 21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 22 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 24 | * Mountain View, CA 94043, or: |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 25 | * |
| 26 | * http://www.sgi.com |
| 27 | * |
| 28 | * For further information regarding this notice, see: |
| 29 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 30 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 31 | */ |
| 32 | |
vapier | 3dc0470 | 2009-08-28 09:59:52 +0000 | [diff] [blame] | 33 | /* $Id: parse_opts.c,v 1.14 2009/08/28 09:59:52 vapier Exp $ */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 34 | |
| 35 | /********************************************************** |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 36 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 37 | * OS Testing - Silicon Graphics, Inc. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 38 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 39 | * FUNCTION NAME : parse_opts |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 40 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 41 | * FUNCTION TITLE : parse standard & user options for system call tests |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 42 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 43 | * SYNOPSIS: |
| 44 | * #include "usctest.h" |
| 45 | * |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 46 | * char *parse_opts(ac, av, user_optarr, uhf) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 47 | * int ac; |
| 48 | * char **av; |
| 49 | * option_t user_optarr[]; |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 50 | * void (*uhf)(); |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 51 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 52 | * AUTHOR : William Roske/Richard Logan |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 53 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 54 | * INITIAL RELEASE : UNICOS 7.0 |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 55 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 56 | * DESCRIPTION |
| 57 | * The parse_opts library routine takes that argc and argv parameters |
| 58 | * recevied by main() and an array of structures defining user options. |
| 59 | * It parses the command line setting flag and argument locations |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 60 | * associated with the options. It uses getopt to do the actual cmd line |
| 61 | * parsing. uhf() is a function to print user define help |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 62 | * |
| 63 | * This module contains the functions usc_global_setup_hook and |
| 64 | * usc_test_looping, which are called by marcos defined in usctest.h. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 65 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 66 | * RETURN VALUE |
| 67 | * parse_opts returns a pointer to an error message if an error occurs. |
| 68 | * This pointer is (char *)NULL if parsing is successful. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 69 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 70 | *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ |
Mike Frysinger | 28606c1 | 2010-08-17 17:22:45 -0400 | [diff] [blame] | 71 | #include "config.h" |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 72 | #include <errno.h> |
| 73 | #include <stdlib.h> |
| 74 | #include <string.h> |
| 75 | #include <sys/param.h> |
| 76 | #include <sys/signal.h> |
| 77 | #include <sys/types.h> |
| 78 | #include <unistd.h> |
| 79 | #include <sys/time.h> |
| 80 | |
| 81 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 82 | #if UNIT_TEST |
| 83 | #include <time.h> |
| 84 | #endif /* UNIT_TEST */ |
| 85 | |
| 86 | #include "test.h" |
| 87 | #define _USC_LIB_ 1 /* indicates we are the library to the usctest.h include */ |
| 88 | #include "usctest.h" |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 89 | |
| 90 | #ifndef USC_COPIES |
| 91 | #define USC_COPIES "USC_COPIES" |
| 92 | #endif |
| 93 | |
| 94 | #ifndef UNIT_TEST |
| 95 | #define UNIT_TEST 0 |
| 96 | #endif |
| 97 | |
| 98 | #ifndef DEBUG |
| 99 | #define DEBUG 0 |
| 100 | #endif |
| 101 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 102 | /* The timing information block. */ |
| 103 | struct tblock tblock={0,((long) -1)>>1,0,0}; |
| 104 | |
Garrett Cooper | d3e6e8f | 2010-12-13 02:55:35 -0800 | [diff] [blame] | 105 | #ifdef GARRETT_IS_A_PEDANTIC_BASTARD |
| 106 | extern pid_t spawned_program_pid; |
| 107 | #endif |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 108 | |
| 109 | /* Define flags and args for standard options */ |
| 110 | int STD_FUNCTIONAL_TEST=1, /* flag indicating to do functional testing code */ |
| 111 | STD_TIMING_ON=0, /* flag indicating to print timing stats */ |
| 112 | STD_PAUSE=0, /* flag indicating to pause before actual start, */ |
| 113 | /* for contention mode */ |
| 114 | STD_INFINITE=0, /* flag indciating to loop forever */ |
| 115 | STD_LOOP_COUNT=1, /* number of iterations */ |
| 116 | STD_COPIES=1, /* number of copies */ |
| 117 | STD_ERRNO_LOG=0; /* flag indicating to do errno logging */ |
| 118 | |
| 119 | float STD_LOOP_DURATION=0.0, /* duration value in fractional seconds */ |
| 120 | STD_LOOP_DELAY=0.0; /* loop delay value in fractional seconds */ |
| 121 | |
| 122 | |
| 123 | char **STD_opt_arr = NULL; /* array of option strings */ |
| 124 | int STD_nopts=0, /* number of elements in STD_opt_arr */ |
| 125 | STD_argind=1; /* argv index to next argv element */ |
| 126 | /* (first argument) */ |
| 127 | /* To getopt users, it is like optind */ |
| 128 | |
| 129 | /* |
| 130 | * The following variables are to support system testing additions. |
| 131 | */ |
| 132 | static int STD_TP_barrier=0; /* flag to do barrier in TEST_PAUSE */ |
| 133 | /* 2 - wait_barrier(), 3 - set_barrier(), * - barrier() */ |
| 134 | static int STD_LP_barrier=0; /* flag to do barrier in TEST_LOOPING */ |
| 135 | /* 2 - wait_barrier(), 3 - set_barrier(), * - barrier() */ |
| 136 | static int STD_TP_shmem_sz=0; /* shmalloc this many words per pe in TEST_PAUSE */ |
| 137 | static int STD_LD_shmem=0; /* flag to do shmem_puts and shmem_gets during delay */ |
| 138 | static int STD_LP_shmem=0; /* flag to do shmem_puts and gets during TEST_LOOPING */ |
| 139 | static int STD_LD_recfun=0; /* do recressive function calls in loop delay */ |
| 140 | static int STD_LP_recfun=0; /* do recressive function calls in TEST_LOOPING */ |
| 141 | static int STD_TP_sbrk=0; /* do sbrk in TEST_PAUSE */ |
| 142 | static int STD_LP_sbrk=0; /* do sbrk in TEST_LOOPING */ |
| 143 | static char *STD_start_break=0; /* original sbrk size */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 144 | static int Debug=0; |
| 145 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 146 | struct std_option_t { |
| 147 | char *optstr; |
| 148 | char *help; |
| 149 | char *flag; |
| 150 | char **arg; |
| 151 | } std_options[] = { |
nstraz | def354d | 2000-08-31 18:40:28 +0000 | [diff] [blame] | 152 | { "c:", " -c n Run n copies concurrently\n", NULL, NULL}, |
| 153 | { "e" , " -e Turn on errno logging\n", NULL, NULL}, |
| 154 | { "f" , " -f Turn off functional testing\n", NULL, NULL}, |
| 155 | { "h" , " -h Show this help screen\n", NULL, NULL}, |
| 156 | { "i:", " -i n Execute test n times\n", NULL, NULL}, |
| 157 | { "I:", " -I x Execute test for x seconds\n", NULL, NULL}, |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 158 | { "p" , " -p Pause for SIGUSR1 before starting\n", NULL, NULL}, |
nstraz | def354d | 2000-08-31 18:40:28 +0000 | [diff] [blame] | 159 | { "P:", " -P x Pause for x seconds between iterations\n", NULL, NULL}, |
| 160 | { "t" , " -t Turn on syscall timing\n", NULL, NULL}, |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 161 | #ifdef UCLINUX |
| 162 | { "C:", " -C ARG Run the child process with arguments ARG (for internal use)\n", |
| 163 | NULL, NULL}, |
| 164 | #endif |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 165 | {NULL, NULL, NULL, NULL}}; |
| 166 | |
| 167 | void print_help(void (*user_help)()); |
| 168 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 169 | /* |
| 170 | * Structure for usc_recressive_func argument |
| 171 | */ |
| 172 | struct usc_bigstack_t { |
| 173 | char space[4096]; |
| 174 | }; |
| 175 | |
| 176 | static struct usc_bigstack_t *STD_bigstack=NULL; |
| 177 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 178 | /* |
| 179 | * Counter of errnos returned (-e option). Indexed by errno. |
| 180 | * Make the array USC_MAX_ERRNO long. That is the first Fortran |
| 181 | * Lib errno. No syscall should return an errno that high. |
| 182 | */ |
| 183 | int STD_ERRNO_LIST[USC_MAX_ERRNO]; |
| 184 | |
| 185 | /* define the string length for Mesg and Mesg2 strings */ |
| 186 | #define STRLEN 2048 |
| 187 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 188 | static char Mesg2[STRLEN]; /* holds possible return string */ |
| 189 | static void usc_recressive_func(); |
| 190 | |
| 191 | /* |
| 192 | * Define bits for options that might have env variable default |
| 193 | */ |
| 194 | #define OPT_iteration 01 |
| 195 | #define OPT_nofunccheck 02 |
| 196 | #define OPT_duration 04 |
| 197 | #define OPT_delay 010 |
| 198 | #define OPT_copies 020 |
| 199 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 200 | #ifdef UCLINUX |
| 201 | /* Allocated and used in self_exec.c: */ |
| 202 | extern char *child_args; /* Arguments to child when -C is used */ |
| 203 | #endif |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 204 | |
| 205 | /********************************************************************** |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 206 | * parse_opts: |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 207 | **********************************************************************/ |
| 208 | char * |
Mike Frysinger | c319020 | 2010-10-13 10:10:45 -0400 | [diff] [blame] | 209 | parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 210 | { |
| 211 | int found; /* flag to indicate that an option specified was */ |
| 212 | /* found in the user's list */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 213 | int k; /* scratch integer for returns and short time usage */ |
| 214 | float ftmp; /* tmp float for parsing env variables */ |
| 215 | char *ptr; /* used in getting env variables */ |
| 216 | int options=0; /* no options specified */ |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 217 | int optstrlen, i; |
| 218 | char *optionstr; |
| 219 | int opt; /* return of getopt */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 220 | |
| 221 | /* |
| 222 | * If not the first time this function is called, release the old STD_opt_arr |
| 223 | * vector. |
| 224 | */ |
| 225 | |
Garrett Cooper | d3e6e8f | 2010-12-13 02:55:35 -0800 | [diff] [blame] | 226 | #ifdef GARRETT_IS_A_PEDANTIC_BASTARD |
| 227 | spawned_program_pid = getpid(); |
| 228 | #endif |
| 229 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 230 | if (STD_opt_arr != NULL) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 231 | free(STD_opt_arr); |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 232 | STD_opt_arr = NULL; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 233 | } |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 234 | /* Calculate how much space we need for the option string */ |
| 235 | optstrlen = 0; |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 236 | for (i = 0; std_options[i].optstr; ++i) |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 237 | optstrlen += strlen(std_options[i].optstr); |
| 238 | if (user_optarr) |
| 239 | for (i = 0; user_optarr[i].option; ++i) { |
| 240 | if (strlen(user_optarr[i].option) > 2) |
| 241 | return "parse_opts: ERROR - Only short options are allowed"; |
| 242 | optstrlen += strlen(user_optarr[i].option); |
| 243 | } |
| 244 | optstrlen += 1; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 245 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 246 | /* Create the option string for getopt */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 247 | optionstr = malloc(optstrlen); |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 248 | if (!optionstr) |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 249 | return "parse_opts: ERROR - Could not allocate memory for optionstr"; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 250 | |
nstraz | 829b40a | 2000-09-06 14:33:29 +0000 | [diff] [blame] | 251 | optionstr[0] = '\0'; |
| 252 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 253 | for (i = 0; std_options[i].optstr; ++i) |
| 254 | strcat(optionstr, std_options[i].optstr); |
| 255 | if (user_optarr) |
| 256 | for (i = 0; user_optarr[i].option; ++i) |
| 257 | /* only add the option if it wasn't there already */ |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 258 | if (strchr(optionstr, user_optarr[i].option[0]) == NULL) |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 259 | strcat(optionstr, user_optarr[i].option); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 260 | |
| 261 | #if DEBUG > 1 |
| 262 | printf("STD_nopts = %d\n", STD_nopts); |
| 263 | #endif |
| 264 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 265 | /* |
| 266 | * Loop through av parsing options. |
| 267 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 268 | while ((opt = getopt(ac, av, optionstr)) > 0) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 269 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 270 | STD_argind = optind; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 271 | #if DEBUG > 0 |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 272 | printf("parse_opts: getopt returned '%c'\n", opt); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 273 | #endif |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 274 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 275 | switch (opt) { |
| 276 | case '?': /* Unknown option */ |
| 277 | return "Unknown option"; |
| 278 | break; |
| 279 | case ':': /* Missing Arg */ |
| 280 | return "Missing argument"; |
| 281 | break; |
| 282 | case 'i': /* Iterations */ |
| 283 | options |= OPT_iteration; |
| 284 | STD_LOOP_COUNT = atoi(optarg); |
| 285 | if (STD_LOOP_COUNT == 0) STD_INFINITE = 1; |
| 286 | break; |
| 287 | case 'P': /* Delay between iterations */ |
| 288 | options |= OPT_delay; |
| 289 | STD_LOOP_DELAY = atof(optarg); |
| 290 | break; |
| 291 | case 'I': /* Time duration */ |
| 292 | options |= OPT_duration; |
| 293 | STD_LOOP_DURATION = atof(optarg); |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 294 | if (STD_LOOP_DURATION == 0.0) STD_INFINITE=1; |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 295 | break; |
| 296 | case 'c': /* Copies */ |
| 297 | options |= OPT_copies; |
| 298 | STD_COPIES = atoi(optarg); |
| 299 | break; |
| 300 | case 'f': /* Functional testing */ |
| 301 | STD_FUNCTIONAL_TEST = 0; |
| 302 | break; |
| 303 | case 'p': /* Pause for SIGUSR1 */ |
| 304 | STD_PAUSE = 1; |
| 305 | break; |
| 306 | case 't': /* syscall timing */ |
| 307 | STD_TIMING_ON = 1; |
| 308 | break; |
| 309 | case 'e': /* errno loggin */ |
| 310 | STD_ERRNO_LOG = 1; |
| 311 | break; |
| 312 | case 'h': /* Help */ |
| 313 | print_help(uhf); |
| 314 | exit(0); |
| 315 | break; |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 316 | #ifdef UCLINUX |
| 317 | case 'C': /* Run child */ |
| 318 | child_args = optarg; |
| 319 | break; |
| 320 | #endif |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 321 | default: |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 322 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 323 | /* Check all the user specified options */ |
| 324 | found=0; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 325 | for (i = 0; user_optarr[i].option; ++i) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 326 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 327 | if (opt == user_optarr[i].option[0]) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 328 | /* Yup, This is a user option, set the flag and look for argument */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 329 | if (user_optarr[i].flag) { |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 330 | *user_optarr[i].flag=1; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 331 | } |
| 332 | found++; |
| 333 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 334 | /* save the argument at the user's location */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 335 | if (user_optarr[i].option[strlen(user_optarr[i].option)-1] == ':') { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 336 | *user_optarr[i].arg = optarg; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 337 | } |
| 338 | break; /* option found - break out of the for loop */ |
| 339 | } |
| 340 | } |
| 341 | /* This condition "should never happen". SO CHECK FOR IT!!!! */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 342 | if (!found) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 343 | sprintf(Mesg2, |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 344 | "parse_opts: ERROR - option:\"%c\" NOT FOUND... INTERNAL " |
| 345 | "ERROR", opt); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 346 | return(Mesg2); |
| 347 | } |
| 348 | } |
| 349 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 350 | } /* end of while */ |
robbiew | 0ea4e1b | 2004-01-05 21:12:51 +0000 | [diff] [blame] | 351 | free(optionstr); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 352 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 353 | STD_argind = optind; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 354 | |
| 355 | /* |
| 356 | * Turn on debug |
| 357 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 358 | if ((ptr = getenv("USC_DEBUG")) != NULL) { |
| 359 | Debug = 1; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 360 | printf("env USC_DEBUG is defined, turning on debug\n"); |
| 361 | } |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 362 | if ((ptr = getenv("USC_VERBOSE")) != NULL) { |
| 363 | Debug = 1; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 364 | printf("env USC_VERBOSE is defined, turning on debug\n"); |
| 365 | } |
| 366 | |
| 367 | /* |
| 368 | * If the USC_ITERATION_ENV environmental variable is set to |
| 369 | * a number, use that number as iteration count (same as -c option). |
| 370 | * The -c option with arg will be used even if this env var is set. |
| 371 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 372 | if (!(options & OPT_iteration) && (ptr = getenv(USC_ITERATION_ENV)) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 373 | if (sscanf(ptr, "%i", &k) == 1) { |
| 374 | if (k == 0) { /* if arg is 0, set infinite loop flag */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 375 | STD_INFINITE = 1; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 376 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 377 | printf("Using env %s, set STD_INFINITE to 1\n", |
| 378 | USC_ITERATION_ENV); |
| 379 | } else { /* else, set the loop count to the arguement */ |
| 380 | STD_LOOP_COUNT=k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 381 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 382 | printf("Using env %s, set STD_LOOP_COUNT to %d\n", |
| 383 | USC_ITERATION_ENV, k); |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | * If the USC_NO_FUNC_CHECK environmental variable is set, we'll |
| 390 | * unset the STD_FUNCTIONAL_TEST variable. |
| 391 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 392 | if (!(options & OPT_nofunccheck) && |
| 393 | (ptr = getenv(USC_NO_FUNC_CHECK)) != NULL) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 394 | STD_FUNCTIONAL_TEST=0; /* Turn off functional testing */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 395 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 396 | printf("Using env %s, set STD_FUNCTIONAL_TEST to 0\n", |
| 397 | USC_NO_FUNC_CHECK); |
| 398 | } |
| 399 | |
| 400 | /* |
| 401 | * If the USC_LOOP_WALLTIME environmental variable is set, |
| 402 | * use that number as duration (same as -I option). |
| 403 | * The -I option with arg will be used even if this env var is set. |
| 404 | */ |
| 405 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 406 | if (!(options & OPT_duration) && |
| 407 | (ptr = getenv(USC_LOOP_WALLTIME)) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 408 | if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 409 | STD_LOOP_DURATION = ftmp; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 410 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 411 | printf("Using env %s, set STD_LOOP_DURATION to %f\n", |
| 412 | USC_LOOP_WALLTIME, ftmp); |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 413 | if (STD_LOOP_DURATION == 0.0) { /* if arg is 0, set infinite loop flag */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 414 | STD_INFINITE = 1; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 415 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 416 | printf("Using env %s, set STD_INFINITE to 1\n", USC_LOOP_WALLTIME); |
| 417 | } |
| 418 | } |
| 419 | } |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 420 | if (!(options & OPT_duration) && (ptr = getenv("USC_DURATION")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 421 | if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 422 | STD_LOOP_DURATION = ftmp; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 423 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 424 | printf("Using env USC_DURATION, set STD_LOOP_DURATION to %f\n", ftmp); |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 425 | if (STD_LOOP_DURATION == 0.0) { /* if arg is 0, set infinite loop flag */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 426 | STD_INFINITE = 1; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 427 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 428 | printf("Using env USC_DURATION, set STD_INFINITE to 1\n"); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | /* |
| 433 | * If the USC_LOOP_DELAY environmental variable is set, |
| 434 | * use that number as delay in factional seconds (same as -P option). |
| 435 | * The -P option with arg will be used even if this env var is set. |
| 436 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 437 | if (!(options & OPT_delay) && (ptr = getenv(USC_LOOP_DELAY)) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 438 | if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 439 | STD_LOOP_DELAY = ftmp; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 440 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 441 | printf("Using env %s, set STD_LOOP_DELAY = %f\n", |
| 442 | USC_LOOP_DELAY, ftmp); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | * If the USC_COPIES environmental variable is set, |
| 448 | * use that number as copies (same as -c option). |
| 449 | * The -c option with arg will be used even if this env var is set. |
| 450 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 451 | if (!(options & OPT_copies) && (ptr = getenv(USC_COPIES)) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 452 | if (sscanf(ptr, "%d", &STD_COPIES) == 1 && STD_COPIES >= 0) { |
| 453 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 454 | printf("Using env %s, set STD_COPIES = %d\n", |
| 455 | USC_COPIES, STD_COPIES); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * The following are special system testing envs to turn on special |
| 461 | * hooks in the code. |
| 462 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 463 | if ((ptr = getenv("USC_TP_BARRIER")) != NULL) { |
| 464 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 465 | STD_TP_barrier=k; |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 466 | else |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 467 | STD_TP_barrier=1; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 468 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 469 | printf("using env USC_TP_BARRIER, Set STD_TP_barrier to %d\n", |
| 470 | STD_TP_barrier); |
| 471 | } |
| 472 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 473 | if ((ptr = getenv("USC_LP_BARRIER")) != NULL) { |
| 474 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 475 | STD_LP_barrier=k; |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 476 | else |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 477 | STD_LP_barrier=1; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 478 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 479 | printf("using env USC_LP_BARRIER, Set STD_LP_barrier to %d\n", |
| 480 | STD_LP_barrier); |
| 481 | } |
| 482 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 483 | if ((ptr = getenv("USC_TP_SHMEM")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 484 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 485 | STD_TP_shmem_sz=k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 486 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 487 | printf("Using env USC_TP_SHMEM, Set STD_TP_shmem_sz to %d\n", |
| 488 | STD_TP_shmem_sz); |
| 489 | } |
| 490 | } |
| 491 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 492 | if ((ptr = getenv("USC_LP_SHMEM")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 493 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 494 | STD_LP_shmem=k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 495 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 496 | printf("Using env USC_LP_SHMEM, Set STD_LP_shmem to %d\n", |
| 497 | STD_LP_shmem); |
| 498 | } |
| 499 | } |
| 500 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 501 | if ((ptr = getenv("USC_LD_SHMEM")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 502 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 503 | STD_LD_shmem=k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 504 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 505 | printf("Using env USC_LD_SHMEM, Set STD_LD_shmem to %d\n", |
| 506 | STD_LD_shmem); |
| 507 | } |
| 508 | } |
| 509 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 510 | if ((ptr = getenv("USC_TP_SBRK")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 511 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 512 | STD_TP_sbrk=k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 513 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 514 | printf("Using env USC_TP_SBRK, Set STD_TP_sbrk to %d\n", |
| 515 | STD_TP_sbrk); |
| 516 | } |
| 517 | } |
| 518 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 519 | #if !defined(UCLINUX) |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 520 | if ((ptr = getenv("USC_LP_SBRK")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 521 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 522 | STD_LP_sbrk=k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 523 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 524 | printf("Using env USC_LP_SBRK, Set STD_LP_sbrk to %d\n", |
| 525 | STD_LP_sbrk); |
| 526 | } |
| 527 | } |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 528 | #endif /* if !defined(UCLINUX) */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 529 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 530 | if ((ptr = getenv("USC_LP_RECFUN")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 531 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 532 | STD_LP_recfun = k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 533 | if (STD_bigstack != NULL) |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 534 | STD_bigstack = malloc(sizeof(struct usc_bigstack_t)); |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 535 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 536 | printf("Using env USC_LP_RECFUN, Set STD_LP_recfun to %d\n", |
| 537 | STD_LP_recfun); |
| 538 | } |
| 539 | } |
| 540 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 541 | if ((ptr = getenv("USC_LD_RECFUN")) != NULL) { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 542 | if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 543 | STD_LD_recfun = k; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 544 | if (STD_bigstack != NULL) |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 545 | STD_bigstack = malloc(sizeof(struct usc_bigstack_t)); |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 546 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 547 | printf("Using env USC_LD_RECFUN, Set STD_LD_recfun to %d\n", |
| 548 | STD_LD_recfun); |
| 549 | } |
| 550 | } |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 551 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 552 | #if UNIT_TEST |
| 553 | printf("The following variables after option and env parsing:\n"); |
| 554 | printf("STD_FUNCTIONAL_TEST = %d\n", STD_FUNCTIONAL_TEST); |
| 555 | printf("STD_LOOP_DURATION = %f\n", STD_LOOP_DURATION); |
| 556 | printf("STD_LOOP_DELAY = %f\n", STD_LOOP_DELAY); |
| 557 | printf("STD_COPIES = %d\n", STD_COPIES); |
| 558 | printf("STD_LOOP_COUNT = %d\n", STD_LOOP_COUNT); |
| 559 | printf("STD_INFINITE = %d\n", STD_INFINITE); |
| 560 | printf("STD_TIMING_ON = %d\n", STD_TIMING_ON); |
| 561 | printf("STD_ERRNO_LOG = %d\n", STD_ERRNO_LOG); |
| 562 | printf("STD_PAUSE = %d\n", STD_PAUSE); |
| 563 | #endif |
| 564 | |
| 565 | return((char *) NULL); |
| 566 | |
| 567 | } /* end of parse_opts */ |
| 568 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 569 | /********************************************************************* |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 570 | * print_help() - print help message and user help message |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 571 | *********************************************************************/ |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 572 | void print_help(void (*user_help)()) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 573 | { |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 574 | STD_opts_help(); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 575 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 576 | if (user_help) |
| 577 | user_help(); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | /********************************************************************* |
| 581 | * STD_opts_help() - return a help string for the STD_OPTIONS. |
| 582 | *********************************************************************/ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 583 | void STD_opts_help() |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 584 | { |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 585 | int i; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 586 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 587 | for (i = 0; std_options[i].optstr; ++i) { |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 588 | if (std_options[i].help) |
vapier | 1820d28 | 2009-07-20 04:48:17 +0000 | [diff] [blame] | 589 | printf("%s", std_options[i].help); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 590 | } |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 591 | } |
| 592 | |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 593 | /* |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 594 | * routine to goto when we get the SIGUSR1 for STD_PAUSE |
| 595 | */ |
| 596 | void STD_go(int sig) |
| 597 | { |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | /*********************************************************************** |
| 602 | * This function will do desired end of global setup test |
| 603 | * hooks. |
| 604 | * Currently it will only do a pause waiting for sigusr1 if |
| 605 | * STD_PAUSE is set. |
| 606 | * |
| 607 | ***********************************************************************/ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 608 | int usc_global_setup_hook() |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 609 | { |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 610 | #ifndef UCLINUX |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 611 | int cnt; |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 612 | /* temp variable to store old signal action to be restored after pause */ |
| 613 | int (*_TMP_FUNC)(void); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 614 | |
| 615 | /* |
| 616 | * Fork STD_COPIES-1 copies. |
| 617 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 618 | for (cnt=1;cnt<STD_COPIES;cnt++) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 619 | switch (fork() ) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 620 | case -1: |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 621 | fprintf(stderr, "%s: fork failed: %d - %s\n", |
| 622 | __FILE__, errno, strerror(errno)); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 623 | break; |
| 624 | case 0: /* child */ |
| 625 | cnt=STD_COPIES; /* to stop the forking */ |
| 626 | break; |
| 627 | |
| 628 | default: /* parent */ |
| 629 | break; |
| 630 | } |
| 631 | } |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 632 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 633 | /* |
| 634 | * pause waiting for sigusr1. |
| 635 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 636 | if (STD_PAUSE) { |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 637 | _TMP_FUNC = (int (*)())signal(SIGUSR1, STD_go); |
| 638 | pause(); |
| 639 | signal(SIGUSR1, (void (*)())_TMP_FUNC); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 640 | } |
| 641 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 642 | #if !defined(UCLINUX) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 643 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 644 | if (STD_TP_sbrk || STD_LP_sbrk) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 645 | STD_start_break=sbrk(0); /* get original sbreak size */ |
| 646 | } |
| 647 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 648 | if (STD_TP_sbrk) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 649 | sbrk(STD_TP_sbrk); |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 650 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 651 | printf("after sbrk(%d)\n", STD_TP_sbrk); |
| 652 | } |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 653 | |
| 654 | #endif /* if !defined(UCLINUX) */ |
| 655 | #endif |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 656 | return 0; |
| 657 | } |
| 658 | |
| 659 | #define USECS_PER_SEC 1000000 /* microseconds per second */ |
| 660 | |
| 661 | /*********************************************************************** |
| 662 | * This function returns the number of get_current_time()'s return |
| 663 | * per second. |
| 664 | ***********************************************************************/ |
| 665 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 666 | static int get_timepersec() |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 667 | { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 668 | return USECS_PER_SEC; /* microseconds per second */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 669 | |
| 670 | } |
| 671 | |
| 672 | /*********************************************************************** |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 673 | * this function will get current time in microseconds since 1970. |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 674 | ***********************************************************************/ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 675 | static int get_current_time() |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 676 | { |
| 677 | struct timeval curtime; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 678 | |
| 679 | gettimeofday(&curtime, NULL); |
| 680 | |
| 681 | /* microseconds since 1970 */ |
| 682 | return (curtime.tv_sec*USECS_PER_SEC) + curtime.tv_usec; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | /*********************************************************************** |
| 686 | * |
| 687 | * This function will determine if test should continue iterating |
| 688 | * If the STD_INFINITE flag is set, return 1. |
| 689 | * If the STD_LOOP_COUNT variable is set, compare it against |
| 690 | * the counter. |
| 691 | * If the STD_LOOP_DURATION variable is set, compare current time against |
| 692 | * calculated stop_time. |
| 693 | * This function will return 1 until all desired looping methods |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 694 | * have been met. |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 695 | * |
| 696 | * counter integer is supplied by the user program. |
| 697 | ***********************************************************************/ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 698 | int usc_test_looping(int counter) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 699 | { |
| 700 | static int first_time = 1; |
| 701 | static int stop_time = 0; /* stop time in rtc or usecs */ |
| 702 | static int delay; /* delay in clocks or usecs */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 703 | int hertz = 0; /* clocks per second or usecs per second */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 704 | int ct, end; /* current time, end delay time */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 705 | int keepgoing = 0; /* used to determine return value */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 706 | |
| 707 | /* |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 708 | * If this is the first iteration and we are looping for |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 709 | * duration of STD_LOOP_DURATION seconds (fractional) or |
| 710 | * doing loop delays, get the clocks per second. |
| 711 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 712 | if (first_time) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 713 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 714 | first_time = 0; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 715 | if (STD_LOOP_DELAY || STD_LOOP_DURATION) { |
mridge | e6508f8 | 2005-01-04 21:00:17 +0000 | [diff] [blame] | 716 | hertz = get_timepersec(); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | /* |
| 720 | * If looping for duration, calculate stop time in |
| 721 | * clocks. |
| 722 | */ |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 723 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 724 | if (STD_LOOP_DURATION) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 725 | ct=get_current_time(); |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 726 | stop_time = (int)((float)hertz * STD_LOOP_DURATION) + ct; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | /* |
| 730 | * If doing delay each iteration, calcuate the number |
| 731 | * of clocks for each delay. |
| 732 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 733 | if (STD_LOOP_DELAY) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 734 | delay = (int)((float)hertz * STD_LOOP_DELAY); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | } |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 738 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 739 | /* |
| 740 | * if delay each iteration, loop for delay clocks. |
| 741 | * This will not be done on first iteration. |
| 742 | * The delay will happen before determining if |
| 743 | * there will be another iteration. |
| 744 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 745 | else if (STD_LOOP_DELAY) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 746 | ct = get_current_time(); |
| 747 | end = ct + delay; |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 748 | while (ct < end) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 749 | /* |
| 750 | * The following are special test hooks in the delay loop. |
| 751 | */ |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 752 | if (STD_LD_recfun) { |
| 753 | if (Debug) |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 754 | printf("calling usc_recressive_func(0, %d, *STD_bigstack)\n", |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 755 | STD_LD_recfun); |
subrata_modak | b2f47f3 | 2007-04-11 04:17:56 +0000 | [diff] [blame] | 756 | usc_recressive_func(0, STD_LD_recfun, *STD_bigstack); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | ct=get_current_time(); |
| 760 | } |
| 761 | } |
| 762 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 763 | if (STD_INFINITE) { |
mreed10 | ef03818 | 2006-04-19 18:23:40 +0000 | [diff] [blame] | 764 | keepgoing++; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 767 | if (STD_LOOP_COUNT && counter < STD_LOOP_COUNT) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 768 | keepgoing++; |
mreed10 | ef03818 | 2006-04-19 18:23:40 +0000 | [diff] [blame] | 769 | } |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 770 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 771 | if (STD_LOOP_DURATION != 0.0 && get_current_time() < stop_time) { |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 772 | keepgoing++; |
mreed10 | ef03818 | 2006-04-19 18:23:40 +0000 | [diff] [blame] | 773 | } |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 774 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 775 | if (keepgoing == 0) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 776 | return 0; |
| 777 | |
| 778 | /* |
| 779 | * The following code allows special system testing hooks. |
| 780 | */ |
| 781 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 782 | if (STD_LP_recfun) { |
| 783 | if (Debug) |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 784 | printf("calling usc_recressive_func(0, %d, *STD_bigstack)\n", |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 785 | STD_LP_recfun); |
subrata_modak | b2f47f3 | 2007-04-11 04:17:56 +0000 | [diff] [blame] | 786 | usc_recressive_func(0, STD_LP_recfun, *STD_bigstack); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 787 | } |
| 788 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 789 | #if !defined(UCLINUX) |
| 790 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 791 | if (STD_LP_sbrk) { |
| 792 | if (Debug) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 793 | printf("about to do sbrk(%d)\n", STD_LP_sbrk); |
| 794 | sbrk(STD_LP_sbrk); |
| 795 | } |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 796 | #endif |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 797 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 798 | |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 799 | if (keepgoing) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 800 | return 1; |
| 801 | else |
| 802 | return 0; /* done - stop iterating */ |
| 803 | } |
| 804 | |
| 805 | |
| 806 | /* |
| 807 | * This function recressively calls itself max times. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 808 | */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 809 | static void usc_recressive_func(int cnt, int max, struct usc_bigstack_t bstack) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 810 | { |
Garrett Cooper | 903910d | 2010-11-23 09:27:44 -0800 | [diff] [blame] | 811 | if (cnt < max) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 812 | usc_recressive_func(cnt+1, max, bstack); |
| 813 | |
| 814 | } |
| 815 | |
| 816 | #if UNIT_TEST |
| 817 | /****************************************************************************** |
| 818 | * UNIT TEST CODE |
| 819 | * UNIT TEST CODE |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 820 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 821 | * this following code is provide so that unit testing can |
| 822 | * be done fairly easily. |
| 823 | ******************************************************************************/ |
| 824 | |
| 825 | int Help = 0; |
| 826 | int Help2 = 0; |
| 827 | char *ptr; |
| 828 | |
| 829 | /* |
| 830 | * Code from usctest.h that not part of this file since we are the library. |
| 831 | */ |
| 832 | |
| 833 | struct usc_errno_t TEST_VALID_ENO[USC_MAX_ERRNO]; |
| 834 | |
Markos Chandras | fd4ada7 | 2012-01-03 11:10:37 +0000 | [diff] [blame^] | 835 | long TEST_RETURN; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 836 | int TEST_ERRNO; |
| 837 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 838 | /* for test specific parse_opts options */ |
| 839 | option_t Options[] = { |
| 840 | { "help", &Help2, NULL }, /* -help option */ |
| 841 | { "h", &Help, NULL }, /* -h option */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 842 | |
| 843 | #if INVALID_TEST_CASES |
| 844 | { "missingflag", NULL, &ptr }, /* error */ |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 845 | { "missingarg:", &Help, NULL }, /* error */ |
| 846 | #endif /* INVALID_TEST_CASES */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 847 | |
| 848 | { NULL, NULL, NULL } |
| 849 | }; |
| 850 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 851 | int main(int argc, char **argv) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 852 | { |
| 853 | int lc; |
| 854 | char *msg; |
| 855 | struct timeval t; |
| 856 | int cnt; |
| 857 | |
Markos Chandras | fd4ada7 | 2012-01-03 11:10:37 +0000 | [diff] [blame^] | 858 | if ((msg = parse_opts(argc, argv, Options, NULL)) != NULL) { |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 859 | printf("ERROR: %s\n", msg); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 860 | exit(1); |
| 861 | } |
| 862 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 863 | TEST_PAUSE; |
| 864 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 865 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 866 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 867 | TEST(gettimeofday(&t, NULL)); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 868 | printf("iter=%d: sec:%d, usec:%6.6d %s", lc+1, t.tv_sec, |
| 869 | t.tv_usec, ctime(&t.tv_sec)); |
| 870 | } |
| 871 | |
| 872 | |
| 873 | TEST_CLEANUP; |
| 874 | |
| 875 | exit(0); |
| 876 | } |
| 877 | |
Garrett Cooper | 8b02c1c | 2011-01-26 01:34:49 -0800 | [diff] [blame] | 878 | #endif /* UNIT_TEST */ |