Skip to content

Commit a13ae88

Browse files
nat-goodspeedbrad-linden
authored andcommitted
Add diagnostic output for LLProcess event history failure.
1 parent fd0389c commit a13ae88

File tree

1 file changed

+93
-55
lines changed

1 file changed

+93
-55
lines changed

indra/llcommon/tests/llprocess_test.cpp

Lines changed: 93 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,27 @@ namespace tut
10851085
return false;
10861086
}
10871087

1088-
std::list<LLSD> mHistory;
1088+
template <typename CALLABLE>
1089+
void checkHistory(CALLABLE&& code)
1090+
{
1091+
try
1092+
{
1093+
// we expect this lambda to contain tut::ensure() calls
1094+
std::forward<CALLABLE>(code)(mHistory);
1095+
}
1096+
catch (const failure&)
1097+
{
1098+
LL_INFOS() << "event history:" << LL_ENDL;
1099+
for (const LLSD& item : mHistory)
1100+
{
1101+
LL_INFOS() << item << LL_ENDL;
1102+
}
1103+
throw;
1104+
}
1105+
}
1106+
1107+
using Listory = std::list<LLSD>;
1108+
Listory mHistory;
10891109
LLTempBoundListener mConnection;
10901110
};
10911111

@@ -1136,23 +1156,26 @@ namespace tut
11361156
// finish out the run
11371157
waitfor(*py.mPy);
11381158
// now verify history
1139-
std::list<LLSD>::const_iterator li(listener.mHistory.begin()),
1140-
lend(listener.mHistory.end());
1141-
ensure("no events", li != lend);
1142-
ensure_equals("history[0]", (*li)["data"].asString(), "abc");
1143-
ensure_equals("history[0] len", (*li)["len"].asInteger(), 3);
1144-
++li;
1145-
ensure("only 1 event", li != lend);
1146-
ensure_equals("history[1]", (*li)["data"].asString(), "abcdef");
1147-
ensure_equals("history[0] len", (*li)["len"].asInteger(), 6);
1148-
++li;
1149-
ensure("only 2 events", li != lend);
1150-
ensure_equals("history[2]", (*li)["data"].asString(), "abcdefghi" EOL);
1151-
ensure_equals("history[0] len", (*li)["len"].asInteger(), 9 + sizeof(EOL) - 1);
1152-
++li;
1153-
// We DO NOT expect a whole new event for the second line because we
1154-
// disconnected.
1155-
ensure("more than 3 events", li == lend);
1159+
listener.checkHistory(
1160+
[](const EventListener::Listory& history)
1161+
{
1162+
auto li(history.begin()), lend(history.end());
1163+
ensure("no events", li != lend);
1164+
ensure_equals("history[0]", (*li)["data"].asString(), "abc");
1165+
ensure_equals("history[0] len", (*li)["len"].asInteger(), 3);
1166+
++li;
1167+
ensure("only 1 event", li != lend);
1168+
ensure_equals("history[1]", (*li)["data"].asString(), "abcdef");
1169+
ensure_equals("history[0] len", (*li)["len"].asInteger(), 6);
1170+
++li;
1171+
ensure("only 2 events", li != lend);
1172+
ensure_equals("history[2]", (*li)["data"].asString(), "abcdefghi" EOL);
1173+
ensure_equals("history[0] len", (*li)["len"].asInteger(), 9 + sizeof(EOL) - 1);
1174+
++li;
1175+
// We DO NOT expect a whole new event for the second line because we
1176+
// disconnected.
1177+
ensure("more than 3 events", li == lend);
1178+
});
11561179
}
11571180

11581181
template<> template<>
@@ -1172,14 +1195,17 @@ namespace tut
11721195
// (or any other intervening layer) does crazy buffering. What we want
11731196
// to ensure is that there was exactly ONE event with "eof" true, and
11741197
// that it was the LAST event.
1175-
std::list<LLSD>::const_reverse_iterator rli(listener.mHistory.rbegin()),
1176-
rlend(listener.mHistory.rend());
1177-
ensure("no events", rli != rlend);
1178-
ensure("last event not \"eof\"", (*rli)["eof"].asBoolean());
1179-
while (++rli != rlend)
1180-
{
1181-
ensure("\"eof\" event not last", ! (*rli)["eof"].asBoolean());
1182-
}
1198+
listener.checkHistory(
1199+
[](const EventListener::Listory& history)
1200+
{
1201+
auto rli(history.rbegin()), rlend(history.rend());
1202+
ensure("no events", rli != rlend);
1203+
ensure("last event not \"eof\"", (*rli)["eof"].asBoolean());
1204+
while (++rli != rlend)
1205+
{
1206+
ensure("\"eof\" event not last", ! (*rli)["eof"].asBoolean());
1207+
}
1208+
});
11831209
}
11841210

