Skip to content

Commit 4e5a7f5

Browse files
add skipped return value for empty pin test
1 parent 0fae769 commit 4e5a7f5

3 files changed

Lines changed: 20 additions & 28 deletions

File tree

tests/empty_pin_store_test.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,7 @@
5151
#include <dlfcn.h>
5252
#endif
5353

54-
#ifdef _WIN32
55-
#define PATH_SEP "\\"
56-
#else
57-
#define PATH_SEP "/"
58-
#endif
59-
60-
#ifndef WOLFPKCS11_DLL_FILENAME
61-
#ifdef __APPLE__
62-
#define WOLFPKCS11_DLL_FILENAME "./src/.libs/libwolfpkcs11.dylib"
63-
#else
64-
#define WOLFPKCS11_DLL_FILENAME "./src/.libs/libwolfpkcs11.so"
65-
#endif
66-
#endif
54+
#include "testdata.h"
6755

6856
#define EMPTY_PIN_TEST_DIR "./store/empty_pin_test"
6957
#define WOLFPKCS11_TOKEN_FILENAME "wp11_token_0000000000000001"
@@ -72,6 +60,7 @@
7260

7361
static int test_passed = 0;
7462
static int test_failed = 0;
63+
static int test_skipped = 0;
7564

7665
#define CHECK_CKR(rv, op, expected) do { \
7766
if (rv != expected) { \
@@ -374,6 +363,7 @@ static int empty_pin_store_test(void)
374363
printf("Skipping empty PIN test: token requires minimum PIN length "
375364
"%lu (empty PIN not allowed)\n",
376365
(unsigned long)tokenInfo.ulMinPinLen);
366+
test_skipped = 1;
377367
pkcs11_final();
378368
return 0;
379369
}
@@ -423,8 +413,13 @@ static void print_results(void)
423413
printf("\n=== Test Results ===\n");
424414
printf("Tests passed: %d\n", test_passed);
425415
printf("Tests failed: %d\n", test_failed);
416+
if (test_skipped != 0) {
417+
printf("Tests skipped: %d\n", test_skipped);
418+
}
426419

427-
if (test_failed == 0) {
420+
if (test_skipped != 0) {
421+
printf("TEST SKIPPED\n");
422+
} else if (test_failed == 0) {
428423
printf("ALL TESTS PASSED!\n");
429424
} else {
430425
printf("SOME TESTS FAILED!\n");
@@ -450,6 +445,9 @@ int main(int argc, char* argv[])
450445

451446
print_results();
452447

448+
if (test_skipped != 0) {
449+
return 77; /* automake: test skipped */
450+
}
453451
return (test_failed == 0) ? 0 : 1;
454452
#else
455453
(void)argc;

tests/testdata.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#define WOLFPKCS11_DLL_SLOT 1
3232
#endif
3333

34+
#ifdef _WIN32
35+
#define PATH_SEP "\\"
36+
#else
37+
#define PATH_SEP "/"
38+
#endif
39+
3440
/* Suppress unused variable warnings across different compilers */
3541
#if defined(_MSC_VER)
3642
#pragma warning(push)

tests/token_path_test.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,21 @@
4343
#include <string.h>
4444
#include <sys/stat.h>
4545

46+
#include "testdata.h"
47+
4648
#ifdef _WIN32
4749
#include <direct.h>
4850
#include <windows.h>
4951
#define MKDIR(path) _mkdir(path)
50-
#define PATH_SEP "\\"
5152
#define ACCESS _access
5253
#define F_OK 0
5354
#else
5455
#include <unistd.h>
5556
#include <sys/types.h>
5657
#define MKDIR(path) mkdir(path, 0755)
57-
#define PATH_SEP "/"
5858
#define ACCESS access
5959
#endif
6060

61-
/* DLL Location and slot */
62-
#ifndef WOLFPKCS11_DLL_FILENAME
63-
#ifdef __MACH__
64-
#define WOLFPKCS11_DLL_FILENAME "./src/.libs/libwolfpkcs11.dylib"
65-
#else
66-
#define WOLFPKCS11_DLL_FILENAME "./src/.libs/libwolfpkcs11.so"
67-
#endif
68-
#endif
69-
#ifndef WOLFPKCS11_DLL_SLOT
70-
#define WOLFPKCS11_DLL_SLOT 1
71-
#endif
72-
7361
#ifndef HAVE_PKCS11_STATIC
7462
static void* dlib;
7563
#endif

0 commit comments

Comments
 (0)