summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/IceUtil/stacktrace/Client.cpp222
-rw-r--r--cpp/test/IceUtil/stacktrace/StackTrace.debug-release.OSX14
-rw-r--r--cpp/test/IceUtil/stacktrace/StackTrace.debug.Linux18
-rw-r--r--cpp/test/IceUtil/stacktrace/StackTrace.debug.OSX14
-rw-r--r--cpp/test/IceUtil/stacktrace/StackTrace.release.Linux2
-rw-r--r--cpp/test/IceUtil/stacktrace/StackTrace.release.OSX4
6 files changed, 132 insertions, 142 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;
}
diff --git a/cpp/test/IceUtil/stacktrace/StackTrace.debug-release.OSX b/cpp/test/IceUtil/stacktrace/StackTrace.debug-release.OSX
index 334072652ae..8f02f6229d8 100644
--- a/cpp/test/IceUtil/stacktrace/StackTrace.debug-release.OSX
+++ b/cpp/test/IceUtil/stacktrace/StackTrace.debug-release.OSX
@@ -1,8 +1,8 @@
0 IceUtil::NullHandleException::NullHandleException(char const*, int) in libIceUtil.3.7a0.dylib
- 1 (anonymous namespace)::Thrower::fifth() in client
- 2 (anonymous namespace)::Thrower::forth() in client
- 3 (anonymous namespace)::Thrower::third() in client
- 4 (anonymous namespace)::Thrower::second() in client
- 5 (anonymous namespace)::Thrower::first() in client
- 6 main() in client
- 7 start() in libdyld.dylib \ No newline at end of file
+ 1 (anonymous namespace)::Thrower::fifth in client
+ 2 (anonymous namespace)::Thrower::forth in client
+ 3 (anonymous namespace)::Thrower::third in client
+ 4 (anonymous namespace)::Thrower::second in client
+ 5 (anonymous namespace)::Thrower::first in client
+ 6 main in client
+ 7 start in libdyld.dylib \ No newline at end of file
diff --git a/cpp/test/IceUtil/stacktrace/StackTrace.debug.Linux b/cpp/test/IceUtil/stacktrace/StackTrace.debug.Linux
index 5f6c0f19732..50a457a9437 100644
--- a/cpp/test/IceUtil/stacktrace/StackTrace.debug.Linux
+++ b/cpp/test/IceUtil/stacktrace/StackTrace.debug.Linux
@@ -1,9 +1,9 @@
- 0 IceUtil::Exception::Exception(char const*, int)
- 1 IceUtil::NullHandleException::NullHandleException(char const*, int)
-client
-client
-client
-client
-client
-client
- 8 __libc_start_main()
+ 0 IceUtil::Exception::Exception(char const*, int) at
+ 1 IceUtil::NullHandleException::NullHandleException(char const*, int) at
+ 2 fifth at
+ 3 forth at
+ 4 third at
+ 5 second at
+ 6 first at
+ 7 main at
+ 8
diff --git a/cpp/test/IceUtil/stacktrace/StackTrace.debug.OSX b/cpp/test/IceUtil/stacktrace/StackTrace.debug.OSX
index 5eeb56428ab..777bc5d8bf9 100644
--- a/cpp/test/IceUtil/stacktrace/StackTrace.debug.OSX
+++ b/cpp/test/IceUtil/stacktrace/StackTrace.debug.OSX
@@ -1,10 +1,10 @@
0 IceUtil::Exception::Exception(char const*, int) in libIceUtil.3.7a0.dylib
1 IceUtil::NullHandleException::NullHandleException(char const*, int) in libIceUtil.3.7a0.dylib
2 IceUtil::NullHandleException::NullHandleException(char const*, int) in libIceUtil.3.7a0.dylib
- 3 (anonymous namespace)::Thrower::fifth() in client
- 4 (anonymous namespace)::Thrower::forth() in client
- 5 (anonymous namespace)::Thrower::third() in client
- 6 (anonymous namespace)::Thrower::second() in client
- 7 (anonymous namespace)::Thrower::first() in client
- 8 main() in client
- 9 start() in libdyld.dylib \ No newline at end of file
+ 3 (anonymous namespace)::Thrower::fifth in client
+ 4 (anonymous namespace)::Thrower::forth in client
+ 5 (anonymous namespace)::Thrower::third in client
+ 6 (anonymous namespace)::Thrower::second in client
+ 7 (anonymous namespace)::Thrower::first in client
+ 8 main in client
+ 9 start in libdyld.dylib \ No newline at end of file
diff --git a/cpp/test/IceUtil/stacktrace/StackTrace.release.Linux b/cpp/test/IceUtil/stacktrace/StackTrace.release.Linux
index 3da3cc083ce..bb009c56c85 100644
--- a/cpp/test/IceUtil/stacktrace/StackTrace.release.Linux
+++ b/cpp/test/IceUtil/stacktrace/StackTrace.release.Linux
@@ -1,4 +1,4 @@
0 IceUtil::Exception::Exception(char const*, int)
1 IceUtil::NullHandleException::NullHandleException(char const*, int)
client
- 3 __libc_start_main()
+ 3 __libc_start_main
diff --git a/cpp/test/IceUtil/stacktrace/StackTrace.release.OSX b/cpp/test/IceUtil/stacktrace/StackTrace.release.OSX
index 4782f2d15e9..3bb0ce97ea5 100644
--- a/cpp/test/IceUtil/stacktrace/StackTrace.release.OSX
+++ b/cpp/test/IceUtil/stacktrace/StackTrace.release.OSX
@@ -1,3 +1,3 @@
0 IceUtil::NullHandleException::NullHandleException(char const*, int) in libIceUtil.3.7a0.dylib
- 1 main() in client
- 2 start() in libdyld.dylib \ No newline at end of file
+ 1 main in client
+ 2 start in libdyld.dylib \ No newline at end of file