diff options
author | Chase Douglas <chase.douglas@ubuntu.com> | 2011-12-14 09:13:34 -0800 |
---|---|---|
committer | Chase Douglas <chase.douglas@ubuntu.com> | 2011-12-14 09:13:34 -0800 |
commit | 6f0204791b3057ad49719675f30810c1b2755aff (patch) | |
tree | f27ec5f34836feed9f86da5c1d9207390d1f3d62 /src | |
parent | bb34e8586f1d74e4717dc8300bea6628b9a38804 (diff) | |
parent | 2e13892e9031e10dc91a2677295be654eb6b7747 (diff) |
Merge in Doxygen branch, which also includes many fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/environment.cpp | 2 | ||||
-rw-r--r-- | src/process.cpp | 40 | ||||
-rw-r--r-- | src/test.cpp | 4 |
3 files changed, 40 insertions, 6 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 8f8078f..0b392ca 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -51,6 +51,8 @@ xorg::testing::Environment::Environment(const std::string& path_to_conf, : d_(new Private(path_to_conf, path_to_server, display)) { } +xorg::testing::Environment::~Environment() {} + void xorg::testing::Environment::SetUp() { static char display_string[6]; snprintf(display_string, 6, ":%d", d_->display); diff --git a/src/process.cpp b/src/process.cpp index 2432076..05a808a 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -1,3 +1,24 @@ +/***************************************************************************** + * + * X testing environment - Google Test environment feat. dummy x server + * + * Copyright (C) 2011 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + * + ****************************************************************************/ + #include "xorg/gtest/process.h" #include <sys/types.h> @@ -61,8 +82,10 @@ bool xorg::testing::Process::Terminate() { throw std::runtime_error("Child process tried to terminate itself"); } else { /* Parent */ if (kill(d_->pid, SIGTERM) < 0) { + d_->pid = -1; return false; } + d_->pid = -1; } return true; } @@ -75,22 +98,29 @@ bool xorg::testing::Process::Kill() { throw std::runtime_error("Child process tried to kill itself"); } else { /* Parent */ if (kill(d_->pid, SIGKILL) < 0) { + d_->pid = -1; return false; } + d_->pid = -1; } return true; } -void xorg::testing::Process::SetEnv(const char* name, const char* value, - bool overwrite) { - if (setenv(name, value, overwrite) != 0) +void xorg::testing::Process::SetEnv(const std::string& name, + const std::string& value, bool overwrite) { + if (setenv(name.c_str(), value.c_str(), overwrite) != 0) throw std::runtime_error("Failed to set environment variable in process"); return; } -const char* xorg::testing::Process::GetEnv(const char* name) { - return getenv(name); +std::string xorg::testing::Process::GetEnv(const std::string& name, + bool* exists) const { + const char* var = getenv(name.c_str()); + if (exists != NULL) + *exists = (var != NULL); + + return std::string(var); } pid_t xorg::testing::Process::Pid() const { diff --git a/src/test.cpp b/src/test.cpp index 199505f..83c1cbd 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * utouch-frame - Touch Frame Library + * X testing environment - Google Test environment feat. dummy x server * * Copyright (C) 2011 Canonical Ltd. * @@ -33,6 +33,8 @@ xorg::testing::Test::Test() : d_(new Private) { d_->display = NULL; } +xorg::testing::Test::~Test() {} + void xorg::testing::Test::SetUp() { d_->display = XOpenDisplay(NULL); if (!d_->display) |