]> feistymeow.org Git - feisty_meow.git/commitdiff
automated the cromp tests
authorFred T. Hamster <fred@feistymeow.org>
Sun, 15 Feb 2026 05:50:24 +0000 (00:50 -0500)
committerFred T. Hamster <fred@feistymeow.org>
Sun, 15 Feb 2026 05:50:24 +0000 (00:50 -0500)
now the cromp tests actually are called, with both the server and client.
this test reveals some issues (bugs) with the cromp code though, where the client loses contact with the server.
also the runtime is way too long for a unit test.

octopi/library/tests_cromp/crompish_pax.h
octopi/library/tests_cromp/example_cromp_data.txt [new file with mode: 0644]
octopi/library/tests_cromp/makefile
octopi/library/tests_cromp/makefile.decoder
octopi/library/tests_cromp/test_cromp_client.cpp
octopi/library/tests_cromp/test_cromp_server.cpp
octopi/library/tests_cromp/test_many_cromp.cpp

index 03b35fa56faceaf564c12d4406449d676cb74a16..709e233ae0af763daaf6f1dc5cd334fbd8b5de25 100644 (file)
 \*****************************************************************************/
 
 #include <cromp/cromp_transaction.h>
+#include <loggers/critical_events.h>
 #include <mathematics/chaos.h>
 #include <octopus/infoton.h>
 #include <octopus/tentacle_helper.h>
 #include <structures/string_array.h>
 
+// uncomment to cause more checking that verifies the packed_size method
+// is reporting accurately.
+//#define CHECK_CROMPISH_PACKED_SIZE
+
 class bubble : public octopi::infoton
 {
 public:
@@ -51,7 +56,7 @@ public:
 
   int data_length() const { return _data.length(); }
 
-  clonable *clone() const { return octopi::cloner<bubble>(*this); }
+  virtual clonable *clone() const { return octopi::cloner<bubble>(*this); }
 
   basis::byte_array &data() { return _data; }
 
@@ -64,15 +69,27 @@ public:
   }
 
   virtual void pack(basis::byte_array &packed_form) const {
+    FUNCDEF("pack")
+#ifdef CHECK_CROMPISH_PACKED_SIZE
+    int prior_len = packed_form.length();
+#endif
     structures::attach(packed_form, _color);
     _bounds.pack(packed_form);
     structures::attach(packed_form, _data);
+#ifdef CHECK_CROMPISH_PACKED_SIZE
+    int predicted_size = packed_size();
+    int new_len = packed_form.length();
+    if (prior_len + predicted_size != new_len) {
+      loggers::deadly_error(class_name(), func, basis::a_sprintf("size predicted=%d but actually was %d", predicted_size, new_len - prior_len));
+    }
+#endif
   }
 
   int packed_size() const {
-    return _data.length() + 2 * sizeof(int)       // packed byte array.
+    return _data.length() + 2 * sizeof(int)   // packed byte array.
         + sizeof(int)                         // packed color.
-        + 4 * sizeof(int);                    // packed screen rectangle.
+        + _bounds.packed_size();              // packed string array.
+///no, old. 4 * sizeof(int);                    
   }
 
   virtual bool unpack(basis::byte_array &packed_form) {
diff --git a/octopi/library/tests_cromp/example_cromp_data.txt b/octopi/library/tests_cromp/example_cromp_data.txt
new file mode 100644 (file)
index 0000000..fd40910
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+
+
index 48a1984831a210456935cc9b51410f6606b2f9ec..a7ab6d68ac2e9749443fd6590cf1632b2c809a4d 100644 (file)
@@ -5,15 +5,20 @@ include cpp/variables.def
 PROJECT = test_cromp
 TYPE = test
 TARGETS = test_cromp_client.exe test_cromp_server.exe test_many_cromp.exe
-LAST_TARGETS = create_decoder_ring
 LOCAL_LIBS_USED = unit_test crypto application configuration filesystem loggers \
   mathematics nodes processes sockets structures textual timely octopus cromp \
   tentacles structures basis 
 USE_SSL = t
-#RUN_TARGETS = $(ACTUAL_TARGETS)
+LAST_TARGETS = create_decoder_ring run_client_server_test
 
 include cpp/rules.def
 
 create_decoder_ring:
        $(MAKE) -f makefile.decoder
 
+run_client_server_test:
+       # launch the server into the background first.  we have to hope it completes, eventually.
+       ($(FEISTY_MEOW_BINARIES)/test_cromp_server &)
+       $(FEISTY_MEOW_BINARIES)/test_cromp_client
+       # zap the server now, since it won't quit otherwise.
+       killall test_cromp_server
index 82d48d01d2ac8bbba816f0eedfdd8a0a8d738192..89451ff4afed2376179328474adbfbd1a7cce965 100644 (file)
@@ -9,7 +9,11 @@ LOCAL_LIBS_USED = unit_test octopus cromp crypto application configuration files
   mathematics nodes processes sockets structures textual timely \
   tentacles structures basis 
 USE_SSL = t
-RUN_TARGETS = $(ACTUAL_TARGETS)
+LAST_TARGETS = decoder_ring
 
 include cpp/rules.def
 
+decoder_ring:
+       $(FEISTY_MEOW_BINARIES)/cromp_decoder < example_cromp_data.txt
+
+
index b0bc262e9b631dd3b4ca53e2c163e57c729e896a..8d99e39cfe640398dad514477855f9bb66474845 100644 (file)
@@ -57,8 +57,8 @@ using namespace unit_test;
 
 #undef LOG
 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
-#undef BASE_LOG
-#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger::get(), astring(s))
+///#undef BASE_LOG
+///#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger::get(), astring(s))
 
 
 #define DEBUG_TESTER
@@ -677,7 +677,7 @@ void cromp_client_tester::report(const time_stamp &start_time,
       packed_transa.length() - payload_portion));
 #endif
 
