Make tests pass on MinGW, add fifth tutorial example
authorCraig Dowell <craigdo@ee.washington.edu>
Thu, 05 Nov 2009 22:29:53 -0800
changeset 5483 ad83d869c08c
parent 5482 fbfdb256aaed
child 5485 1739c7bafd29
Make tests pass on MinGW, add fifth tutorial example
src/core/test.cc
test.py
--- a/src/core/test.cc	Thu Nov 05 19:15:28 2009 -0800
+++ b/src/core/test.cc	Thu Nov 05 22:29:53 2009 -0800
@@ -204,6 +204,10 @@
 void 
 TestCase::SetBaseDir (std::string basedir)
 {
+  //
+  // C and C++ allow one to use forward slashes even on systems where the 
+  // separator is actually a backslash.
+  //
   if (basedir[basedir.length () - 1] != '/')
     {
       m_basedir = basedir + "/";
@@ -223,6 +227,10 @@
 void 
 TestCase::SetTempDir (std::string tempdir)
 {
+  //
+  // C and C++ allow one to use forward slashes even on systems where the 
+  // separator is actually a backslash.
+  //
   if (tempdir[tempdir.length () - 1] != '/')
     {
       m_tempdir = tempdir + "/";
@@ -242,9 +250,25 @@
 std::string 
 TestCase::GetSourceDir (std::string file)
 {
+  //
+  // The <file> parameter is actually going to be __FILE__ which may have 
+  // backslashes in it on win32 systems.  For example,
+  //
+  //   ..\src\common\pcap-file-test-suite.cc  (win32)
+  //
+  // or
+  //
+  //   ../src/common/pcap-file-test-suite.cc  (grown-up systems)
+  //
+#ifdef WIN32
+  std::string::size_type relPathBegin = file.find_first_of ("\\");
+  std::string::size_type relPathEnd = file.find_last_of ("\\");
+#else
   std::string::size_type relPathBegin = file.find_first_of ("/");
+  std::string::size_type relPathEnd = file.find_last_of ("/");
+#endif
+
   NS_ABORT_MSG_IF (relPathBegin == std::string::npos, "TestCase::GetSourceDir(): Internal Error");
-  std::string::size_type relPathEnd = file.find_last_of ("/");
   NS_ABORT_MSG_IF (relPathEnd == std::string::npos, "TestCase::GetSourceDir(): Internal Error");
 
   return GetBaseDir () + file.substr (relPathBegin, relPathEnd + 1 - relPathBegin);
@@ -504,6 +528,10 @@
 void 
 TestSuite::SetBaseDir (std::string basedir)
 {
+  //
+  // C and C++ allow one to use forward slashes even on systems where the 
+  // separator is actually a backslash.
+  //
   if (basedir[basedir.length () - 1] != '/')
     {
       m_basedir = basedir + "/";
@@ -523,6 +551,10 @@
 void 
 TestSuite::SetTempDir (std::string tempdir)
 {
+  //
+  // C and C++ allow one to use forward slashes even on systems where the 
+  // separator is actually a backslash.
+  //
   if (tempdir[tempdir.length () - 1] != '/')
     {
       m_tempdir = tempdir + "/";
--- a/test.py	Thu Nov 05 19:15:28 2009 -0800
+++ b/test.py	Thu Nov 05 22:29:53 2009 -0800
@@ -132,6 +132,7 @@
     ("tutorial/second", "True", "True"),
     ("tutorial/third", "True", "True"),
     ("tutorial/fourth", "True", "True"),
+    ("tutorial/fifth", "True", "True"),
 
     ("udp/udp-echo", "True", "True"),