From 2f282741b276397bb4443f3e1320803dab81778f Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Sun, 15 Feb 2026 01:25:09 -0500 Subject: [PATCH] working through busted octopus tests now --- octopi/library/octopus/entity_data_bin.h | 3 + octopi/library/tests_cromp/makefile | 2 +- .../library/tests_cromp/test_cromp_client.cpp | 3 - octopi/library/tests_octopus/makefile | 6 +- octopi/library/tests_octopus/test_bin.cpp | 22 ++++--- .../tests_octopus/test_bin_threaded.cpp | 66 +++++++++++-------- testkit/prepare_tools.sh | 2 + 7 files changed, 59 insertions(+), 45 deletions(-) diff --git a/octopi/library/octopus/entity_data_bin.h b/octopi/library/octopus/entity_data_bin.h index 54f5f5f2..0ed4b004 100644 --- a/octopi/library/octopus/entity_data_bin.h +++ b/octopi/library/octopus/entity_data_bin.h @@ -104,6 +104,9 @@ public: // note that this should be called periodically by the controlling object. // it will not be called automatically. + basis::base_synchronizer &locker() { return *_ent_lock; } + //!< provided for tighter synchronization; this should be used very carefully, e.g. with auto_synchronizer. + private: entity_item_hash *_table; // our main storage object. basis::mutex *_ent_lock; // protects our structures. diff --git a/octopi/library/tests_cromp/makefile b/octopi/library/tests_cromp/makefile index a7ab6d68..ab8f75a4 100644 --- a/octopi/library/tests_cromp/makefile +++ b/octopi/library/tests_cromp/makefile @@ -19,6 +19,6 @@ create_decoder_ring: 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 + $(FEISTY_MEOW_BINARIES)/test_cromp_client --sends 1008 # zap the server now, since it won't quit otherwise. killall test_cromp_server diff --git a/octopi/library/tests_cromp/test_cromp_client.cpp b/octopi/library/tests_cromp/test_cromp_client.cpp index 8d99e39c..092851a5 100644 --- a/octopi/library/tests_cromp/test_cromp_client.cpp +++ b/octopi/library/tests_cromp/test_cromp_client.cpp @@ -57,9 +57,6 @@ 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)) - #define DEBUG_TESTER // uncomment for noisier version. diff --git a/octopi/library/tests_octopus/makefile b/octopi/library/tests_octopus/makefile index 6784c3bd..ba9b2123 100644 --- a/octopi/library/tests_octopus/makefile +++ b/octopi/library/tests_octopus/makefile @@ -4,11 +4,11 @@ include cpp/variables.def PROJECT = tests_octopus TYPE = test -TARGETS = t_bin.exe t_bin_threaded.exe t_entity.exe t_identity.exe \ - t_security.exe t_unpacker.exe t_file_transfer.exe +TARGETS = test_bin.exe test_bin_threaded.exe test_entity.exe test_identity.exe \ + test_security.exe test_unpacker.exe test_file_transfer.exe LOCAL_LIBS_USED = tentacles octopus sockets unit_test application configuration loggers \ textual timely processes filesystem structures basis -VCPP_USE_SOCK = t +#VCPP_USE_SOCK = t RUN_TARGETS = $(ACTUAL_TARGETS) include cpp/rules.def diff --git a/octopi/library/tests_octopus/test_bin.cpp b/octopi/library/tests_octopus/test_bin.cpp index 74c85090..b80b93f1 100644 --- a/octopi/library/tests_octopus/test_bin.cpp +++ b/octopi/library/tests_octopus/test_bin.cpp @@ -17,19 +17,20 @@ \*****************************************************************************/ #include +#include #include -#include #include #include #include -#include #include #include -#include +#include #include #include +#include #include #include +#include #include @@ -38,14 +39,15 @@ using namespace basis; using namespace loggers; using namespace octopi; using namespace textual; +using namespace unit_test; const int ITEM_COUNT = 10000; // the number of times to repeat each test operation. -#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger().get(), astring(s)) -#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger().get(), astring(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 test_bin : public application_shell +class test_bin : virtual public unit_base, virtual public application_shell { public: test_bin() : application_shell() {} @@ -72,7 +74,7 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); //LOG("note memory usage and hit a key:"); //c = getchar(); - program_wide_logger().get().eol(parser_bits::NO_ENDING); + program_wide_logger::get().eol(parser_bits::NO_ENDING); for (int i = 1; i <= ITEM_COUNT; i++) { // test the basic filling of the values in an entity. octopus_request_id req_id; @@ -91,12 +93,12 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); fflush(NULL_POINTER); } } - program_wide_logger().get().eol(parser_bits::CRLF_AT_END); + program_wide_logger::get().eol(parser_bits::CRLF_AT_END); LOG(""); int items_seen = 0; - program_wide_logger().get().eol(parser_bits::NO_ENDING); + program_wide_logger::get().eol(parser_bits::NO_ENDING); if (q == ANY) { while (item_list.length()) { octopus_request_id id; @@ -160,7 +162,7 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); } else { deadly_error(class_name(), "looping", "bad enum value"); } - program_wide_logger().get().eol(parser_bits::CRLF_AT_END); + program_wide_logger::get().eol(parser_bits::CRLF_AT_END); LOG(""); item_list.reset(); item_list.shrink(); diff --git a/octopi/library/tests_octopus/test_bin_threaded.cpp b/octopi/library/tests_octopus/test_bin_threaded.cpp index e939c9b9..f069fe8d 100644 --- a/octopi/library/tests_octopus/test_bin_threaded.cpp +++ b/octopi/library/tests_octopus/test_bin_threaded.cpp @@ -13,25 +13,27 @@ \*****************************************************************************/ #include +#include #include -#include +#include #include #include #include #include -#include -#include #include -#include -#include -#include -#include +#include #include #include #include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include #include @@ -40,10 +42,15 @@ #endif using namespace application; +using namespace basis; using namespace loggers; +using namespace mathematics; using namespace octopi; using namespace processes; +using namespace structures; +using namespace textual; using namespace timely; +using namespace unit_test; // global constants... @@ -86,7 +93,7 @@ const int MONKS_CLEANING_TIME = 10 * SECOND_ms; // a very short duration for data to live. #define LOG(to_print) printf("%s\n", (char *)astring(to_print).s()); -//CLASS_EMERGENCY_LOG(program_wide_logger().get(), to_print) +//CLASS_EMERGENCY_LOG(program_wide_logger::get().get(), to_print) // our macro for logging with a timestamp. // global objects... @@ -105,9 +112,9 @@ octopus_request_id create_request_id() octopus_request_id req_id; if (randomizer().inclusive(1, 100) < 25) { // some of the time we make a totally random entity id. - int sequencer = randomizer().inclusive(1, MAXINT - 10); - int add_in = randomizer().inclusive(0, MAXINT - 10); - int process_id = randomizer().inclusive(0, MAXINT - 10); + int sequencer = randomizer().inclusive(1, MAXINT32 - 10); + int add_in = randomizer().inclusive(0, MAXINT32 - 10); + int process_id = randomizer().inclusive(0, MAXINT32 - 10); req_id._entity = octopus_entity(string_manipulation::make_random_name(), process_id, sequencer, add_in); } else { @@ -118,7 +125,7 @@ octopus_request_id create_request_id() req_id._entity = octopus_entity("boringentity", process_id, sequencer, add_in); } - req_id._request_num = randomizer().inclusive(1, MAXINT - 10); + req_id._request_num = randomizer().inclusive(1, MAXINT32 - 10); return req_id; } @@ -243,20 +250,23 @@ public: void perform_activity(void *formal(data)) { FUNCDEF("perform_activity"); while (!should_stop()) { - // one activation of monk has devastating consequences. we empty out - // the data one item at a time until we see no data at all. after - // cleaning each item, we ensure that the deadwood is cleaned out. - binger._ent_lock->lock(); + { + // one activation of monk has devastating consequences. we empty out + // the data one item at a time until we see no data at all. after + // cleaning each item, we ensure that the deadwood is cleaned out. +//// binger._ent_lock->lock(); + auto_synchronizer l(binger.locker()); LOG(a_sprintf("monk sees %d items.", binger.items_held())); - while (binger.items_held()) { - // grab one instance of any item in the bin. - octopus_request_id id; - infoton *found = binger.acquire_for_any(id); - WHACK(found); - // also clean out things a lot faster than normal. - binger.clean_out_deadwood(MONKS_CLEANING_TIME); + while (binger.items_held()) { + // grab one instance of any item in the bin. + octopus_request_id id; + infoton *found = binger.acquire_for_any(id); + WHACK(found); + // also clean out things a lot faster than normal. + binger.clean_out_deadwood(MONKS_CLEANING_TIME); + } +/// binger._ent_lock->unlock(); } - binger._ent_lock->unlock(); LOG(a_sprintf("after a little cleaning, monk sees %d items.", binger.items_held())); // snooze. int sleepy_time = randomizer().inclusive(MIN_MONK_THREAD_PAUSE, @@ -271,7 +281,7 @@ LOG(a_sprintf("after a little cleaning, monk sees %d items.", binger.items_held( class test_entity_data_bin_threaded : public application_shell { public: - test_entity_data_bin_threaded() : application_shell(class_name()) {} + test_entity_data_bin_threaded() : application_shell() {} DEFINE_CLASS_NAME("test_entity_data_bin_threaded"); @@ -329,7 +339,7 @@ int test_entity_data_bin_threaded::execute() // how many evaporated due to timeout. - guards::alert_message("t_bin_threaded:: works for all functions tested."); + critical_events::alert_message("t_bin_threaded:: works for all functions tested."); return 0; } diff --git a/testkit/prepare_tools.sh b/testkit/prepare_tools.sh index 5fe1a227..7f38d293 100644 --- a/testkit/prepare_tools.sh +++ b/testkit/prepare_tools.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" + # Author: Chris Koeritz # # Note: -- 2.43.0