-  BASE_LOG(a_sprintf("sent %.0f items, %.0f bytes, %.0f bytes per item,%s"
+  LOG(a_sprintf("sent %.0f items, %.0f bytes, %.0f bytes per item,%s"
       "payload %.0f bytes, overhead %.0f bytes, percent overhead %.1f%%,%s"
       "in %.2f seconds is %f ms/item%s"
       "at %.2f %cb/sec & %.2f items/sec.",
@@ -809,7 +809,7 @@ int cromp_client_tester::execute()
 ///  int char_read = fgetc(stdin);
 #endif
 
-  BASE_LOG("cromp_client:: works for those functions tested.");
+  LOG("works for those functions tested.");
 
   return 0;
 }
index be3db71b928dc06abd64f93e77298ab02f74a5bb..e036d8c6714c7f6f35aa3feafa12eb91c63788df 100644 (file)
 
 #include "crompish_pax.h"
 
+#include <application/application_shell.h>
+#include <application/command_line.h>
+#include <application/hoople_main.h>
+#include <basis/astring.h>
 #include <basis/byte_array.h>
 #include <basis/functions.h>
-#include <basis/astring.h>
 #include <cromp/cromp_server.h>
-#include <timely/time_stamp.h>
-#include <octopus/tentacle.h>
-#include <application/application_shell.h>
-#include <application/command_line.h>
 #include <loggers/console_logger.h>
 #include <loggers/file_logger.h>
-#include <structures/static_memory_gremlin.h>
+#include <loggers/program_wide_logger.h>
+#include <octopus/tentacle.h>
 #include <sockets/internet_address.h>
 #include <sockets/machine_uid.h>
 #include <sockets/tcpip_stack.h>
+#include <structures/static_memory_gremlin.h>
+#include <timely/time_control.h>
+#include <timely/time_stamp.h>
 #include <unit_test/unit_base.h>
 
 using namespace application;
@@ -119,7 +122,7 @@ public:
     bubble *inf = dynamic_cast<bubble *>(&to_chow);
     if (!inf) return NO_HANDLER;
 //LOG("caching product!  success getting unpacked etc.");
-    bubble *junk = (bubble *)inf->clone();
+    bubble *junk = dynamic_cast<bubble *>(inf->clone());
     store_product(junk, item_id);
     return OKAY;
   }
@@ -139,7 +142,7 @@ cromp_server_tester::cromp_server_tester()
   _encryption(false)
 {
   FUNCDEF("constructor");
-  SET_DEFAULT_COMBO_LOGGER;
+///  SET_DEFAULT_COMBO_LOGGER;
   LOG("");
   LOG("");
 
index bd64ff71c2829acebaddc63366039ac011fdd61d..c3acb5a5ea54d35869c563987ea79e18faa16f08 100644 (file)
 
 #include "crompish_pax.h"
 
-#include <basis/chaos.h>
-#include <basis/istring.h>
-#include <basis/portable.h>
-#include <data_struct/amorph.h>
+#include <mathematics/chaos.h>
+#include <basis/astring.h>
+
+#include <application/application_shell.h>
+#include <application/command_line.h>
+#include <application/hoople_main.h>
+#include <structures/amorph.h>
 #include <cromp/cromp_client.h>
 #include <octopus/entity_defs.h>
 #include <octopus/infoton.h>
-#include <opsystem/application_shell.h>
-#include <opsystem/command_line.h>
 #include <loggers/console_logger.h>
+#include <loggers/critical_events.h>
 #include <loggers/file_logger.h>
-#include <data_struct/static_memory_gremlin.h>
-#include <sockets/address.h>
+#include <loggers/program_wide_logger.h>
+#include <sockets/internet_address.h>
+#include <structures/static_memory_gremlin.h>
+#include <timely/time_control.h>
+#include <unit_test/unit_base.h>
 
 #include <stdio.h>
 
+using namespace application;
+using namespace basis;
+using namespace configuration;
+using namespace cromp;
+using namespace mathematics;
+using namespace filesystem;
+using namespace loggers;
+using namespace octopi;
+using namespace processes;
+using namespace sockets;
+using namespace structures;
+using namespace textual;
+using namespace timely;
+using namespace unit_test;
+
 #define DEBUG_TESTER
   // uncomment for noisier version.
 
 const int REPORTING_INTERVAL = 20 * SECOND_ms;
   // how frequently we tell about bad crompers.
 
-#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s)
-#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger(), s)
+#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
+#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger::get(), astring(s))
 
-class many_cromp_tester : public application_shell
+class many_cromp_tester : virtual public unit_base, virtual public application_shell
 {
 public:
   many_cromp_tester();
@@ -51,7 +71,7 @@ public:
 
   virtual int execute();
 
-  IMPLEMENT_CLASS_NAME("many_cromp_tester");
+  DEFINE_CLASS_NAME("many_cromp_tester");
 
 private:
   amorph<cromp_client> _uplinks;  // a list of cromp clients.
@@ -59,10 +79,11 @@ private:
   int _count;  // number of cromps.
 };
 
-////////////////////////////////////////////////////////////////////////////
+//////////////
 
 many_cromp_tester::many_cromp_tester()
-: application_shell("many_cromp_tester"),
+: application_shell(),
+///"many_cromp_tester"),
   _uplinks(),
   _encryption(false),
   _count(1)
@@ -73,21 +94,21 @@ many_cromp_tester::many_cromp_tester()
 
   internet_address server_loc;
 
-  command_line args(__argc, __argv);
-//LOG(isprintf("argc is %d and first is %s", __argc, __argv[0]));
+  command_line args(application::_global_argc, application::_global_argv);
+//LOG(a_sprintf("argc is %d and first is %s", application::_global_argc, application::_global_argv[0]));
 
   // check for a port on the command line.
-  istring port_text;
+  astring port_text;
   int port = 5678;
   if (args.get_value("port", port_text, false)) {
-    LOG(istring("using port: ") + port_text);
+    LOG(astring("using port: ") + port_text);
     port = port_text.convert(5678);
   }
   server_loc.port = port;
 
-  istring count_text;
+  astring count_text;
   if (args.get_value("count", count_text, false)) {
-    LOG(istring("using count: ") + count_text);
+    LOG(astring("using count: ") + count_text);
     _count = count_text.convert(_count);
   }
 
@@ -101,25 +122,25 @@ many_cromp_tester::many_cromp_tester()
   }
 
   // check for a hostname on the command line.
-  istring hostname("local");
-  istring host_temp;
+  astring hostname("local");
+  astring host_temp;
   if (args.get_value("host", host_temp, false)) {
-    LOG(istring("using host: ") + host_temp);
+    LOG(astring("using host: ") + host_temp);
     hostname = host_temp;
   }
-LOG(istring("using host: ") + hostname);
+LOG(astring("using host: ") + hostname);
   strcpy(server_loc.hostname, hostname.s());
 
-LOG(istring("opening at ") + server_loc.text_form());
+LOG(astring("opening at ") + server_loc.text_form());
 
-LOG(isprintf("count of %d cromps will be created.", _count));
+LOG(a_sprintf("count of %d cromps will be created.", _count));
 
   for (int i = 0; i < _count; i++) {
-LOG(isprintf("%d. A", i));
+LOG(a_sprintf("%d. A", i));
     cromp_client *uplink = new cromp_client(server_loc);
-LOG(isprintf("%d. B", i));
+LOG(a_sprintf("%d. B", i));
     uplink->add_tentacle(new bubbles_tentacle(false));
-LOG(isprintf("%d. C", i));
+LOG(a_sprintf("%d. C", i));
     _uplinks.append(uplink);
   }
 
@@ -142,7 +163,7 @@ int many_cromp_tester::execute()
   for (int i = 0; i < _uplinks.elements(); i++) {
     outcome ret = _uplinks.borrow(i)->connect();
     if (ret != cromp_client::OKAY) {
-      deadly_error(class_name(), func, istring("connection failed with error: ")
+      deadly_error(class_name(), func, astring("connection failed with error: ")
           + cromp_client::outcome_name(ret));
     }
   }
@@ -160,13 +181,13 @@ time_stamp when_to_leave(10 * HOUR_ms);
 
     if (time_stamp() > next_report) {
       int connected = _uplinks.elements() - unconnected;
-      LOG(isprintf("[ %d connected and %d did not ]", connected, unconnected));
+      LOG(a_sprintf("[ %d connected and %d did not ]", connected, unconnected));
       next_report.reset(REPORTING_INTERVAL);
     }
 
 //do something with uplinks.
 
-    portable::sleep_ms(100);
+    time_control::sleep_ms(100);
   }
 
 
@@ -175,7 +196,7 @@ time_stamp when_to_leave(10 * HOUR_ms);
   return 0;
 }
 
-////////////////////////////////////////////////////////////////////////////
+//////////////
 
 HOOPLE_MAIN(many_cromp_tester, )