[NFC][sanitizer] Clang format sanitizer_linux_test.cpp
GitOrigin-RevId: 7005772e453423e424f49f04d1f5dd96acc08249
diff --git a/lib/sanitizer_common/tests/sanitizer_linux_test.cpp b/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
index 025cba9..338c4d3 100644
--- a/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
+++ b/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
@@ -13,18 +13,17 @@
#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_LINUX
-#include "sanitizer_common/sanitizer_linux.h"
+# include <pthread.h>
+# include <sched.h>
+# include <stdlib.h>
-#include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_file.h"
-#include "gtest/gtest.h"
+# include <algorithm>
+# include <vector>
-#include <pthread.h>
-#include <sched.h>
-#include <stdlib.h>
-
-#include <algorithm>
-#include <vector>
+# include "gtest/gtest.h"
+# include "sanitizer_common/sanitizer_common.h"
+# include "sanitizer_common/sanitizer_file.h"
+# include "sanitizer_common/sanitizer_linux.h"
namespace __sanitizer {
@@ -109,9 +108,8 @@
void ThreadListerTest::SpawnTidReporter(pthread_t *pthread_id, tid_t *tid) {
pthread_mutex_lock(&thread_arg.tid_reported_mutex);
thread_arg.reported_tid = -1;
- ASSERT_EQ(0, pthread_create(pthread_id, NULL,
- TidReporterThread,
- &thread_arg));
+ ASSERT_EQ(0,
+ pthread_create(pthread_id, NULL, TidReporterThread, &thread_arg));
while (thread_arg.reported_tid == (tid_t)(-1))
pthread_cond_wait(&thread_arg.tid_reported_cond,
&thread_arg.tid_reported_mutex);
@@ -129,8 +127,8 @@
static bool Includes(std::vector<tid_t> first, std::vector<tid_t> second) {
std::sort(first.begin(), first.end());
std::sort(second.begin(), second.end());
- return std::includes(first.begin(), first.end(),
- second.begin(), second.end());
+ return std::includes(first.begin(), first.end(), second.begin(),
+ second.end());
}
static bool HasElement(const std::vector<tid_t> &vector, tid_t element) {
@@ -187,7 +185,7 @@
EXPECT_EQ(0, getenv(kEnvName));
}
-#if (defined(__x86_64__) || defined(__i386__)) && !SANITIZER_ANDROID
+# if (defined(__x86_64__) || defined(__i386__)) && !SANITIZER_ANDROID
// libpthread puts the thread descriptor at the end of stack space.
void *thread_descriptor_size_test_func(void *arg) {
uptr descr_addr = (uptr)pthread_self();
@@ -206,48 +204,48 @@
ASSERT_EQ(0, pthread_join(tid, &result));
EXPECT_EQ((uptr)result, ThreadDescriptorSize());
}
-#endif
+# endif
TEST(SanitizerCommon, LibraryNameIs) {
EXPECT_FALSE(LibraryNameIs("", ""));
char full_name[256];
- const char *paths[] = { "", "/", "/path/to/" };
- const char *suffixes[] = { "", "-linux", ".1.2", "-linux.1.2" };
- const char *base_names[] = { "lib", "lib.0", "lib-i386" };
- const char *wrong_names[] = { "", "lib.9", "lib-x86_64" };
+ const char *paths[] = {"", "/", "/path/to/"};
+ const char *suffixes[] = {"", "-linux", ".1.2", "-linux.1.2"};
+ const char *base_names[] = {"lib", "lib.0", "lib-i386"};
+ const char *wrong_names[] = {"", "lib.9", "lib-x86_64"};
for (uptr i = 0; i < ARRAY_SIZE(paths); i++)
for (uptr j = 0; j < ARRAY_SIZE(suffixes); j++) {
for (uptr k = 0; k < ARRAY_SIZE(base_names); k++) {
internal_snprintf(full_name, ARRAY_SIZE(full_name), "%s%s%s.so",
paths[i], base_names[k], suffixes[j]);
EXPECT_TRUE(LibraryNameIs(full_name, base_names[k]))
- << "Full name " << full_name
- << " doesn't match base name " << base_names[k];
+ << "Full name " << full_name << " doesn't match base name "
+ << base_names[k];
for (uptr m = 0; m < ARRAY_SIZE(wrong_names); m++)
EXPECT_FALSE(LibraryNameIs(full_name, wrong_names[m]))
- << "Full name " << full_name
- << " matches base name " << wrong_names[m];
+ << "Full name " << full_name << " matches base name "
+ << wrong_names[m];
}
}
}
-#if defined(__mips64)
+# if defined(__mips64)
// Effectively, this is a test for ThreadDescriptorSize() which is used to
// compute ThreadSelf().
TEST(SanitizerLinux, ThreadSelfTest) {
ASSERT_EQ(pthread_self(), ThreadSelf());
}
-#endif
+# endif
TEST(SanitizerCommon, StartSubprocessTest) {
int pipe_fds[2];
ASSERT_EQ(0, pipe(pipe_fds));
-#if SANITIZER_ANDROID
+# if SANITIZER_ANDROID
const char *shell = "/system/bin/sh";
-#else
+# else
const char *shell = "/bin/sh";
-#endif
+# endif
const char *argv[] = {shell, "-c", "echo -n 'hello'", (char *)NULL};
int pid = StartSubprocess(shell, argv, GetEnviron(),
/* stdin */ kInvalidFd, /* stdout */ pipe_fds[1]);