summaryrefslogtreecommitdiff
path: root/cpp/test/IceUtil/stacktrace/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/IceUtil/stacktrace/Client.cpp')
-rw-r--r--cpp/test/IceUtil/stacktrace/Client.cpp222
1 files changed, 106 insertions, 116 deletions
diff --git a/cpp/test/IceUtil/stacktrace/Client.cpp b/cpp/test/IceUtil/stacktrace/Client.cpp
index ff71e1866cc..9e47d7cbf73 100644
--- a/cpp/test/IceUtil/stacktrace/Client.cpp
+++ b/cpp/test/IceUtil/stacktrace/Client.cpp
@@ -15,14 +15,6 @@
using namespace IceUtil;
using namespace std;
-#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) && \
- !defined(ICE_STATIC_LIBS)
-# define HAS_STACK_TRACES
-#endif
-
-#if defined(_WIN32) && !defined(ICE_OS_WINRT) && !defined(__MINGW32__)
-# define HAS_STACK_TRACES
-#endif
namespace IceUtilInternal
{
@@ -41,32 +33,32 @@ public:
void first()
{
- _idx++;
- second();
+ _idx++;
+ second();
}
void second()
{
- _idx++;
- third();
+ _idx++;
+ third();
}
void third()
{
- _idx++;
- forth();
+ _idx++;
+ forth();
}
void forth()
{
- _idx++;
- fifth();
+ _idx++;
+ fifth();
}
void fifth()
{
- _idx++;
- throw IceUtil::NullHandleException(__FILE__, __LINE__);
+ _idx++;
+ throw IceUtil::NullHandleException(__FILE__, __LINE__);
}
private:
@@ -84,27 +76,27 @@ getIceHome()
string iceHome = (ret > 0 && ret < buf.size()) ? IceUtil::wstringToString(&buf[0]) : string("");
if(!iceHome.empty())
{
- return iceHome;
+ return iceHome;
}
else
{
- HKEY hKey;
-
- string key = string("SOFTWARE\\ZeroC\\Ice ") + ICE_STRING_VERSION;
- const wstring keyName = IceUtil::stringToWstring(key);
-
- if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName.c_str(), 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
- {
- return "";
- }
-
- WCHAR buf[512];
- DWORD bufSize = sizeof(buf);
- if(RegQueryValueExW(hKey, L"InstallDir", 0, NULL, (LPBYTE)buf, &bufSize) != ERROR_SUCCESS)
- {
- return "";
- }
- return IceUtil::wstringToString(wstring(buf));
+ HKEY hKey;
+
+ string key = string("SOFTWARE\\ZeroC\\Ice ") + ICE_STRING_VERSION;
+ const wstring keyName = IceUtil::stringToWstring(key);
+
+ if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName.c_str(), 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
+ {
+ return "";
+ }
+
+ WCHAR buf[512];
+ DWORD bufSize = sizeof(buf);
+ if(RegQueryValueExW(hKey, L"InstallDir", 0, NULL, (LPBYTE)buf, &bufSize) != ERROR_SUCCESS)
+ {
+ return "";
+ }
+ return IceUtil::wstringToString(wstring(buf));
}
}
#endif
@@ -122,8 +114,8 @@ standardizeVersion(string& str)
size_t pos = 0;
while((pos = str.find(v1, pos)) != string::npos)
{
- str.replace(pos, v1.length(), v2);
- pos += v2.length();
+ str.replace(pos, v1.length(), v2);
+ pos += v2.length();
}
}
#else
@@ -135,7 +127,7 @@ splitLines(const string& str)
string line;
while(std::getline(is, line))
{
- result.push_back(line);
+ result.push_back(line);
};
return result;
}
@@ -144,8 +136,6 @@ splitLines(const string& str)
int main(int argc, char* argv[])
{
-#ifdef HAS_STACK_TRACES
-
bool optimized = false;
#ifdef NDEBUG
optimized = true;
@@ -160,22 +150,22 @@ int main(int argc, char* argv[])
if(binDist)
{
- //
- // For Windows we only run the test against bindist if PDBs were installed
- //
- string pdb = getIceHome() + "\\bin\\icebox.pdb";
- if(!ifstream(pdb))
- {
- cout << "Test requires PDBs to be installed" << endl;
- return EXIT_SUCCESS;
- }
+ //
+ // For Windows we only run the test against bindist if PDBs were installed
+ //
+ string pdb = getIceHome() + "\\bin\\icebox.pdb";
+ if(!ifstream(pdb))
+ {
+ cout << "Test requires PDBs to be installed" << endl;
+ return EXIT_SUCCESS;
+ }
}
else if(optimized)
{
- //
- // Only support debug srcdist Windows builds
- //
- return EXIT_SUCCESS;
+ //
+ // Only support debug srcdist Windows builds
+ //
+ return EXIT_SUCCESS;
}
#endif
@@ -195,25 +185,25 @@ int main(int argc, char* argv[])
if(binDist && !optimized)
{
- filename += "debug-release";
+ filename += "debug-release";
}
else if(optimized)
#else
if(optimized)
#endif
{
- filename += "release";
+ filename += "release";
#if defined(_MSC_VER)
# if(_MSC_VER == 1800)
- filename += "-vc120";
+ filename += "-vc120";
# elif(_MSC_VER == 1900)
- filename += "-vc140";
+ filename += "-vc140";
# endif
#endif
}
else
{
- filename += "debug";
+ filename += "debug";
}
#if defined(_WIN32)
@@ -227,79 +217,79 @@ int main(int argc, char* argv[])
while(true)
{
#if defined(_WIN32) && defined(NDEBUG)
- bool match = true;
+ bool match = true;
#endif
- ifstream ifs(filename.c_str());
- stringstream sstr;
- sstr << ifs.rdbuf();
+ ifstream ifs(filename.c_str());
+ stringstream sstr;
+ sstr << ifs.rdbuf();
#if defined(__APPLE__)
- string expected = sstr.str();
- standardizeVersion(expected);
+ string expected = sstr.str();
+ standardizeVersion(expected);
#else
- vector<string> expected = splitLines(sstr.str());
+ vector<string> expected = splitLines(sstr.str());
#endif
- ThrowerPtr thrower = new Thrower();
- try
- {
- thrower->first();
- }
- catch(const IceUtil::Exception& ex)
- {
- string stack = ex.ice_stackTrace();
+ ThrowerPtr thrower = new Thrower();
+ try
+ {
+ thrower->first();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ string stack = ex.ice_stackTrace();
+ // cerr << "\n full stack trace is \n" << stack << endl;
+
#ifdef __APPLE__
- standardizeVersion(stack);
- if(expected.size() < stack.size())
- {
- test(stack.compare(0, expected.size(), expected) == 0);
- }
- else
- {
- test(stack == expected);
- }
- break;
+ standardizeVersion(stack);
+ if(expected.size() < stack.size())
+ {
+ test(stack.compare(0, expected.size(), expected) == 0);
+ }
+ else
+ {
+ test(stack == expected);
+ }
+ break;
#else
- vector<string> actual = splitLines(stack);
- test(expected.size() <= actual.size());
- for(size_t i = 0; i < expected.size(); ++i)
- {
- if(actual[i].find(expected[i]) == string::npos)
- {
+ vector<string> actual = splitLines(stack);
+ test(expected.size() <= actual.size());
+ for(size_t i = 0; i < expected.size(); ++i)
+ {
+ if(actual[i].find(expected[i]) == string::npos)
+ {
#if defined(_WIN32) && defined(NDEBUG)
- match = false;
- //
- // With windows optimized builds retry with the alternate
- // expect file.
- //
- if(filename != "StackTrace.release.Win32")
- {
- break;
- }
- else
- {
- test(false);
- }
+ match = false;
+ //
+ // With windows optimized builds retry with the alternate
+ // expect file.
+ //
+ if(filename != "StackTrace.release.Win32")
+ {
+ break;
+ }
+ else
+ {
+ test(false);
+ }
#else
- test(false);
+ cerr << "could not find `" << expected[i] << "` in " << actual[i] << endl;
+ test(false);
#endif
- }
- }
+ }
+ }
#if defined(_WIN32) && defined(NDEBUG)
- if(!match && filename != "StackTrace.release.Win32")
- {
- filename = "StackTrace.release.Win32";
- continue;
- }
+ if(!match && filename != "StackTrace.release.Win32")
+ {
+ filename = "StackTrace.release.Win32";
+ continue;
+ }
#endif
- break;
+ break;
#endif
- }
+ }
}
cout << "ok" << endl;
-#else
- cout << "Test not supported on this platform" << endl;
-#endif
return EXIT_SUCCESS;
}