summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-03-22 20:30:51 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-03-22 20:30:51 +0000
commit60c68897dcbb8e172dc4f7c89602e0cc84d2f0bf (patch)
tree559d71eee1162de623fa9d4fe9a1a21de7a33815
parent5f3b360f26fb05b2c1b6666321359346f2ddb5a4 (diff)
string LD_PRELOAD from variable list for test comparison
-rw-r--r--sal/qa/osl/process/osl_process.cxx34
1 files changed, 30 insertions, 4 deletions
diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx
index 2ab03963b..ea5b4ec5c 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -363,6 +363,32 @@ private:
string_container_t exclude_list_;
};
+namespace
+{
+ class starts_with
+ : public std::unary_function<const std::string&, bool>
+ {
+ private:
+ const std::string m_rString;
+ public:
+ starts_with(const char *pString) : m_rString(pString) {}
+ bool operator()(const std::string &rEntry) const
+ {
+ return rEntry.find(m_rString) == 0;
+ }
+ };
+
+ void tidy_container(string_container_t &env_container)
+ {
+ //sort them because there are no guarantees to ordering
+ std::sort(env_container.begin(), env_container.end());
+ //remove LD_PRELOAD because valgrind injects that into the
+ //parent process
+ env_container.erase(std::remove_if(env_container.begin(), env_container.end(),
+ starts_with("LD_PRELOAD=")), env_container.end());
+ }
+}
+
#ifdef WNT
void read_parent_environment(string_container_t* env_container)
{
@@ -375,14 +401,14 @@ private:
p += l + 1;
}
FreeEnvironmentStrings(env);
- std::sort(env_container->begin(), env_container->end());
+ tidy_container(*env_container);
}
#else
void read_parent_environment(string_container_t* env_container)
{
for (int i = 0; NULL != environ[i]; i++)
env_container->push_back(std::string(environ[i]));
- std::sort(env_container->begin(), env_container->end());
+ tidy_container(*env_container);
}
#endif
@@ -454,7 +480,7 @@ public:
std::string line;
while (std::getline(file, line, '\0'))
env_container->push_back(line);
- std::sort(env_container->begin(), env_container->end());
+ tidy_container(*env_container);
}
//------------------------------------------------
@@ -580,7 +606,7 @@ public:
CPPUNIT_ASSERT_MESSAGE
(
- "Parent an child environment not equal",
+ "Parent and child environment not equal",
compare_environments()
);
}