[Openvpn-devel,5/9] Add ifdef guards to unit test

Message ID 20210512131511.1309914-6-arne@rfc2549.org
State Changes Requested
Headers show
Series Miscellaneous cleanup patches/small fixes | expand

Commit Message

Arne Schwabe May 12, 2021, 3:15 a.m. UTC
the unit tests do not compile under windows since they are missing
the correct ifdef guards

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 tests/unit_tests/openvpn/test_argv.c       | 2 ++
 tests/unit_tests/openvpn/test_auth_token.c | 2 ++
 tests/unit_tests/openvpn/test_crypto.c     | 4 ++++
 tests/unit_tests/openvpn/test_misc.c       | 2 ++
 tests/unit_tests/openvpn/test_ncp.c        | 2 ++
 tests/unit_tests/openvpn/test_tls_crypt.c  | 2 ++
 6 files changed, 14 insertions(+)

Comments

Gert Doering May 14, 2021, 2:22 a.m. UTC | #1
Hi,

On Wed, May 12, 2021 at 03:15:07PM +0200, Arne Schwabe wrote:
> the unit tests do not compile under windows since they are missing
> the correct ifdef guards

While I totally agree with "WE MUST HAVE MORE #IFDEF!!" (in best
OpenVPN tradition), I do not think that this is the right place or
time.

> diff --git a/tests/unit_tests/openvpn/test_argv.c b/tests/unit_tests/openvpn/test_argv.c
> index 3dc470a52..6ab9be53c 100644
> --- a/tests/unit_tests/openvpn/test_argv.c
> +++ b/tests/unit_tests/openvpn/test_argv.c
> @@ -2,7 +2,9 @@
>  #include "syshead.h"
>  
>  #include <stdio.h>
> +#ifdef HAVE_UNISTD_H
>  #include <unistd.h>
> +#endif

As far as I can see, all these test modules include "syshead.h", which
already has the unistd.h (with guard!).

So maybe a better version of this patch would be to remove <unistd.h>
and all other includes that are already pulled in by "syshead.h"?

gert

Patch

diff --git a/tests/unit_tests/openvpn/test_argv.c b/tests/unit_tests/openvpn/test_argv.c
index 3dc470a52..6ab9be53c 100644
--- a/tests/unit_tests/openvpn/test_argv.c
+++ b/tests/unit_tests/openvpn/test_argv.c
@@ -2,7 +2,9 @@ 
 #include "syshead.h"
 
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
diff --git a/tests/unit_tests/openvpn/test_auth_token.c b/tests/unit_tests/openvpn/test_auth_token.c
index dbde86318..b0fbd6dec 100644
--- a/tests/unit_tests/openvpn/test_auth_token.c
+++ b/tests/unit_tests/openvpn/test_auth_token.c
@@ -30,7 +30,9 @@ 
 #include "syshead.h"
 
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/openvpn/test_crypto.c
index af83da689..edbee2c95 100644
--- a/tests/unit_tests/openvpn/test_crypto.c
+++ b/tests/unit_tests/openvpn/test_crypto.c
@@ -30,7 +30,11 @@ 
 #include "syshead.h"
 
 #include <stdio.h>
+
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
diff --git a/tests/unit_tests/openvpn/test_misc.c b/tests/unit_tests/openvpn/test_misc.c
index c3bea8fc8..f09ad4ba0 100644
--- a/tests/unit_tests/openvpn/test_misc.c
+++ b/tests/unit_tests/openvpn/test_misc.c
@@ -30,7 +30,9 @@ 
 #include "syshead.h"
 
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
diff --git a/tests/unit_tests/openvpn/test_ncp.c b/tests/unit_tests/openvpn/test_ncp.c
index 4077be5e8..5a886ca26 100644
--- a/tests/unit_tests/openvpn/test_ncp.c
+++ b/tests/unit_tests/openvpn/test_ncp.c
@@ -30,7 +30,9 @@ 
 #include "syshead.h"
 
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
diff --git a/tests/unit_tests/openvpn/test_tls_crypt.c b/tests/unit_tests/openvpn/test_tls_crypt.c
index 218772e8b..15788aa2f 100644
--- a/tests/unit_tests/openvpn/test_tls_crypt.c
+++ b/tests/unit_tests/openvpn/test_tls_crypt.c
@@ -30,7 +30,9 @@ 
 #include "syshead.h"
 
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>