summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2018-11-14 16:23:02 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-11-14 16:23:02 +0000
commit1e73bcce67e3fbc3e0281fdaf52d83e3708fac47 (patch)
treeea7cadfbbfad426dd0babaf1416e1bee99cd54b7
parentdf1575e4e91ac5d4b257de0600e4ae50d890a39d (diff)
parentee066f32b89ad63be902005d2ea5f2bcf0f1f940 (diff)
downloadextras-android-cts-9.0_r6.tar.gz
Merge "Snap for 5130802 from e29a1b3735bb8b8a1fa8882b8a379011f4a4a805 to pie-cts-release" into pie-cts-releaseandroid-cts-9.0_r6android-cts-9.0_r5
-rw-r--r--simpleperf/cmd_record_test.cpp2
-rw-r--r--simpleperf/cmd_stat_test.cpp13
-rw-r--r--simpleperf/test_util.h16
3 files changed, 25 insertions, 6 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index 64bc7fbf..8fea4382 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -271,8 +271,10 @@ TEST(record_cmd, existing_threads) {
}
TEST(record_cmd, no_monitored_threads) {
+ ScopedAppPackageName scoped_package_name("");
TemporaryFile tmpfile;
ASSERT_FALSE(RecordCmd()->Run({"-o", tmpfile.path}));
+ ASSERT_FALSE(RecordCmd()->Run({"-o", tmpfile.path, ""}));
}
TEST(record_cmd, more_than_one_event_types) {
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp
index 61b65a1e..c24ccbc9 100644
--- a/simpleperf/cmd_stat_test.cpp
+++ b/simpleperf/cmd_stat_test.cpp
@@ -100,7 +100,11 @@ TEST(stat_cmd, existing_threads) {
ASSERT_TRUE(StatCmd()->Run({"-t", tid_list, "sleep", "1"}));
}
-TEST(stat_cmd, no_monitored_threads) { ASSERT_FALSE(StatCmd()->Run({""})); }
+TEST(stat_cmd, no_monitored_threads) {
+ ScopedAppPackageName scoped_package_name("");
+ ASSERT_FALSE(StatCmd()->Run({}));
+ ASSERT_FALSE(StatCmd()->Run({""}));
+}
TEST(stat_cmd, group_option) {
ASSERT_TRUE(
@@ -162,11 +166,8 @@ TEST(stat_cmd, no_modifier_for_clock_events) {
}
TEST(stat_cmd, handle_SIGHUP) {
- if (!GetDefaultAppPackageName().empty()) {
- // See http://b/79495636.
- GTEST_LOG_(INFO) << "Omit this test in app's context.";
- return;
- }
+ // See http://b/79495636.
+ ScopedAppPackageName scoped_package_name("");
std::thread thread([]() {
sleep(1);
kill(getpid(), SIGHUP);
diff --git a/simpleperf/test_util.h b/simpleperf/test_util.h
index f5fb590f..054acdea 100644
--- a/simpleperf/test_util.h
+++ b/simpleperf/test_util.h
@@ -19,6 +19,7 @@
#include <string>
#include <vector>
+#include "environment.h"
#include "read_elf.h"
#include "workload.h"
@@ -56,3 +57,18 @@ bool IsInNativeAbi();
return; \
} \
} while (0)
+
+class ScopedAppPackageName {
+ public:
+ ScopedAppPackageName(const std::string name) {
+ saved_name_ = GetDefaultAppPackageName();
+ SetDefaultAppPackageName(name);
+ }
+
+ ~ScopedAppPackageName() {
+ SetDefaultAppPackageName(saved_name_);
+ }
+
+ private:
+ std::string saved_name_;
+};