summaryrefslogtreecommitdiff
path: root/sal/qa/osl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-02-22 21:13:06 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-02-22 21:13:06 +0000
commitd83d6212f93d792d0d024de1c20a75ff3e839955 (patch)
tree70371c5110f5d1757e8fa6ed3db01afd2a373905 /sal/qa/osl
parent933acd0e9aa0565b23e615c314a8044148c32d5e (diff)
Account for the possibilty of a newline in an env variable
So, lets getline on '\0' and keep it simple.
Diffstat (limited to 'sal/qa/osl')
-rw-r--r--sal/qa/osl/process/osl_process.cxx26
-rw-r--r--sal/qa/osl/process/osl_process_child.cxx6
2 files changed, 12 insertions, 20 deletions
diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx
index 22f82e4cf..dc9a8e307 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -378,6 +378,7 @@ class Test_osl_executeProcess : public CppUnit::TestFixture
{
const OUString env_param_;
+ OUString temp_file_url_;
OUString temp_file_path_;
rtl_uString* parameters_[2];
int parameters_count_;
@@ -402,14 +403,18 @@ public:
//------------------------------------------------
virtual void setUp()
{
- temp_file_path_ = create_temp_file();
+ temp_file_path_ = create_temp_file(temp_file_url_);
parameters_[1] = temp_file_path_.pData;
}
+ virtual void tearDown()
+ {
+ osl::File::remove(temp_file_url_);
+ }
+
//------------------------------------------------
- OUString create_temp_file()
+ OUString create_temp_file(OUString &temp_file_url)
{
- OUString temp_file_url;
FileBase::RC rc = FileBase::createTempFile(0, 0, &temp_file_url);
CPPUNIT_ASSERT_MESSAGE("createTempFile failed", FileBase::E_None == rc);
@@ -434,20 +439,11 @@ public:
);
std::string line;
- while (std::getline(file, line))
+ while (std::getline(file, line, '\0'))
env_container->push_back(line);
}
//------------------------------------------------
- void dump_env(const string_container_t& env, OUString file_name)
- {
- OString fname = OUStringToOString(file_name, osl_getThreadTextEncoding());
- std::ofstream file(fname.getStr());
- std::ostream_iterator<std::string> oi(file, "\n");
- std::copy(env.begin(), env.end(), oi);
- }
-
- //------------------------------------------------
// environment of the child process that was
// started. The child process writes his
// environment into a file
@@ -677,9 +673,6 @@ public:
}
CPPUNIT_TEST_SUITE(Test_osl_executeProcess);
- //TODO: very odd, these pass locally for me, but fail on tinderbox,
- //disable until I can reproduce the failure
-#if 0
//TODO: Repair these under windows.
#ifndef WNT
CPPUNIT_TEST(osl_execProc_parent_equals_child_environment);
@@ -689,7 +682,6 @@ public:
// CPPUNIT_TEST(osl_execProc_test_batch);
///TODO: Repair test (or tested function ;-) - test fails.
// CPPUNIT_TEST(osl_execProc_exe_name_in_argument_list);
-#endif
CPPUNIT_TEST_SUITE_END();
};
diff --git a/sal/qa/osl/process/osl_process_child.cxx b/sal/qa/osl/process/osl_process_child.cxx
index 124fcd14b..0417874cf 100644
--- a/sal/qa/osl/process/osl_process_child.cxx
+++ b/sal/qa/osl/process/osl_process_child.cxx
@@ -89,7 +89,7 @@ void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
while (size_t l = _tcslen(reinterpret_cast<wchar_t*>(p)))
{
w_to_a(p, buffer, sizeof(buffer));
- file << buffer << std::endl;
+ file << buffer << '\0';
p += l + 1;
}
FreeEnvironmentStrings(env);
@@ -100,8 +100,8 @@ void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
void dump_env(char* file_path)
{
std::ofstream file(file_path);
- for (int i = 0; NULL != environ[i]; i++)
- file << environ[i] << std::endl;
+ for (int i = 0; NULL != environ[i]; ++i)
+ file << environ[i] << '\0';
}
#endif