mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Remove syscall tests' dependency on glog
PiperOrigin-RevId: 245469859 Change-Id: I0610e477cc3a884275852e83028ecfb501f2c039
This commit is contained in:
committed by
Shentubot
parent
5f13338d30
commit
59442238d4
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -103,7 +103,6 @@ TEST(ConcurrencyTest, MultiProcessConcurrency) {
|
||||
if (child_pid == 0) {
|
||||
while (true) {
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
ASSERT_THAT(child_pid, SyscallSucceeds());
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user