| … | … | @@ -0,0 +1,27 @@ |
| 1 | #include <opencog/atomspace/AtomSpace.h> | |
| 2 | #include <opencog/atoms/value/FloatValue.h> | |
| 3 | #include <opencog/atoms/value/VoidValue.h> | |
| 4 | #include <opencog/atoms/atom_types/atom_names.h> | |
| 5 | #include <opencog/cogserver/atoms/CogServerNode.h> | |
| 6 | #include <opencog/cogserver/types/atom_types.h> | |
| 7 | ||
| 8 | #define DECLARE_TEST_COGSERVER \ | |
| 9 | AtomSpacePtr _test_asp; \ | |
| 10 | CogServerNodePtr _test_csrv; | |
| 11 | ||
| 12 | #define INIT_TEST_COGSERVER(port) \ | |
| 13 | _test_asp = createAtomSpace(); \ | |
| 14 | _test_csrv = CogServerNodeCast( \ | |
| 15 | _test_asp->add_node(COG_SERVER_NODE, "test-cogserver")); \ | |
| 16 | _test_csrv->setValue(_test_asp->add_atom(Predicate("*-telnet-port-*")), \ | |
| 17 | createFloatValue((double)(port))); \ | |
| 18 | _test_csrv->setValue(_test_asp->add_atom(Predicate("*-web-port-*")), \ | |
| 19 | createFloatValue(0.0)); \ | |
| 20 | _test_csrv->setValue(_test_asp->add_atom(Predicate("*-mcp-port-*")), \ | |
| 21 | createFloatValue(0.0)); \ | |
| 22 | _test_csrv->setValue(_test_asp->add_atom(Predicate("*-start-*")), \ | |
| 23 | createVoidValue()); | |
| 24 | ||
| 25 | #define STOP_TEST_COGSERVER \ | |
| 26 | _test_csrv->setValue(_test_asp->add_atom(Predicate("*-stop-*")), \ | |
| 27 | createVoidValue()); |
| … | … | @@ -33,10 +33,10 @@ |
| 33 | 33 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 36 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | 36 | |
| 38 | 37 | #include <opencog/util/Logger.h> |
| 39 | 38 | #include <opencog/util/Config.h> |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | using namespace opencog; |
| 42 | 42 | |
| … | … | @@ -45,18 +45,14 @@ class AlphaEquivUTest : public CxxTest::TestSuite |
| 45 | 45 | private: |
| 46 | 46 | AtomSpacePtr _as; |
| 47 | 47 | std::string uri; |
| 48 | CogServer* srvr = NULL; | |
| 49 | std::thread * main_loop = NULL; | |
| 48 | DECLARE_TEST_COGSERVER | |
| 50 | 49 | |
| 51 | 50 | public: |
| 52 | 51 | |
| 53 | 52 | AlphaEquivUTest(void); |
| 54 | 53 | ~AlphaEquivUTest() |
| 55 | 54 | { |
| 56 | srvr->stop(); | |
| 57 | main_loop->join(); | |
| 58 | srvr->disableNetworkServer(); | |
| 59 | delete main_loop; | |
| 55 | STOP_TEST_COGSERVER | |
| 60 | 56 | |
| 61 | 57 | logger().flush(); |
| 62 | 58 | |
| … | … | @@ -83,12 +79,7 @@ AlphaEquivUTest:: AlphaEquivUTest(void) |
| 83 | 79 | |
| 84 | 80 | uri = "cog://localhost:16311"; |
| 85 | 81 | |
| 86 | // Create a single cogserver node that will act as | |
| 87 | // as the repo for the duration of the test. | |
| 88 | srvr = &cogserver(); | |
| 89 | srvr->loadModules(); | |
| 90 | srvr->enableNetworkServer(16311); | |
| 91 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 82 | INIT_TEST_COGSERVER(16311); | |
| 92 | 83 | printf("Started CogServer\n"); |
| 93 | 84 | } |
| 94 | 85 |
| … | … | @@ -34,11 +34,11 @@ |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | 36 | #include <opencog/atomspace/AtomSpace.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 38 | 37 | |
| 39 | 38 | #include <opencog/persist/api/StorageNode.h> |
| 40 | 39 | |
| 41 | 40 | #include <opencog/util/Logger.h> |
| 41 | #include "../TestCogServer.h" | |
| 42 | 42 | |
| 43 | 43 | using namespace opencog; |
| 44 | 44 | |
| … | … | @@ -46,8 +46,7 @@ class SimpleBasicDeleteUTest : 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 SimpleBasicDeleteUTest : public CxxTest::TestSuite |
| 59 | 58 | |
| 60 | 59 | uri = "cog://localhost:16310"; |
| 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(16310); | |
| 67 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 61 | INIT_TEST_COGSERVER(16310); | |
| 68 | 62 | printf("Started CogServer\n"); |
| 69 | 63 | } |
| 70 | 64 | |
| 71 | 65 | ~SimpleBasicDeleteUTest() |
| 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()) |
| … | … | @@ -33,10 +33,10 @@ |
| 33 | 33 | #include <opencog/atoms/atom_types/atom_types.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atomspace/AtomSpace.h> |
| 36 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 38 | 37 | |
| 39 | 38 | #include <opencog/util/Logger.h> |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | using namespace opencog; |
| 42 | 42 | |
| … | … | @@ -44,8 +44,7 @@ class BasicSaveUTest : public CxxTest::TestSuite |
| 44 | 44 | { |
| 45 | 45 | private: |
| 46 | 46 | std::string uri; |
| 47 | CogServer* srvr = NULL; | |
| 48 | std::thread * main_loop = NULL; | |
| 47 | DECLARE_TEST_COGSERVER | |
| 49 | 48 | |
| 50 | 49 | Handle n1[10]; |
| 51 | 50 | Handle n2[10]; |
| … | … | @@ -67,21 +66,13 @@ class BasicSaveUTest : public CxxTest::TestSuite |
| 67 | 66 | |
| 68 | 67 | uri = "cog://localhost:16301"; |
| 69 | 68 | |
| 70 | // Create a single cogserver node that will act as | |
| 71 | // as the repo for the duration of the test. | |
| 72 | srvr = &cogserver(); | |
| 73 | srvr->loadModules(); | |
| 74 | srvr->enableNetworkServer(16301); | |
| 75 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 69 | INIT_TEST_COGSERVER(16301); | |
| 76 | 70 | printf("Started CogServer\n"); |
| 77 | 71 | } |
| 78 | 72 | |
| 79 | 73 | ~BasicSaveUTest() |
| 80 | 74 | { |
| 81 | srvr->stop(); | |
| 82 | main_loop->join(); | |
| 83 | srvr->disableNetworkServer(); | |
| 84 | delete main_loop; | |
| 75 | STOP_TEST_COGSERVER | |
| 85 | 76 | |
| 86 | 77 | // erase the log file if no assertions failed |
| 87 | 78 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -34,9 +34,9 @@ |
| 34 | 34 | #include <opencog/atoms/base/Node.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 38 | 37 | |
| 39 | 38 | #include <opencog/util/Logger.h> |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | using namespace opencog; |
| 42 | 42 | |
| … | … | @@ -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 | logger().flush(); |
| 76 | 72 | |
| … | … | @@ -105,12 +101,7 @@ DeleteUTest:: DeleteUTest(void) |
| 105 | 101 | logger().set_level(Logger::INFO); |
| 106 | 102 | logger().set_print_to_stdout_flag(true); |
| 107 | 103 | |
| 108 | // Create a single cogserver node that will act as | |
| 109 | // as the repo for the duration of the test. | |
| 110 | srvr = &cogserver(); | |
| 111 | srvr->loadModules(); | |
| 112 | srvr->enableNetworkServer(16305); | |
| 113 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 104 | INIT_TEST_COGSERVER(16305); | |
| 114 | 105 | printf("Started CogServer\n"); |
| 115 | 106 | } |
| 116 | 107 |
| … | … | @@ -34,9 +34,9 @@ |
| 34 | 34 | #include <opencog/guile/SchemeEval.h> |
| 35 | 35 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 38 | 37 | |
| 39 | 38 | #include <opencog/util/Logger.h> |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | using namespace opencog; |
| 42 | 42 | |
| … | … | @@ -48,18 +48,14 @@ class SimpleFetchUTest : public CxxTest::TestSuite |
| 48 | 48 | |
| 49 | 49 | AtomSpacePtr _as; |
| 50 | 50 | SchemeEval* eval; |
| 51 | CogServer* srvr = NULL; | |
| 52 | std::thread * main_loop = NULL; | |
| 51 | DECLARE_TEST_COGSERVER | |
| 53 | 52 | |
| 54 | 53 | public: |
| 55 | 54 | |
| 56 | 55 | SimpleFetchUTest(void); |
| 57 | 56 | ~SimpleFetchUTest() |
| 58 | 57 | { |
| 59 | srvr->stop(); | |
| 60 | main_loop->join(); | |
| 61 | srvr->disableNetworkServer(); | |
| 62 | delete main_loop; | |
| 58 | STOP_TEST_COGSERVER | |
| 63 | 59 | |
| 64 | 60 | // erase the log file if no assertions failed |
| 65 | 61 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -85,12 +81,7 @@ SimpleFetchUTest::SimpleFetchUTest(void) |
| 85 | 81 | |
| 86 | 82 | srv_open = "(cog-open (CogSimpleStorageNode \"" + uri + "\"))\n"; |
| 87 | 83 | |
| 88 | // Create a single cogserver node that will act as | |
| 89 | // as the repo for the duration of the test. | |
| 90 | srvr = &cogserver(); | |
| 91 | srvr->loadModules(); | |
| 92 | srvr->enableNetworkServer(16304); | |
| 93 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 84 | INIT_TEST_COGSERVER(16304); | |
| 94 | 85 | printf("Started CogServer\n"); |
| 95 | 86 | } |
| 96 | 87 |
| … | … | @@ -31,9 +31,9 @@ |
| 31 | 31 | #include <opencog/atoms/base/Node.h> |
| 32 | 32 | #include <opencog/atoms/value/FloatValue.h> |
| 33 | 33 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 34 | #include <opencog/cogserver/server/CogServer.h> | |
| 35 | 34 | |
| 36 | 35 | #include <opencog/util/Logger.h> |
| 36 | #include "../TestCogServer.h" | |
| 37 | 37 | |
| 38 | 38 | using namespace opencog; |
| 39 | 39 | |
| … | … | @@ -41,8 +41,7 @@ class LargeFlatUTest : public CxxTest::TestSuite |
| 41 | 41 | { |
| 42 | 42 | private: |
| 43 | 43 | AtomSpacePtr _as; |
| 44 | CogServer* srvr = NULL; | |
| 45 | std::thread * main_loop = NULL; | |
| 44 | DECLARE_TEST_COGSERVER | |
| 46 | 45 | |
| 47 | 46 | // 75000 * 7 == half-a-million atoms |
| 48 | 47 | // 19000 * 7 == 133K atoms |
| … | … | @@ -88,21 +87,13 @@ LargeFlatUTest::LargeFlatUTest(void) |
| 88 | 87 | logger().set_level(Logger::INFO); |
| 89 | 88 | logger().set_print_to_stdout_flag(true); |
| 90 | 89 | |
| 91 | // Create a single cogserver node that will act as | |
| 92 | // as the repo for the duration of the test. | |
| 93 | srvr = &cogserver(); | |
| 94 | srvr->loadModules(); | |
| 95 | srvr->enableNetworkServer(16308); | |
| 96 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 90 | INIT_TEST_COGSERVER(16308); | |
| 97 | 91 | printf("Started CogServer\n"); |
| 98 | 92 | } |
| 99 | 93 | |
| 100 | 94 | LargeFlatUTest::~LargeFlatUTest() |
| 101 | 95 | { |
| 102 | srvr->stop(); | |
| 103 | main_loop->join(); | |
| 104 | srvr->disableNetworkServer(); | |
| 105 | delete main_loop; | |
| 96 | STOP_TEST_COGSERVER | |
| 106 | 97 | logger().flush(); |
| 107 | 98 | |
| 108 | 99 | // erase the log file if no assertions failed |
| … | … | @@ -33,9 +33,9 @@ |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 36 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | 36 | |
| 38 | 37 | #include <opencog/util/Logger.h> |
| 38 | #include "../TestCogServer.h" | |
| 39 | 39 | |
| 40 | 40 | using namespace opencog; |
| 41 | 41 | |
| … | … | @@ -43,8 +43,7 @@ class LargeZipfUTest : public CxxTest::TestSuite |
| 43 | 43 | { |
| 44 | 44 | private: |
| 45 | 45 | AtomSpacePtr _as; |
| 46 | CogServer* srvr = NULL; | |
| 47 | std::thread * main_loop = NULL; | |
| 46 | DECLARE_TEST_COGSERVER | |
| 48 | 47 | |
| 49 | 48 | #define NWORDS 5000 |
| 50 | 49 | Handle hword[NWORDS]; |
| … | … | @@ -76,22 +75,13 @@ LargeZipfUTest:: LargeZipfUTest(void) |
| 76 | 75 | logger().set_level(Logger::INFO); |
| 77 | 76 | logger().set_print_to_stdout_flag(true); |
| 78 | 77 | |
| 79 | ||
| 80 | // Create a single cogserver node that will act as | |
| 81 | // as the repo for the duration of the test. | |
| 82 | srvr = &cogserver(); | |
| 83 | srvr->loadModules(); | |
| 84 | srvr->enableNetworkServer(16309); | |
| 85 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 78 | INIT_TEST_COGSERVER(16309); | |
| 86 | 79 | printf("Started CogServer\n"); |
| 87 | 80 | } |
| 88 | 81 | |
| 89 | 82 | LargeZipfUTest::~LargeZipfUTest() |
| 90 | 83 | { |
| 91 | srvr->stop(); | |
| 92 | main_loop->join(); | |
| 93 | srvr->disableNetworkServer(); | |
| 94 | delete main_loop; | |
| 84 | STOP_TEST_COGSERVER | |
| 95 | 85 | logger().flush(); |
| 96 | 86 | |
| 97 | 87 | // erase the log file if no assertions failed |
| … | … | @@ -36,10 +36,10 @@ |
| 36 | 36 | #include <opencog/atoms/value/LinkValue.h> |
| 37 | 37 | #include <opencog/atomspace/AtomSpace.h> |
| 38 | 38 | |
| 39 | #include <opencog/cogserver/server/CogServer.h> | |
| 40 | 39 | #include <opencog/persist/api/StorageNode.h> |
| 41 | 40 | |
| 42 | 41 | #include <opencog/util/Logger.h> |
| 42 | #include "../TestCogServer.h" | |
| 43 | 43 | |
| 44 | 44 | using namespace opencog; |
| 45 | 45 | |
| … | … | @@ -47,8 +47,7 @@ class SimpleMultiDeleteUTest : public CxxTest::TestSuite |
| 47 | 47 | { |
| 48 | 48 | private: |
| 49 | 49 | std::string uri; |
| 50 | CogServer* srvr = NULL; | |
| 51 | std::thread* main_loop = NULL; | |
| 50 | DECLARE_TEST_COGSERVER | |
| 52 | 51 | |
| 53 | 52 | AtomSpacePtr as; |
| 54 | 53 | StorageNodePtr store; |
| … | … | @@ -63,21 +62,13 @@ class SimpleMultiDeleteUTest : public CxxTest::TestSuite |
| 63 | 62 | |
| 64 | 63 | uri = "cog://localhost:16312"; |
| 65 | 64 | |
| 66 | // Create a single cogserver node that will act as | |
| 67 | // as the repo for the duration of the test. | |
| 68 | srvr = &cogserver(); | |
| 69 | srvr->loadModules(); | |
| 70 | srvr->enableNetworkServer(16312); | |
| 71 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 65 | INIT_TEST_COGSERVER(16312); | |
| 72 | 66 | printf("Started CogServer\n"); |
| 73 | 67 | } |
| 74 | 68 | |
| 75 | 69 | ~SimpleMultiDeleteUTest() |
| 76 | 70 | { |
| 77 | srvr->stop(); | |
| 78 | main_loop->join(); | |
| 79 | srvr->disableNetworkServer(); | |
| 80 | delete main_loop; | |
| 71 | STOP_TEST_COGSERVER | |
| 81 | 72 | |
| 82 | 73 | // erase the log file if no assertions failed |
| 83 | 74 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -34,11 +34,11 @@ |
| 34 | 34 | #include <opencog/atoms/base/Link.h> |
| 35 | 35 | #include <opencog/atoms/base/Node.h> |
| 36 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 38 | 37 | |
| 39 | 38 | #include <opencog/atoms/value/FloatValue.h> |
| 40 | 39 | |
| 41 | 40 | #include <opencog/util/Logger.h> |
| 41 | #include "../TestCogServer.h" | |
| 42 | 42 | |
| 43 | 43 | using namespace opencog; |
| 44 | 44 | |
| … | … | @@ -46,8 +46,7 @@ class MultiPersistUTest : public CxxTest::TestSuite |
| 46 | 46 | { |
| 47 | 47 | private: |
| 48 | 48 | AtomSpacePtr _as; |
| 49 | CogServer* srvr = NULL; | |
| 50 | std::thread * main_loop = NULL; | |
| 49 | DECLARE_TEST_COGSERVER | |
| 51 | 50 | StorageNodePtr store; |
| 52 | 51 | |
| 53 | 52 | #define NTHREADS 6 |
| … | … | @@ -76,10 +75,7 @@ class MultiPersistUTest : public CxxTest::TestSuite |
| 76 | 75 | MultiPersistUTest(void); |
| 77 | 76 | ~MultiPersistUTest() |
| 78 | 77 | { |
| 79 | srvr->stop(); | |
| 80 | main_loop->join(); | |
| 81 | srvr->disableNetworkServer(); | |
| 82 | delete main_loop; | |
| 78 | STOP_TEST_COGSERVER | |
| 83 | 79 | |
| 84 | 80 | // erase the log file if no assertions failed |
| 85 | 81 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -106,12 +102,7 @@ MultiPersistUTest:: MultiPersistUTest(void) |
| 106 | 102 | logger().set_level(Logger::INFO); |
| 107 | 103 | logger().set_print_to_stdout_flag(true); |
| 108 | 104 | |
| 109 | // Create a single cogserver node that will act as | |
| 110 | // as the repo for the duration of the test. | |
| 111 | srvr = &cogserver(); | |
| 112 | srvr->loadModules(); | |
| 113 | srvr->enableNetworkServer(16306); | |
| 114 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 105 | INIT_TEST_COGSERVER(16306); | |
| 115 | 106 | printf("Started CogServer\n"); |
| 116 | 107 | |
| 117 | 108 | n_threads = NTHREADS; |
| … | … | @@ -35,10 +35,10 @@ |
| 35 | 35 | #include <opencog/atoms/base/Link.h> |
| 36 | 36 | #include <opencog/atoms/base/Node.h> |
| 37 | 37 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 38 | #include <opencog/cogserver/server/CogServer.h> | |
| 39 | 38 | #include <opencog/atoms/value/FloatValue.h> |
| 40 | 39 | |
| 41 | 40 | #include <opencog/util/Logger.h> |
| 41 | #include "../TestCogServer.h" | |
| 42 | 42 | |
| 43 | 43 | using namespace opencog; |
| 44 | 44 | |
| … | … | @@ -70,8 +70,7 @@ class MultiUserUTest : public CxxTest::TestSuite |
| 70 | 70 | StorageNodePtr _store[NUSERS]; |
| 71 | 71 | std::atomic<int> nstarted; |
| 72 | 72 | |
| 73 | CogServer* srvr = NULL; | |
| 74 | std::thread * main_loop = NULL; | |
| 73 | DECLARE_TEST_COGSERVER | |
| 75 | 74 | |
| 76 | 75 | #define NCLAUSE 8 |
| 77 | 76 | #define NATOMS (NUSERS * NCLAUSE) |
| … | … | @@ -98,10 +97,7 @@ class MultiUserUTest : public CxxTest::TestSuite |
| 98 | 97 | MultiUserUTest(void); |
| 99 | 98 | ~MultiUserUTest() |
| 100 | 99 | { |
| 101 | srvr->stop(); | |
| 102 | main_loop->join(); | |
| 103 | srvr->disableNetworkServer(); | |
| 104 | delete main_loop; | |
| 100 | STOP_TEST_COGSERVER | |
| 105 | 101 | |
| 106 | 102 | // Erase the log file if no assertions failed |
| 107 | 103 | logger().flush(); |
| … | … | @@ -131,12 +127,7 @@ MultiUserUTest:: MultiUserUTest(void) |
| 131 | 127 | // logger().set_level(Logger::DEBUG); |
| 132 | 128 | logger().set_print_to_stdout_flag(true); |
| 133 | 129 | |
| 134 | // Create a single cogserver node that will act as | |
| 135 | // as the repo for the duration of the test. | |
| 136 | srvr = &cogserver(); | |
| 137 | srvr->loadModules(); | |
| 138 | srvr->enableNetworkServer(16307); | |
| 139 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 130 | INIT_TEST_COGSERVER(16307); | |
| 140 | 131 | printf("Started CogServer\n"); |
| 141 | 132 | |
| 142 | 133 | n_threads = NUSERS; |
| … | … | @@ -32,11 +32,11 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/cogserver/server/CogServer.h> | |
| 36 | 35 | |
| 37 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 38 | 37 | |
| 39 | 38 | #include <opencog/util/Logger.h> |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | using namespace opencog; |
| 42 | 42 | |
| … | … | @@ -44,8 +44,7 @@ class PersistUTest : 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 PersistUTest : public CxxTest::TestSuite |
| 67 | 66 | PersistUTest(void); |
| 68 | 67 | ~PersistUTest() |
| 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()) |
| … | … | @@ -94,12 +90,7 @@ PersistUTest:: PersistUTest(void) |
| 94 | 90 | // logger().set_level(Logger::DEBUG); |
| 95 | 91 | logger().set_print_to_stdout_flag(true); |
| 96 | 92 | |
| 97 | // Create a single cogserver node that will act as | |
| 98 | // as the repo for the duration of the test. | |
| 99 | srvr = &cogserver(); | |
| 100 | srvr->loadModules(); | |
| 101 | srvr->enableNetworkServer(16303); | |
| 102 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 93 | INIT_TEST_COGSERVER(16303); | |
| 103 | 94 | printf("Started CogServer\n"); |
| 104 | 95 | } |
| 105 | 96 |
| … | … | @@ -34,10 +34,10 @@ |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 38 | 37 | |
| 39 | 38 | #include <opencog/util/Logger.h> |
| 40 | 39 | #include <opencog/util/Config.h> |
| 40 | #include "../TestCogServer.h" | |
| 41 | 41 | |
| 42 | 42 | using namespace opencog; |
| 43 | 43 | |
| … | … | @@ -46,18 +46,14 @@ class SimpleQueryPersistUTest : public CxxTest::TestSuite |
| 46 | 46 | private: |
| 47 | 47 | AtomSpacePtr _as; |
| 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 | |
| 54 | 53 | SimpleQueryPersistUTest(void); |
| 55 | 54 | ~SimpleQueryPersistUTest() |
| 56 | 55 | { |
| 57 | srvr->stop(); | |
| 58 | main_loop->join(); | |
| 59 | srvr->disableNetworkServer(); | |
| 60 | delete main_loop; | |
| 56 | STOP_TEST_COGSERVER | |
| 61 | 57 | |
| 62 | 58 | logger().flush(); |
| 63 | 59 | |
| … | … | @@ -83,12 +79,7 @@ SimpleQueryPersistUTest:: SimpleQueryPersistUTest(void) |
| 83 | 79 | |
| 84 | 80 | uri = "cog://localhost:16313"; |
| 85 | 81 | |
| 86 | // Create a single cogserver node that will act as | |
| 87 | // as the repo for the duration of the test. | |
| 88 | srvr = &cogserver(); | |
| 89 | srvr->loadModules(); | |
| 90 | srvr->enableNetworkServer(16313); | |
| 91 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 82 | INIT_TEST_COGSERVER(16313); | |
| 92 | 83 | printf("Started CogServer\n"); |
| 93 | 84 | } |
| 94 | 85 |
| … | … | @@ -29,9 +29,9 @@ |
| 29 | 29 | #include <opencog/atoms/base/Node.h> |
| 30 | 30 | #include <opencog/atomspace/AtomSpace.h> |
| 31 | 31 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 32 | #include <opencog/cogserver/server/CogServer.h> | |
| 33 | 32 | |
| 34 | 33 | #include <opencog/util/Logger.h> |
| 34 | #include "../TestCogServer.h" | |
| 35 | 35 | |
| 36 | 36 | using namespace opencog; |
| 37 | 37 | |
| … | … | @@ -40,8 +40,7 @@ class ServerHangUTest : public CxxTest::TestSuite |
| 40 | 40 | private: |
| 41 | 41 | AtomSpacePtr _as; |
| 42 | 42 | std::string uri; |
| 43 | CogServer* srvr = nullptr; | |
| 44 | std::thread* main_loop = nullptr; | |
| 43 | DECLARE_TEST_COGSERVER | |
| 45 | 44 | |
| 46 | 45 | public: |
| 47 | 46 | |
| … | … | @@ -52,11 +51,7 @@ class ServerHangUTest : public CxxTest::TestSuite |
| 52 | 51 | |
| 53 | 52 | uri = "cog://localhost:16314"; |
| 54 | 53 | |
| 55 | // Create a CogServer for the duration of the test. | |
| 56 | srvr = &cogserver(); | |
| 57 | srvr->loadModules(); | |
| 58 | srvr->enableNetworkServer(16314); | |
| 59 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 54 | INIT_TEST_COGSERVER(16314); | |
| 60 | 55 | printf("Started CogServer on port 16314\n"); |
| 61 | 56 | } |
| 62 | 57 | |
| … | … | @@ -66,12 +61,8 @@ class ServerHangUTest : public CxxTest::TestSuite |
| 66 | 61 | // The fix in SocketManager::network_gone() now closes all |
| 67 | 62 | // sockets, allowing handler threads to exit. |
| 68 | 63 | printf("Stopping CogServer...\n"); |
| 69 | srvr->stop(); | |
| 70 | printf("Joining server thread...\n"); | |
| 71 | main_loop->join(); | |
| 72 | printf("Server thread joined.\n"); | |
| 73 | srvr->disableNetworkServer(); | |
| 74 | delete main_loop; | |
| 64 | STOP_TEST_COGSERVER | |
| 65 | printf("Server stopped.\n"); | |
| 75 | 66 | |
| 76 | 67 | logger().flush(); |
| 77 | 68 |
| … | … | @@ -36,7 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | 37 | #include <opencog/atoms/value/LinkValue.h> |
| 38 | 38 | #include <opencog/atoms/value/StringValue.h> |
| 39 | #include <opencog/cogserver/server/CogServer.h> | |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 42 | 42 | |
| … | … | @@ -49,8 +49,7 @@ class SimpleValueSaveUTest : public CxxTest::TestSuite |
| 49 | 49 | { |
| 50 | 50 | private: |
| 51 | 51 | std::string uri; |
| 52 | CogServer* srvr = NULL; | |
| 53 | std::thread * main_loop = NULL; | |
| 52 | DECLARE_TEST_COGSERVER | |
| 54 | 53 | |
| 55 | 54 | public: |
| 56 | 55 | |
| … | … | @@ -61,21 +60,13 @@ class SimpleValueSaveUTest : public CxxTest::TestSuite |
| 61 | 60 | |
| 62 | 61 | uri = "cog://localhost:16302"; |
| 63 | 62 | |
| 64 | // Create a single cogserver node that will act as | |
| 65 | // as the repo for the duration of the test. | |
| 66 | srvr = &cogserver(); | |
| 67 | srvr->loadModules(); | |
| 68 | srvr->enableNetworkServer(16302); | |
| 69 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 63 | INIT_TEST_COGSERVER(16302); | |
| 70 | 64 | printf("Started CogServer\n"); |
| 71 | 65 | } |
| 72 | 66 | |
| 73 | 67 | ~SimpleValueSaveUTest() |
| 74 | 68 | { |
| 75 | srvr->stop(); | |
| 76 | main_loop->join(); | |
| 77 | srvr->disableNetworkServer(); | |
| 78 | delete main_loop; | |
| 69 | STOP_TEST_COGSERVER | |
| 79 | 70 | |
| 80 | 71 | // erase the log file if no assertions failed |
| 81 | 72 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -33,7 +33,7 @@ |
| 33 | 33 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 36 | #include <opencog/cogserver/server/CogServer.h> | |
| 36 | #include "../TestCogServer.h" | |
| 37 | 37 | |
| 38 | 38 | #include <opencog/util/Logger.h> |
| 39 | 39 | #include <opencog/util/Config.h> |
| … | … | @@ -45,18 +45,14 @@ class AlphaEquivUTest : public CxxTest::TestSuite |
| 45 | 45 | private: |
| 46 | 46 | AtomSpacePtr _as; |
| 47 | 47 | std::string uri; |
| 48 | CogServer* srvr = NULL; | |
| 49 | std::thread * main_loop = NULL; | |
| 48 | DECLARE_TEST_COGSERVER | |
| 50 | 49 | |
| 51 | 50 | public: |
| 52 | 51 | |
| 53 | 52 | AlphaEquivUTest(void); |
| 54 | 53 | ~AlphaEquivUTest() |
| 55 | 54 | { |
| 56 | srvr->stop(); | |
| 57 | main_loop->join(); | |
| 58 | srvr->disableNetworkServer(); | |
| 59 | delete main_loop; | |
| 55 | STOP_TEST_COGSERVER | |
| 60 | 56 | |
| 61 | 57 | logger().flush(); |
| 62 | 58 | |
| … | … | @@ -83,12 +79,7 @@ AlphaEquivUTest:: AlphaEquivUTest(void) |
| 83 | 79 | |
| 84 | 80 | uri = "cog://localhost:16011"; |
| 85 | 81 | |
| 86 | // Create a single cogserver node that will act as | |
| 87 | // as the repo for the duration of the test. | |
| 88 | srvr = &cogserver(); | |
| 89 | srvr->loadModules(); | |
| 90 | srvr->enableNetworkServer(16011); | |
| 91 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 82 | INIT_TEST_COGSERVER(16011); | |
| 92 | 83 | printf("Started CogServer\n"); |
| 93 | 84 | } |
| 94 | 85 |
| … | … | @@ -34,7 +34,7 @@ |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | 36 | #include <opencog/atomspace/AtomSpace.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | #include "../TestCogServer.h" | |
| 38 | 38 | |
| 39 | 39 | #include <opencog/persist/api/StorageNode.h> |
| 40 | 40 |
| … | … | @@ -33,7 +33,7 @@ |
| 33 | 33 | #include <opencog/atoms/atom_types/atom_types.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atomspace/AtomSpace.h> |
| 36 | #include <opencog/cogserver/server/CogServer.h> | |
| 36 | #include "../TestCogServer.h" | |
| 37 | 37 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 38 | 38 | |
| 39 | 39 | #include <opencog/util/Logger.h> |
| … | … | @@ -44,8 +44,7 @@ class BasicSaveUTest : public CxxTest::TestSuite |
| 44 | 44 | { |
| 45 | 45 | private: |
| 46 | 46 | std::string uri; |
| 47 | CogServer* srvr = NULL; | |
| 48 | std::thread * main_loop = NULL; | |
| 47 | DECLARE_TEST_COGSERVER | |
| 49 | 48 | |
| 50 | 49 | Handle n1[10]; |
| 51 | 50 | Handle n2[10]; |
| … | … | @@ -68,21 +67,13 @@ class BasicSaveUTest : public CxxTest::TestSuite |
| 68 | 67 | |
| 69 | 68 | uri = "cog://localhost:16001"; |
| 70 | 69 | |
| 71 | // Create a single cogserver node that will act as | |
| 72 | // as the repo for the duration of the test. | |
| 73 | srvr = &cogserver(); | |
| 74 | srvr->loadModules(); | |
| 75 | srvr->enableNetworkServer(16001); | |
| 76 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 70 | INIT_TEST_COGSERVER(16001); | |
| 77 | 71 | printf("Started CogServer\n"); |
| 78 | 72 | } |
| 79 | 73 | |
| 80 | 74 | ~BasicSaveUTest() |
| 81 | 75 | { |
| 82 | srvr->stop(); | |
| 83 | main_loop->join(); | |
| 84 | srvr->disableNetworkServer(); | |
| 85 | delete main_loop; | |
| 76 | STOP_TEST_COGSERVER | |
| 86 | 77 | |
| 87 | 78 | // erase the log file if no assertions failed |
| 88 | 79 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -34,7 +34,7 @@ |
| 34 | 34 | #include <opencog/atoms/base/Node.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | 36 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | #include "../TestCogServer.h" | |
| 38 | 38 | |
| 39 | 39 | #include <opencog/util/Logger.h> |
| 40 | 40 |
| … | … | @@ -34,7 +34,7 @@ |
| 34 | 34 | #include <opencog/guile/SchemeEval.h> |
| 35 | 35 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | #include "../TestCogServer.h" | |
| 38 | 38 | |
| 39 | 39 | #include <opencog/util/Logger.h> |
| 40 | 40 | |
| … | … | @@ -48,8 +48,7 @@ class FetchUTest : public CxxTest::TestSuite |
| 48 | 48 | |
| 49 | 49 | AtomSpacePtr _as; |
| 50 | 50 | SchemeEval* eval; |
| 51 | CogServer* srvr = NULL; | |
| 52 | std::thread * main_loop = NULL; | |
| 51 | DECLARE_TEST_COGSERVER | |
| 53 | 52 | |
| 54 | 53 | public: |
| 55 | 54 |
| … | … | @@ -31,7 +31,7 @@ |
| 31 | 31 | #include <opencog/atoms/base/Node.h> |
| 32 | 32 | #include <opencog/atoms/value/FloatValue.h> |
| 33 | 33 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 34 | #include <opencog/cogserver/server/CogServer.h> | |
| 34 | #include "../TestCogServer.h" | |
| 35 | 35 | |
| 36 | 36 | #include <opencog/util/Logger.h> |
| 37 | 37 | |
| … | … | @@ -41,8 +41,7 @@ class LargeFlatUTest : public CxxTest::TestSuite |
| 41 | 41 | { |
| 42 | 42 | private: |
| 43 | 43 | AtomSpacePtr _as; |
| 44 | CogServer* srvr = NULL; | |
| 45 | std::thread * main_loop = NULL; | |
| 44 | DECLARE_TEST_COGSERVER | |
| 46 | 45 | |
| 47 | 46 | // 75000 * 7 == half-a-million atoms |
| 48 | 47 | // 19000 * 7 == 133K atoms |
| … | … | @@ -88,21 +87,13 @@ LargeFlatUTest::LargeFlatUTest(void) |
| 88 | 87 | logger().set_level(Logger::INFO); |
| 89 | 88 | logger().set_print_to_stdout_flag(true); |
| 90 | 89 | |
| 91 | // Create a single cogserver node that will act as | |
| 92 | // as the repo for the duration of the test. | |
| 93 | srvr = &cogserver(); | |
| 94 | srvr->loadModules(); | |
| 95 | srvr->enableNetworkServer(16008); | |
| 96 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 90 | INIT_TEST_COGSERVER(16008); | |
| 97 | 91 | printf("Started CogServer\n"); |
| 98 | 92 | } |
| 99 | 93 | |
| 100 | 94 | LargeFlatUTest::~LargeFlatUTest() |
| 101 | 95 | { |
| 102 | srvr->stop(); | |
| 103 | main_loop->join(); | |
| 104 | srvr->disableNetworkServer(); | |
| 105 | delete main_loop; | |
| 96 | STOP_TEST_COGSERVER | |
| 106 | 97 | |
| 107 | 98 | logger().flush(); |
| 108 | 99 | // erase the log file if no assertions failed |
| … | … | @@ -33,7 +33,7 @@ |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 36 | #include <opencog/cogserver/server/CogServer.h> | |
| 36 | #include "../TestCogServer.h" | |
| 37 | 37 | |
| 38 | 38 | #include <opencog/util/Logger.h> |
| 39 | 39 | |
| … | … | @@ -43,8 +43,7 @@ class LargeZipfUTest : public CxxTest::TestSuite |
| 43 | 43 | { |
| 44 | 44 | private: |
| 45 | 45 | AtomSpacePtr _as; |
| 46 | CogServer* srvr = NULL; | |
| 47 | std::thread * main_loop = NULL; | |
| 46 | DECLARE_TEST_COGSERVER | |
| 48 | 47 | |
| 49 | 48 | #define NWORDS 35000 |
| 50 | 49 | Handle hword[NWORDS]; |
| … | … | @@ -76,21 +75,13 @@ LargeZipfUTest:: LargeZipfUTest(void) |
| 76 | 75 | logger().set_level(Logger::INFO); |
| 77 | 76 | logger().set_print_to_stdout_flag(true); |
| 78 | 77 | |
| 79 | // Create a single cogserver node that will act as | |
| 80 | // as the repo for the duration of the test. | |
| 81 | srvr = &cogserver(); | |
| 82 | srvr->loadModules(); | |
| 83 | srvr->enableNetworkServer(16009); | |
| 84 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 78 | INIT_TEST_COGSERVER(16009); | |
| 85 | 79 | printf("Started CogServer\n"); |
| 86 | 80 | } |
| 87 | 81 | |
| 88 | 82 | LargeZipfUTest::~LargeZipfUTest() |
| 89 | 83 | { |
| 90 | srvr->stop(); | |
| 91 | main_loop->join(); | |
| 92 | srvr->disableNetworkServer(); | |
| 93 | delete main_loop; | |
| 84 | STOP_TEST_COGSERVER | |
| 94 | 85 | |
| 95 | 86 | logger().flush(); |
| 96 | 87 |
| … | … | @@ -36,7 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/value/LinkValue.h> |
| 37 | 37 | #include <opencog/atomspace/AtomSpace.h> |
| 38 | 38 | |
| 39 | #include <opencog/cogserver/server/CogServer.h> | |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | #include <opencog/persist/api/StorageNode.h> |
| 41 | 41 | |
| 42 | 42 | #include <opencog/util/Logger.h> |
| … | … | @@ -47,8 +47,7 @@ class MultiDeleteUTest : public CxxTest::TestSuite |
| 47 | 47 | { |
| 48 | 48 | private: |
| 49 | 49 | std::string uri; |
| 50 | CogServer* srvr = NULL; | |
| 51 | std::thread* main_loop = NULL; | |
| 50 | DECLARE_TEST_COGSERVER | |
| 52 | 51 | |
| 53 | 52 | AtomSpacePtr as; |
| 54 | 53 | StorageNodePtr store; |
| … | … | @@ -63,21 +62,13 @@ class MultiDeleteUTest : public CxxTest::TestSuite |
| 63 | 62 | |
| 64 | 63 | uri = "cog://localhost:16012"; |
| 65 | 64 | |
| 66 | // Create a single cogserver node that will act as | |
| 67 | // as the repo for the duration of the test. | |
| 68 | srvr = &cogserver(); | |
| 69 | srvr->loadModules(); | |
| 70 | srvr->enableNetworkServer(16012); | |
| 71 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 65 | INIT_TEST_COGSERVER(16012); | |
| 72 | 66 | printf("Started CogServer\n"); |
| 73 | 67 | } |
| 74 | 68 | |
| 75 | 69 | ~MultiDeleteUTest() |
| 76 | 70 | { |
| 77 | srvr->stop(); | |
| 78 | main_loop->join(); | |
| 79 | srvr->disableNetworkServer(); | |
| 80 | delete main_loop; | |
| 71 | STOP_TEST_COGSERVER | |
| 81 | 72 | |
| 82 | 73 | // erase the log file if no assertions failed |
| 83 | 74 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -34,7 +34,7 @@ |
| 34 | 34 | #include <opencog/atoms/base/Link.h> |
| 35 | 35 | #include <opencog/atoms/base/Node.h> |
| 36 | 36 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | #include "../TestCogServer.h" | |
| 38 | 38 | |
| 39 | 39 | #include <opencog/atoms/value/FloatValue.h> |
| 40 | 40 | |
| … | … | @@ -46,8 +46,7 @@ class MultiPersistUTest : public CxxTest::TestSuite |
| 46 | 46 | { |
| 47 | 47 | private: |
| 48 | 48 | AtomSpacePtr _as; |
| 49 | CogServer* srvr = NULL; | |
| 50 | std::thread * main_loop = NULL; | |
| 49 | DECLARE_TEST_COGSERVER | |
| 51 | 50 | StorageNodePtr store; |
| 52 | 51 | |
| 53 | 52 | #define NTHREADS 6 |
| … | … | @@ -76,10 +75,7 @@ class MultiPersistUTest : public CxxTest::TestSuite |
| 76 | 75 | MultiPersistUTest(void); |
| 77 | 76 | ~MultiPersistUTest() |
| 78 | 77 | { |
| 79 | srvr->stop(); | |
| 80 | main_loop->join(); | |
| 81 | srvr->disableNetworkServer(); | |
| 82 | delete main_loop; | |
| 78 | STOP_TEST_COGSERVER | |
| 83 | 79 | |
| 84 | 80 | // erase the log file if no assertions failed |
| 85 | 81 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |
| … | … | @@ -106,12 +102,7 @@ MultiPersistUTest:: MultiPersistUTest(void) |
| 106 | 102 | logger().set_level(Logger::INFO); |
| 107 | 103 | logger().set_print_to_stdout_flag(true); |
| 108 | 104 | |
| 109 | // Create a single cogserver node that will act as | |
| 110 | // as the repo for the duration of the test. | |
| 111 | srvr = &cogserver(); | |
| 112 | srvr->loadModules(); | |
| 113 | srvr->enableNetworkServer(16006); | |
| 114 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 105 | INIT_TEST_COGSERVER(16006); | |
| 115 | 106 | printf("Started CogServer\n"); |
| 116 | 107 | |
| 117 | 108 | n_threads = NTHREADS; |
| … | … | @@ -36,7 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/base/Link.h> |
| 37 | 37 | #include <opencog/atoms/base/Node.h> |
| 38 | 38 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 39 | #include <opencog/cogserver/server/CogServer.h> | |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | #include <opencog/atoms/value/FloatValue.h> |
| 41 | 41 | |
| 42 | 42 | #include <opencog/util/Logger.h> |
| … | … | @@ -71,8 +71,7 @@ class MultiUserUTest : public CxxTest::TestSuite |
| 71 | 71 | StorageNodePtr _store[NUSERS]; |
| 72 | 72 | std::atomic<int> nstarted; |
| 73 | 73 | |
| 74 | CogServer* srvr = NULL; | |
| 75 | std::thread * main_loop = NULL; | |
| 74 | DECLARE_TEST_COGSERVER | |
| 76 | 75 | |
| 77 | 76 | #define NCLAUSE 8 |
| 78 | 77 | #define NATOMS (NUSERS * NCLAUSE) |
| … | … | @@ -99,10 +98,7 @@ class MultiUserUTest : public CxxTest::TestSuite |
| 99 | 98 | MultiUserUTest(void); |
| 100 | 99 | ~MultiUserUTest() |
| 101 | 100 | { |
| 102 | srvr->stop(); | |
| 103 | main_loop->join(); | |
| 104 | srvr->disableNetworkServer(); | |
| 105 | delete main_loop; | |
| 101 | STOP_TEST_COGSERVER | |
| 106 | 102 | |
| 107 | 103 | // Erase the log file if no assertions failed |
| 108 | 104 | logger().flush(); |
| … | … | @@ -133,13 +129,7 @@ MultiUserUTest:: MultiUserUTest(void) |
| 133 | 129 | // logger().set_level(Logger::DEBUG); |
| 134 | 130 | logger().set_print_to_stdout_flag(true); |
| 135 | 131 | |
| 136 | // Create a single cogserver node that will act as | |
| 137 | // as the repo for the duration of the test. | |
| 138 | srvr = &cogserver(); | |
| 139 | srvr->loadModules(); | |
| 140 | srvr->set_max_open_sockets(30); | |
| 141 | srvr->enableNetworkServer(16007); | |
| 142 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 132 | INIT_TEST_COGSERVER(16007); | |
| 143 | 133 | printf("Started CogServer\n"); |
| 144 | 134 | |
| 145 | 135 | n_threads = NUSERS; |
| … | … | @@ -32,7 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/cogserver/server/CogServer.h> | |
| 35 | #include "../TestCogServer.h" | |
| 36 | 36 | |
| 37 | 37 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 38 | 38 | |
| … | … | @@ -44,8 +44,7 @@ class PersistUTest : 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 PersistUTest : public CxxTest::TestSuite |
| 67 | 66 | PersistUTest(void); |
| 68 | 67 | ~PersistUTest() |
| 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()) |
| … | … | @@ -95,12 +91,7 @@ PersistUTest:: PersistUTest(void) |
| 95 | 91 | // logger().set_level(Logger::DEBUG); |
| 96 | 92 | logger().set_print_to_stdout_flag(true); |
| 97 | 93 | |
| 98 | // Create a single cogserver node that will act as | |
| 99 | // as the repo for the duration of the test. | |
| 100 | srvr = &cogserver(); | |
| 101 | srvr->loadModules(); | |
| 102 | srvr->enableNetworkServer(16003); | |
| 103 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 94 | INIT_TEST_COGSERVER(16003); | |
| 104 | 95 | printf("Started CogServer\n"); |
| 105 | 96 | } |
| 106 | 97 |
| … | … | @@ -34,7 +34,7 @@ |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | 36 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 37 | #include <opencog/cogserver/server/CogServer.h> | |
| 37 | #include "../TestCogServer.h" | |
| 38 | 38 | |
| 39 | 39 | #include <opencog/util/Logger.h> |
| 40 | 40 | #include <opencog/util/Config.h> |
| … | … | @@ -46,18 +46,14 @@ class QueryPersistUTest : public CxxTest::TestSuite |
| 46 | 46 | private: |
| 47 | 47 | AtomSpacePtr _as; |
| 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 | |
| 54 | 53 | QueryPersistUTest(void); |
| 55 | 54 | ~QueryPersistUTest() |
| 56 | 55 | { |
| 57 | srvr->stop(); | |
| 58 | main_loop->join(); | |
| 59 | srvr->disableNetworkServer(); | |
| 60 | delete main_loop; | |
| 56 | STOP_TEST_COGSERVER | |
| 61 | 57 | |
| 62 | 58 | logger().flush(); |
| 63 | 59 | |
| … | … | @@ -83,12 +79,7 @@ QueryPersistUTest:: QueryPersistUTest(void) |
| 83 | 79 | |
| 84 | 80 | uri = "cog://localhost:16013"; |
| 85 | 81 | |
| 86 | // Create a single cogserver node that will act as | |
| 87 | // as the repo for the duration of the test. | |
| 88 | srvr = &cogserver(); | |
| 89 | srvr->loadModules(); | |
| 90 | srvr->enableNetworkServer(16013); | |
| 91 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 82 | INIT_TEST_COGSERVER(16013); | |
| 92 | 83 | printf("Started CogServer\n"); |
| 93 | 84 | } |
| 94 | 85 |
| … | … | @@ -36,7 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | 37 | #include <opencog/atoms/value/LinkValue.h> |
| 38 | 38 | #include <opencog/atoms/value/StringValue.h> |
| 39 | #include <opencog/cogserver/server/CogServer.h> | |
| 39 | #include "../TestCogServer.h" | |
| 40 | 40 | |
| 41 | 41 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 42 | 42 | |
| … | … | @@ -49,8 +49,7 @@ class ValueSaveUTest : public CxxTest::TestSuite |
| 49 | 49 | { |
| 50 | 50 | private: |
| 51 | 51 | std::string uri; |
| 52 | CogServer* srvr = NULL; | |
| 53 | std::thread * main_loop = NULL; | |
| 52 | DECLARE_TEST_COGSERVER | |
| 54 | 53 | |
| 55 | 54 | public: |
| 56 | 55 | |
| … | … | @@ -63,21 +62,13 @@ class ValueSaveUTest : public CxxTest::TestSuite |
| 63 | 62 | |
| 64 | 63 | uri = "cog://localhost:16002"; |
| 65 | 64 | |
| 66 | // Create a single cogserver node that will act as | |
| 67 | // as the repo for the duration of the test. | |
| 68 | srvr = &cogserver(); | |
| 69 | srvr->loadModules(); | |
| 70 | srvr->enableNetworkServer(16002); | |
| 71 | main_loop = new std::thread(&CogServer::serverLoop, srvr); | |
| 65 | INIT_TEST_COGSERVER(16002); | |
| 72 | 66 | printf("Started CogServer\n"); |
| 73 | 67 | } |
| 74 | 68 | |
| 75 | 69 | ~ValueSaveUTest() |
| 76 | 70 | { |
| 77 | srvr->stop(); | |
| 78 | main_loop->join(); | |
| 79 | srvr->disableNetworkServer(); | |
| 80 | delete main_loop; | |
| 71 | STOP_TEST_COGSERVER | |
| 81 | 72 | |
| 82 | 73 | // erase the log file if no assertions failed |
| 83 | 74 | if (!CxxTest::TestTracker::tracker().suiteFailed()) |