[Openvpn-devel,v2] unit-test: fix test_crypto when USE_COMP is not defined

Message ID 20220121140941.13930-1-a@unstable.cc
State Superseded
Headers show
Series
  • [Openvpn-devel,v2] unit-test: fix test_crypto when USE_COMP is not defined
Related show

Commit Message

Antonio Quartulli Jan. 21, 2022, 2:09 p.m.
This unit-test did not consider the case when USE_COMP is not defined,
thus generating a compiler error.

Adapt the test to the case when no compression is available.

Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---

v2:
* restore original MTU numbers - this can be addressed by another patch

 tests/unit_tests/openvpn/test_crypto.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Gert Doering Jan. 21, 2022, 2:29 p.m. | #1
Hi,

On Fri, Jan 21, 2022 at 03:09:41PM +0100, Antonio Quartulli wrote:
> This unit-test did not consider the case when USE_COMP is not defined,
> thus generating a compiler error.
> 
> Adapt the test to the case when no compression is available.
> 
> Cc: Arne Schwabe <arne@rfc2549.org>
> Signed-off-by: Antonio Quartulli <a@unstable.cc>

NAK.  Github says it now fails at "make check" time.

[ RUN      ] test_occ_mtu_calculation
[  ERROR   ] --- 0x5a8 != 0x5a9
[  FAILED  ] test_occ_mtu_calculation
[==========] 6 test(s) run.
[   LINE   ] --- test_crypto.c:304: error: Failure!
[  PASSED  ] 5 test(s).
[  FAILED  ] 1 test(s), listed below:
[  FAILED  ] test_occ_mtu_calculation

gert

Patch

diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/openvpn/test_crypto.c
index 19ce174e..8aa2fd0f 100644
--- a/tests/unit_tests/openvpn/test_crypto.c
+++ b/tests/unit_tests/openvpn/test_crypto.c
@@ -278,30 +278,34 @@  test_occ_mtu_calculation(void **state)
     linkmtu = calc_options_string_link_mtu(&o, &f);
     assert_int_equal(linkmtu, 1440);
 
-    /* --secret, cipher BF-CBC, auth SHA1 */
+    /* secret, cipher BF-CBC, auth SHA1 */
     o.ciphername = "BF-CBC";
     o.authname = "SHA1";
     linkmtu = calc_options_string_link_mtu(&o, &f);
     assert_int_equal(linkmtu, 1444);
 
-    /* --secret, cipher BF-CBC, auth SHA1, tcp-client */
+    /* secret, cipher BF-CBC, auth SHA1, tcp-client */
     o.ce.proto = PROTO_TCP_CLIENT;
     linkmtu = calc_options_string_link_mtu(&o, &f);
     assert_int_equal(linkmtu, 1446);
 
     o.ce.proto = PROTO_UDP;
 
-    /* --secret, comp-lzo yes, cipher BF-CBC, auth SHA1 */
+#if defined(USE_COMP)
+    /* secret, comp-lzo yes, cipher BF-CBC, auth SHA1 */
     o.comp.alg = COMP_ALG_LZO;
     linkmtu = calc_options_string_link_mtu(&o, &f);
     assert_int_equal(linkmtu, 1445);
+#endif
 
-    /* --secret, comp-lzo yes, cipher BF-CBC, auth SHA1, fragment 1200 */
+    /* secret, comp-lzo yes, cipher BF-CBC, auth SHA1, fragment 1200 */
     o.ce.fragment = 1200;
     linkmtu = calc_options_string_link_mtu(&o, &f);
     assert_int_equal(linkmtu, 1449);
 
+#if defined(USE_COMP)
     o.comp.alg = COMP_ALG_UNDEF;
+#endif
     o.ce.fragment = 0;
 
     /* TLS mode */
@@ -309,7 +313,7 @@  test_occ_mtu_calculation(void **state)
     o.tls_client = true;
     o.pull = true;
 
-    /* tls client, cipher AES-128-CBC, auth SHA1, tls-auth*/
+    /* tls client, cipher AES-128-CBC, auth SHA1, tls-auth */
     o.authname = "SHA1";
     o.ciphername = "AES-128-CBC";
     o.tls_auth_file = "dummy";
@@ -346,6 +350,7 @@  test_occ_mtu_calculation(void **state)
     assert_int_equal(linkmtu, 1449);
 
 
+#if defined(USE_COMP)
     /* tls client, auth SHA1, cipher AES-256-GCM, fragment, comp-lzo yes */
     o.comp.alg = COMP_ALG_LZO;
     o.ce.fragment = 1200;
@@ -356,6 +361,7 @@  test_occ_mtu_calculation(void **state)
     o.ce.socks_proxy_server = "socks.example.com";
     linkmtu = calc_options_string_link_mtu(&o, &f);
     assert_int_equal(linkmtu, 1464);
+#endif
 
     gc_free(&gc);
 }