diff options
author | Yabin Cui <yabinc@google.com> | 2016-07-07 17:18:04 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-07-07 17:18:04 +0000 |
commit | 6efb4bf6ca3ee70606465c1b8fa4ca39a9cdb7ad (patch) | |
tree | f79f890625a75ca432016f5ae2a9a8b472646daa /simpleperf/cmd_stat_test.cpp | |
parent | 26edabd38691d46881cff0c6fd8c14e065940fbf (diff) | |
parent | 11615de8326ebec451e3011bf2875e811fddfcb2 (diff) | |
download | extras-6efb4bf6ca3ee70606465c1b8fa4ca39a9cdb7ad.tar.gz |
Merge \"Simpleperf: add auto generated summaries in stat command.\"
am: 11615de832
Change-Id: I41e95398507e62f442d948273c12cb65e5d1730d
Diffstat (limited to 'simpleperf/cmd_stat_test.cpp')
-rw-r--r-- | simpleperf/cmd_stat_test.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp index d0adfe52..684e50fc 100644 --- a/simpleperf/cmd_stat_test.cpp +++ b/simpleperf/cmd_stat_test.cpp @@ -16,7 +16,9 @@ #include <gtest/gtest.h> +#include <android-base/file.h> #include <android-base/stringprintf.h> +#include <android-base/test_utils.h> #include "command.h" #include "get_test_data.h" @@ -93,3 +95,18 @@ TEST(stat_cmd, group_option) { "cpu-cycles:u,cpu-clock:u", "--group", "cpu-cycles:k,cpu-clock:k", "sleep", "1"})); } + +TEST(stat_cmd, auto_generated_summary) { + TemporaryFile tmp_file; + ASSERT_TRUE(StatCmd()->Run({"--group", "cpu-clock:u,cpu-clock:k", "-o", + tmp_file.path, "sleep", "1"})); + std::string s; + ASSERT_TRUE(android::base::ReadFileToString(tmp_file.path, &s)); + size_t pos = s.find("cpu-clock:u"); + ASSERT_NE(s.npos, pos); + pos = s.find("cpu-clock:k", pos); + ASSERT_NE(s.npos, pos); + pos += strlen("cpu-clock:k"); + // Check if the summary of cpu-clock is generated. + ASSERT_NE(s.npos, s.find("cpu-clock", pos)); +} |