summaryrefslogtreecommitdiffhomepage
path: root/test/util
diff options
context:
space:
mode:
Diffstat (limited to 'test/util')
-rw-r--r--test/util/fs_util.cc6
-rw-r--r--test/util/fs_util.h20
-rw-r--r--test/util/fs_util_test.cc9
-rw-r--r--test/util/logging.cc2
-rw-r--r--test/util/mount_util.h6
-rw-r--r--test/util/posix_error.h2
-rw-r--r--test/util/proc_util.cc3
-rw-r--r--test/util/temp_path.cc7
-rw-r--r--test/util/temp_path.h4
-rw-r--r--test/util/test_util.cc5
10 files changed, 37 insertions, 27 deletions
diff --git a/test/util/fs_util.cc b/test/util/fs_util.cc
index bc90bd78e..ae49725a0 100644
--- a/test/util/fs_util.cc
+++ b/test/util/fs_util.cc
@@ -290,7 +290,7 @@ PosixError WalkTree(
}
PosixErrorOr<std::vector<std::string>> ListDir(absl::string_view abspath,
- bool skipdots) {
+ bool skipdots) {
std::vector<std::string> files;
DIR* dir = opendir(std::string(abspath).c_str());
@@ -381,7 +381,7 @@ PosixError RecursivelyCreateDir(absl::string_view path) {
// Makes a path absolute with respect to an optional base. If no base is
// provided it will use the current working directory.
PosixErrorOr<std::string> MakeAbsolute(absl::string_view filename,
- absl::string_view base) {
+ absl::string_view base) {
if (filename.empty()) {
return PosixError(EINVAL, "filename cannot be empty.");
}
@@ -494,7 +494,7 @@ std::string CleanPath(const absl::string_view unclean_path) {
}
PosixErrorOr<std::string> GetRelativePath(absl::string_view source,
- absl::string_view dest) {
+ absl::string_view dest) {
if (!absl::StartsWith(source, "/") || !absl::StartsWith(dest, "/")) {
// At least one of the inputs is not an absolute path.
return PosixError(
diff --git a/test/util/fs_util.h b/test/util/fs_util.h
index eb7cdaa24..3969f8309 100644
--- a/test/util/fs_util.h
+++ b/test/util/fs_util.h
@@ -61,7 +61,7 @@ PosixError SetContents(absl::string_view path, absl::string_view contents);
PosixError CreateWithContents(absl::string_view path,
absl::string_view contents, int mode = 0666);
-// Attempts to read the entire contents of the file into the provided std::string
+// Attempts to read the entire contents of the file into the provided string
// buffer or returns an error.
PosixError GetContents(absl::string_view path, std::string* output);
@@ -69,7 +69,7 @@ PosixError GetContents(absl::string_view path, std::string* output);
PosixErrorOr<std::string> GetContents(absl::string_view path);
// Attempts to read the entire contents of the provided fd into the provided
-// std::string or returns an error.
+// string or returns an error.
PosixError GetContentsFD(int fd, std::string* output);
// Attempts to read the entire contents of the provided fd or returns an error.
@@ -94,7 +94,7 @@ PosixError WalkTree(
// method does not walk the tree recursively it only returns the elements
// in that directory.
PosixErrorOr<std::vector<std::string>> ListDir(absl::string_view abspath,
- bool skipdots);
+ bool skipdots);
// Attempt to recursively delete a directory or file. Returns an error and
// the number of undeleted directories and files. If either
@@ -108,20 +108,20 @@ PosixError RecursivelyCreateDir(absl::string_view path);
// Makes a path absolute with respect to an optional base. If no base is
// provided it will use the current working directory.
PosixErrorOr<std::string> MakeAbsolute(absl::string_view filename,
- absl::string_view base);
+ absl::string_view base);
// Generates a relative path from the source directory to the destination
// (dest) file or directory. This uses ../ when necessary for destinations
// which are not nested within the source. Both source and dest are required
-// to be absolute paths, and an empty std::string will be returned if they are not.
+// to be absolute paths, and an empty string will be returned if they are not.
PosixErrorOr<std::string> GetRelativePath(absl::string_view source,
- absl::string_view dest);
+ absl::string_view dest);
// Returns the part of the path before the final "/", EXCEPT:
// * If there is a single leading "/" in the path, the result will be the
// leading "/".
// * If there is no "/" in the path, the result is the empty prefix of the
-// input std::string.
+// input string.
absl::string_view Dirname(absl::string_view path);
// Return the parts of the path, split on the final "/". If there is no
@@ -135,7 +135,7 @@ std::pair<absl::string_view, absl::string_view> SplitPath(
// "/" in the path, the result is the same as the input.
// Note that this function's behavior differs from the Unix basename
// command if path ends with "/". For such paths, this function returns the
-// empty std::string.
+// empty string.
absl::string_view Basename(absl::string_view path);
// Collapse duplicate "/"s, resolve ".." and "." path elements, remove
@@ -144,7 +144,7 @@ absl::string_view Basename(absl::string_view path);
// NOTE: This respects relative vs. absolute paths, but does not
// invoke any system calls (getcwd(2)) in order to resolve relative
// paths wrt actual working directory. That is, this is purely a
-// std::string manipulation, completely independent of process state.
+// string manipulation, completely independent of process state.
std::string CleanPath(absl::string_view path);
// Returns the full path to the executable of the given pid or a PosixError.
@@ -174,7 +174,7 @@ inline std::string JoinPath(absl::string_view path) {
std::string JoinPath(absl::string_view path1, absl::string_view path2);
template <typename... T>
inline std::string JoinPath(absl::string_view path1, absl::string_view path2,
- absl::string_view path3, const T&... args) {
+ absl::string_view path3, const T&... args) {
return internal::JoinPathImpl({path1, path2, path3, args...});
}
} // namespace testing
diff --git a/test/util/fs_util_test.cc b/test/util/fs_util_test.cc
index 4e12076a1..2a200320a 100644
--- a/test/util/fs_util_test.cc
+++ b/test/util/fs_util_test.cc
@@ -29,7 +29,8 @@ namespace {
TEST(FsUtilTest, RecursivelyCreateDirManualDelete) {
const TempPath root = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());
- const std::string base_path = JoinPath(root.path(), "/a/b/c/d/e/f/g/h/i/j/k/l/m");
+ const std::string base_path =
+ JoinPath(root.path(), "/a/b/c/d/e/f/g/h/i/j/k/l/m");
ASSERT_THAT(Exists(base_path), IsPosixErrorOkAndHolds(false));
ASSERT_NO_ERRNO(RecursivelyCreateDir(base_path));
@@ -48,7 +49,8 @@ TEST(FsUtilTest, RecursivelyCreateDirManualDelete) {
TEST(FsUtilTest, RecursivelyCreateAndDeleteDir) {
const TempPath root = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());
- const std::string base_path = JoinPath(root.path(), "/a/b/c/d/e/f/g/h/i/j/k/l/m");
+ const std::string base_path =
+ JoinPath(root.path(), "/a/b/c/d/e/f/g/h/i/j/k/l/m");
ASSERT_THAT(Exists(base_path), IsPosixErrorOkAndHolds(false));
ASSERT_NO_ERRNO(RecursivelyCreateDir(base_path));
@@ -60,7 +62,8 @@ TEST(FsUtilTest, RecursivelyCreateAndDeleteDir) {
TEST(FsUtilTest, RecursivelyCreateAndDeletePartial) {
const TempPath root = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());
- const std::string base_path = JoinPath(root.path(), "/a/b/c/d/e/f/g/h/i/j/k/l/m");
+ const std::string base_path =
+ JoinPath(root.path(), "/a/b/c/d/e/f/g/h/i/j/k/l/m");
ASSERT_THAT(Exists(base_path), IsPosixErrorOkAndHolds(false));
ASSERT_NO_ERRNO(RecursivelyCreateDir(base_path));
diff --git a/test/util/logging.cc b/test/util/logging.cc
index cc71d77b0..5d5e76c46 100644
--- a/test/util/logging.cc
+++ b/test/util/logging.cc
@@ -50,7 +50,7 @@ int WriteNumber(int fd, uint32_t val) {
constexpr int kBufferSize = 11;
char buf[kBufferSize];
- // Convert the number to std::string.
+ // Convert the number to string.
char* s = buf + sizeof(buf) - 1;
size_t size = 0;
diff --git a/test/util/mount_util.h b/test/util/mount_util.h
index 7782e6bf2..38ec6c8a1 100644
--- a/test/util/mount_util.h
+++ b/test/util/mount_util.h
@@ -30,9 +30,11 @@ namespace testing {
// Mount mounts the filesystem, and unmounts when the returned reference is
// destroyed.
-inline PosixErrorOr<Cleanup> Mount(const std::string &source, const std::string &target,
+inline PosixErrorOr<Cleanup> Mount(const std::string &source,
+ const std::string &target,
const std::string &fstype, uint64_t mountflags,
- const std::string &data, uint64_t umountflags) {
+ const std::string &data,
+ uint64_t umountflags) {
if (mount(source.c_str(), target.c_str(), fstype.c_str(), mountflags,
data.c_str()) == -1) {
return PosixError(errno, "mount failed");
diff --git a/test/util/posix_error.h b/test/util/posix_error.h
index b604f4f8f..ad666bce0 100644
--- a/test/util/posix_error.h
+++ b/test/util/posix_error.h
@@ -51,7 +51,7 @@ class ABSL_MUST_USE_RESULT PosixError {
std::string error_message() const { return msg_; }
- // ToString produces a full std::string representation of this posix error
+ // ToString produces a full string representation of this posix error
// including the printable representation of the errno and the error message.
std::string ToString() const;
diff --git a/test/util/proc_util.cc b/test/util/proc_util.cc
index 9d4db37c3..75b24da37 100644
--- a/test/util/proc_util.cc
+++ b/test/util/proc_util.cc
@@ -76,7 +76,8 @@ PosixErrorOr<ProcMapsEntry> ParseProcMapsLine(absl::string_view line) {
if (parts.size() == 6) {
// A filename is present. However, absl::StrSplit retained the whitespace
// between the inode number and the filename.
- map_entry.filename = std::string(absl::StripLeadingAsciiWhitespace(parts[5]));
+ map_entry.filename =
+ std::string(absl::StripLeadingAsciiWhitespace(parts[5]));
}
return map_entry;
diff --git a/test/util/temp_path.cc b/test/util/temp_path.cc
index de7c04a6f..35aacb172 100644
--- a/test/util/temp_path.cc
+++ b/test/util/temp_path.cc
@@ -70,13 +70,16 @@ std::string NewTempAbsPathInDir(absl::string_view const dir) {
return JoinPath(dir, NextTempBasename());
}
-std::string NewTempAbsPath() { return NewTempAbsPathInDir(GetAbsoluteTestTmpdir()); }
+std::string NewTempAbsPath() {
+ return NewTempAbsPathInDir(GetAbsoluteTestTmpdir());
+}
std::string NewTempRelPath() { return NextTempBasename(); }
std::string GetAbsoluteTestTmpdir() {
char* env_tmpdir = getenv("TEST_TMPDIR");
- std::string tmp_dir = env_tmpdir != nullptr ? std::string(env_tmpdir) : "/tmp";
+ std::string tmp_dir =
+ env_tmpdir != nullptr ? std::string(env_tmpdir) : "/tmp";
return MakeAbsolute(tmp_dir, "").ValueOrDie();
}
diff --git a/test/util/temp_path.h b/test/util/temp_path.h
index 89302e0fd..92d669503 100644
--- a/test/util/temp_path.h
+++ b/test/util/temp_path.h
@@ -30,7 +30,7 @@ namespace testing {
// Distinct calls to NewTempAbsPathInDir from the same process, even from
// multiple threads, are guaranteed to return different paths. Distinct calls to
// NewTempAbsPathInDir from different processes are not synchronized.
-std::string NewTempAbsPathInDir(absl::string_view base);
+std::string NewTempAbsPathInDir(absl::string_view const dir);
// Like NewTempAbsPathInDir, but the returned path is in the test's temporary
// directory, as provided by the testing framework.
@@ -105,7 +105,7 @@ class TempPath {
// Changes the path this TempPath represents. If the TempPath already
// represented a path, deletes and returns that path. Otherwise returns the
- // empty std::string.
+ // empty string.
std::string reset(std::string newpath);
std::string reset() { return reset(""); }
diff --git a/test/util/test_util.cc b/test/util/test_util.cc
index bf0029951..e42bba04a 100644
--- a/test/util/test_util.cc
+++ b/test/util/test_util.cc
@@ -73,7 +73,7 @@ Platform GvisorPlatform() {
CPUVendor GetCPUVendor() {
uint32_t eax, ebx, ecx, edx;
std::string vendor_str;
- // Get vendor std::string (issue CPUID with eax = 0)
+ // Get vendor string (issue CPUID with eax = 0)
GETCPUID(eax, ebx, ecx, edx, 0, 0);
vendor_str.append(reinterpret_cast<char*>(&ebx), 4);
vendor_str.append(reinterpret_cast<char*>(&edx), 4);
@@ -93,7 +93,8 @@ bool operator==(const KernelVersion& first, const KernelVersion& second) {
PosixErrorOr<KernelVersion> ParseKernelVersion(absl::string_view vers_str) {
KernelVersion version = {};
- std::vector<std::string> values = absl::StrSplit(vers_str, absl::ByAnyChar(".-"));
+ std::vector<std::string> values =
+ absl::StrSplit(vers_str, absl::ByAnyChar(".-"));
if (values.size() == 2) {
ASSIGN_OR_RETURN_ERRNO(version.major, Atoi<int>(values[0]));
ASSIGN_OR_RETURN_ERRNO(version.minor, Atoi<int>(values[1]));