summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-06-27 16:00:20 -0700
committerYabin Cui <yabinc@google.com>2016-06-27 16:00:20 -0700
commita486a4b8aeeffb7bd0574134ca16c9ca1c061847 (patch)
treeb3ff9876fd63f36cdd110224d70772a8cff1164e
parent041bdd8e102e20cc8345560f037a8b032bd132e8 (diff)
downloadextras-nougat-dev.tar.gz
Simpleperf: fix flaky tests.nougat-dev
Simpleperf stat/record command may need 1 second to set security.perf_harden property. So the monitored child threads should run longer than 1 second. Bug: 29763505 Change-Id: I9bf6dcba03f3fc5c91130f38a08ce0062e104103
-rw-r--r--simpleperf/cmd_record_test.cpp5
-rw-r--r--simpleperf/cmd_stat_test.cpp7
2 files changed, 6 insertions, 6 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index a89febfe..1a468e29 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -171,8 +171,7 @@ TEST(record_cmd, existing_processes) {
CreateProcesses(2, &workloads);
std::string pid_list =
android::base::StringPrintf("%d,%d", workloads[0]->GetPid(), workloads[1]->GetPid());
- TemporaryFile tmpfile;
- ASSERT_TRUE(RecordCmd()->Run({"-p", pid_list, "-o", tmpfile.path}));
+ ASSERT_TRUE(RunRecordCmd({"-p", pid_list}));
}
TEST(record_cmd, existing_threads) {
@@ -182,7 +181,7 @@ TEST(record_cmd, existing_threads) {
std::string tid_list =
android::base::StringPrintf("%d,%d", workloads[0]->GetPid(), workloads[1]->GetPid());
TemporaryFile tmpfile;
- ASSERT_TRUE(RecordCmd()->Run({"-t", tid_list, "-o", tmpfile.path}));
+ ASSERT_TRUE(RunRecordCmd({"-t", tid_list}));
}
TEST(record_cmd, no_monitored_threads) {
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp
index 27f1f091..45ed3dc5 100644
--- a/simpleperf/cmd_stat_test.cpp
+++ b/simpleperf/cmd_stat_test.cpp
@@ -57,7 +57,8 @@ TEST(stat_cmd, event_modifier) {
void CreateProcesses(size_t count, std::vector<std::unique_ptr<Workload>>* workloads) {
workloads->clear();
for (size_t i = 0; i < count; ++i) {
- auto workload = Workload::CreateWorkload({"sleep", "1"});
+ // Create a workload runs longer than profiling time.
+ auto workload = Workload::CreateWorkload({"sleep", "1000"});
ASSERT_TRUE(workload != nullptr);
ASSERT_TRUE(workload->Start());
workloads->push_back(std::move(workload));
@@ -69,7 +70,7 @@ TEST(stat_cmd, existing_processes) {
CreateProcesses(2, &workloads);
std::string pid_list =
android::base::StringPrintf("%d,%d", workloads[0]->GetPid(), workloads[1]->GetPid());
- ASSERT_TRUE(StatCmd()->Run({"-p", pid_list}));
+ ASSERT_TRUE(StatCmd()->Run({"-p", pid_list, "sleep", "1"}));
}
TEST(stat_cmd, existing_threads) {
@@ -78,7 +79,7 @@ TEST(stat_cmd, existing_threads) {
// Process id can be used as thread id in linux.
std::string tid_list =
android::base::StringPrintf("%d,%d", workloads[0]->GetPid(), workloads[1]->GetPid());
- ASSERT_TRUE(StatCmd()->Run({"-t", tid_list}));
+ ASSERT_TRUE(StatCmd()->Run({"-t", tid_list, "sleep", "1"}));
}
TEST(stat_cmd, no_monitored_threads) {