summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@ubuntu.com>2011-12-14 11:10:59 -0800
committerChase Douglas <chase.douglas@ubuntu.com>2011-12-14 11:10:59 -0800
commit327d46a503ab1f57134e9d3a56f6792b151e8c03 (patch)
treebcb51b7bd494f1996e43a87f269b2c64bc8751d0
parent8b2947df181dba16e07bd399d33ef0ae60aebdeb (diff)
Make Process::GetEnv and SetEnv static methods
They do not modify or use a Process object. They are merely helper functions.
-rw-r--r--include/xorg/gtest/process.h44
-rw-r--r--src/process.cpp2
2 files changed, 24 insertions, 22 deletions
diff --git a/include/xorg/gtest/process.h b/include/xorg/gtest/process.h
index 9cd207e..4359f21 100644
--- a/include/xorg/gtest/process.h
+++ b/include/xorg/gtest/process.h
@@ -56,6 +56,29 @@ namespace testing {
class Process {
public:
/**
+ * Helper function to adjust the environment of the current process.
+ *
+ * @param [in] name Name of the environment variable.
+ * @param [in] value Value of the environment variable.
+ * @param [in] overwrite Whether to overwrite the value of existing env
+ * variables.
+ *
+ * @throws std::runtime_error if adjusting the environment does not succeed.
+ */
+ static void SetEnv(const std::string& name, const std::string& value,
+ bool overwrite);
+
+ /**
+ * Helper function to query the environment of the current process.
+ *
+ * @param [in] name The name of the environment variable.
+ * @param [out] exists If not NULL, the variable will be set to true if the
+ * environment variable exists and to false otherwise.
+ * @returns The value of the environment variable, or an empty string.
+ */
+ static std::string GetEnv(const std::string& name, bool* exists = NULL);
+
+ /**
* Creates a child-process that is in a terminated state.
*/
Process();
@@ -115,27 +138,6 @@ class Process {
bool Kill();
/**
- * Adjusts the environment of the child process.
- *
- * @param [in] name Name of the environment variable.
- * @param [in] value Value of the environment variable.
- * @param [in] overwrite Whether to overwrite the value of existing env variables.
- *
- * @throws std::runtime_error if adjusting the environment does not succeed.
- */
- void SetEnv(const std::string& name, const std::string& value, bool overwrite);
-
- /**
- * Queries the environment of the child process.
- *
- * @param [in] name The name of the environment variable.
- * @param [out] exists If not NULL, the variable will be set to true if the
- * environment variable exists and to false otherwise.
- * @returns The value of the environment variable, or an empty string.
- */
- std::string GetEnv(const std::string& name, bool* exists = NULL) const;
-
- /**
* Accesses the pid of the child process.
*
* @returns The pid of the child process or -1.
diff --git a/src/process.cpp b/src/process.cpp
index 05a808a..bfe067d 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -115,7 +115,7 @@ void xorg::testing::Process::SetEnv(const std::string& name,
}
std::string xorg::testing::Process::GetEnv(const std::string& name,
- bool* exists) const {
+ bool* exists) {
const char* var = getenv(name.c_str());
if (exists != NULL)
*exists = (var != NULL);