11851211
template<> template<>
@@ -1202,13 +1228,17 @@ namespace tut
12021228
ensure_equals("getLimit() after setlimit(10)", childout.getLimit(), 10);
12031229
// okay, pump I/O to pick up output from child
12041230
waitfor(*py.mPy);
1205-
ensure("no events", ! listener.mHistory.empty());
1206-
// For all we know, that data could have arrived in several different
1207-
// bursts... probably not, but anyway, only check the last one.
1208-
ensure_equals("event[\"len\"]",
1209-
listener.mHistory.back()["len"].asInteger(), abc.length());
1210-
ensure_equals("length of setLimit(10) data",
1211-
listener.mHistory.back()["data"].asString().length(), 10);
1231+
listener.checkHistory(
1232+
[abc](const EventListener::Listory& history)
1233+
{
1234+
ensure("no events", ! history.empty());
1235+
// For all we know, that data could have arrived in several different
1236+
// bursts... probably not, but anyway, only check the last one.
1237+
ensure_equals("event[\"len\"]",
1238+
history.back()["len"].asInteger(), abc.length());
1239+
ensure_equals("length of setLimit(10) data",
1240+
history.back()["data"].asString().length(), 10);
1241+
});
12121242
}
12131243

12141244
template<> template<>
@@ -1275,18 +1305,22 @@ namespace tut
12751305
params.postend = pumpname;
12761306
LLProcessPtr child = LLProcess::create(params);
12771307
ensure("shouldn't have launched", ! child);
1278-
ensure_equals("number of postend events", listener.mHistory.size(), 1);
1279-
LLSD postend(listener.mHistory.front());
1280-
ensure("has id", ! postend.has("id"));
1281-
ensure_equals("desc", postend["desc"].asString(), std::string(params.desc));
1282-
ensure_equals("state", postend["state"].asInteger(), LLProcess::UNSTARTED);
1283-
ensure("has data", ! postend.has("data"));
1284-
std::string error(postend["string"]);
1285-
// All we get from canned parameter validation is a bool, so the
1286-
// "validation failed" message we ourselves generate can't mention
1287-
// "executable" by name. Just check that it's nonempty.
1288-
//ensure_contains("error", error, "executable");
1289-
ensure("string", ! error.empty());
1308+
listener.checkHistory(
1309+
[&params](const EventListener::Listory& history)
1310+
{
1311+
ensure_equals("number of postend events", history.size(), 1);
1312+
LLSD postend(history.front());
1313+
ensure("has id", ! postend.has("id"));
1314+
ensure_equals("desc", postend["desc"].asString(), std::string(params.desc));
1315+
ensure_equals("state", postend["state"].asInteger(), LLProcess::UNSTARTED);
1316+
ensure("has data", ! postend.has("data"));
1317+
std::string error(postend["string"]);
1318+
// All we get from canned parameter validation is a bool, so the
1319+
// "validation failed" message we ourselves generate can't mention
1320+
// "executable" by name. Just check that it's nonempty.
1321+
//ensure_contains("error", error, "executable");
1322+
ensure("string", ! error.empty());
1323+
});
12901324
}
12911325

12921326
template<> template<>
@@ -1308,16 +1342,20 @@ namespace tut
13081342
{
13091343
yield();
13101344
}
1311-
ensure("no postend event", i < timeout);
1312-
ensure_equals("number of postend events", listener.mHistory.size(), 1);
1313-
LLSD postend(listener.mHistory.front());
1314-
ensure_equals("id", postend["id"].asInteger(), childid);
1315-
ensure("desc empty", ! postend["desc"].asString().empty());
1316-
ensure_equals("state", postend["state"].asInteger(), LLProcess::EXITED);
1317-
ensure_equals("data", postend["data"].asInteger(), 35);
1318-
std::string str(postend["string"]);
1319-
ensure_contains("string", str, "exited");
1320-
ensure_contains("string", str, "35");
1345+
listener.checkHistory(
1346+
[i, timeout, childid](const EventListener::Listory& history)
1347+
{
1348+
ensure("no postend event", i < timeout);
1349+
ensure_equals("number of postend events", history.size(), 1);
1350+
LLSD postend(history.front());
1351+
ensure_equals("id", postend["id"].asInteger(), childid);
1352+
ensure("desc empty", ! postend["desc"].asString().empty());
1353+
ensure_equals("state", postend["state"].asInteger(), LLProcess::EXITED);
1354+
ensure_equals("data", postend["data"].asInteger(), 35);
1355+
std::string str(postend["string"]);
1356+
ensure_contains("string", str, "exited");
1357+
ensure_contains("string", str, "35");
1358+
});
13211359
}
13221360

13231361
struct PostendListener

0 commit comments

Comments
 (0)