summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2017-04-27 21:48:44 -0500
committerJosh Gao2017-12-19 19:16:12 -0600
commit30171a8b475df2989276f65dcc80fbaa786e1fba (patch)
treece803dcca3337951975fa15c1d5759a313849f57 /debuggerd
parent51c2088f3be507f83c7580dd06c5e3c271116285 (diff)
downloadplatform-system-core-30171a8b475df2989276f65dcc80fbaa786e1fba.tar.gz
platform-system-core-30171a8b475df2989276f65dcc80fbaa786e1fba.tar.xz
platform-system-core-30171a8b475df2989276f65dcc80fbaa786e1fba.zip
base: extract {ASSERT,EXPECT}_MATCH helpers from debuggerd_test.
Add some helper macros that perform regex string matching to <android-base/test_utils.h>. Test: libbase_test32/64 on host Change-Id: I1b0f03dc73f8b4fdfb8ac6c75d59ef421e0e9640
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/debuggerd_test.cpp17
1 files changed, 1 insertions, 16 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index 0d17a3b5c..939f4d257 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -36,6 +36,7 @@
36#include <android-base/parseint.h> 36#include <android-base/parseint.h>
37#include <android-base/properties.h> 37#include <android-base/properties.h>
38#include <android-base/strings.h> 38#include <android-base/strings.h>
39#include <android-base/test_utils.h>
39#include <android-base/unique_fd.h> 40#include <android-base/unique_fd.h>
40#include <cutils/sockets.h> 41#include <cutils/sockets.h>
41#include <gtest/gtest.h> 42#include <gtest/gtest.h>
@@ -75,22 +76,6 @@ constexpr char kWaitForGdbKey[] = "debug.debuggerd.wait_for_gdb";
75 return value; \ 76 return value; \
76 }() 77 }()
77 78
78#define ASSERT_MATCH(str, pattern) \
79 do { \
80 std::regex r((pattern)); \
81 if (!std::regex_search((str), r)) { \
82 FAIL() << "regex mismatch: expected " << (pattern) << " in: \n" << (str); \
83 } \
84 } while (0)
85
86#define ASSERT_NOT_MATCH(str, pattern) \
87 do { \
88 std::regex r((pattern)); \
89 if (std::regex_search((str), r)) { \
90 FAIL() << "regex mismatch: expected to not find " << (pattern) << " in: \n" << (str); \
91 } \
92 } while (0)
93
94#define ASSERT_BACKTRACE_FRAME(result, frame_name) \ 79#define ASSERT_BACKTRACE_FRAME(result, frame_name) \
95 ASSERT_MATCH(result, R"(#\d\d pc [0-9a-f]+\s+ /system/lib)" ARCH_SUFFIX \ 80 ASSERT_MATCH(result, R"(#\d\d pc [0-9a-f]+\s+ /system/lib)" ARCH_SUFFIX \
96 R"(/libc.so \()" frame_name R"(\+)") 81 R"(/libc.so \()" frame_name R"(\+)")