summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2018-05-23 11:16:46 -0500
committerElliott Hughes2018-05-23 12:06:20 -0500
commit1be0d1481b26281bf699238d5699b38a52b31382 (patch)
treeabe0ba22d28d621564481ef56040e27534605a11 /base/include/android-base/test_utils.h
parent9f6f8bf0dcb7f08c8c0afc1685f5d1a54b41b4cb (diff)
downloadplatform-system-core-1be0d1481b26281bf699238d5699b38a52b31382.tar.gz
platform-system-core-1be0d1481b26281bf699238d5699b38a52b31382.tar.xz
platform-system-core-1be0d1481b26281bf699238d5699b38a52b31382.zip
Add StdioLogger for command-line tools.
Bug: N/A Test: ran tests Change-Id: If366a4ea25aea1becdd3e443eba225e9bd52ebba
Diffstat (limited to 'base/include/android-base/test_utils.h')
-rw-r--r--base/include/android-base/test_utils.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/base/include/android-base/test_utils.h b/base/include/android-base/test_utils.h
index b95fa07ce..b29676f7c 100644
--- a/base/include/android-base/test_utils.h
+++ b/base/include/android-base/test_utils.h
@@ -58,21 +58,33 @@ class TemporaryDir {
58 DISALLOW_COPY_AND_ASSIGN(TemporaryDir); 58 DISALLOW_COPY_AND_ASSIGN(TemporaryDir);
59}; 59};
60 60
61class CapturedStderr { 61class CapturedStdFd {
62 public: 62 public:
63 CapturedStderr(); 63 CapturedStdFd(int std_fd);
64 ~CapturedStderr(); 64 ~CapturedStdFd();
65 65
66 int fd() const; 66 int fd() const;
67 std::string str();
67 68
68 private: 69 private:
69 void init(); 70 void Init();
70 void reset(); 71 void Reset();
71 72
72 TemporaryFile temp_file_; 73 TemporaryFile temp_file_;
73 int old_stderr_; 74 int std_fd_;
75 int old_fd_;
74 76
75 DISALLOW_COPY_AND_ASSIGN(CapturedStderr); 77 DISALLOW_COPY_AND_ASSIGN(CapturedStdFd);
78};
79
80class CapturedStderr : public CapturedStdFd {
81 public:
82 CapturedStderr() : CapturedStdFd(STDERR_FILENO) {}
83};
84
85class CapturedStdout : public CapturedStdFd {
86 public:
87 CapturedStdout() : CapturedStdFd(STDOUT_FILENO) {}
76}; 88};
77 89
78#define ASSERT_MATCH(str, pattern) \ 90#define ASSERT_MATCH(str, pattern) \