From 5d71af609ae2eefeda9569a555fc3a0e2e212084 Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Sun, 15 Feb 2026 14:01:19 -0500 Subject: [PATCH] clobbering our way through the errors --- octopi/library/tests_octopus/test_entity.cpp | 52 +++++++++---- .../library/tests_octopus/test_identity.cpp | 32 ++++++-- .../library/tests_octopus/test_security.cpp | 37 +++++++-- .../library/tests_octopus/test_unpacker.cpp | 78 ++++++++++++++----- 4 files changed, 151 insertions(+), 48 deletions(-) diff --git a/octopi/library/tests_octopus/test_entity.cpp b/octopi/library/tests_octopus/test_entity.cpp index d9240982..a23cb176 100644 --- a/octopi/library/tests_octopus/test_entity.cpp +++ b/octopi/library/tests_octopus/test_entity.cpp @@ -16,17 +16,21 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ +#include +#include #include -#include #include #include -#include -#include +#include #include #include -#include +#include +#include +#include #include +#include #include +#include #ifdef __WIN32__ #include @@ -34,21 +38,35 @@ #include #endif +using namespace application; +using namespace basis; +using namespace configuration; +using namespace loggers; +using namespace mathematics; +using namespace octopi; +using namespace sockets; +using namespace textual; +using namespace unit_test; + +#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s)) + const int ITERATE_EACH_TEST = 1000; // the number of times to repeat each test operation. -class test_entity : public application_shell +class test_entity : virtual public unit_base, virtual public application_shell { public: - test_entity() : application_shell(class_name()) {} + test_entity() : application_shell() {} +//class_name() DEFINE_CLASS_NAME("test_entity"); virtual int execute(); }; int test_entity::execute() { + FUNCDEF("execute"); chaos rando; - SET_DEFAULT_COMBO_LOGGER; +/// SET_DEFAULT_COMBO_LOGGER; tcpip_stack stack; octopus_entity blankie; @@ -63,8 +81,8 @@ int test_entity::execute() for (int i = 0; i < ITERATE_EACH_TEST; i++) { // test the basic filling of the values in an entity. octopus_entity blank_ent; - int sequencer = rando.inclusive(1, MAXINT - 10); - int add_in = rando.inclusive(0, MAXINT - 10); + int sequencer = rando.inclusive(1, MAXINT32 - 10); + int add_in = rando.inclusive(0, MAXINT32 - 10); octopus_entity filled_ent(stack.hostname(), application_configuration::process_id(), sequencer, add_in); blank_ent = octopus_entity(stack.hostname(), application_configuration::process_id(), sequencer, @@ -76,9 +94,9 @@ int test_entity::execute() astring text2 = blank_ent.to_text(); if (text1 != text2) deadly_error(class_name(), "to_text test", "strings are different"); -///log(text1); +///LOG(text1); octopus_entity georgio = octopus_entity::from_text(text2); -///log(georgio.to_text()); +///LOG(georgio.to_text()); if (georgio != filled_ent) deadly_error(class_name(), "from_text test", "entity is different after from_text"); @@ -96,7 +114,7 @@ int test_entity::execute() if (blank_ent != filled_ent) deadly_error(class_name(), "reset from attribs test", "failed to resolve to same id"); -// log(a_sprintf("%d: ", i + 1) + filled_ent.mangled_form()); +// LOG(a_sprintf("%d: ", i + 1) + filled_ent.mangled_form()); byte_array chunk1; filled_ent.pack(chunk1); @@ -108,10 +126,10 @@ int test_entity::execute() // test of entity packing and size calculation. octopus_entity ent(string_manipulation::make_random_name(1, 428), - randomizer().inclusive(0, MAXINT/2), - randomizer().inclusive(0, MAXINT/2), - randomizer().inclusive(0, MAXINT/2)); - octopus_request_id bobo(ent, randomizer().inclusive(0, MAXINT/2)); + randomizer().inclusive(0, MAXINT32/2), + randomizer().inclusive(0, MAXINT32/2), + randomizer().inclusive(0, MAXINT32/2)); + octopus_request_id bobo(ent, randomizer().inclusive(0, MAXINT32/2)); int packed_estimate = bobo.packed_size(); byte_array packed_bobo; bobo.pack(packed_bobo); @@ -121,7 +139,7 @@ int test_entity::execute() } - log("octopus_entity:: works for those functions tested."); + LOG(astring(class_name()) + ":: works for those functions tested."); return 0; } diff --git a/octopi/library/tests_octopus/test_identity.cpp b/octopi/library/tests_octopus/test_identity.cpp index eb7dd35f..8e541c55 100644 --- a/octopi/library/tests_octopus/test_identity.cpp +++ b/octopi/library/tests_octopus/test_identity.cpp @@ -16,28 +16,46 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ +#include +#include #include +#include +#include +#include #include #include #include #include #include -#include -#include #include +#include + +using namespace application; +using namespace basis; +//using namespace configuration; +using namespace loggers; +using namespace mathematics; +using namespace octopi; +//using namespace sockets; +using namespace textual; +using namespace unit_test; + +#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s)) ////////////// -class test_octopus_identity : public application_shell +class test_octopus_identity : virtual public unit_base, virtual public application_shell { public: - test_octopus_identity() : application_shell(class_name()) {} + test_octopus_identity() : application_shell() {} +//class_name() DEFINE_CLASS_NAME("test_octopus_identity"); virtual int execute(); }; int test_octopus_identity::execute() { + FUNCDEF("execute") octopus logos("local", 18 * MEGABYTE); identity_infoton *ide = new identity_infoton; @@ -55,7 +73,7 @@ int test_octopus_identity::execute() deadly_error(class_name(), "evaluate test", astring("the evaluation failed with an error ") + tentacle::outcome_name(ret)); -log("point a"); +LOG("point a"); octopus_request_id response_id; // based on bogus from before. infoton *response = logos.acquire_result(junk_id._entity, response_id); @@ -70,14 +88,14 @@ log("point a"); octopus_entity my_ide = new_id->_new_name; -log(astring("new id is: ") + my_ide.text_form()); +LOG(astring("new id is: ") + my_ide.text_form()); if (my_ide.blank()) deadly_error(class_name(), "retrieving id", astring("the new entity id is blank.")); - log("octopus:: identity works for those functions tested."); + LOG("octopus:: identity works for those functions tested."); return 0; } diff --git a/octopi/library/tests_octopus/test_security.cpp b/octopi/library/tests_octopus/test_security.cpp index 4ce733b1..3be12117 100644 --- a/octopi/library/tests_octopus/test_security.cpp +++ b/octopi/library/tests_octopus/test_security.cpp @@ -17,19 +17,38 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ +#include +#include #include #include -#include +#include +#include +#include +#include #include #include #include #include -#include -#include #include #include +//#include +#include #include #include +#include + +using namespace application; +using namespace basis; +using namespace configuration; +using namespace loggers; +using namespace mathematics; +using namespace octopi; +using namespace sockets; +using namespace structures; +using namespace textual; +using namespace unit_test; + +#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s)) ////////////// @@ -44,6 +63,10 @@ public: simple_infoton() : infoton(simp_classifier()) {} + virtual void text_form(basis::base_string &state_fill) const { + state_fill.concatenate_string(astring("futzle=") + futzle); + } + virtual void pack(byte_array &packed_form) const { futzle.pack(packed_form); } @@ -96,16 +119,18 @@ public: // a while, log out, do another one, let it time out, try to access // something with dead id hoping to be rejected, etc. -class test_octopus_security : public application_shell +class test_octopus_security : virtual public unit_base, virtual public application_shell { public: - test_octopus_security() : application_shell(class_name()) {} + test_octopus_security() : application_shell() {} +//class_name() DEFINE_CLASS_NAME("test_octopus_security"); virtual int execute(); }; int test_octopus_security::execute() { + FUNCDEF("execute") octopus logos("local", 18 * MEGABYTE); simple_tentacle *tenty = new simple_tentacle; logos.add_tentacle(tenty); @@ -173,7 +198,7 @@ int test_octopus_security::execute() astring("the operation failed with an error ") + tentacle::outcome_name(ret)); - log("octopus:: security works for those functions tested."); + LOG(astring(class_name()) + ":: security works for those functions tested."); WHACK(guardian); diff --git a/octopi/library/tests_octopus/test_unpacker.cpp b/octopi/library/tests_octopus/test_unpacker.cpp index 1ad69a8d..ed16fcf8 100644 --- a/octopi/library/tests_octopus/test_unpacker.cpp +++ b/octopi/library/tests_octopus/test_unpacker.cpp @@ -16,25 +16,41 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ +#include +#include #include -#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include #include +#include +#include +#include + +using namespace application; +using namespace basis; +using namespace configuration; +using namespace loggers; +using namespace mathematics; +using namespace octopi; +using namespace sockets; +using namespace structures; +using namespace textual; +using namespace unit_test; + +#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s)) //hmmm: provide equality ops to be able to check that same stuff // came back out that went in. -class test_unpacker : public application_shell +class test_unpacker : virtual public unit_base, virtual public application_shell { public: - test_unpacker() : application_shell(class_name()) {} + test_unpacker() : application_shell() {} DEFINE_CLASS_NAME("test_unpacker"); virtual int execute(); void test_unpacking(); @@ -63,17 +79,23 @@ const char *addr_list[] = { "address" }; SAFE_STATIC_CONST(string_array, addr_classifier, (base_classifier() + string_array(1, addr_list))) -class address_ton : public infoton, public network_address +class address_ton : public infoton, public internet_address { public: address_ton() : infoton(addr_classifier() + "leaf") {} + const char *class_name() const { return "address_ton"; } + virtual void pack(byte_array &packed_form) const { - network_address::pack(packed_form); + internet_address::pack(packed_form); + } + + virtual void text_form(basis::base_string &state_fill) const { + state_fill.concatenate_string(internet_address::text_form()); } virtual bool unpack(byte_array &packed_form) { - return network_address::unpack(packed_form); + return internet_address::unpack(packed_form); } virtual int packed_size() const { @@ -94,11 +116,17 @@ public: float_ton() : infoton(math_classifier() + "float") {} + const char *class_name() const { return "float_ton"; } + virtual void pack(byte_array &packed_form) const { structures::attach(packed_form, f1); structures::attach(packed_form, d1); } + virtual void text_form(basis::base_string &state_fill) const { + state_fill.concatenate_string(a_sprintf("f1=%f d1=%f", f1, d1)); + } + virtual int packed_size() const { return sizeof(double) + sizeof(float); } @@ -124,6 +152,19 @@ public: int_set_ton() : infoton(math_classifier() + "intset") {} + const char *class_name() const { return "int_set_ton"; } + + virtual void text_form(basis::base_string &state_fill) const { + state_fill.concatenate_string(astring("( ")); + for (int indy = 0; indy < nums.length(); indy++) { + state_fill.concatenate_string(a_sprintf("%d", nums[indy])); + if (indy < nums.length() - 1) { + state_fill.concatenate_string(astring(", ")); + } + } + state_fill.concatenate_string(astring(" )")); + } + virtual void pack(byte_array &packed_form) const { structures::attach(packed_form, nums.elements()); for (int i = 0; i < nums.elements(); i++) @@ -173,7 +214,7 @@ public: reformed = NULL_POINTER; if (classifier.length() < 2) return BAD_INPUT; astring key = classifier[1]; - if (key == "float") { + if (key == astring("float")) { float_ton *to_return = new float_ton; if (!to_return->unpack(packed_form)) { WHACK(to_return); @@ -181,7 +222,7 @@ public: } reformed = to_return; return OKAY; - } else if (key == "intset") { + } else if (key == astring("intset")) { int_set_ton *to_return = new int_set_ton; if (!to_return->unpack(packed_form)) { WHACK(to_return); @@ -250,7 +291,7 @@ public: real_class.zap(0, 0); to_chow.set_classifier(real_class); // route to octopus. - return _unpackers.evaluate((infoton *)to_chow.clone(), item_id); + return _unpackers.evaluate(dynamic_cast(to_chow.clone()), item_id); } void expunge(const octopus_entity &formal(whackola)) {} @@ -352,7 +393,7 @@ void test_unpacker::test_unpacking() chunkmo += 0x37; chunkmo += 0x65; address_ton norf; - (network_address &)norf = network_address(internet_address + (internet_address &)norf = internet_address(internet_address (chunkmo, "urp", 23841)); chunkmo.reset(); infoton::fast_pack(chunkmo, norf); @@ -361,7 +402,7 @@ void test_unpacker::test_unpacking() if (!infoton::fast_unpack(chunkmo, clarfiator, pacula)) deadly_error(class_name(), "test fast_unpack", "chunkmo has errors"); infoton *scrung = NULL_POINTER; -//log(astring("classif is ") + clarfiator.text_form()); +//LOG(astring("classif is ") + clarfiator.text_form()); outcome scrung_ret = unpacky.restore(clarfiator, pacula, scrung); if (scrung_ret != tentacle::OKAY) @@ -372,7 +413,7 @@ void test_unpacker::test_unpacking() if (!rescrung) deadly_error(class_name(), "test fast_unpack", "wrong dynamic type for scrung"); address_ton &prescrung = *rescrung; - if ((network_address &)prescrung != (network_address &)norf) + if ((internet_address &)prescrung != (internet_address &)norf) deadly_error(class_name(), "test fast_unpack", "wrong network address restored"); WHACK(scrung); } @@ -382,12 +423,13 @@ const int MAXIMUM_TESTS = 10; int test_unpacker::execute() { + FUNCDEF("execute"); int iters = 0; while (iters++ < MAXIMUM_TESTS) { -//log(a_sprintf("iter #%d", iters)); +//LOG(a_sprintf("iter #%d", iters)); test_unpacking(); } - log("unpacking octopus:: works for all functions tested."); + LOG(astring(class_name()) + ":: works for all functions tested."); //time_control::sleep_ms(30000); return 0; } -- 2.43.0