- CMDLINE_PROCESS
-#endif
- }
-
- /* Set TMPDIR to specified test directory. */
- if (test_dir != NULL)
- {
- setenv ("TMPDIR", test_dir, 1);
-
- if (chdir (test_dir) < 0)
- {
- perror ("chdir");
- exit (1);
- }
- }
- else
- {
- test_dir = getenv ("TMPDIR");
- if (test_dir == NULL || test_dir[0] == '\0')
- test_dir = "/tmp";
- }
-
- /* Make sure we see all message, even those on stdout. */
- setvbuf (stdout, NULL, _IONBF, 0);
-
- /* make sure temporary files are deleted. */
- atexit (delete_temp_files);
-
- /* Correct for the possible parameters. */
- argv += optind - 1;
- argc -= optind - 1;
-
- /* Call the initializing function, if one is available. */
-#ifdef PREPARE
- PREPARE (argc, argv);
-#endif
-
- /* If we are not expected to fork run the function immediately. */
- if (direct)
- return TEST_FUNCTION;
-
- /* Set up the test environment:
- - prevent core dumps
- - set up the timer
- - fork and execute the function. */
-
- pid = fork ();
- if (pid == 0)
- {
- /* This is the child. */
-#ifdef RLIMIT_CORE
- /* Try to avoid dumping core. */
- struct rlimit core_limit;
- core_limit.rlim_cur = 0;
- core_limit.rlim_max = 0;
- setrlimit (RLIMIT_CORE, &core_limit);
-#endif
-
- /* Execute the test function and exit with the return value. */
- exit (TEST_FUNCTION);
- }
- else if (pid < 0)