| … | … | @@ -46,8 +46,7 @@ class BasicDeleteUTest : public CxxTest::TestSuite |
| 46 | 46 | { |
| 47 | 47 | private: |
| 48 | 48 | std::string uri; |
| 49 | CogServer* srvr = NULL; | |
| 50 | std::thread* main_loop = NULL; | |
| 49 | DECLARE_TEST_COGSERVER | |
| 51 | 50 | |
| 52 | 51 | public: |
| 53 | 52 | |
| … | … | @@ -59,21 +58,13 @@ class BasicDeleteUTest : public CxxTest::TestSuite |
| 59 | 58 | |
| 60 | 59 | uri = "cog://localhost:16010"; |
| 61 | 60 | |
| 62 | // Create a single cogserver node that will act as | |
| 63 | // as the repo for the duration of the test. | |
| 64 | srvr = &cogserver(); | |
| 65 | srvr->loadModules(); | |
| 66 | srvr->enableNetworkServer(16010); | |
| 67 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 61 | INIT_TEST_COGSERVER(16010); | |
| 68 | 62 | printf("Started CogServer\n"); |
| 69 | 63 | } |
| 70 | 64 | |
| 71 | 65 | ~BasicDeleteUTest() |
| 72 | 66 | { |
| 73 | srvr->stop(); | |
| 74 | main_loop->join(); | |
| 75 | srvr->disableNetworkServer(); | |
| 76 | delete main_loop; | |
| 67 | STOP_TEST_COGSERVER | |
| 77 | 68 | |
| 78 | 69 | // erase the log file if no assertions failed |
| 79 | 70 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -44,8 +44,7 @@ class DeleteUTest : public CxxTest::TestSuite |
| 44 | 44 | { |
| 45 | 45 | private: |
| 46 | 46 | AtomSpacePtr _as; |
| 47 | CogServer* srvr = NULL; | |
| 48 | std::thread * main_loop = NULL; | |
| 47 | DECLARE_TEST_COGSERVER | |
| 49 | 48 | |
| 50 | 49 | NodePtr n1[10]; |
| 51 | 50 | NodePtr n2[10]; |
| … | … | @@ -67,10 +66,7 @@ class DeleteUTest : public CxxTest::TestSuite |
| 67 | 66 | DeleteUTest(void); |
| 68 | 67 | ~DeleteUTest() |
| 69 | 68 | { |
| 70 | srvr->stop(); | |
| 71 | main_loop->join(); | |
| 72 | srvr->disableNetworkServer(); | |
| 73 | delete main_loop; | |
| 69 | STOP_TEST_COGSERVER | |
| 74 | 70 | |
| 75 | 71 | // erase the log file if no assertions failed |
| 76 | 72 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -104,12 +100,7 @@ DeleteUTest:: DeleteUTest(void) |
| 104 | 100 | logger().set_print_to_stdout_flag(true); |
| 105 | 101 | // logger().set_sync_flag(true); |
| 106 | 102 | |
| 107 | // Create a single cogserver node that will act as | |
| 108 | // as the repo for the duration of the test. | |
| 109 | srvr = &cogserver(); | |
| 110 | srvr->loadModules(); | |
| 111 | srvr->enableNetworkServer(16005); | |
| 112 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 103 | INIT_TEST_COGSERVER(16005); | |
| 113 | 104 | printf("Started CogServer\n"); |
| 114 | 105 | } |
| 115 | 106 |
| … | … | @@ -55,10 +55,7 @@ class FetchUTest : public CxxTest::TestSuite |
| 55 | 55 | FetchUTest(void); |
| 56 | 56 | ~FetchUTest() |
| 57 | 57 | { |
| 58 | srvr->stop(); | |
| 59 | main_loop->join(); | |
| 60 | srvr->disableNetworkServer(); | |
| 61 | delete main_loop; | |
| 58 | STOP_TEST_COGSERVER | |
| 62 | 59 | |
| 63 | 60 | logger().flush(); |
| 64 | 61 | |
| … | … | @@ -86,12 +83,7 @@ FetchUTest::FetchUTest(void) |
| 86 | 83 | |
| 87 | 84 | srv_open = "(cog-open (CogStorageNode \"" + uri + "\"))\n"; |
| 88 | 85 | |
| 89 | // Create a single cogserver node that will act as | |
| 90 | // as the repo for the duration of the test. | |
| 91 | srvr = &cogserver(); | |
| 92 | srvr->loadModules(); | |
| 93 | srvr->enableNetworkServer(16004); | |
| 94 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 86 | INIT_TEST_COGSERVER(16004); | |
| 95 | 87 | printf("Started CogServer\n"); |
| 96 | 88 | } |
| 97 | 89 |
| … | … | @@ -197,13 +197,13 @@ void MultiDeleteUTest::test_add_delete(void) |
| 197 | 197 | store->load_atomspace(); |
| 198 | 198 | printf("Final AtomSpace size=%lu\n", as->get_size()); |
| 199 | 199 | |
| 200 | // Size should be 19: the 18 from before plus that annoying | |
| 201 | // (Predicate "*-TruthValueKey-*") | |
| 200 | // Size should be 20: the 18 from before plus that annoying | |
| 201 | // (Predicate "*-TruthValueKey-*") And also *-IsKeyFlag-* | |
| 202 | 202 | // Well, actually, there is no guarantee that the removes will |
| 203 | 203 | // happen after the stores. Best we can do is check lower and |
| 204 | // upper bounds of 18 and 34: | |
| 205 | size_t min_size = 3 + n_threads + 6; | |
| 206 | size_t max_size = 3 + 2*(n_threads + 6); | |
| 204 | // upper bounds of 20 and 36: | |
| 205 | size_t min_size = 4 + n_threads + 6; | |
| 206 | size_t max_size = 4 + 2*(n_threads + 6); | |
| 207 | 207 | if (as->get_size() < min_size or max_size < as->get_size()) |
| 208 | 208 | printf("Error: Bad size! AtomSpace contents =\n%s\n", |
| 209 | 209 | as->to_string().c_str()); |