@@ -19,6 +19,7 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
1919namespace bp = boost::process;
2020namespace as = boost::asio;
2121namespace fs = std::filesystem;
22+ namespace vi = std::views;
2223using namespace std ::literals;
2324using namespace pmon ;
2425
@@ -63,9 +64,9 @@ namespace MultiClientTests
6364 }
6465 }
6566 // Attach a child process HANDLE to the job.
66- void Attach (HANDLE process_handle ) const
67+ void Attach (HANDLE hChild ) const
6768 {
68- if (!::AssignProcessToJobObject (hJob_, process_handle )) {
69+ if (!::AssignProcessToJobObject (hJob_, hChild )) {
6970 ThrowLastError_ (" AssignProcessToJobObject" );
7071 }
7172 }
@@ -101,9 +102,9 @@ namespace MultiClientTests
101102 }
102103
103104 TestProcess (const TestProcess&) = delete ;
104- TestProcess & operator =(const TestProcess&) = delete ;
105- TestProcess (TestProcess&&) = delete ;
106- TestProcess & operator =(TestProcess&&) = delete ;
105+ TestProcess& operator =(const TestProcess&) = delete ;
106+ TestProcess (TestProcess&& other) noexcept = delete ;
107+ TestProcess& operator =(TestProcess&& other) noexcept = delete ;
107108
108109 void Quit ()
109110 {
@@ -260,6 +261,10 @@ namespace MultiClientTests
260261 {
261262 return PresenterProcess{ ioctx, jobMan, std::move (args) };
262263 }
264+ std::unique_ptr<ClientProcess> LaunchClientAsPtr (std::vector<std::string> args = {})
265+ {
266+ return std::make_unique<ClientProcess>(ioctx, jobMan, std::move (args));
267+ }
263268 };
264269
265270 TEST_CLASS (CommonFixtureTests)
@@ -675,8 +680,6 @@ namespace MultiClientTests
675680 }
676681 };
677682
678-
679-
680683 TEST_CLASS (TrackingTests)
681684 {
682685 CommonTestFixture fixture_;
@@ -758,5 +761,28 @@ namespace MultiClientTests
758761 Assert::AreEqual (0ull , status.nsmStreamedPids .size ());
759762 }
760763 }
764+ // test a large number of clients running
765+ TEST_METHOD (ClientStressTest)
766+ {
767+ // launch target for tracking
768+ auto presenter = fixture_.LaunchPresenter ();
769+ std::this_thread::sleep_for (250ms);
770+ // launch clients
771+ std::vector<std::unique_ptr<ClientProcess>> clientPtrs;
772+ for (int i = 0 ; i < 32 ; i++) {
773+ clientPtrs.push_back (fixture_.LaunchClientAsPtr ({
774+ " --process-id" s, std::to_string (presenter.GetId ()),
775+ " --run-time" s, " 2.25" s,
776+ " --etw-flush-period-ms" s, " 8" s,
777+ }));
778+ }
779+ // verify they all have read frames
780+ for (auto &&[i, pClient] : vi::enumerate (clientPtrs)) {
781+ const auto frames = std::move (pClient->GetFrames ().frames );
782+ Logger::WriteMessage (std::format (" Read [{}] frames from client #{}\n " ,
783+ frames.size (), i).c_str ());
784+ Assert::IsTrue (frames.size () >= 100ull , L" Minimum threshold frames received" );
785+ }
786+ }
761787 };
762788}
0 commit comments