Skip to content

Commit b66a108

Browse files
committed
CRL Monitor Test Fix
1. For Mach and FreeBsd builds, add the function link_file() which makes a hard link for a file. 2. Add a macro STAGE_FILE that either calls copy_file or link_file depending on doing a Mach or FreeBSD build or not. This is to work around how the CRL Monitor is detecting file changes made by the CRL monitor test in the testsuite. Linux and Windows are detecting the file copies and deletes, and how macOS detects them. kevent sees the link as a single change to the parent directory and reads it. When you copy the file, kevent sees the new file getting opened and triggering the file update.
1 parent 4f8fd98 commit b66a108

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

tests/utils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ int copy_file(const char* in, const char* out)
111111
XFCLOSE(outFile);
112112
return ret;
113113
}
114+
115+
#if defined(__MACH__) || defined(__FreeBSD__)
116+
int link_file(const char* in, const char* out)
117+
{
118+
return link(in, out);
119+
}
120+
#endif
114121
#endif /* !NO_FILESYSTEM */
115122

116123
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \

testsuite/testsuite.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static int test_crl_monitor(void)
327327
if (i % 2 == 0) {
328328
/* succeed on even rounds */
329329
sprintf(buf, "%s/%s", tmpDir, "crl.pem");
330-
if (copy_file("certs/crl/crl.pem", buf) != 0) {
330+
if (STAGE_FILE("certs/crl/crl.pem", buf) != 0) {
331331
fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf);
332332
goto cleanup;
333333
}
@@ -350,7 +350,7 @@ static int test_crl_monitor(void)
350350
else {
351351
/* fail on odd rounds */
352352
sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
353-
if (copy_file("certs/crl/crl.revoked", buf) != 0) {
353+
if (STAGE_FILE("certs/crl/crl.revoked", buf) != 0) {
354354
fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf);
355355
goto cleanup;
356356
}

wolfssl/test.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,13 @@ int rem_dir(const char* dirName);
656656
int rem_file(const char* fileName);
657657
int copy_file(const char* in, const char* out);
658658

659+
#if defined(__MACH__) || defined(__FreeBSD__)
660+
int link_file(const char* in, const char* out);
661+
#define STAGE_FILE(x,y) link_file((x),(y))
662+
#else
663+
#define STAGE_FILE(x,y) copy_file((x),(y))
664+
#endif
665+
659666
void signal_ready(tcp_ready* ready);
660667

661668
/* wolfSSL */

0 commit comments

Comments
 (0)