[Openvpn-devel,02/28] Remove dead PID_TEST code

Message ID 20220422134038.3801239-3-arne@rfc2549.org
State Accepted
Headers show
Series Stateless three-way handshake and control channel improvements | expand

Commit Message

Arne Schwabe April 22, 2022, 3:40 a.m. UTC
Enabling this test produces compile errors and by the looks of it the
test has been broken for many years.
---
 src/openvpn/init.c      |  5 ----
 src/openvpn/packet_id.c | 56 -----------------------------------------
 src/openvpn/packet_id.h | 10 --------
 3 files changed, 71 deletions(-)

Comments

Gert Doering April 22, 2022, 6:09 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

Trivial enough, and indeed, this sort of test code is better suited
in the cmocka unit tests nowadays than compiling a special openvpn
binary...  have not tested it, just verified that only stuff between
#ifdef PID_TEST ... #endif gets ripped out.

Your patch has been applied to the master branch.

commit e21425a7ae7728e16634fd0e8cfba90b48a5309e
Author: Arne Schwabe
Date:   Fri Apr 22 15:40:31 2022 +0200

     Remove dead PID_TEST code

     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20220422134038.3801239-3-arne@rfc2549.org>
     URL: https://www.mail-archive.com/search?l=mid&q=20220422134038.3801239-3-arne@rfc2549.org
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index d5be3cf9f..e41bb9d4b 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -791,11 +791,6 @@  init_static(void)
 
     init_ssl_lib();
 
-#ifdef PID_TEST
-    packet_id_interactive_test();       /* test the sequence number code */
-    return false;
-#endif
-
 #ifdef SCHEDULE_TEST
     schedule_test();
     return false;
diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c
index 494320309..e357909d7 100644
--- a/src/openvpn/packet_id.c
+++ b/src/openvpn/packet_id.c
@@ -634,59 +634,3 @@  packet_id_debug_print(int msglevel,
 }
 
 #endif /* ifdef ENABLE_DEBUG */
-
-#ifdef PID_TEST
-
-void
-packet_id_interactive_test(void)
-{
-    struct packet_id pid;
-    struct packet_id_net pin;
-    bool long_form;
-    bool count = 0;
-    bool test;
-
-    const int seq_backtrack = 10;
-    const int time_backtrack = 10;
-
-    packet_id_init(&pid, seq_backtrack, time_backtrack);
-
-    while (true)
-    {
-        char buf[80];
-        if (!fgets(buf, sizeof(buf), stdin))
-        {
-            break;
-        }
-        update_time();
-        if (sscanf(buf, "%lu,%u", &pin.time, &pin.id) == 2)
-        {
-            packet_id_reap_test(&pid.rec);
-            test = packet_id_test(&pid.rec, &pin);
-            printf("packet_id_test (%" PRIi64 ", " packet_id_format ") returned %d\n",
-                   (int64_t)pin.time,
-                   (packet_id_print_type)pin.id,
-                   test);
-            if (test)
-            {
-                packet_id_add(&pid.rec, &pin);
-            }
-        }
-        else
-        {
-            long_form = (count < 20);
-            packet_id_alloc_outgoing(&pid.send, &pin, long_form);
-            printf("(%" PRIi64 "(" packet_id_format "), %d)\n",
-                   (int64_t)pin.time,
-                   (packet_id_print_type)pin.id,
-                   long_form);
-            if (pid.send.id == 10)
-            {
-                pid.send.id = 0xFFFFFFF8;
-            }
-            ++count;
-        }
-    }
-    packet_id_free(&pid);
-}
-#endif /* ifdef PID_TEST */
diff --git a/src/openvpn/packet_id.h b/src/openvpn/packet_id.h
index bb613282e..410071e26 100644
--- a/src/openvpn/packet_id.h
+++ b/src/openvpn/packet_id.h
@@ -35,11 +35,6 @@ 
 #include "error.h"
 #include "otime.h"
 
-/*
- * Enables OpenVPN to be compiled in special packet_id test mode.
- */
-/*#define PID_TEST*/
-
 #if 1
 /*
  * These are the types that members of
@@ -296,11 +291,6 @@  packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *
 
 const char *packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc);
 
-#ifdef PID_TEST
-void packet_id_interactive_test(void);
-
-#endif
-
 static inline int
 packet_id_size(bool long_form)
 {