From 04f7a03780478562019a174aa23b6a9a1267b3c1 2011-06-08 16:36:30 From: Jan Kaluza Date: 2011-06-08 16:36:30 Subject: [PATCH] Fixed some bad bugs + improved tests --- diff --git a/backends/libpurple/main.cpp b/backends/libpurple/main.cpp index 026d88447e563c908d9792597c0e9df7a7876910..4be4e3a95ad50800ad175f495a5fb9a4955df1fa 100644 --- a/backends/libpurple/main.cpp +++ b/backends/libpurple/main.cpp @@ -479,6 +479,9 @@ static PurpleCoreUiOps coreUiOps = }; static void signed_on(PurpleConnection *gc, gpointer unused) { + for (int i = 0; i<1500; i++) { + std::cout << "A\n"; + } PurpleAccount *account = purple_connection_get_account(gc); np->handleConnected(np->m_accounts[account]); } diff --git a/src/networkplugin.cpp b/src/networkplugin.cpp index fa393588033ad24f3dbe9779857c4ec7d3d4a4cf..9f35885f7a14da5453655bd474562625e174df78 100644 --- a/src/networkplugin.cpp +++ b/src/networkplugin.cpp @@ -266,7 +266,7 @@ void NetworkPlugin::handleVCardPayload(const std::string &data) { } void NetworkPlugin::handleDataRead(const Swift::SafeByteArray &data) { - m_data.insert(m_data.begin(), data.begin(), data.end()); + m_data.insert(m_data.end(), data.begin(), data.end()); while (m_data.size() != 0) { unsigned int expected_size; diff --git a/src/networkpluginserver.cpp b/src/networkpluginserver.cpp index ce39caa3b23848bfd965a3fd481348e838448e99..0ccd6167f14dfd7a1ca36d131be55ba60068067e 100644 --- a/src/networkpluginserver.cpp +++ b/src/networkpluginserver.cpp @@ -90,7 +90,7 @@ static int exec_(const char *path, const char *host, const char *port, const cha if ( pid == 0 ) { // child process execlp(path, path, "--host", host, "--port", port, config, NULL); - exit(1); + abort(); } else if ( pid < 0 ) { // fork failed status = -1; @@ -195,13 +195,9 @@ void NetworkPluginServer::handleDisconnectedPayload(const std::string &data) { return; } - User *user = m_userManager->getUser(payload.user()); - if (!user) { - return; - } - m_component->m_userRegistry->onPasswordInvalid(payload.user()); - user = m_userManager->getUser(payload.user()); + + User *user = m_userManager->getUser(payload.user()); if (!user) { return; } @@ -230,7 +226,7 @@ void NetworkPluginServer::handleBuddyChangedPayload(const std::string &data) { // TODO: ERROR return; } - + std::cout << payload.buddyname() << "\n"; User *user = m_userManager->getUser(payload.username()); if (!user) return; @@ -326,8 +322,8 @@ void NetworkPluginServer::handleConvMessagePayload(const std::string &data, bool } void NetworkPluginServer::handleDataRead(Client *c, const Swift::SafeByteArray &data) { - c->data.insert(c->data.begin(), data.begin(), data.end()); - + c->data.insert(c->data.end(), data.begin(), data.end()); + std::cout << "READ\n"; while (c->data.size() != 0) { unsigned int expected_size; @@ -343,11 +339,12 @@ void NetworkPluginServer::handleDataRead(Client *c, const Swift::SafeByteArray & pbnetwork::WrapperMessage wrapper; if (wrapper.ParseFromArray(&c->data[4], expected_size) == false) { + std::cout << "PARSING ERROR " << expected_size << "\n"; c->data.erase(c->data.begin(), c->data.begin() + 4 + expected_size); - return; + continue; } c->data.erase(c->data.begin(), c->data.begin() + 4 + expected_size); - + std::cout << "TYPE " << wrapper.type() << " " << (int) pbnetwork::WrapperMessage_Type_TYPE_CONNECTED << " " << c->data.size() << "\n"; switch(wrapper.type()) { case pbnetwork::WrapperMessage_Type_TYPE_CONNECTED: handleConnectedPayload(wrapper.payload()); @@ -403,6 +400,10 @@ void NetworkPluginServer::pingTimeout() { void NetworkPluginServer::handleUserCreated(User *user) { Client *c = getFreeClient(); + if (!c) { + user->handleDisconnected("Internal Server Error, please reconnect."); + return; + } user->setData(c); c->users.push_back(user); diff --git a/tests/runtests.py b/tests/runtests.py index 5386ff9e81e311401b60d8638a28e261d7e80640..653a9d1e7c36c44754e06f8b66f8602fe583fb7f 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -23,43 +23,46 @@ def run_spectrum(backend, test): ) f.close() p = Popen("../spectrum/src/spectrum sample.cfg > " + backend + "_" + test + ".log 2>&1", shell=True) - time.sleep(2) + time.sleep(3) return p +def one_test_run(): + os.system("killall spectrum 2> /dev/null") + os.system("rm *.log") -os.system("killall spectrum 2> /dev/null") -os.system("rm *.log") - -for backend in os.listdir("../backends"): - if not os.path.isdir("../backends/" + backend) or backend == "CMakeFiles": - continue - - for d in os.listdir("."): - binary = d + "/" + d + "_test" - if not os.path.exists(binary): + for backend in os.listdir("../backends"): + if not os.path.isdir("../backends/" + backend) or backend == "CMakeFiles" or backend.startswith("libirc"): continue - p = run_spectrum(backend, d) + for d in os.listdir("."): + binary = d + "/" + d + "_test" + if not os.path.exists(binary) or d.find("bad") != -1: + continue - if backend.find("purple") >= 0: - p = Popen(binary + " pyjim%jabber.cz@localhost test", shell=True) - - else: - p = Popen(binary + " testnickname%irc.freenode.net@localhost test", shell=True) + p = run_spectrum(backend, d) - seconds = 0 - while p.poll() is None and seconds < 20: - time.sleep(1) - seconds += 1 + if backend.find("purple") >= 0: + p = Popen(binary + " pyjim%jabber.cz@localhost test", shell=True) + + else: + p = Popen(binary + " testnickname%irc.freenode.net@localhost test", shell=True) - if p.returncode == 0: - print "[ PASS ]", backend, binary - else: - if seconds == 20: - print "[ TIME ]", backend, binary + seconds = 0 + while p.poll() is None and seconds < 20: + time.sleep(1) + seconds += 1 + + if p.returncode == 0 and seconds < 20: + print "[ PASS ]", backend, binary else: - print "[ FAIL ]", backend, binary + if seconds == 20: + print "[ TIME ]", backend, binary + else: + print "[ FAIL ]", backend, binary + + os.system("killall spectrum 2> /dev/null") - os.system("killall spectrum 2> /dev/null") +while True: + one_test_run()