diff options
author | Tamir Duberstein <tamird@google.com> | 2019-04-26 12:46:14 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-26 12:47:46 -0700 |
commit | 59442238d4d9e48433cd0601ffa53e280fb872bc (patch) | |
tree | 0857202d3ffeb4255d872507c4e6baf9329e4a1e | |
parent | 5f13338d30fb59241cf7f1aa6374c54c69677314 (diff) |
Remove syscall tests' dependency on glog
PiperOrigin-RevId: 245469859
Change-Id: I0610e477cc3a884275852e83028ecfb501f2c039
-rw-r--r-- | WORKSPACE | 30 | ||||
-rw-r--r-- | test/syscalls/linux/affinity.cc | 3 | ||||
-rw-r--r-- | test/syscalls/linux/concurrency.cc | 1 | ||||
-rw-r--r-- | test/syscalls/linux/exec.cc | 11 | ||||
-rw-r--r-- | test/syscalls/linux/poll.cc | 4 | ||||
-rw-r--r-- | test/syscalls/linux/proc.cc | 10 | ||||
-rw-r--r-- | test/syscalls/linux/proc_pid_smaps.cc | 7 | ||||
-rw-r--r-- | test/syscalls/linux/ptrace.cc | 3 | ||||
-rw-r--r-- | test/syscalls/linux/sendfile_socket.cc | 6 | ||||
-rw-r--r-- | test/syscalls/linux/socket_inet_loopback.cc | 3 | ||||
-rw-r--r-- | test/syscalls/linux/socket_netlink_route.cc | 4 | ||||
-rw-r--r-- | test/syscalls/linux/socket_unix_non_stream.cc | 8 | ||||
-rw-r--r-- | test/util/BUILD | 1 | ||||
-rw-r--r-- | test/util/capability_util.cc | 6 | ||||
-rw-r--r-- | test/util/proc_util.cc | 3 | ||||
-rw-r--r-- | test/util/temp_path.cc | 8 | ||||
-rw-r--r-- | test/util/test_util.cc | 7 | ||||
-rw-r--r-- | test/util/test_util.h | 10 |
18 files changed, 60 insertions, 65 deletions
@@ -123,36 +123,30 @@ go_repository( # System Call test dependencies. http_archive( name = "com_github_gflags_gflags", - sha256 = "6e16c8bc91b1310a44f3965e616383dbda48f83e8c1eaa2370a215057b00cabe", - strip_prefix = "gflags-77592648e3f3be87d6c7123eb81cbad75f9aef5a", + sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf", + strip_prefix = "gflags-2.2.2", urls = [ - "https://mirror.bazel.build/github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz", - "https://github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz", + "https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz", + "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz", ], ) http_archive( name = "com_google_absl", - strip_prefix = "abseil-cpp-master", - urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"], -) - -http_archive( - name = "com_google_glog", - sha256 = "eaabbfc16ecfacb36960ca9c8977f40172c51e4b03234331a1f84040a77ab12c", - strip_prefix = "glog-781096619d3dd368cfebd33889e417a168493ce7", + sha256 = "01ba1185a0e6e048e4890f39e383515195bc335f0627cdddc0c325ee68be4434", + strip_prefix = "abseil-cpp-cd86d0d20ab167c33b23d3875db68d1d4bad3a3b", urls = [ - "https://mirror.bazel.build/github.com/google/glog/archive/781096619d3dd368cfebd33889e417a168493ce7.tar.gz", - "https://github.com/google/glog/archive/781096619d3dd368cfebd33889e417a168493ce7.tar.gz", + "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/cd86d0d20ab167c33b23d3875db68d1d4bad3a3b.tar.gz", + "https://github.com/abseil/abseil-cpp/archive/cd86d0d20ab167c33b23d3875db68d1d4bad3a3b.tar.gz", ], ) http_archive( name = "com_google_googletest", - sha256 = "353ab86e35cea1cd386115279cf4b16695bbf21b897bfbf2721cf4cb5f64ade8", - strip_prefix = "googletest-997d343dd680e541ef96ce71ee54a91daf2577a0", + sha256 = "574e884a41f0a9b76f849a5cdd89c393651e7537e5daa725cf12511232cbd74b", + strip_prefix = "googletest-61cdca569b1f7e4629f8b949f0a9606c28281a6b", urls = [ - "https://mirror.bazel.build/github.com/google/googletest/archive/997d343dd680e541ef96ce71ee54a91daf2577a0.zip", - "https://github.com/google/googletest/archive/997d343dd680e541ef96ce71ee54a91daf2577a0.zip", + "https://mirror.bazel.build/github.com/google/googletest/archive/61cdca569b1f7e4629f8b949f0a9606c28281a6b.tar.gz", + "https://github.com/google/googletest/archive/61cdca569b1f7e4629f8b949f0a9606c28281a6b.tar.gz", ], ) diff --git a/test/syscalls/linux/affinity.cc b/test/syscalls/linux/affinity.cc index 3b59d5777..81bd9bcb5 100644 --- a/test/syscalls/linux/affinity.cc +++ b/test/syscalls/linux/affinity.cc @@ -121,8 +121,7 @@ TEST_F(AffinityTest, SchedSetAffinityOnlyNonexistentCPUFails) { // it's implicitly returned by raw sched_getaffinity syscall. int cpu = cpuset_size_ * 8 - 1; if (cpu <= NumCPUs()) { - LOG(INFO) << "Skipping test: cpu " << cpu << " exists"; - return; + GTEST_SKIP() << "Skipping test: cpu " << cpu << " exists"; } CPU_SET(cpu, &mask_); EXPECT_THAT( diff --git a/test/syscalls/linux/concurrency.cc b/test/syscalls/linux/concurrency.cc index f5a941ca8..7978845c1 100644 --- a/test/syscalls/linux/concurrency.cc +++ b/test/syscalls/linux/concurrency.cc @@ -103,7 +103,6 @@ TEST(ConcurrencyTest, MultiProcessConcurrency) { if (child_pid == 0) { while (true) { } - __builtin_unreachable(); } ASSERT_THAT(child_pid, SyscallSucceeds()); diff --git a/test/syscalls/linux/exec.cc b/test/syscalls/linux/exec.cc index d5a938a98..30bc4b608 100644 --- a/test/syscalls/linux/exec.cc +++ b/test/syscalls/linux/exec.cc @@ -21,6 +21,7 @@ #include <sys/time.h> #include <unistd.h> +#include <iostream> #include <memory> #include <string> #include <vector> @@ -567,26 +568,26 @@ void ExecFromThread() { bool ValidateProcCmdlineVsArgv(const int argc, const char* const* argv) { auto contents_or = GetContents("/proc/self/cmdline"); if (!contents_or.ok()) { - LOG(ERROR) << "Unable to get /proc/self/cmdline: " << contents_or.error(); + std::cerr << "Unable to get /proc/self/cmdline: " << contents_or.error(); return false; } auto contents = contents_or.ValueOrDie(); if (contents.back() != '\0') { - LOG(ERROR) << "Non-null terminated /proc/self/cmdline!"; + std::cerr << "Non-null terminated /proc/self/cmdline!"; return false; } contents.pop_back(); std::vector<std::string> procfs_cmdline = absl::StrSplit(contents, '\0'); if (static_cast<int>(procfs_cmdline.size()) != argc) { - LOG(ERROR) << "argc = " << argc << " != " << procfs_cmdline.size(); + std::cerr << "argc = " << argc << " != " << procfs_cmdline.size(); return false; } for (int i = 0; i < argc; ++i) { if (procfs_cmdline[i] != argv[i]) { - LOG(ERROR) << "Procfs command line argument " << i << " mismatch " - << procfs_cmdline[i] << " != " << argv[i]; + std::cerr << "Procfs command line argument " << i << " mismatch " + << procfs_cmdline[i] << " != " << argv[i]; return false; } } diff --git a/test/syscalls/linux/poll.cc b/test/syscalls/linux/poll.cc index 67a86cc22..cd2161bb1 100644 --- a/test/syscalls/linux/poll.cc +++ b/test/syscalls/linux/poll.cc @@ -16,7 +16,9 @@ #include <sys/resource.h> #include <sys/socket.h> #include <sys/types.h> + #include <algorithm> +#include <iostream> #include "gtest/gtest.h" #include "absl/synchronization/notification.h" @@ -264,7 +266,7 @@ TEST_F(PollTest, Nfds) { } rlim_t max_fds = rlim.rlim_cur; - LOG(INFO) << "Using limit: " << max_fds; + std::cout << "Using limit: " << max_fds; // Create an eventfd. Since its value is initially zero, it is writable. FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD()); diff --git a/test/syscalls/linux/proc.cc b/test/syscalls/linux/proc.cc index 67d3d18c7..a55ecaef1 100644 --- a/test/syscalls/linux/proc.cc +++ b/test/syscalls/linux/proc.cc @@ -133,7 +133,6 @@ PosixError WithSubprocess(SubprocessCallback const& running, while (true) { SleepSafe(absl::Milliseconds(100)); } - __builtin_unreachable(); } close(pipe_fds[1]); // Close the write end. @@ -565,12 +564,9 @@ TEST(ProcSelfMaps, MapUnmap) { } TEST(ProcSelfMaps, Mprotect) { - if (!IsRunningOnGvisor()) { - // FIXME: Linux's mprotect() sometimes fails to merge VMAs in this - // case. - LOG(WARNING) << "Skipping test on Linux"; - return; - } + // FIXME: Linux's mprotect() sometimes fails to merge VMAs in this + // case. + SKIP_IF(!IsRunningOnGvisor()); // Reserve 5 pages of address space. Mapping m = ASSERT_NO_ERRNO_AND_VALUE( diff --git a/test/syscalls/linux/proc_pid_smaps.cc b/test/syscalls/linux/proc_pid_smaps.cc index 4aefc1b41..5f9c42ce5 100644 --- a/test/syscalls/linux/proc_pid_smaps.cc +++ b/test/syscalls/linux/proc_pid_smaps.cc @@ -16,6 +16,7 @@ #include <stdint.h> #include <algorithm> +#include <iostream> #include <string> #include <utility> #include <vector> @@ -172,7 +173,7 @@ PosixErrorOr<std::vector<ProcPidSmapsEntry>> ParseProcPidSmaps( return; } unknown_fields.insert(std::string(key)); - LOG(INFO) << "skipping unknown smaps field " << key; + std::cerr << "skipping unknown smaps field " << key; }; auto lines = absl::StrSplit(contents, '\n', absl::SkipEmpty()); @@ -189,8 +190,8 @@ PosixErrorOr<std::vector<ProcPidSmapsEntry>> ParseProcPidSmaps( // "key:value" (where value in practice will be preceded by a variable // amount of whitespace). if (!entry) { - LOG(WARNING) << "smaps line not considered a maps line: " - << maybe_maps_entry.error_message(); + std::cerr << "smaps line not considered a maps line: " + << maybe_maps_entry.error_message(); return PosixError( EINVAL, absl::StrCat("smaps field line without preceding maps line: ", l)); diff --git a/test/syscalls/linux/ptrace.cc b/test/syscalls/linux/ptrace.cc index 668d49128..7927b1697 100644 --- a/test/syscalls/linux/ptrace.cc +++ b/test/syscalls/linux/ptrace.cc @@ -22,6 +22,7 @@ #include <sys/wait.h> #include <unistd.h> +#include <iostream> #include <utility> #include "gmock/gmock.h" @@ -1188,7 +1189,7 @@ TEST(PtraceTest, SeizeSetOptions) { // gVisor is not susceptible to this race because // kernel.Task.waitCollectTraceeStopLocked() checks specifically for an // active ptraceStop, which is not initiated if SIGKILL is pending. - LOG(INFO) << "Observed syscall-exit after SIGKILL"; + std::cout << "Observed syscall-exit after SIGKILL"; ASSERT_THAT(waitpid(child_pid, &status, 0), SyscallSucceedsWithValue(child_pid)); } diff --git a/test/syscalls/linux/sendfile_socket.cc b/test/syscalls/linux/sendfile_socket.cc index 7010dc211..e2ccf17ce 100644 --- a/test/syscalls/linux/sendfile_socket.cc +++ b/test/syscalls/linux/sendfile_socket.cc @@ -17,6 +17,8 @@ #include <sys/sendfile.h> #include <sys/socket.h> #include <unistd.h> + +#include <iostream> #include <vector> #include "gtest/gtest.h" @@ -110,7 +112,7 @@ TEST(SendFileTest, SendMultiple) { addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_port = server_addr.sin_port; - LOG(INFO) << "Connecting on port=" << server_addr.sin_port; + std::cout << "Connecting on port=" << server_addr.sin_port; ASSERT_THAT( RetryEINTR(connect)( outf.get(), reinterpret_cast<struct sockaddr *>(&addr), sizeof(addr)), @@ -119,7 +121,7 @@ TEST(SendFileTest, SendMultiple) { int cnt = 0; for (size_t sent = 0; sent < data.size(); cnt++) { const size_t remain = data.size() - sent; - LOG(INFO) << "sendfile, size=" << data.size() << ", sent=" << sent + std::cout << "sendfile, size=" << data.size() << ", sent=" << sent << ", remain=" << remain; // Send data and verify that sendfile returns the correct value. diff --git a/test/syscalls/linux/socket_inet_loopback.cc b/test/syscalls/linux/socket_inet_loopback.cc index 4195e402c..a079b85dd 100644 --- a/test/syscalls/linux/socket_inet_loopback.cc +++ b/test/syscalls/linux/socket_inet_loopback.cc @@ -18,6 +18,7 @@ #include <sys/socket.h> #include <atomic> +#include <iostream> #include <memory> #include <string> #include <tuple> @@ -1025,7 +1026,7 @@ TEST_P(SocketMultiProtocolInetLoopbackTest, PortReuseTwoSockets) { setsockopt(fd2, SOL_SOCKET, SO_REUSEPORT, &portreuse2, sizeof(int)), SyscallSucceeds()); - LOG(INFO) << portreuse1 << " " << portreuse2; + std::cout << portreuse1 << " " << portreuse2; int ret = bind(fd2, reinterpret_cast<sockaddr*>(&addr), addrlen); // Verify that two sockets can be bound to the same port only if diff --git a/test/syscalls/linux/socket_netlink_route.cc b/test/syscalls/linux/socket_netlink_route.cc index fa895d841..50943d384 100644 --- a/test/syscalls/linux/socket_netlink_route.cc +++ b/test/syscalls/linux/socket_netlink_route.cc @@ -18,6 +18,8 @@ #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> + +#include <iostream> #include <vector> #include "gtest/gtest.h" @@ -210,7 +212,7 @@ TEST(NetlinkRouteTest, GetLinkDump) { ASSERT_GE(hdr->nlmsg_len, NLMSG_SPACE(sizeof(struct ifinfomsg))); const struct ifinfomsg* msg = reinterpret_cast<const struct ifinfomsg*>(NLMSG_DATA(hdr)); - LOG(INFO) << "Found interface idx=" << msg->ifi_index + std::cout << "Found interface idx=" << msg->ifi_index << ", type=" << std::hex << msg->ifi_type; if (msg->ifi_type == ARPHRD_LOOPBACK) { loopbackFound = true; diff --git a/test/syscalls/linux/socket_unix_non_stream.cc b/test/syscalls/linux/socket_unix_non_stream.cc index a84939011..8e0cbee4c 100644 --- a/test/syscalls/linux/socket_unix_non_stream.cc +++ b/test/syscalls/linux/socket_unix_non_stream.cc @@ -138,9 +138,7 @@ TEST_P(UnixNonStreamSocketPairTest, FragmentedSendMsg) { // // TODO: When internal UDS support SO_SNDBUF, we can assert that // we always get the right SO_SNDBUF on gVisor. - LOG(INFO) << "SO_SNDBUF = " << actual_sndbuf << ", want " << sndbuf - << ". Skipping test"; - return; + GTEST_SKIP() << "SO_SNDBUF = " << actual_sndbuf << ", want " << sndbuf; } // Create a contiguous region of memory of 2*UIO_MAXIOV*PAGE_SIZE. We'll call @@ -196,9 +194,7 @@ TEST_P(UnixNonStreamSocketPairTest, FragmentedRecvMsg) { // // TODO: When internal UDS support SO_SNDBUF, we can assert that // we always get the right SO_SNDBUF on gVisor. - LOG(INFO) << "SO_SNDBUF = " << actual_sndbuf << ", want " << sndbuf - << ". Skipping test"; - return; + GTEST_SKIP() << "SO_SNDBUF = " << actual_sndbuf << ", want " << sndbuf; } std::vector<char> write_buf(buffer_size, 'a'); diff --git a/test/util/BUILD b/test/util/BUILD index fac0730b4..a4b47de56 100644 --- a/test/util/BUILD +++ b/test/util/BUILD @@ -226,7 +226,6 @@ cc_library( "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/time", - "@com_google_glog//:glog", "@com_google_googletest//:gtest", ], ) diff --git a/test/util/capability_util.cc b/test/util/capability_util.cc index 0656775d6..d1dd95e76 100644 --- a/test/util/capability_util.cc +++ b/test/util/capability_util.cc @@ -19,6 +19,8 @@ #include <sys/mman.h> #include <sys/wait.h> +#include <iostream> + #include "absl/strings/str_cat.h" #include "test/util/memory_util.h" #include "test/util/posix_error.h" @@ -61,13 +63,13 @@ PosixErrorOr<bool> CanCreateUserNamespace() { // is in a chroot environment (i.e., the caller's root directory does // not match the root directory of the mount namespace in which it // resides)." - LOG(INFO) << "clone(CLONE_NEWUSER) failed with EPERM"; + std::cerr << "clone(CLONE_NEWUSER) failed with EPERM"; return false; } else if (errno == EUSERS) { // "(since Linux 3.11) CLONE_NEWUSER was specified in flags, and the call // would cause the limit on the number of nested user namespaces to be // exceeded. See user_namespaces(7)." - LOG(INFO) << "clone(CLONE_NEWUSER) failed with EUSERS"; + std::cerr << "clone(CLONE_NEWUSER) failed with EUSERS"; return false; } else { // Unexpected error code; indicate an actual error. diff --git a/test/util/proc_util.cc b/test/util/proc_util.cc index 7ebce0759..2d9eb1986 100644 --- a/test/util/proc_util.cc +++ b/test/util/proc_util.cc @@ -15,6 +15,7 @@ #include "test/util/proc_util.h" #include <algorithm> +#include <iostream> #include <vector> #include "absl/strings/ascii.h" @@ -86,7 +87,7 @@ PosixErrorOr<std::vector<ProcMapsEntry>> ParseProcMaps( std::vector<ProcMapsEntry> entries; auto lines = absl::StrSplit(contents, '\n', absl::SkipEmpty()); for (const auto& l : lines) { - LOG(INFO) << "line: " << l; + std::cout << "line: " << l; ASSIGN_OR_RETURN_ERRNO(auto entry, ParseProcMapsLine(l)); entries.push_back(entry); } diff --git a/test/util/temp_path.cc b/test/util/temp_path.cc index 11c14fb1a..48ce82d20 100644 --- a/test/util/temp_path.cc +++ b/test/util/temp_path.cc @@ -15,8 +15,10 @@ #include "test/util/temp_path.h" #include <unistd.h> + #include <atomic> #include <cstdlib> +#include <iostream> #include "gtest/gtest.h" #include "absl/time/clock.h" @@ -52,9 +54,9 @@ void TryDeleteRecursively(std::string const& path) { int undeleted_files = 0; auto status = RecursivelyDelete(path, &undeleted_dirs, &undeleted_files); if (undeleted_dirs || undeleted_files || !status.ok()) { - LOG(WARNING) << path << ": failed to delete " << undeleted_dirs - << " directories and " << undeleted_files - << " files: " << status; + std::cerr << path << ": failed to delete " << undeleted_dirs + << " directories and " << undeleted_files + << " files: " << status; } } } diff --git a/test/util/test_util.cc b/test/util/test_util.cc index ebcbca238..9b7cfa4dc 100644 --- a/test/util/test_util.cc +++ b/test/util/test_util.cc @@ -25,6 +25,7 @@ #include <unistd.h> #include <ctime> +#include <iostream> #include <vector> #include "absl/base/attributes.h" @@ -54,8 +55,8 @@ Platform GvisorPlatform() { if (strcmp(env, "kvm") == 0) { return Platform::kKVM; } - LOG(FATAL) << "unknown platform " << env; - __builtin_unreachable(); + std::cerr << "unknown platform " << env; + abort(); } // Inline cpuid instruction. Preserve %ebx/%rbx register. In PIC compilations @@ -227,7 +228,7 @@ void SleepSafe(absl::Duration duration) { uint64_t Megabytes(uint64_t n) { // Overflow check, upper 20 bits in n shouldn't be set. - CHECK(!(0xfffff00000000000 & n)); + TEST_CHECK(!(0xfffff00000000000 & n)); return n << 20; } diff --git a/test/util/test_util.h b/test/util/test_util.h index 6f2fa4875..905412b24 100644 --- a/test/util/test_util.h +++ b/test/util/test_util.h @@ -186,7 +186,6 @@ #include <vector> #include <gflags/gflags.h> -#include <glog/logging.h> #include "gmock/gmock.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -210,12 +209,9 @@ void TestInit(int* argc, char*** argv); // SKIP_IF may be used to skip a test case. // // These cases are still emitted, but a SKIPPED line will appear. -#define SKIP_IF(expr) \ - do { \ - if (expr) { \ - std::cout << "\033[0;33m[ SKIPPED ]\033[m => " << #expr << std::endl; \ - return; \ - } \ +#define SKIP_IF(expr) \ + do { \ + if (expr) GTEST_SKIP() << #expr; \ } while (0) enum class Platform { |