Skip to content

Commit d730ccf

Browse files
committed
Rewrite tests into python scripts for easier portability
- Add shared test helper and cross-platform test runner - Extract binary lookup and run_wolfssl() into tests/wolfclu_test.py so all test files share the same logic for finding the wolfssl binary across Linux (./wolfssl) and Windows (x64/Debug/wolfssl.exe etc.). - Add tests/run_tests.py which discovers and runs all *-test.py files, intended for Windows where `make check` is not available. - Enable PKCS7 and CRL in MSVC - Fix three Windows bugs uncovered by the test: - Add StartTCP() (WSAStartup) in client and server setup so Winsock is initialized before gethostbyname/connect calls - Pass SNI hostname (-S flag) to the underlying client_test so modern TLS servers accept the connection - Implement checkStdin() for Windows using WaitForSingleObject so s_client exits promptly when stdin is a closed pipe - Update user_settings.h with defines required for TLS 1.3 and full wolfCLU functionality: WOLFSSL_TLS13, HAVE_HKDF, WC_RSA_PSS, HAVE_SUPPORTED_CURVES, HAVE_FFDHE_2048, HAVE_SNI. - Fix run_wolfssl() to use stdin=DEVNULL when no input is provided, preventing subprocesses from blocking on inherited stdin (e.g. over SSH/network sessions on Windows). - Also add WOLFCLU_SKIP_SLOW_TESTS env var to skip slow tests on Windows, and optimize large file creation to a single write. - Add HAVE_PKCS12 to Windows user_settings.h. Skip binary DER stdin test on Windows where pipe binary mode is unreliable. - Combine ocsp-test.sh and ocsp-interop-test.sh into a single Python test module that tests all client/responder combinations (wolfssl and openssl). - Add StartTCP() in OCSP setup for Winsock initialization on Windows. - Add HAVE_OCSP and HAVE_OCSP_RESPONDER to Windows user_settings.h. - Rewrite base64 test from bash to Python unittest - Rewrite bench test from bash to Python unittest - Rewrite client test to Python and fix Windows networking bugs - Replace tests/client/client-test.sh with a cross-platform Python unittest. - Rewrite dgst test from bash to Python unittest - Rewrite dh test from bash to Python unittest - Rewrite dsa test from bash to Python unittest - Rewrite enc test from bash to Python unittest - Rewrite genkey sign/verify test from bash to Python unittest - Rewrite hash test from bash to Python unittest - Rewrite pkcs7/pkcs8/pkcs12 tests from bash to Python unittest - Rewrite pkey/rsa/ecparam tests from bash to Python unittest - Rewrite rand test from bash to Python unittest - Rewrite server test from bash to Python unittest - Rewrite encdec test from bash to Python unittest - Rewrite x509/CRL tests from bash to Python unittest - Rewrite OCSP tests from bash to Python unittest - Rewrite OCSP SCGI test from bash to Python, drop nginx dependency - Replace nginx + bash with a pure-Python HTTP-to-SCGI proxy using stdlib http.server and raw sockets for the SCGI netstring protocol. No external dependencies needed. - Remove nginx from CI apt-get installs since it is no longer required for testing.
1 parent cb5d98a commit d730ccf

84 files changed

Lines changed: 5250 additions & 4143 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/fsanitize-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ jobs:
6767
# Don't prompt for anything
6868
export DEBIAN_FRONTEND=noninteractive
6969
sudo apt-get update
70-
# openssl and nginx used for ocsp testing
71-
sudo apt-get install -y openssl nginx
70+
# openssl used for ocsp interop testing
71+
sudo apt-get install -y openssl
7272
7373
- name: Checking cache for wolfssl
7474
uses: actions/cache@v4

.github/workflows/ubuntu-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
# Don't prompt for anything
1818
export DEBIAN_FRONTEND=noninteractive
1919
sudo apt-get update
20-
# openssl and nginx used for ocsp testing
21-
sudo apt-get install -y openssl nginx
20+
# openssl used for ocsp interop testing
21+
sudo apt-get install -y openssl
2222
- uses: actions/checkout@master
2323
with:
2424
repository: wolfssl/wolfssl

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ AGENTS.md
4343
Win32/
4444
x64/
4545
.vs/
46-
46+
__pycache__/
4747
CLAUDE.md

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ dist_doc_DATA=
1919
check_SCRIPTS=
2020
dist_noinst_SCRIPTS=
2121

22+
TEST_EXTENSIONS = .sh .py
23+
PY_LOG_COMPILER = $(PYTHON)
24+
2225
#includes additional rules from aminclude.am
2326
@INC_AMINCLUDE@
2427
DISTCLEANFILES+= aminclude.am
@@ -61,6 +64,7 @@ include tests/hash/include.am
6164
include tests/bench/include.am
6265
include tests/client/include.am
6366
include tests/server/include.am
67+
include tests/testEncDec/include.am
6468
include ide/include.am
6569
#####include data/include.am
6670

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ AC_PROG_INSTALL
5555
AC_PROG_LN_S
5656
AC_PROG_MAKE_SET
5757
AM_PROG_CC_C_O
58+
AM_PATH_PYTHON([3.0],, [:])
59+
AC_SUBST([PYTHON])
5860

