Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/client/linux/handler/exception_handler_unittest.cc

Issue 1551983002: Fix -Wunused-function warnings in ASAN builds. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 Google Inc. 1 // Copyright (c) 2010 Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 TEST(ExceptionHandlerTest, ChildCrashWithPath) { 257 TEST(ExceptionHandlerTest, ChildCrashWithPath) {
258 ASSERT_NO_FATAL_FAILURE(ChildCrash(false)); 258 ASSERT_NO_FATAL_FAILURE(ChildCrash(false));
259 } 259 }
260 260
261 TEST(ExceptionHandlerTest, ChildCrashWithFD) { 261 TEST(ExceptionHandlerTest, ChildCrashWithFD) {
262 ASSERT_NO_FATAL_FAILURE(ChildCrash(true)); 262 ASSERT_NO_FATAL_FAILURE(ChildCrash(true));
263 } 263 }
264 264
265 #endif // !ADDRESS_SANITIZER
266
267 static bool DoneCallbackReturnFalse(const MinidumpDescriptor& descriptor, 265 static bool DoneCallbackReturnFalse(const MinidumpDescriptor& descriptor,
268 void* context, 266 void* context,
269 bool succeeded) { 267 bool succeeded) {
270 return false; 268 return false;
271 } 269 }
272 270
273 static bool DoneCallbackReturnTrue(const MinidumpDescriptor& descriptor, 271 static bool DoneCallbackReturnTrue(const MinidumpDescriptor& descriptor,
274 void* context, 272 void* context,
275 bool succeeded) { 273 bool succeeded) {
276 return true; 274 return true;
(...skipping 21 matching lines...) Expand all
298 raise(SIGKILL); 296 raise(SIGKILL);
299 } 297 }
300 298
301 static bool InstallRaiseSIGKILL() { 299 static bool InstallRaiseSIGKILL() {
302 struct sigaction sa; 300 struct sigaction sa;
303 memset(&sa, 0, sizeof(sa)); 301 memset(&sa, 0, sizeof(sa));
304 sa.sa_handler = RaiseSIGKILL; 302 sa.sa_handler = RaiseSIGKILL;
305 return sigaction(SIGSEGV, &sa, NULL) != -1; 303 return sigaction(SIGSEGV, &sa, NULL) != -1;
306 } 304 }
307 305
308 #ifndef ADDRESS_SANITIZER
309
310 static void CrashWithCallbacks(ExceptionHandler::FilterCallback filter, 306 static void CrashWithCallbacks(ExceptionHandler::FilterCallback filter,
311 ExceptionHandler::MinidumpCallback done, 307 ExceptionHandler::MinidumpCallback done,
312 string path) { 308 string path) {
313 ExceptionHandler handler( 309 ExceptionHandler handler(
314 MinidumpDescriptor(path), filter, done, NULL, true, -1); 310 MinidumpDescriptor(path), filter, done, NULL, true, -1);
315 // Crash with the exception handler in scope. 311 // Crash with the exception handler in scope.
316 DoNullPointerDereference(); 312 DoNullPointerDereference();
317 } 313 }
318 314
319 TEST(ExceptionHandlerTest, RedeliveryOnFilterCallbackFalse) { 315 TEST(ExceptionHandlerTest, RedeliveryOnFilterCallbackFalse) {
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 ASSERT_TRUE(module); 867 ASSERT_TRUE(module);
872 868
873 EXPECT_EQ(kMemoryAddress, module->base_address()); 869 EXPECT_EQ(kMemoryAddress, module->base_address());
874 EXPECT_EQ(kMemorySize, module->size()); 870 EXPECT_EQ(kMemorySize, module->size());
875 EXPECT_EQ(kMemoryName, module->code_file()); 871 EXPECT_EQ(kMemoryName, module->code_file());
876 EXPECT_EQ(module_identifier, module->debug_identifier()); 872 EXPECT_EQ(module_identifier, module->debug_identifier());
877 873
878 unlink(minidump_desc.path()); 874 unlink(minidump_desc.path());
879 } 875 }
880 876
877 #ifndef ADDRESS_SANITIZER
878
881 static const unsigned kControlMsgSize = 879 static const unsigned kControlMsgSize =
882 CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(struct ucred)); 880 CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(struct ucred));
883 881
884 static bool 882 static bool
885 CrashHandler(const void* crash_context, size_t crash_context_size, 883 CrashHandler(const void* crash_context, size_t crash_context_size,
886 void* context) { 884 void* context) {
887 const int fd = (intptr_t) context; 885 const int fd = (intptr_t) context;
888 int fds[2]; 886 int fds[2];
889 if (pipe(fds) == -1) { 887 if (pipe(fds) == -1) {
890 // There doesn't seem to be any way to reliably handle 888 // There doesn't seem to be any way to reliably handle
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 sys_close(fds[1]); 921 sys_close(fds[1]);
924 if (ret <= 0) 922 if (ret <= 0)
925 return false; 923 return false;
926 924
927 char b; 925 char b;
928 IGNORE_RET(HANDLE_EINTR(sys_read(fds[0], &b, 1))); 926 IGNORE_RET(HANDLE_EINTR(sys_read(fds[0], &b, 1)));
929 927
930 return true; 928 return true;
931 } 929 }
932 930
933 #ifndef ADDRESS_SANITIZER
934
935 TEST(ExceptionHandlerTest, ExternalDumper) { 931 TEST(ExceptionHandlerTest, ExternalDumper) {
936 int fds[2]; 932 int fds[2];
937 ASSERT_NE(socketpair(AF_UNIX, SOCK_DGRAM, 0, fds), -1); 933 ASSERT_NE(socketpair(AF_UNIX, SOCK_DGRAM, 0, fds), -1);
938 static const int on = 1; 934 static const int on = 1;
939 setsockopt(fds[0], SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); 935 setsockopt(fds[0], SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
940 setsockopt(fds[1], SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); 936 setsockopt(fds[1], SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
941 937
942 const pid_t child = fork(); 938 const pid_t child = fork();
943 if (child == 0) { 939 if (child == 0) {
944 close(fds[0]); 940 close(fds[0]);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 EXPECT_EQ(child, static_cast<int32_t>(thread_id)); 1187 EXPECT_EQ(child, static_cast<int32_t>(thread_id));
1192 1188
1193 const MDRawExceptionStream* raw = exception->exception(); 1189 const MDRawExceptionStream* raw = exception->exception();
1194 ASSERT_TRUE(raw); 1190 ASSERT_TRUE(raw);
1195 EXPECT_EQ(MD_EXCEPTION_CODE_LIN_DUMP_REQUESTED, 1191 EXPECT_EQ(MD_EXCEPTION_CODE_LIN_DUMP_REQUESTED,
1196 raw->exception_record.exception_code); 1192 raw->exception_record.exception_code);
1197 1193
1198 close(fds[1]); 1194 close(fds[1]);
1199 unlink(minidump_filename.c_str()); 1195 unlink(minidump_filename.c_str());
1200 } 1196 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698