Repository: mesos Updated Branches: refs/heads/master b4324db84 -> 200980e25
Replaced most instances of `/dev/null` with `os::DEV_NULL`. `os::DEV_NULL` is a constant defined in stout that points to `/dev/null` on Posix and `NUL` on Windows. The two locations behave similarly on their respective platforms. This change future-proofs this code on Windows (only fails at runtime) in case the related features are added or enabled on the Windows build. This change leaves some `/dev/null` strings in tests alone, in tests that use other `/dev` files, like `/dev/zero`. Review: https://reviews.apache.org/r/57481 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/200980e2 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/200980e2 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/200980e2 Branch: refs/heads/master Commit: 200980e25fa25a3ccffd03cace81efe8cec94163 Parents: ceaa9c0 Author: Joseph Wu <[email protected]> Authored: Thu Mar 9 13:58:29 2017 -0800 Committer: Joseph Wu <[email protected]> Committed: Thu Mar 16 16:59:06 2017 -0700 ---------------------------------------------------------------------- src/checks/health_checker.cpp | 1 + src/common/command_utils.cpp | 4 +++- src/docker/docker.cpp | 25 ++++++++++---------- src/hdfs/hdfs.cpp | 11 +++++---- src/launcher/fetcher.cpp | 4 +++- src/slave/container_loggers/lib_logrotate.cpp | 5 ++-- src/slave/container_loggers/lib_logrotate.hpp | 3 ++- src/slave/container_loggers/logrotate.hpp | 3 ++- .../containerizer/mesos/io/switchboard.cpp | 4 +++- .../mesos/isolators/docker/volume/driver.cpp | 5 ++-- .../mesos/isolators/network/cni/cni.cpp | 6 +++-- .../mesos/isolators/network/port_mapping.cpp | 5 ++-- .../mesos/isolators/posix/disk.cpp | 3 ++- .../mesos/provisioner/backends/copy.cpp | 8 ++++--- src/tests/command_executor_tests.cpp | 5 +++- src/tests/container_logger_tests.cpp | 3 ++- src/tests/containerizer/cgroups_tests.cpp | 5 ++-- src/tests/containerizer/docker_tests.cpp | 8 ++++--- .../containerizer/io_switchboard_tests.cpp | 12 ++++++---- src/tests/containerizer/port_mapping_tests.cpp | 7 +++--- src/tests/containerizer/xfs_quota_tests.cpp | 8 ++++--- src/tests/script.cpp | 6 +++-- src/tests/uri_fetcher_tests.cpp | 4 ---- src/uri/fetchers/copy.cpp | 3 ++- src/uri/fetchers/curl.cpp | 3 ++- src/uri/fetchers/docker.cpp | 5 ++-- 26 files changed, 94 insertions(+), 62 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/checks/health_checker.cpp ---------------------------------------------------------------------- diff --git a/src/checks/health_checker.cpp b/src/checks/health_checker.cpp index 7efefe9..a26e9b5 100644 --- a/src/checks/health_checker.cpp +++ b/src/checks/health_checker.cpp @@ -47,6 +47,7 @@ #include <stout/try.hpp> #include <stout/unreachable.hpp> +#include <stout/os/constants.hpp> #include <stout/os/killtree.hpp> #include "common/status_utils.hpp" http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/common/command_utils.cpp ---------------------------------------------------------------------- diff --git a/src/common/command_utils.cpp b/src/common/command_utils.cpp index 09e8051..cb9de72 100644 --- a/src/common/command_utils.cpp +++ b/src/common/command_utils.cpp @@ -24,6 +24,8 @@ #include <stout/os.hpp> #include <stout/unreachable.hpp> +#include <stout/os/constants.hpp> + #include "common/command_utils.hpp" #include "common/status_utils.hpp" @@ -46,7 +48,7 @@ static Future<string> launch( Try<Subprocess> s = subprocess( path, argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/docker/docker.cpp ---------------------------------------------------------------------- diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp index 634ab40..44fbde8 100755 --- a/src/docker/docker.cpp +++ b/src/docker/docker.cpp @@ -27,6 +27,7 @@ #include <stout/strings.hpp> #include <stout/stringify.hpp> +#include <stout/os/constants.hpp> #include <stout/os/killtree.hpp> #include <stout/os/read.hpp> #include <stout/os/write.hpp> @@ -156,7 +157,7 @@ Future<Version> Docker::version() const Try<Subprocess> s = subprocess( cmd, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -942,7 +943,7 @@ Future<Option<int>> Docker::run( Try<Subprocess> s = subprocess( path, argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), _stdout, _stderr, nullptr); @@ -992,8 +993,8 @@ Future<Nothing> Docker::stop( Try<Subprocess> s = subprocess( cmd, - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE()); if (s.isError()) { @@ -1040,8 +1041,8 @@ Future<Nothing> Docker::kill( Try<Subprocess> s = subprocess( cmd, - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE()); if (s.isError()) { @@ -1065,8 +1066,8 @@ Future<Nothing> Docker::rm( Try<Subprocess> s = subprocess( cmd, - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE()); if (s.isError()) { @@ -1104,7 +1105,7 @@ void Docker::_inspect( Try<Subprocess> s = subprocess( cmd, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -1223,7 +1224,7 @@ Future<list<Docker::Container>> Docker::ps( Try<Subprocess> s = subprocess( cmd, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -1392,7 +1393,7 @@ Future<Docker::Image> Docker::pull( Try<Subprocess> s = subprocess( path, argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE(), nullptr); @@ -1528,7 +1529,7 @@ Future<Docker::Image> Docker::__pull( Try<Subprocess> s_ = subprocess( path, argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE(), nullptr, http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/hdfs/hdfs.cpp ---------------------------------------------------------------------- diff --git a/src/hdfs/hdfs.cpp b/src/hdfs/hdfs.cpp index 4aea868..93450b9 100644 --- a/src/hdfs/hdfs.cpp +++ b/src/hdfs/hdfs.cpp @@ -31,6 +31,7 @@ #include <stout/path.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> #include <stout/os/exists.hpp> #include <stout/os/shell.hpp> @@ -143,7 +144,7 @@ Future<bool> HDFS::exists(const string& path) Try<Subprocess> s = subprocess( hadoop, {"hadoop", "fs", "-test", "-e", normalize(path)}, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -182,7 +183,7 @@ Future<Bytes> HDFS::du(const string& _path) Try<Subprocess> s = subprocess( hadoop, {"hadoop", "fs", "-du", path}, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -235,7 +236,7 @@ Future<Nothing> HDFS::rm(const string& path) Try<Subprocess> s = subprocess( hadoop, {"hadoop", "fs", "-rm", normalize(path)}, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -271,7 +272,7 @@ Future<Nothing> HDFS::copyFromLocal(const string& from, const string& to) Try<Subprocess> s = subprocess( hadoop, {"hadoop", "fs", "-copyFromLocal", from, normalize(to)}, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -303,7 +304,7 @@ Future<Nothing> HDFS::copyToLocal(const string& from, const string& to) Try<Subprocess> s = subprocess( hadoop, {"hadoop", "fs", "-copyToLocal", normalize(from), to}, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/launcher/fetcher.cpp ---------------------------------------------------------------------- diff --git a/src/launcher/fetcher.cpp b/src/launcher/fetcher.cpp index 362ad06..42980f5 100644 --- a/src/launcher/fetcher.cpp +++ b/src/launcher/fetcher.cpp @@ -28,6 +28,8 @@ #include <stout/protobuf.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> + #include <mesos/mesos.hpp> #include <mesos/fetcher/fetcher.hpp> @@ -98,7 +100,7 @@ static Try<bool> extract( Try<Subprocess> extractProcess = subprocess( command[0], command, - in.getOrElse(Subprocess::PATH("/dev/null")), + in.getOrElse(Subprocess::PATH(os::DEV_NULL)), out.getOrElse(Subprocess::FD(STDOUT_FILENO)), Subprocess::FD(STDERR_FILENO)); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/container_loggers/lib_logrotate.cpp ---------------------------------------------------------------------- diff --git a/src/slave/container_loggers/lib_logrotate.cpp b/src/slave/container_loggers/lib_logrotate.cpp index acaad38..ae5d0ac 100644 --- a/src/slave/container_loggers/lib_logrotate.cpp +++ b/src/slave/container_loggers/lib_logrotate.cpp @@ -39,6 +39,7 @@ #include <stout/path.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> #include <stout/os/environment.hpp> #include <stout/os/fcntl.hpp> #include <stout/os/killtree.hpp> @@ -189,7 +190,7 @@ public: path::join(flags.launcher_dir, mesos::internal::logger::rotate::NAME), {mesos::internal::logger::rotate::NAME}, Subprocess::FD(outfds.read, Subprocess::IO::OWNED), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::FD(STDERR_FILENO), &outFlags, environment, @@ -236,7 +237,7 @@ public: path::join(flags.launcher_dir, mesos::internal::logger::rotate::NAME), {mesos::internal::logger::rotate::NAME}, Subprocess::FD(errfds.read, Subprocess::IO::OWNED), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::FD(STDERR_FILENO), &errFlags, environment, http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/container_loggers/lib_logrotate.hpp ---------------------------------------------------------------------- diff --git a/src/slave/container_loggers/lib_logrotate.hpp b/src/slave/container_loggers/lib_logrotate.hpp index 561ddb6..5c6d3a9 100644 --- a/src/slave/container_loggers/lib_logrotate.hpp +++ b/src/slave/container_loggers/lib_logrotate.hpp @@ -26,6 +26,7 @@ #include <stout/flags.hpp> #include <stout/option.hpp> +#include <stout/os/constants.hpp> #include <stout/os/exists.hpp> #include <stout/os/pagesize.hpp> #include <stout/os/shell.hpp> @@ -148,7 +149,7 @@ struct Flags : public virtual LoggerFlags // Check if `logrotate` exists via the help command. // TODO(josephw): Consider a more comprehensive check. Try<std::string> helpCommand = - os::shell(value + " --help > /dev/null"); + os::shell(value + " --help > " + os::DEV_NULL); if (helpCommand.isError()) { return Error( http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/container_loggers/logrotate.hpp ---------------------------------------------------------------------- diff --git a/src/slave/container_loggers/logrotate.hpp b/src/slave/container_loggers/logrotate.hpp index 1fce8e3..c6dbd61 100644 --- a/src/slave/container_loggers/logrotate.hpp +++ b/src/slave/container_loggers/logrotate.hpp @@ -26,6 +26,7 @@ #include <stout/option.hpp> #include <stout/path.hpp> +#include <stout/os/constants.hpp> #include <stout/os/pagesize.hpp> @@ -103,7 +104,7 @@ struct Flags : public virtual flags::FlagsBase // Check if `logrotate` exists via the help command. // TODO(josephw): Consider a more comprehensive check. Try<std::string> helpCommand = - os::shell(value + " --help > /dev/null"); + os::shell(value + " --help > " + os::DEV_NULL); if (helpCommand.isError()) { return Error( http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/containerizer/mesos/io/switchboard.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp b/src/slave/containerizer/mesos/io/switchboard.cpp index 27395f9..6418094 100644 --- a/src/slave/containerizer/mesos/io/switchboard.cpp +++ b/src/slave/containerizer/mesos/io/switchboard.cpp @@ -46,6 +46,8 @@ #include <stout/path.hpp> #include <stout/recordio.hpp> +#include <stout/os/constants.hpp> + #ifndef __WINDOWS__ #include <stout/posix/os.hpp> #endif // __WINDOWS__ @@ -552,7 +554,7 @@ Future<Option<ContainerLaunchInfo>> IOSwitchboard::_prepare( Try<Subprocess> child = subprocess( path::join(flags.launcher_dir, IOSwitchboardServer::NAME), {IOSwitchboardServer::NAME}, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), loggerIO.out, loggerIO.err, &switchboardFlags, http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/containerizer/mesos/isolators/docker/volume/driver.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/driver.cpp b/src/slave/containerizer/mesos/isolators/docker/volume/driver.cpp index cf0466c..8cc1b12 100644 --- a/src/slave/containerizer/mesos/isolators/docker/volume/driver.cpp +++ b/src/slave/containerizer/mesos/isolators/docker/volume/driver.cpp @@ -22,6 +22,7 @@ #include <stout/stringify.hpp> +#include <stout/os/constants.hpp> #include <stout/os/killtree.hpp> #include "common/status_utils.hpp" @@ -85,7 +86,7 @@ Future<string> DriverClient::mount( Try<Subprocess> s = subprocess( dvdcli, argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE(), nullptr, @@ -169,7 +170,7 @@ Future<Nothing> DriverClient::unmount( Try<Subprocess> s = subprocess( dvdcli, argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE(), nullptr, http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/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 392c391..fdb9ce5 100644 --- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp +++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp @@ -30,6 +30,8 @@ #include <stout/path.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> + #include "common/protobuf_utils.hpp" #include "linux/fs.hpp" @@ -1036,8 +1038,8 @@ Future<Nothing> NetworkCniIsolatorProcess::__isolate( Try<Subprocess> s = subprocess( path::join(flags.launcher_dir, "mesos-containerizer"), argv, - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), &setup.flags); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp index 4ecc4aa..dfa71fb 100644 --- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp +++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp @@ -49,6 +49,7 @@ #include <stout/strings.hpp> #include <stout/utils.hpp> +#include <stout/os/constants.hpp> #include <stout/os/exists.hpp> #include <stout/os/realpath.hpp> #include <stout/os/stat.hpp> @@ -3091,7 +3092,7 @@ Future<Nothing> PortMappingIsolatorProcess::update( Try<Subprocess> s = subprocess( path::join(flags.launcher_dir, "mesos-network-helper"), argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::FD(STDOUT_FILENO), Subprocess::FD(STDERR_FILENO), &update.flags); @@ -3217,7 +3218,7 @@ Future<ResourceStatistics> PortMappingIsolatorProcess::usage( Try<Subprocess> s = subprocess( path::join(flags.launcher_dir, "mesos-network-helper"), argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::FD(STDERR_FILENO), &statistics.flags); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/containerizer/mesos/isolators/posix/disk.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/isolators/posix/disk.cpp b/src/slave/containerizer/mesos/isolators/posix/disk.cpp index db05833..805566c 100644 --- a/src/slave/containerizer/mesos/isolators/posix/disk.cpp +++ b/src/slave/containerizer/mesos/isolators/posix/disk.cpp @@ -41,6 +41,7 @@ #include <stout/strings.hpp> #include <stout/path.hpp> +#include <stout/os/constants.hpp> #include <stout/os/exists.hpp> #include <stout/os/killtree.hpp> #include <stout/os/stat.hpp> @@ -542,7 +543,7 @@ private: Try<Subprocess> s = subprocess( "du", command, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE(), nullptr, http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/slave/containerizer/mesos/provisioner/backends/copy.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/provisioner/backends/copy.cpp b/src/slave/containerizer/mesos/provisioner/backends/copy.cpp index 0ce3e1e..584cc65 100644 --- a/src/slave/containerizer/mesos/provisioner/backends/copy.cpp +++ b/src/slave/containerizer/mesos/provisioner/backends/copy.cpp @@ -29,6 +29,8 @@ #include <stout/foreach.hpp> #include <stout/os.hpp> +#include <stout/os/constants.hpp> + #include "common/status_utils.hpp" #include "slave/containerizer/mesos/provisioner/backends/copy.hpp" @@ -233,8 +235,8 @@ Future<Nothing> CopyBackendProcess::_provision( Try<Subprocess> s = subprocess( "cp", args, - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE()); if (s.isError()) { @@ -280,7 +282,7 @@ Future<bool> CopyBackendProcess::destroy(const string& rootfs) Try<Subprocess> s = subprocess( "rm", argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::FD(STDOUT_FILENO), Subprocess::FD(STDERR_FILENO)); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/command_executor_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/command_executor_tests.cpp b/src/tests/command_executor_tests.cpp index a53fff3..da4b653 100644 --- a/src/tests/command_executor_tests.cpp +++ b/src/tests/command_executor_tests.cpp @@ -32,6 +32,8 @@ #include <stout/gtest.hpp> +#include <stout/os/constants.hpp> + #include "master/master.hpp" #include "master/detector/standalone.hpp" @@ -280,7 +282,8 @@ TEST_P(CommandExecutorTest, NoTransitionFromKillingToRunning) HealthCheck healthCheck; healthCheck.set_type(HealthCheck::COMMAND); - healthCheck.mutable_command()->set_value("ls " + tmpPath + " >/dev/null"); + healthCheck.mutable_command()->set_value( + "ls " + tmpPath + " > " + os::DEV_NULL); healthCheck.set_delay_seconds(0); healthCheck.set_grace_period_seconds(0); healthCheck.set_interval_seconds(0); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/container_logger_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/container_logger_tests.cpp b/src/tests/container_logger_tests.cpp index dd7bbcb..4ccb2e4 100644 --- a/src/tests/container_logger_tests.cpp +++ b/src/tests/container_logger_tests.cpp @@ -35,6 +35,7 @@ #include <stout/strings.hpp> #include <stout/try.hpp> +#include <stout/os/constants.hpp> #include <stout/os/exists.hpp> #include <stout/os/killtree.hpp> #include <stout/os/mkdir.hpp> @@ -560,7 +561,7 @@ TEST_F(ContainerLoggerTest, LOGROTATE_ModuleFDOwnership) // the same FDs (integers) opened by the container logger. vector<int> fds; for (int i = 0; i < 50; i++) { - Try<int> fd = os::open("/dev/null", O_RDONLY); + Try<int> fd = os::open(os::DEV_NULL, O_RDONLY); ASSERT_SOME(fd); fds.push_back(fd.get()); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/containerizer/cgroups_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/cgroups_tests.cpp b/src/tests/containerizer/cgroups_tests.cpp index 8489e50..431f86f 100644 --- a/src/tests/containerizer/cgroups_tests.cpp +++ b/src/tests/containerizer/cgroups_tests.cpp @@ -49,6 +49,7 @@ #include <stout/stringify.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> #include <stout/os/pagesize.hpp> #include "linux/cgroups.hpp" @@ -1372,7 +1373,7 @@ TEST_F(CgroupsAnyHierarchyDevicesTest, ROOT_CGROUPS_Devices) EXPECT_TRUE(whitelist->empty()); // Verify that we can't open /dev/null. - Try<int_fd> fd = os::open("/dev/null", O_RDWR); + Try<int_fd> fd = os::open(os::DEV_NULL, O_RDWR); EXPECT_ERROR(fd); // Add /dev/null to the list of allowed devices. @@ -1397,7 +1398,7 @@ TEST_F(CgroupsAnyHierarchyDevicesTest, ROOT_CGROUPS_Devices) EXPECT_EQ(entry.get(), whitelist.get()[0]); // Verify that we can now open and write to /dev/null. - fd = os::open("/dev/null", O_WRONLY); + fd = os::open(os::DEV_NULL, O_WRONLY); ASSERT_SOME(fd); Try<Nothing> write = os::write(fd.get(), "nonsense"); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/containerizer/docker_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/docker_tests.cpp b/src/tests/containerizer/docker_tests.cpp index 0718243..4660afc 100644 --- a/src/tests/containerizer/docker_tests.cpp +++ b/src/tests/containerizer/docker_tests.cpp @@ -29,6 +29,8 @@ #include <stout/option.hpp> #include <stout/gtest.hpp> +#include <stout/os/constants.hpp> + #include "docker/docker.hpp" #include "mesos/resources.hpp" @@ -446,9 +448,9 @@ TEST_F(DockerTest, ROOT_DOCKER_CancelPull) Try<Subprocess> s = process::subprocess( tests::flags.docker + " rmi lingmann/1gb", - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null"), - Subprocess::PATH("/dev/null")); + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL), + Subprocess::PATH(os::DEV_NULL)); ASSERT_SOME(s); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/containerizer/io_switchboard_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/io_switchboard_tests.cpp b/src/tests/containerizer/io_switchboard_tests.cpp index a2d7c32..9408ba7 100644 --- a/src/tests/containerizer/io_switchboard_tests.cpp +++ b/src/tests/containerizer/io_switchboard_tests.cpp @@ -31,6 +31,8 @@ #include <stout/protobuf.hpp> #include <stout/uuid.hpp> +#include <stout/os/constants.hpp> + #include <mesos/http.hpp> #include <mesos/mesos.hpp> @@ -162,7 +164,7 @@ protected: TEST_F(IOSwitchboardServerTest, RedirectLog) { - Try<int> nullFd = os::open("/dev/null", O_RDWR); + Try<int> nullFd = os::open(os::DEV_NULL, O_RDWR); ASSERT_SOME(nullFd); Try<std::array<int, 2>> stdoutPipe_ = os::pipe(); @@ -250,7 +252,7 @@ TEST_F(IOSwitchboardServerTest, RedirectLog) TEST_F(IOSwitchboardServerTest, AttachOutput) { - Try<int> nullFd = os::open("/dev/null", O_RDWR); + Try<int> nullFd = os::open(os::DEV_NULL, O_RDWR); ASSERT_SOME(nullFd); string stdoutPath = path::join(sandbox.get(), "stdout"); @@ -366,7 +368,7 @@ TEST_F(IOSwitchboardServerTest, SendHeartbeat) const std::array<int, 2>& stdoutPipe = stdoutPipe_.get(); - Try<int> nullFd = os::open("/dev/null", O_RDWR); + Try<int> nullFd = os::open(os::DEV_NULL, O_RDWR); ASSERT_SOME(nullFd); Duration heartbeat = Milliseconds(10); @@ -473,7 +475,7 @@ TEST_F(IOSwitchboardServerTest, AttachInput) const std::array<int, 2>& stdoutPipe = stdoutPipe_.get(); - Try<int> nullFd = os::open("/dev/null", O_RDWR); + Try<int> nullFd = os::open(os::DEV_NULL, O_RDWR); ASSERT_SOME(nullFd); string stdinPath = path::join(sandbox.get(), "stdin"); @@ -604,7 +606,7 @@ TEST_F(IOSwitchboardServerTest, ReceiveHeartbeat) const std::array<int, 2>& stdoutPipe = stdoutPipe_.get(); - Try<int> nullFd = os::open("/dev/null", O_RDWR); + Try<int> nullFd = os::open(os::DEV_NULL, O_RDWR); ASSERT_SOME(nullFd); string socketPath = path::join(sandbox.get(), "mesos-io-switchboard"); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/containerizer/port_mapping_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/port_mapping_tests.cpp b/src/tests/containerizer/port_mapping_tests.cpp index eb183f2..a528382 100644 --- a/src/tests/containerizer/port_mapping_tests.cpp +++ b/src/tests/containerizer/port_mapping_tests.cpp @@ -34,6 +34,7 @@ #include <stout/net.hpp> #include <stout/stopwatch.hpp> +#include <stout/os/constants.hpp> #include <stout/os/stat.hpp> #include <stout/os/exists.hpp> @@ -379,7 +380,7 @@ protected: Try<Subprocess> s = subprocess( path::join(flags.launcher_dir, "mesos-network-helper"), argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::FD(STDERR_FILENO), &statistics.flags); @@ -1511,7 +1512,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_SmallEgressLimit) // neither 'ports' nor 'ephemeral_ports', which makes it a good port // to use on the host. ostringstream command1; - command1 << "nc -l localhost " << invalidPort << " > /dev/null"; + command1 << "nc -l localhost " << invalidPort << " > " << os::DEV_NULL; Try<Subprocess> s = subprocess(command1.str().c_str()); ASSERT_SOME(s); @@ -1675,7 +1676,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_PortMappingStatistics) // connections to the localhost IP are filtered out when retrieving // the RTT information inside containers. ostringstream command1; - command1 << "nc -l " << hostIP << " " << invalidPort << " > /dev/null"; + command1 << "nc -l " << hostIP << " " << invalidPort << " > " << os::DEV_NULL; Try<Subprocess> s = subprocess(command1.str().c_str()); ASSERT_SOME(s); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/containerizer/xfs_quota_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/xfs_quota_tests.cpp b/src/tests/containerizer/xfs_quota_tests.cpp index 241f449..7beb60b 100644 --- a/src/tests/containerizer/xfs_quota_tests.cpp +++ b/src/tests/containerizer/xfs_quota_tests.cpp @@ -32,6 +32,8 @@ #include <stout/os.hpp> #include <stout/path.hpp> +#include <stout/os/constants.hpp> + #include "linux/fs.hpp" #include "master/master.hpp" @@ -107,7 +109,7 @@ public: // Attach the loop to a backing file. Try<Subprocess> losetup = subprocess( "losetup " + loop.get() + " " + devPath, - Subprocess::PATH("/dev/null")); + Subprocess::PATH(os::DEV_NULL)); ASSERT_SOME(losetup); AWAIT_READY(losetup->status()); @@ -120,7 +122,7 @@ public: // should be good enough for tests. Try<Subprocess> mkfs = subprocess( "mkfs.xfs -f " + loopDevice.get(), - Subprocess::PATH("/dev/null")); + Subprocess::PATH(os::DEV_NULL)); ASSERT_SOME(mkfs); AWAIT_READY(mkfs->status()); @@ -150,7 +152,7 @@ public: if (loopDevice.isSome()) { Try<Subprocess> cmdProcess = subprocess( "losetup -d " + loopDevice.get(), - Subprocess::PATH("/dev/null")); + Subprocess::PATH(os::DEV_NULL)); if (cmdProcess.isSome()) { cmdProcess->status().await(Seconds(15)); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/script.cpp ---------------------------------------------------------------------- diff --git a/src/tests/script.cpp b/src/tests/script.cpp index 1f5dac4..3b68b84 100644 --- a/src/tests/script.cpp +++ b/src/tests/script.cpp @@ -27,6 +27,8 @@ #include <stout/stringify.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> + #include "common/status_utils.hpp" #include "mesos/mesos.hpp" @@ -93,8 +95,8 @@ void execute(const string& script) // Redirect output to /dev/null unless the test is verbose. if (!flags.verbose) { - if (freopen("/dev/null", "w", stdout) == nullptr || - freopen("/dev/null", "w", stderr) == nullptr) { + if (freopen(os::DEV_NULL, "w", stdout) == nullptr || + freopen(os::DEV_NULL, "w", stderr) == nullptr) { std::cerr << "Failed to redirect stdout/stderr to /dev/null:" << os::strerror(errno) << std::endl; abort(); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/tests/uri_fetcher_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/uri_fetcher_tests.cpp b/src/tests/uri_fetcher_tests.cpp index 40bec5b..4892909 100644 --- a/src/tests/uri_fetcher_tests.cpp +++ b/src/tests/uri_fetcher_tests.cpp @@ -385,9 +385,6 @@ TEST_F(DockerFetcherPluginTest, INTERNET_CURL_InvokeFetchByName) class CopyFetcherPluginTest : public TemporaryDirectoryTest {}; -// TODO(hausdorff): Enable this test on Windows. `/dev/null` does not exist on -// Windows, causing this to fail. -#ifndef __WINDOWS__ // Tests CopyFetcher plugin for fetching a valid file. TEST_F(CopyFetcherPluginTest, FetchExistingFile) { @@ -409,7 +406,6 @@ TEST_F(CopyFetcherPluginTest, FetchExistingFile) // Validate the fetched file's content. EXPECT_SOME_EQ("abc", os::read(path::join(dir, "file"))); } -#endif // __WINDOWS__ // Negative test case that tests CopyFetcher plugin for a non-exiting file. http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/uri/fetchers/copy.cpp ---------------------------------------------------------------------- diff --git a/src/uri/fetchers/copy.cpp b/src/uri/fetchers/copy.cpp index 2cfef5a..9c79ac6 100644 --- a/src/uri/fetchers/copy.cpp +++ b/src/uri/fetchers/copy.cpp @@ -30,6 +30,7 @@ #include <stout/path.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> #include <stout/os/mkdir.hpp> #include "uri/fetchers/copy.hpp" @@ -99,7 +100,7 @@ Future<Nothing> CopyFetcherPlugin::fetch( Try<Subprocess> s = subprocess( "cp", argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/uri/fetchers/curl.cpp ---------------------------------------------------------------------- diff --git a/src/uri/fetchers/curl.cpp b/src/uri/fetchers/curl.cpp index 7b746d6..a592eb5 100644 --- a/src/uri/fetchers/curl.cpp +++ b/src/uri/fetchers/curl.cpp @@ -30,6 +30,7 @@ #include <stout/path.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> #include <stout/os/mkdir.hpp> #include "uri/fetchers/curl.hpp" @@ -109,7 +110,7 @@ Future<Nothing> CurlFetcherPlugin::fetch( Try<Subprocess> s = subprocess( "curl", argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); http://git-wip-us.apache.org/repos/asf/mesos/blob/200980e2/src/uri/fetchers/docker.cpp ---------------------------------------------------------------------- diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp index 68f380d..d051a4d 100644 --- a/src/uri/fetchers/docker.cpp +++ b/src/uri/fetchers/docker.cpp @@ -31,6 +31,7 @@ #include <stout/option.hpp> #include <stout/strings.hpp> +#include <stout/os/constants.hpp> #include <stout/os/mkdir.hpp> #include <stout/os/write.hpp> @@ -114,7 +115,7 @@ static Future<http::Response> curl( Try<Subprocess> s = subprocess( "curl", argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE()); @@ -232,7 +233,7 @@ static Future<int> download( Try<Subprocess> s = subprocess( "curl", argv, - Subprocess::PATH("/dev/null"), + Subprocess::PATH(os::DEV_NULL), Subprocess::PIPE(), Subprocess::PIPE());
