add mymktemp function for random output file name in test.h

This commit is contained in:
lchristina26
2015-02-04 11:52:37 -07:00
parent db5a95b370
commit ed80732957
2 changed files with 58 additions and 7 deletions

View File

@ -47,12 +47,7 @@ enum {
NUMARGS = 3
};
#ifndef USE_WINDOWS_API
static const char outputName[] = "/tmp/output";
#else
static const char outputName[] = "output";
#endif
static const char *outputName;
int myoptind = 0;
char* myoptarg = NULL;
@ -77,6 +72,16 @@ int testsuite_test(int argc, char** argv)
tcp_ready ready;
THREAD_TYPE serverThread;
#ifndef USE_WINDOWS_API
char tempName[] = "/tmp/output-XXXXXX";
int len = 18;
int num = 6;
#else
char tempName[] = "fnXXXXXX";
int len = 8;
int num = 6;
#endif
#ifdef HAVE_CAVIUM
int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
if (ret != 0)
@ -136,6 +141,13 @@ int testsuite_test(int argc, char** argv)
echo_args.argc = 3;
echo_args.argv = myArgv;
/* Create unique file name */
outputName = mymktemp(tempName, len, num);
if (outputName == NULL) {
printf("Could not create unique file name");
return EXIT_FAILURE;
}
strcpy(echo_args.argv[0], "echoclient");
strcpy(echo_args.argv[1], "input");
strcpy(echo_args.argv[2], outputName);