Fixed use of `os::which`.
Because `os::which` was added to its own header, all uses of it now need
to include said header.
In `tests/environment.cpp`, instead of using `os::system("which foo")`,
we now use `os::which("foo")` to be compatible with Windows.
Review: https://reviews.apache.org/r/65145
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0086ae1a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0086ae1a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0086ae1a
Branch: refs/heads/1.5.x
Commit: 0086ae1ae2525a49adbbcaa04f0ffd280b362a26
Parents: b8e66e2
Author: Andrew Schwartzmeyer <[email protected]>
Authored: Fri Jan 12 15:17:02 2018 -0800
Committer: Andrew Schwartzmeyer <[email protected]>
Committed: Tue Jan 16 13:38:02 2018 -0800
----------------------------------------------------------------------
.../mesos/isolators/docker/volume/isolator.cpp | 1 +
.../mesos/isolators/network/cni/cni.cpp | 1 +
.../cni/plugins/port_mapper/port_mapper.cpp | 2 ++
src/slave/containerizer/mesos/launch.cpp | 1 +
src/tests/environment.cpp | 18 ++++++++++--------
5 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0086ae1a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
index ba9e20c..44cf9b2 100644
--- a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
+++ b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
@@ -22,6 +22,7 @@
#include <stout/os.hpp>
#include <stout/os/realpath.hpp>
+#include <stout/os/which.hpp>
#include "slave/flags.hpp"
#include "slave/state.hpp"
http://git-wip-us.apache.org/repos/asf/mesos/blob/0086ae1a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index 61de16b..af1d477 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -33,6 +33,7 @@
#include <stout/os/constants.hpp>
#include <stout/os/realpath.hpp>
+#include <stout/os/which.hpp>
#include "common/protobuf_utils.hpp"
http://git-wip-us.apache.org/repos/asf/mesos/blob/0086ae1a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
----------------------------------------------------------------------
diff --git
a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
index de64d65..c40b57f 100644
---
a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
+++
b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
@@ -17,6 +17,8 @@
#include <stout/os.hpp>
#include <stout/protobuf.hpp>
+#include <stout/os/which.hpp>
+
#include <process/collect.hpp>
#include <process/dispatch.hpp>
#include <process/io.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/0086ae1a/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp
b/src/slave/containerizer/mesos/launch.cpp
index c45a038..2328ea9 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -39,6 +39,7 @@
#include <stout/unreachable.hpp>
#include <stout/os/realpath.hpp>
+#include <stout/os/which.hpp>
#include <stout/os/write.hpp>
#include <mesos/mesos.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/0086ae1a/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index 72bd621..13a4c95 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -50,6 +50,7 @@
#include <stout/os/pstree.hpp>
#include <stout/os/shell.hpp>
#include <stout/os/temp.hpp>
+#include <stout/os/which.hpp>
#ifdef __linux__
#include "linux/cgroups.hpp"
@@ -215,7 +216,7 @@ class CurlFilter : public TestFilter
public:
CurlFilter()
{
- curlError = os::system("which curl") != 0;
+ curlError = os::which("curl").isNone();
if (curlError) {
std::cerr
<< "-------------------------------------------------------------\n"
@@ -240,8 +241,8 @@ class NvidiaGpuFilter : public TestFilter
public:
NvidiaGpuFilter()
{
- exists = os::system("which nvidia-smi") == 0;
- if (!exists) {
+ nvidiaGpuError = os::which("nvidia-smi").isNone();
+ if (nvidiaGpuError) {
std::cerr
<< "-------------------------------------------------------------\n"
<< "No 'nvidia-smi' command found so no Nvidia GPU tests will run\n"
@@ -252,11 +253,11 @@ public:
bool disable(const ::testing::TestInfo* test) const
{
- return matches(test, "NVIDIA_GPU_") && !exists;
+ return matches(test, "NVIDIA_GPU_") && nvidiaGpuError;
}
private:
- bool exists;
+ bool nvidiaGpuError;
};
@@ -396,6 +397,7 @@ public:
InternetFilter()
{
error = os::system("ping -c 1 -W 1 google.com") != 0;
+ // TODO(andschwa): Make ping command cross-platform.
if (error) {
std::cerr
<< "-------------------------------------------------------------\n"
@@ -420,7 +422,7 @@ class LogrotateFilter : public TestFilter
public:
LogrotateFilter()
{
- logrotateError = os::system("which logrotate") != 0;
+ logrotateError = os::which("logrotate").isNone();
if (logrotateError) {
std::cerr
<< "-------------------------------------------------------------\n"
@@ -446,7 +448,7 @@ class NetcatFilter : public TestFilter
public:
NetcatFilter()
{
- netcatError = os::system("which nc") != 0;
+ netcatError = os::which("nc").isNone();
if (netcatError) {
std::cerr
<< "-------------------------------------------------------------\n"
@@ -736,7 +738,7 @@ class UnzipFilter : public TestFilter
public:
UnzipFilter()
{
- unzipError = os::system("which unzip") != 0;
+ unzipError = os::which("unzip").isNone();
if (unzipError) {
std::cerr
<< "-------------------------------------------------------------\n"