mirror of https://github.com/wolfSSL/wolfssl.git
Cleanup of the test code that looks for the WolfSSL root directory. Now it tries to open the certs/ntru-cert.pem file in each directory up (limited to 5) until it opens it.
parent
d31cec0df0
commit
f977caa492
|
@ -1261,12 +1261,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) && !defined(STACK_TRAP)
|
||||
wolfSSL_Debugging_ON();
|
||||
#endif
|
||||
if (CurrentDir("_build"))
|
||||
ChangeDirBack(1);
|
||||
else if (CurrentDir("client"))
|
||||
ChangeDirBack(2);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
ChangeToWolfRoot();
|
||||
|
||||
#ifdef HAVE_STACK_SIZE
|
||||
StackSizeCheck(&args, client_test);
|
||||
|
|
|
@ -261,10 +261,7 @@ void echoclient_test(void* args)
|
|||
CyaSSL_Debugging_ON();
|
||||
#endif
|
||||
#ifndef CYASSL_TIRTOS
|
||||
if (CurrentDir("echoclient"))
|
||||
ChangeDirBack(2);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
ChangeToWolfRoot();
|
||||
#endif
|
||||
echoclient_test(&args);
|
||||
|
||||
|
|
|
@ -393,10 +393,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
|
||||
CyaSSL_Debugging_ON();
|
||||
#endif
|
||||
if (CurrentDir("echoserver"))
|
||||
ChangeDirBack(2);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
ChangeToWolfRoot();
|
||||
echoserver_test(&args);
|
||||
CyaSSL_Cleanup();
|
||||
|
||||
|
|
|
@ -906,12 +906,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||
#if defined(DEBUG_CYASSL) && !defined(WOLFSSL_MDK_SHELL)
|
||||
CyaSSL_Debugging_ON();
|
||||
#endif
|
||||
if (CurrentDir("_build"))
|
||||
ChangeDirBack(1);
|
||||
else if (CurrentDir("server"))
|
||||
ChangeDirBack(2);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
ChangeToWolfRoot();
|
||||
|
||||
#ifdef HAVE_STACK_SIZE
|
||||
StackSizeCheck(&args, server_test);
|
||||
|
|
|
@ -60,10 +60,7 @@ int unit_test(int argc, char** argv)
|
|||
#endif /* HAVE_CAVIUM */
|
||||
|
||||
#ifndef WOLFSSL_TIRTOS
|
||||
if (CurrentDir("tests") || CurrentDir("_build"))
|
||||
ChangeDirBack(1);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
ChangeToWolfRoot();
|
||||
#endif
|
||||
|
||||
ApiTest();
|
||||
|
|
|
@ -29,24 +29,6 @@
|
|||
#include <wolfssl/test.h>
|
||||
#include "wolfcrypt/test/test.h"
|
||||
|
||||
/* This function changes the current directory to the wolfssl root */
|
||||
static void ChangeDirToRoot(void)
|
||||
{
|
||||
/* Normal Command Line=_build, Visual Studio=testsuite */
|
||||
if (CurrentDir("testsuite") || CurrentDir("_build")) {
|
||||
ChangeDirBack(1);
|
||||
}
|
||||
|
||||
/* Xcode: To output application to correct location: */
|
||||
/* 1. Xcode->Preferences->Locations->Locations */
|
||||
/* 2. Derived Data Advanced -> Custom */
|
||||
/* 3. Relative to Workspace, Build/Products */
|
||||
/* Build/Products/Debug or Build/Products/Release */
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release")) {
|
||||
ChangeDirBack(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef SINGLE_THREADED
|
||||
|
||||
|
@ -118,7 +100,7 @@ int testsuite_test(int argc, char** argv)
|
|||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_TIRTOS)
|
||||
ChangeDirToRoot();
|
||||
ChangeToWolfRoot();
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_TIRTOS
|
||||
|
@ -431,7 +413,7 @@ int main(int argc, char** argv)
|
|||
server_args.argc = argc;
|
||||
server_args.argv = argv;
|
||||
|
||||
ChangeDirToRoot();
|
||||
ChangeToWolfRoot();
|
||||
|
||||
wolfcrypt_test(&server_args);
|
||||
if (server_args.return_code != 0) return server_args.return_code;
|
||||
|
|
114
wolfssl/test.h
114
wolfssl/test.h
|
@ -1160,87 +1160,43 @@ static INLINE int OpenNitroxDevice(int dma_mode,int dev_id)
|
|||
#endif /* HAVE_CAVIUM */
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
/* Wolf Root Directory Helper */
|
||||
/* KEIL-RL File System does not support relative directry */
|
||||
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS)
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
/* do back x number of directories */
|
||||
static INLINE void ChangeDirBack(int x)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
XMEMSET(path, 0, MAX_PATH);
|
||||
XSTRNCAT(path, ".\\", MAX_PATH);
|
||||
while (x-- > 0) {
|
||||
XSTRNCAT(path, "..\\", MAX_PATH);
|
||||
/* Maximum depth to search for WolfSSL root */
|
||||
#define MAX_WOLF_ROOT_DEPTH 5
|
||||
|
||||
static INLINE int ChangeToWolfRoot(void)
|
||||
{
|
||||
int depth;
|
||||
XFILE file;
|
||||
char path[MAX_PATH];
|
||||
XMEMSET(path, 0, MAX_PATH);
|
||||
|
||||
for(depth = 0; depth < MAX_WOLF_ROOT_DEPTH; depth++) {
|
||||
file = XFOPEN(ntruCert, "rb");
|
||||
if (file != XBADFILE) {
|
||||
XFCLOSE(file);
|
||||
break;
|
||||
}
|
||||
#ifdef USE_WINDOWS_API
|
||||
XSTRNCAT(path, "..\\", MAX_PATH);
|
||||
SetCurrentDirectoryA(path);
|
||||
#else
|
||||
XSTRNCAT(path, "../", MAX_PATH);
|
||||
if (chdir(path) < 0) {
|
||||
printf("chdir to %s failed\n", path);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
SetCurrentDirectoryA(path);
|
||||
}
|
||||
|
||||
/* does current dir contain str */
|
||||
static INLINE int CurrentDir(const char* str)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
char* baseName;
|
||||
|
||||
GetCurrentDirectoryA(sizeof(path), path);
|
||||
|
||||
baseName = strrchr(path, '\\');
|
||||
if (baseName)
|
||||
baseName++;
|
||||
else
|
||||
baseName = path;
|
||||
|
||||
if (strstr(baseName, str))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_FS)
|
||||
/* KEIL-RL File System does not support relative directry */
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
#else
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
/* do back x number of directories */
|
||||
static INLINE void ChangeDirBack(int x)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
XMEMSET(path, 0, MAX_PATH);
|
||||
XSTRNCAT(path, "./", MAX_PATH);
|
||||
while (x-- > 0) {
|
||||
XSTRNCAT(path, "../", MAX_PATH);
|
||||
}
|
||||
if (chdir(path) < 0) {
|
||||
printf("chdir to %s failed\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
/* does current dir contain str */
|
||||
static INLINE int CurrentDir(const char* str)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
char* baseName;
|
||||
|
||||
if (getcwd(path, sizeof(path)) == NULL) {
|
||||
printf("no current dir?\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
baseName = strrchr(path, '/');
|
||||
if (baseName)
|
||||
baseName++;
|
||||
else
|
||||
baseName = path;
|
||||
|
||||
if (strstr(baseName, str))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* USE_WINDOWS_API */
|
||||
#endif /* !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS) */
|
||||
|
||||
|
||||
#ifdef USE_WOLFSSL_MEMORY
|
||||
|
|
Loading…
Reference in New Issue