5961
# Checks for headers/libraries
6062
AC_CHECK_HEADERS([sys/time.h string.h termios.h unistd.h])

ide/winvs/user_settings.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@
2525
#define WOLFSSL_SHA512
2626

2727
#define HAVE_TLS_EXTENSIONS
28+
#define HAVE_SNI
29+
#define WOLFSSL_TLS13
30+
#define HAVE_HKDF
31+
#define WC_RSA_PSS
32+
#define HAVE_SUPPORTED_CURVES
33+
#define HAVE_FFDHE_2048
2834
#define OPENSSL_ALL
2935
#define OPENSSL_EXTRA
36+
#define HAVE_PKCS7
37+
#define HAVE_PKCS12
38+
#define HAVE_CRL
39+
#define HAVE_OCSP
40+
#define HAVE_OCSP_RESPONDER
3041

3142
#endif /* _WIN_USER_SETTINGS_H_ */

src/client/client.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,10 +2091,21 @@ static void Usage(void)
20912091
#endif
20922092
}
20932093

2094-
#ifndef USE_WINDOWS_API
20952094
int checkStdin(void)
20962095
{
20972096
int stop = 0;
2097+
#ifdef USE_WINDOWS_API
2098+
HANDLE stdinHandle = GetStdHandle(STD_INPUT_HANDLE);
2099+
if (stdinHandle == INVALID_HANDLE_VALUE || stdinHandle == NULL) {
2100+
stop = 1; /* no stdin available */
2101+
}
2102+
else {
2103+
DWORD waitResult = WaitForSingleObject(stdinHandle, 0);
2104+
if (waitResult == WAIT_OBJECT_0) {
2105+
stop = 1; /* stdin has data or is closed */
2106+
}
2107+
}
2108+
#else
20982109
fd_set readfds;
20992110
struct timeval timeout;
21002111
timeout.tv_sec = 0;
@@ -2107,11 +2118,9 @@ int checkStdin(void)
21072118
if (select(1, &readfds, NULL, NULL, &timeout)){
21082119
stop = 1;
21092120
}
2110-
2121+
#endif
21112122
return stop;
2112-
21132123
}
2114-
#endif
21152124

21162125
static int AlwaysAllow(int preverify, WOLFSSL_X509_STORE_CTX* store)
21172126
{
@@ -4224,7 +4233,6 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42244233
goto exit;
42254234
}
42264235

4227-
#ifndef USE_WINDOWS_API
42284236
if (!disable_stdin_chk) {
42294237
int stop = checkStdin();
42304238

@@ -4234,7 +4242,6 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42344242
goto exit;
42354243
}
42364244
}
4237-
#endif
42384245

42394246
err = ClientRead(ssl, reply, sizeof(reply)-1, 1, "", exitWithRet);
42404247
if (exitWithRet && (err != 0)) {

src/client/clu_client_setup.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ static const char caFileFlag[] = "-A";
6565
static const char noClientCert[] = "-x";
6666
static const char startTLSFlag[] = "-M";
6767
static const char disableCRLFlag[] = "-C";
68+
static const char sniFlag[] = "-S";
6869

6970
int myoptind = 0;
7071
char* myoptarg = NULL;
7172

72-
#define MAX_CLIENT_ARGS 15
73+
#define MAX_CLIENT_ARGS 17
7374

7475
/* return WOLFCLU_SUCCESS on success */
7576
static int _addClientArg(const char** args, const char* in, int* idx)
@@ -193,6 +194,14 @@ int wolfCLU_Client(int argc, char** argv)
193194
&clientArgc);
194195
}
195196
}
197+
198+
/* Set SNI hostname so modern servers accept the connection */
199+
if (ret == WOLFCLU_SUCCESS && host != NULL) {
200+
ret = _addClientArg(clientArgv, sniFlag, &clientArgc);
201+
if (ret == WOLFCLU_SUCCESS) {
202+
ret = _addClientArg(clientArgv, host, &clientArgc);
203+
}
204+
}
196205
break;
197206

198207
case WOLFCLU_STARTTLS:
@@ -264,6 +273,7 @@ int wolfCLU_Client(int argc, char** argv)
264273
}
265274

266275
if (ret == WOLFCLU_SUCCESS) {
276+
StartTCP();
267277
args.argv = (char**)clientArgv;
268278
args.argc = clientArgc;
269279

src/ocsp/clu_ocsp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,8 @@ int wolfCLU_OcspSetup(int argc, char** argv)
13071307
return ret;
13081308
}
13091309

1310+
StartTCP();
1311+
13101312
if (!(isClientMode ^ isResponderMode)) {
13111313
wolfCLU_LogError("Can't detect side (client vs responder) or multiple sides specified");
13121314
wolfCLU_OcspHelp();

src/server/clu_server_setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ int wolfCLU_Server(int argc, char** argv)
190190
}
191191

192192
if (ret == WOLFCLU_SUCCESS) {
193+
StartTCP();
193194
args.argv = (char**)serverArgv;
194195
args.argc = serverArgc;
195196
server_test(&args);

0 commit comments

Comments
 (0)