summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/test/Ice/retry/Client.cpp2
-rw-r--r--cpp/test/Ice/retry/InstrumentationI.cpp47
-rw-r--r--cpp/test/Ice/retry/InstrumentationI.h1
-rw-r--r--cpp/test/TestSuite/MainPage.xaml.cpp76
-rw-r--r--cpp/test/TestSuite/MainPage.xaml.h26
5 files changed, 100 insertions, 52 deletions
diff --git a/cpp/test/Ice/retry/Client.cpp b/cpp/test/Ice/retry/Client.cpp
index beb68825a4a..e858a70e877 100644
--- a/cpp/test/Ice/retry/Client.cpp
+++ b/cpp/test/Ice/retry/Client.cpp
@@ -39,6 +39,8 @@ main(int argc, char* argv[])
try
{
+ initCounts();
+
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
initData.observer = getObserver();
diff --git a/cpp/test/Ice/retry/InstrumentationI.cpp b/cpp/test/Ice/retry/InstrumentationI.cpp
index 1a156e93fea..f5e4e9c8591 100644
--- a/cpp/test/Ice/retry/InstrumentationI.cpp
+++ b/cpp/test/Ice/retry/InstrumentationI.cpp
@@ -13,7 +13,7 @@
namespace
{
-int nRetry = 0;
+int nRetry = 0;
int nFailure = 0;
int nInvocation = 0;
IceUtil::Mutex* staticMutex = 0;
@@ -39,44 +39,44 @@ class InvocationObserverI : public Ice::Instrumentation::InvocationObserver
{
public:
- virtual void
+ virtual void
attach()
{
}
- virtual void
+ virtual void
detach()
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(staticMutex);
++nInvocation;
}
- virtual void
+ virtual void
failed(const ::std::string&)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(staticMutex);
++nFailure;
}
- virtual void
+ virtual void
retried()
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(staticMutex);
++nRetry;
}
- virtual void
+ virtual void
userException()
{
}
- virtual ::Ice::Instrumentation::RemoteObserverPtr
+ virtual ::Ice::Instrumentation::RemoteObserverPtr
getRemoteObserver(const ::Ice::ConnectionInfoPtr&, const ::Ice::EndpointPtr&, ::Ice::Int, ::Ice::Int)
{
return 0;
}
- virtual ::Ice::Instrumentation::CollocatedObserverPtr
+ virtual ::Ice::Instrumentation::CollocatedObserverPtr
getCollocatedObserver(const Ice::ObjectAdapterPtr&, ::Ice::Int, ::Ice::Int)
{
return 0;
@@ -90,49 +90,49 @@ class CommunicatorObserverI : public Ice::Instrumentation::CommunicatorObserver
{
public:
- virtual Ice::Instrumentation::ObserverPtr
+ virtual Ice::Instrumentation::ObserverPtr
getConnectionEstablishmentObserver(const Ice::EndpointPtr&, const ::std::string&)
{
return 0;
}
- virtual Ice::Instrumentation::ObserverPtr
+ virtual Ice::Instrumentation::ObserverPtr
getEndpointLookupObserver(const Ice::EndpointPtr&)
{
return 0;
}
- virtual Ice::Instrumentation::ConnectionObserverPtr
- getConnectionObserver(const Ice::ConnectionInfoPtr&,
- const Ice::EndpointPtr&,
+ virtual Ice::Instrumentation::ConnectionObserverPtr
+ getConnectionObserver(const Ice::ConnectionInfoPtr&,
+ const Ice::EndpointPtr&,
Ice::Instrumentation::ConnectionState,
const Ice::Instrumentation::ConnectionObserverPtr&)
{
return 0;
}
- virtual Ice::Instrumentation::ThreadObserverPtr
- getThreadObserver(const ::std::string&,
- const ::std::string&,
- Ice::Instrumentation::ThreadState,
+ virtual Ice::Instrumentation::ThreadObserverPtr
+ getThreadObserver(const ::std::string&,
+ const ::std::string&,
+ Ice::Instrumentation::ThreadState,
const Ice::Instrumentation::ThreadObserverPtr&)
{
return 0;
}
- virtual Ice::Instrumentation::InvocationObserverPtr
+ virtual Ice::Instrumentation::InvocationObserverPtr
getInvocationObserver(const Ice::ObjectPrx&, const ::std::string&, const Ice::Context&)
{
return invocationObserver;
}
- virtual Ice::Instrumentation::DispatchObserverPtr
+ virtual Ice::Instrumentation::DispatchObserverPtr
getDispatchObserver(const Ice::Current&, Ice::Int)
{
return 0;
}
- virtual void
+ virtual void
setObserverUpdater(const Ice::Instrumentation::ObserverUpdaterPtr&)
{
}
@@ -171,6 +171,13 @@ testEqual(int& value, int expected)
}
+void initCounts()
+{
+ nRetry = 0;
+ nFailure = 0;
+ nInvocation = 0;
+}
+
Ice::Instrumentation::CommunicatorObserverPtr
getObserver()
{
diff --git a/cpp/test/Ice/retry/InstrumentationI.h b/cpp/test/Ice/retry/InstrumentationI.h
index 23d644fba62..f9607d4ec88 100644
--- a/cpp/test/Ice/retry/InstrumentationI.h
+++ b/cpp/test/Ice/retry/InstrumentationI.h
@@ -14,6 +14,7 @@ void testRetryCount(int);
void testFailureCount(int);
void testInvocationCount(int);
+void initCounts();
Ice::Instrumentation::CommunicatorObserverPtr getObserver();
#endif
diff --git a/cpp/test/TestSuite/MainPage.xaml.cpp b/cpp/test/TestSuite/MainPage.xaml.cpp
index 013c611c42f..aa64f17b31d 100644
--- a/cpp/test/TestSuite/MainPage.xaml.cpp
+++ b/cpp/test/TestSuite/MainPage.xaml.cpp
@@ -225,7 +225,9 @@ class Runnable : public IceUtil::Thread, public Test::MainHelper
{
public:
- Runnable(const TestRunnerPtr&, const string&, const TestConfig&, const vector<string>& options = vector<string>());
+ Runnable(const TestRunnerPtr&, const string&, DllCache&, const TestConfig&,
+ const vector<string>& options = vector<string>());
+
virtual ~Runnable();
virtual void run();
void waitForStart();
@@ -249,7 +251,7 @@ private:
int _status;
Ice::CommunicatorPtr _communicator;
FARPROC _dllTestShutdown;
- HINSTANCE _hnd;
+ DllCache& _dlls;
vector<string> _options;
};
typedef IceUtil::Handle<Runnable> RunnablePtr;
@@ -259,7 +261,7 @@ class TestRunner : public IceUtil::Thread
public:
TestRunner(const std::shared_ptr<TestCase>&, const TestConfig&, MainPage^,
- const Ice::CommunicatorPtr&);
+ const Ice::CommunicatorPtr&, DllCache&);
virtual void run();
void runClientServerTest(const string&, const string&);
void runClientServerTestWithRemoteServer(const string&);
@@ -274,41 +276,40 @@ private:
TestConfig _config;
MainPage^ _page;
Ice::CommunicatorPtr _communicator;
+ DllCache& _dlls;
};
-Runnable::Runnable(const TestRunnerPtr& runner, const string& test, const TestConfig& config, const vector<string>& options) :
+Runnable::Runnable(const TestRunnerPtr& runner, const string& test, DllCache& dlls, const TestConfig& config,
+ const vector<string>& options) :
_runner(runner),
_test(test),
_config(config),
_started(false),
_completed(false),
_status(0),
+ _dlls(dlls),
_options(options)
{
}
Runnable::~Runnable()
{
- if(_hnd != 0)
- {
- FreeLibrary(_hnd);
- }
}
void
Runnable::run()
{
- _hnd = LoadPackagedLibrary(IceUtil::stringToWstring(_test).c_str(), 0);
- if(_hnd == 0)
+ HINSTANCE hnd = _dlls.loadDll(_test);
+ if(hnd == 0)
{
ostringstream os;
- os << "failed to load `" << _test + "': error code: " << GetLastError();
+ os << "failed to load `" << _test << "': error code: " << GetLastError();
_runner->printLineToConsoleOutput(os.str());
completed(-1);
return;
}
- _dllTestShutdown = GetProcAddress(_hnd, "dllTestShutdown");
+ _dllTestShutdown = GetProcAddress(hnd, "dllTestShutdown");
if(_dllTestShutdown == 0)
{
_runner->printLineToConsoleOutput("failed to find dllTestShutdown function from `" + _test + "'");
@@ -316,7 +317,7 @@ Runnable::run()
return;
}
- FARPROC dllMain = GetProcAddress(_hnd, "dllMain");
+ FARPROC dllMain = GetProcAddress(hnd, "dllMain");
if(dllMain == 0)
{
_runner->printLineToConsoleOutput("failed to find dllMain function from `" + _test + "'");
@@ -464,11 +465,12 @@ Runnable::completed(int status)
}
TestRunner::TestRunner(const TestCasePtr& test, const TestConfig& config, MainPage^ page,
- const Ice::CommunicatorPtr& communicator) :
+ const Ice::CommunicatorPtr& communicator, DllCache& dlls) :
_test(test),
_config(config),
_page(page),
- _communicator(communicator)
+ _communicator(communicator),
+ _dlls(dlls)
{
}
@@ -543,7 +545,7 @@ TestRunner::run()
if(!_test->serverAMD.empty() && _config.server == "winrt")
{
printLineToConsoleOutput("*** running test with AMD server " + _test->name);
- runClientServerTest(_test->server, _test->client);
+ runClientServerTest(_test->serverAMD, _test->client);
}
//
@@ -581,14 +583,14 @@ TestRunner::runClientServerTest(const string& server, const string& client)
RunnablePtr serverRunable;
TestConfig svrConfig = _config;
svrConfig.type = TestConfigTypeServer;
- serverRunable = new Runnable(this, _test->prefix + server, svrConfig);
+ serverRunable = new Runnable(this, _test->prefix + server, _dlls, svrConfig);
serverRunable->start();
serverRunable->getThreadControl().detach();
serverRunable->waitForStart();
TestConfig cltConfig = _config;
cltConfig.type = TestConfigTypeClient;
- RunnablePtr clientRunable = new Runnable(this, _test->prefix + client, cltConfig);
+ RunnablePtr clientRunable = new Runnable(this, _test->prefix + client, _dlls, cltConfig);
clientRunable->start();
clientRunable->getThreadControl().detach();
@@ -694,13 +696,13 @@ TestRunner::runClientServerTestWithRemoteServer(const string& client)
TestConfig cltConfig = _config;
cltConfig.type = TestConfigTypeClient;
- RunnablePtr clientRunable = new Runnable(this, _test->prefix + client, cltConfig, configuration->options);
- clientRunable->start();
- clientRunable->getThreadControl().detach();
+ RunnablePtr runnable = new Runnable(this, _test->prefix + client, _dlls, cltConfig, configuration->options);
+ runnable->start();
+ runnable->getThreadControl().detach();
try
{
- clientRunable->waitForCompleted();
+ runnable->waitForCompleted();
}
catch(...)
{
@@ -724,7 +726,7 @@ TestRunner::runClientTest(const string& client, bool collocated)
{
TestConfig cltConfig = _config;
cltConfig.type = collocated ? TestConfigTypeColloc : TestConfigTypeClient;
- RunnablePtr clientRunable = new Runnable(this, _test->prefix + client, cltConfig);
+ RunnablePtr clientRunable = new Runnable(this, _test->prefix + client, _dlls, cltConfig);
clientRunable->start();
clientRunable->getThreadControl().detach();
clientRunable->waitForCompleted();
@@ -754,6 +756,28 @@ TestCase::TestCase(const string& module, const string& name, const string& clien
{
}
+HINSTANCE
+DllCache::loadDll(const std::string& name)
+{
+ map<string, HINSTANCE>::const_iterator p = _dlls.find(name);
+ if(p != _dlls.end())
+ {
+ return p->second;
+ }
+
+ HINSTANCE hnd = LoadPackagedLibrary(IceUtil::stringToWstring(name).c_str(), 0);
+ _dlls.insert(make_pair(name, hnd));
+ return hnd;
+}
+
+DllCache::~DllCache()
+{
+ for(map<string, HINSTANCE>::const_iterator p = _dlls.begin(); p != _dlls.end(); ++p)
+ {
+ FreeLibrary(p->second);
+ }
+}
+
MainPage::MainPage() :
_names(ref new Vector<String^>()),
_protocols(ref new Vector<String^>()),
@@ -894,7 +918,7 @@ MainPage::runSelectedTest()
config.server = selectedLanguage();
config.host = IceUtil::wstringToString(_host->Text->Data());
- TestRunnerPtr t = new TestRunner(_allTests[_tests->SelectedIndex], config, this, communicator());
+ TestRunnerPtr t = new TestRunner(_allTests[_tests->SelectedIndex], config, this, communicator(), _dlls);
t->start();
t->getThreadControl().detach();
}
@@ -902,8 +926,8 @@ MainPage::runSelectedTest()
void
TestSuite::MainPage::initializeSupportedTests()
{
- _allTests = allTest(selectedLanguage() != "winrt");
- _names->Clear();
+ _allTests = allTest(selectedLanguage() != "winrt");
+ _names->Clear();
for(vector<TestCasePtr>::const_iterator i = _allTests.begin(); i != _allTests.end(); ++i)
{
TestCasePtr test = *i;
diff --git a/cpp/test/TestSuite/MainPage.xaml.h b/cpp/test/TestSuite/MainPage.xaml.h
index ccf32dfda38..c9106044271 100644
--- a/cpp/test/TestSuite/MainPage.xaml.h
+++ b/cpp/test/TestSuite/MainPage.xaml.h
@@ -21,7 +21,7 @@ namespace TestSuite
struct TestConfiguration
{
- TestConfiguration(const std::string& name = "",
+ TestConfiguration(const std::string& name = "",
const std::vector<std::string>& options = std::vector<std::string>(),
const std::vector<std::string>& languages = std::vector<std::string>());
@@ -75,21 +75,34 @@ findChild(Windows::UI::Xaml::DependencyObject^ parent, Platform::String^ name)
return nullptr;
}
+class DllCache
+{
+public:
+
+ ~DllCache();
+
+ HINSTANCE loadDll(const std::string&);
+
+private:
+
+ std::map<std::string, HINSTANCE> _dlls;
+};
+
[Windows::Foundation::Metadata::WebHostHidden]
public ref class MainPage sealed
{
public:
-
+
MainPage();
-
+
void completed();
void failed(Platform::String^ reason);
void printToConsoleOutput(Platform::String^ message, bool newline);
protected:
-
+
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
-
+
private:
void btnRun_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
@@ -108,12 +121,13 @@ private:
void initializeSupportedTests();
Ice::CommunicatorPtr communicator();
-
+
Platform::Collections::Vector<Platform::String^>^ _names;
Platform::Collections::Vector<Platform::String^>^ _protocols;
Platform::Collections::Vector<Platform::String^>^ _messages;
std::vector<TestCasePtr> _allTests;
+ DllCache _dlls;
Windows::UI::Xaml::Controls::ListBox^ _tests;
Windows::UI::Xaml::Controls::ComboBox^ _language;