summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_stat_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-07-07 17:18:04 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-07-07 17:18:04 +0000
commit6efb4bf6ca3ee70606465c1b8fa4ca39a9cdb7ad (patch)
treef79f890625a75ca432016f5ae2a9a8b472646daa /simpleperf/cmd_stat_test.cpp
parent26edabd38691d46881cff0c6fd8c14e065940fbf (diff)
parent11615de8326ebec451e3011bf2875e811fddfcb2 (diff)
downloadextras-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.cpp17
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));
+}