Skip to content

Commit 7005772

Browse files
committed
[NFC][sanitizer] Clang format sanitizer_linux_test.cpp
1 parent b78d4c1 commit 7005772

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp

+28-30
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@
1313
#include "sanitizer_common/sanitizer_platform.h"
1414
#if SANITIZER_LINUX
1515

16-
#include "sanitizer_common/sanitizer_linux.h"
16+
# include <pthread.h>
17+
# include <sched.h>
18+
# include <stdlib.h>
1719

18-
#include "sanitizer_common/sanitizer_common.h"
19-
#include "sanitizer_common/sanitizer_file.h"
20-
#include "gtest/gtest.h"
20+
# include <algorithm>
21+
# include <vector>
2122

22-
#include <pthread.h>
23-
#include <sched.h>
24-
#include <stdlib.h>
25-
26-
#include <algorithm>
27-
#include <vector>
23+
# include "gtest/gtest.h"
24+
# include "sanitizer_common/sanitizer_common.h"
25+
# include "sanitizer_common/sanitizer_file.h"
26+
# include "sanitizer_common/sanitizer_linux.h"
2827

2928
namespace __sanitizer {
3029

@@ -109,9 +108,8 @@ void *TidReporterThread(void *argument) {
109108
void ThreadListerTest::SpawnTidReporter(pthread_t *pthread_id, tid_t *tid) {
110109
pthread_mutex_lock(&thread_arg.tid_reported_mutex);
111110
thread_arg.reported_tid = -1;
112-
ASSERT_EQ(0, pthread_create(pthread_id, NULL,
113-
TidReporterThread,
114-
&thread_arg));
111+
ASSERT_EQ(0,
112+
pthread_create(pthread_id, NULL, TidReporterThread, &thread_arg));
115113
while (thread_arg.reported_tid == (tid_t)(-1))
116114
pthread_cond_wait(&thread_arg.tid_reported_cond,
117115
&thread_arg.tid_reported_mutex);
@@ -129,8 +127,8 @@ static std::vector<tid_t> ReadTidsToVector(ThreadLister *thread_lister) {
129127
static bool Includes(std::vector<tid_t> first, std::vector<tid_t> second) {
130128
std::sort(first.begin(), first.end());
131129
std::sort(second.begin(), second.end());
132-
return std::includes(first.begin(), first.end(),
133-
second.begin(), second.end());
130+
return std::includes(first.begin(), first.end(), second.begin(),
131+
second.end());
134132
}
135133

136134
static bool HasElement(const std::vector<tid_t> &vector, tid_t element) {
@@ -187,7 +185,7 @@ TEST(SanitizerCommon, SetEnvTest) {
187185
EXPECT_EQ(0, getenv(kEnvName));
188186
}
189187

190-
#if (defined(__x86_64__) || defined(__i386__)) && !SANITIZER_ANDROID
188+
# if (defined(__x86_64__) || defined(__i386__)) && !SANITIZER_ANDROID
191189
// libpthread puts the thread descriptor at the end of stack space.
192190
void *thread_descriptor_size_test_func(void *arg) {
193191
uptr descr_addr = (uptr)pthread_self();
@@ -206,48 +204,48 @@ TEST(SanitizerLinux, ThreadDescriptorSize) {
206204
ASSERT_EQ(0, pthread_join(tid, &result));
207205
EXPECT_EQ((uptr)result, ThreadDescriptorSize());
208206
}
209-
#endif
207+
# endif
210208

211209
TEST(SanitizerCommon, LibraryNameIs) {
212210
EXPECT_FALSE(LibraryNameIs("", ""));
213211

214212
char full_name[256];
215-
const char *paths[] = { "", "/", "/path/to/" };
216-
const char *suffixes[] = { "", "-linux", ".1.2", "-linux.1.2" };
217-
const char *base_names[] = { "lib", "lib.0", "lib-i386" };
218-
const char *wrong_names[] = { "", "lib.9", "lib-x86_64" };
213+
const char *paths[] = {"", "/", "/path/to/"};
214+
const char *suffixes[] = {"", "-linux", ".1.2", "-linux.1.2"};
215+
const char *base_names[] = {"lib", "lib.0", "lib-i386"};
216+
const char *wrong_names[] = {"", "lib.9", "lib-x86_64"};
219217
for (uptr i = 0; i < ARRAY_SIZE(paths); i++)
220218
for (uptr j = 0; j < ARRAY_SIZE(suffixes); j++) {
221219
for (uptr k = 0; k < ARRAY_SIZE(base_names); k++) {
222220
internal_snprintf(full_name, ARRAY_SIZE(full_name), "%s%s%s.so",
223221
paths[i], base_names[k], suffixes[j]);
224222
EXPECT_TRUE(LibraryNameIs(full_name, base_names[k]))
225-
<< "Full name " << full_name
226-
<< " doesn't match base name " << base_names[k];
223+
<< "Full name " << full_name << " doesn't match base name "
224+
<< base_names[k];
227225
for (uptr m = 0; m < ARRAY_SIZE(wrong_names); m++)
228226
EXPECT_FALSE(LibraryNameIs(full_name, wrong_names[m]))
229-
<< "Full name " << full_name
230-
<< " matches base name " << wrong_names[m];
227+
<< "Full name " << full_name << " matches base name "
228+
<< wrong_names[m];
231229
}
232230
}
233231
}
234232

235-
#if defined(__mips64)
233+
# if defined(__mips64)
236234
// Effectively, this is a test for ThreadDescriptorSize() which is used to
237235
// compute ThreadSelf().
238236
TEST(SanitizerLinux, ThreadSelfTest) {
239237
ASSERT_EQ(pthread_self(), ThreadSelf());
240238
}
241-
#endif
239+
# endif
242240

243241
TEST(SanitizerCommon, StartSubprocessTest) {
244242
int pipe_fds[2];
245243
ASSERT_EQ(0, pipe(pipe_fds));
246-
#if SANITIZER_ANDROID
244+
# if SANITIZER_ANDROID
247245
const char *shell = "/system/bin/sh";
248-
#else
246+
# else
249247
const char *shell = "/bin/sh";
250-
#endif
248+
# endif
251249
const char *argv[] = {shell, "-c", "echo -n 'hello'", (char *)NULL};
252250
int pid = StartSubprocess(shell, argv, GetEnviron(),
253251
/* stdin */ kInvalidFd, /* stdout */ pipe_fds[1]);

0 commit comments

Comments
 (0)