summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-02-14 11:11:24 +0100
committerJan Holesovsky <kendy@suse.cz>2011-02-14 11:11:24 +0100
commitf3ca6f1b5af9a0016f552cc24ab901fd13185877 (patch)
tree80b9b2dbe9a36732ae3c077ee229eb7764901efc /sal
parentc6c823866063db13631d3b766669b656a538d31a (diff)
unittest: Allow concurrent run of the osl_File.cxx tests.
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/osl/file/osl_File.cxx57
1 files changed, 45 insertions, 12 deletions
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index a37d9c393cdc..073e80192500 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -6009,22 +6009,55 @@ namespace osl_Directory
//########################################
OUString get_test_path()
{
- OUString tmp;
- FileBase::RC rc = FileBase::getTempDirURL(tmp);
+ static OUString test_path;
+ if (test_path.isEmpty())
+ {
+ OUString tmp;
+ FileBase::RC rc = FileBase::getTempDirURL(tmp);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "Getting the location of TMP dir failed",
+ rc == FileBase::E_None
+ );
+
+ OUString system_path;
+ rc = FileBase::getSystemPathFromFileURL(tmp, system_path);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "Cannot convert the TMP dir to system path",
+ rc == FileBase::E_None
+ );
- CPPUNIT_ASSERT_MESSAGE
- (
- "Test path creation failed",
- rc == FileBase::E_None
- );
+ OString tmp_x(rtl::OUStringToOString(system_path, RTL_TEXTENCODING_UTF8 ));
+ if (tmp_x.lastIndexOf('/') != (tmp_x.getLength() - 1))
+ tmp_x += rtl::OString('/');
- OUStringBuffer b(tmp);
- if (tmp.lastIndexOf('/') != (tmp.getLength() - 1))
- b.appendAscii("/");
+#ifndef WNT
+ // FIXME would be nice to create unique dir even on Windows
+ tmp_x += rtl::OString("XXXXXX");
+ char *out = mkdtemp(const_cast<char*>(tmp_x.getStr()));
- b.appendAscii(TEST_PATH_POSTFIX);
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "mkdtemp call failed",
+ out != NULL
+ );
+
+ tmp_x += rtl::OString('/');
+#endif
+ tmp_x += rtl::OString(TEST_PATH_POSTFIX);
- return b.makeStringAndClear();
+ rc = FileBase::getFileURLFromSystemPath(rtl::OStringToOUString(tmp_x, RTL_TEXTENCODING_UTF8), test_path);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "Cannot convert the system path back to an URL",
+ rc == FileBase::E_None
+ );
+ }
+ return test_path;
}
//########################################