From 101ab28f0c317e8c8489f0189f81b7b4e2381e9a Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Sat, 29 Dec 2018 10:27:16 -0500
Subject: [PATCH] SL-793: Fix lllogin_test.cpp for new LLCoros implementation.

Delete the test for SRV timeout: lllogin no longer issues an SRV query. That
test only confuses the test program without exercising any useful paths in
production code.

As with other tests dating from the previous LLCoros implementation, we need a
few llcoro::suspend() calls sprinkled in so that a fiber marked ready -- by
fulfilling the future for which it is waiting -- gets a chance to run.

Clear LLEventPumps between test functions.
---
 indra/llcommon/llcoros.cpp                    |  4 +-
 .../login/tests/lllogin_test.cpp              | 48 ++++---------------
 2 files changed, 11 insertions(+), 41 deletions(-)

diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp
index f5ffd96cec6..939c70b7eaf 100644
--- a/indra/llcommon/llcoros.cpp
+++ b/indra/llcommon/llcoros.cpp
@@ -241,9 +241,7 @@ void LLCoros::winlevel(const callable_t& callable)
 
 #endif
 
-// Top-level wrapper around caller's coroutine callable. This function accepts
-// the coroutine library's implicit coro::self& parameter and saves it, but
-// does not pass it down to the caller's callable.
+// Top-level wrapper around caller's coroutine callable.
 void LLCoros::toplevel(const std::string& name, const callable_t& callable)
 {
     CoroData* corodata = new CoroData(name);
diff --git a/indra/viewer_components/login/tests/lllogin_test.cpp b/indra/viewer_components/login/tests/lllogin_test.cpp
index 774823d7351..f8e48e38247 100644
--- a/indra/viewer_components/login/tests/lllogin_test.cpp
+++ b/indra/viewer_components/login/tests/lllogin_test.cpp
@@ -164,11 +164,15 @@ namespace tut
 {
     struct llviewerlogin_data
     {
-		llviewerlogin_data() :
+        llviewerlogin_data() :
             pumps(LLEventPumps::instance())
-		{}
-		LLEventPumps& pumps;
-	};
+        {}
+        ~llviewerlogin_data()
+        {
+            pumps.clear();
+        }
+        LLEventPumps& pumps;
+    };
 
     typedef test_group<llviewerlogin_data> llviewerlogin_group;
     typedef llviewerlogin_group::object llviewerlogin_object;
@@ -241,6 +245,7 @@ namespace tut
 		data["responses"]["login"] = "false";
 		dummyXMLRPC.setResponse(data);
 		dummyXMLRPC.sendReply();
+		llcoro::suspend();
 
 		ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline");
 	}
@@ -280,41 +285,8 @@ namespace tut
 		data["transfer_rate"] = 0;
 		dummyXMLRPC.setResponse(data);
 		dummyXMLRPC.sendReply();
-
-		ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline");
-	}
-
-	template<> template<>
-    void llviewerlogin_object::test<4>()
-    {
-        DEBUG;
-		// Test SRV request timeout.
-		set_test_name("LLLogin SRV timeout testing");
-
-		// Testing normal login procedure.
-
-		LLLogin login;
-		LoginListener listener("test_ear");
-		listener.listenTo(login.getEventPump());
-
-		LLSD credentials;
-		credentials["first"] = "these";
-		credentials["last"] = "don't";
-		credentials["passwd"] = "matter";
-		credentials["cfg_srv_timeout"] = 0.0f;
-
-		login.connect("login.bar.com", credentials);
 		llcoro::suspend();
 
-		// Get the mainloop eventpump, which needs a pinging in order to drive the 
-		// SRV timeout.
-		LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
-		LLSD frame_event;
-		mainloop.post(frame_event);
-
-		ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); 
-		ensure_equals("Attempt", listener.lastEvent()["data"]["attempt"].asInteger(), 1); 
-		ensure_equals("URI", listener.lastEvent()["data"]["request"]["uri"].asString(), "login.bar.com");
-
+		ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline");
 	}
 }
-- 
GitLab