summaryrefslogtreecommitdiffstats
path: root/testSystemTools.cxx
diff options
context:
space:
mode:
authorKWSys Robot <kwrobot@kitware.com>2014-07-02 14:57:17 (GMT)
committerBrad King <brad.king@kitware.com>2014-07-07 13:04:19 (GMT)
commit3d127627f8e28d97ecc44515e274b3780ae3f4b9 (patch)
tree4c1cd35ad2f054bf041265162e49db23cdc38b6a /testSystemTools.cxx
parented52685dd7ea5c54e7a5e6caa789293d76f10b15 (diff)
downloadCMake-3d127627f8e28d97ecc44515e274b3780ae3f4b9.zip
CMake-3d127627f8e28d97ecc44515e274b3780ae3f4b9.tar.gz
CMake-3d127627f8e28d97ecc44515e274b3780ae3f4b9.tar.bz2
KWSys 2014-07-02 (c2a329ce)
Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ c2a329ce | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' c282e64f..c2a329ce Chuck Atkins (3): e4bba930 Directory: Make sure the /* suffix uses correct slashes 97817ce7 SystemTools: Refactor test file and directory locations 8f991ab0 SystemTools: Use extended paths on Windows for > 256 length Clinton Stimpson (1): c2a329ce Encoding: Fixes uses of stat() on Windows to work with unicode. Change-Id: I8e3aa1ba66ce80900cb25a692287495b911dcbd0
Diffstat (limited to 'testSystemTools.cxx')
-rw-r--r--testSystemTools.cxx257
1 files changed, 231 insertions, 26 deletions
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index 69825a8..8b21081 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -98,32 +98,124 @@ static bool CheckEscapeChars(kwsys_stl::string input,
static bool CheckFileOperations()
{
bool res = true;
-
- if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_BIN_FILE) !=
+ const kwsys_stl::string testBinFile(TEST_SYSTEMTOOLS_SOURCE_DIR
+ "/testSystemTools.bin");
+ const kwsys_stl::string testTxtFile(TEST_SYSTEMTOOLS_SOURCE_DIR
+ "/testSystemTools.cxx");
+ const kwsys_stl::string testNewDir(TEST_SYSTEMTOOLS_BINARY_DIR
+ "/testSystemToolsNewDir");
+ const kwsys_stl::string testNewFile(testNewDir + "/testNewFile.txt");
+
+ if (kwsys::SystemTools::DetectFileType(testBinFile.c_str()) !=
kwsys::SystemTools::FileTypeBinary)
{
kwsys_ios::cerr
<< "Problem with DetectFileType - failed to detect type of: "
- << TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
+ << testBinFile << kwsys_ios::endl;
res = false;
}
- if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_SRC_FILE) !=
+ if (kwsys::SystemTools::DetectFileType(testTxtFile.c_str()) !=
kwsys::SystemTools::FileTypeText)
{
kwsys_ios::cerr
<< "Problem with DetectFileType - failed to detect type of: "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << testTxtFile << kwsys_ios::endl;
res = false;
}
-
- if (kwsys::SystemTools::FileLength(TEST_SYSTEMTOOLS_BIN_FILE) != 766)
+
+ if (kwsys::SystemTools::FileLength(testBinFile.c_str()) != 766)
{
kwsys_ios::cerr
<< "Problem with FileLength - incorrect length for: "
- << TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
- res = false;
+ << testBinFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::MakeDirectory(testNewDir.c_str()))
+ {
+ kwsys_ios::cerr
+ << "Problem with MakeDirectory for: "
+ << testNewDir << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::Touch(testNewFile.c_str(), true))
+ {
+ kwsys_ios::cerr
+ << "Problem with Touch for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::RemoveFile(testNewFile.c_str()))
+ {
+ kwsys_ios::cerr
+ << "Problem with RemoveFile: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ kwsys::SystemTools::Touch(testNewFile.c_str(), true);
+ if (!kwsys::SystemTools::RemoveADirectory(testNewDir.c_str()))
+ {
+ kwsys_ios::cerr
+ << "Problem with RemoveADirectory for: "
+ << testNewDir << kwsys_ios::endl;
+ res = false;
+ }
+
+#ifdef KWSYS_TEST_SYSTEMTOOLS_LONG_PATHS
+ // Perform the same file and directory creation and deletion tests but
+ // with paths > 256 characters in length.
+
+ const kwsys_stl::string testNewLongDir(
+ TEST_SYSTEMTOOLS_BINARY_DIR "/"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "01234567890123");
+ const kwsys_stl::string testNewLongFile(testNewLongDir + "/"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "0123456789.txt");
+
+ if (!kwsys::SystemTools::MakeDirectory(testNewLongDir.c_str()))
+ {
+ kwsys_ios::cerr
+ << "Problem with MakeDirectory for: "
+ << testNewLongDir << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::Touch(testNewLongFile.c_str(), true))
+ {
+ kwsys_ios::cerr
+ << "Problem with Touch for: "
+ << testNewLongFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::RemoveFile(testNewLongFile.c_str()))
+ {
+ kwsys_ios::cerr
+ << "Problem with RemoveFile: "
+ << testNewLongFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ kwsys::SystemTools::Touch(testNewLongFile.c_str(), true);
+ if (!kwsys::SystemTools::RemoveADirectory(testNewLongDir.c_str()))
+ {
+ kwsys_ios::cerr
+ << "Problem with RemoveADirectory for: "
+ << testNewLongDir << kwsys_ios::endl;
+ res = false;
}
+#endif
return res;
}
@@ -138,7 +230,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with CapitalizedWords "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << '"' << test << '"' << kwsys_ios::endl;
res = false;
}
@@ -148,7 +240,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with UnCapitalizedWords "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << '"' << test << '"' << kwsys_ios::endl;
res = false;
}
@@ -158,7 +250,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with AddSpaceBetweenCapitalizedWords "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << '"' << test << '"' << kwsys_ios::endl;
res = false;
}
@@ -168,7 +260,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with AppendStrings "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A\" \" Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
@@ -179,7 +271,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with AppendStrings "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had\" \" A \" \"Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
@@ -188,7 +280,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with CountChar "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
@@ -198,7 +290,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with RemoveChars "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
@@ -209,7 +301,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with RemoveCharsButUpperHex "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
@@ -221,7 +313,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ReplaceChars "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres2;
@@ -231,7 +323,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with StringStartsWith "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
@@ -240,7 +332,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with StringEndsWith "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
@@ -249,7 +341,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with DuplicateString "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
@@ -260,7 +352,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with CropString "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
@@ -271,16 +363,124 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with Split "
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
- res = false;
+ << "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
+ res = false;
+ }
+
+#ifdef _WIN32
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath
+ ("L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") !=
+ L"\\\\?\\L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\""
+ << kwsys_ios::endl;
+ res = false;
}
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath
+ ("L:/Local Mojo/Hex Power Pack/Iffy Voodoo") !=
+ L"\\\\?\\L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"L:/Local Mojo/Hex Power Pack/Iffy Voodoo\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath
+ ("\\\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") !=
+ L"\\\\?\\UNC\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"\\\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath
+ ("//Foo/Local Mojo/Hex Power Pack/Iffy Voodoo") !=
+ L"\\\\?\\UNC\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"//Foo/Local Mojo/Hex Power Pack/Iffy Voodoo\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath("//") !=
+ L"//")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"//\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\") !=
+ L"\\\\.\\")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"\\\\.\\\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\X") !=
+ L"\\\\.\\X")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"\\\\.\\X\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\X:") !=
+ L"\\\\?\\X:")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"\\\\.\\X:\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\X:\\") !=
+ L"\\\\?\\X:\\")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"\\\\.\\X:\\\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (kwsys::SystemTools::ConvertToWindowsExtendedPath("NUL") !=
+ L"\\\\.\\NUL")
+ {
+ kwsys_ios::cerr
+ << "Problem with ConvertToWindowsExtendedPath "
+ << "\"NUL\""
+ << kwsys_ios::endl;
+ res = false;
+ }
+
+#endif
+
if (kwsys::SystemTools::ConvertToWindowsOutputPath
("L://Local Mojo/Hex Power Pack/Iffy Voodoo") !=
"\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"")
{
kwsys_ios::cerr
<< "Problem with ConvertToWindowsOutputPath "
+ << "\"L://Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
res = false;
}
@@ -291,6 +491,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ConvertToWindowsOutputPath "
+ << "\"//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
res = false;
}
@@ -301,6 +502,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ConvertToUnixOutputPath "
+ << "\"//Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
res = false;
}
@@ -308,14 +510,17 @@ static bool CheckStringOperations()
int targc;
char **targv;
kwsys::SystemTools::ConvertWindowsCommandLineToUnixArguments
- ("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"", &targc, &targv);
+ ("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"",
+ &targc, &targv);
if (targc != 4 || strcmp(targv[1],"Local Mojo\\Voodoo.asp") ||
strcmp(targv[2],"-CastHex") ||
strcmp(targv[3],"D:\\My Secret Mojo\\Voodoo.mp3"))
{
kwsys_ios::cerr
<< "Problem with ConvertWindowsCommandLineToUnixArguments"
- << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+ << "\'\"Local Mojo\\Voodoo.asp\" "
+ << "-CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"\'"
+ << kwsys_ios::endl;
res = false;
}
for (;targc >=0; --targc)