diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-02-22 21:13:06 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-22 21:13:06 +0000 |
commit | fccef9d68d48abe7bef0ed15b1d77d364675c195 (patch) | |
tree | c79e49bf3d9f680d4d481a36913435feeb554c81 /sal | |
parent | 14c6bbf67d386fed4af3062a69f53bc058638afa (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')
-rw-r--r-- | sal/qa/osl/process/osl_process.cxx | 26 | ||||
-rw-r--r-- | sal/qa/osl/process/osl_process_child.cxx | 6 |
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 9ec0e6ee332d..333aae46a9a5 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 45d5d6ddcf79..bc34217dc880 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 |