simpleperf: support building cts test.
1. build cts test libraries.
2. change tests to use tmpfile instead of perf.data.
3. support extracting testdata from cts test file.
Bug: 27387280
Change-Id: I7c5db77f3157d586d0c9beb446b247626e7cce36
diff --git a/simpleperf/cmd_dumprecord_test.cpp b/simpleperf/cmd_dumprecord_test.cpp
index 574fb2a..441851f 100644
--- a/simpleperf/cmd_dumprecord_test.cpp
+++ b/simpleperf/cmd_dumprecord_test.cpp
@@ -17,27 +17,12 @@
#include <gtest/gtest.h>
#include "command.h"
-#include "test_util.h"
+#include "get_test_data.h"
-class DumpRecordCommandTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- record_cmd = CreateCommandInstance("record");
- ASSERT_TRUE(record_cmd != nullptr);
- dumprecord_cmd = CreateCommandInstance("dump");
- ASSERT_TRUE(dumprecord_cmd != nullptr);
- }
-
- std::unique_ptr<Command> record_cmd;
- std::unique_ptr<Command> dumprecord_cmd;
-};
-
-TEST_F(DumpRecordCommandTest, no_options) {
- ASSERT_TRUE(record_cmd->Run({"-a", "sleep", SLEEP_SEC}));
- ASSERT_TRUE(dumprecord_cmd->Run({}));
+static std::unique_ptr<Command> DumpCmd() {
+ return CreateCommandInstance("dump");
}
-TEST_F(DumpRecordCommandTest, record_file_option) {
- ASSERT_TRUE(record_cmd->Run({"-a", "-o", "perf2.data", "sleep", SLEEP_SEC}));
- ASSERT_TRUE(dumprecord_cmd->Run({"perf2.data"}));
+TEST(cmd_dump, record_file_option) {
+ ASSERT_TRUE(DumpCmd()->Run({GetTestData("perf.data")}));
}