summaryrefslogtreecommitdiff
path: root/simpleperf/main.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2017-07-14 15:59:56 -0700
committerYabin Cui <yabinc@google.com>2017-07-14 17:58:51 -0700
commit616b3a020bf708f364e0608107ded083930ac6b4 (patch)
treecf7de582ecda3ec87fe4a9f35b71f55aa996fe56 /simpleperf/main.cpp
parent9aa1dc2f3039db9faee9d581360a5d65caddb8f4 (diff)
downloadextras-616b3a020bf708f364e0608107ded083930ac6b4.tar.gz
simpleperf: change the way running cts tests.
Before this CL, CtsSimpleperfTestCases copies itself to the app's directory, then run it using run-as. With this CL, CtsSimpleperfTestCases keeps itself in /data/local/tmp, but forces stat/record cmd to run with --app option. This gives more freedom to tests: 1. They can stay in shell's context with --in-app option. 2. The stat/record cmds are started in the shell's context, so they can collect information no available in app's context (like data in /sys/kernel/debug/tracing/events). This is a preparation to add tests for recording tracepoint events. It also matches the way we want users to use simpleperf (with --app option). Bug: http://b/29520177 Test: run CtsSimpleperfTestCases. Change-Id: I1709adfb1ff7169df87560226c197e473fdf8516
Diffstat (limited to 'simpleperf/main.cpp')
-rw-r--r--simpleperf/main.cpp52
1 files changed, 1 insertions, 51 deletions
diff --git a/simpleperf/main.cpp b/simpleperf/main.cpp
index ae3e6292..d359dd13 100644
--- a/simpleperf/main.cpp
+++ b/simpleperf/main.cpp
@@ -14,58 +14,8 @@
* limitations under the License.
*/
-#include <string.h>
-
-#include <string>
-#include <vector>
-
-#include <android-base/logging.h>
-
#include "command.h"
-#include "utils.h"
int main(int argc, char** argv) {
- android::base::InitLogging(argv, android::base::StderrLogger);
- std::vector<std::string> args;
- android::base::LogSeverity log_severity = android::base::INFO;
-
- for (int i = 1; i < argc; ++i) {
- if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
- args.insert(args.begin(), "help");
- } else if (strcmp(argv[i], "--log") == 0) {
- if (i + 1 < argc) {
- ++i;
- if (!GetLogSeverity(argv[i], &log_severity)) {
- LOG(ERROR) << "Unknown log severity: " << argv[i];
- return 1;
- }
- } else {
- LOG(ERROR) << "Missing argument for --log option.\n";
- return 1;
- }
- } else if (strcmp(argv[i], "--version") == 0) {
- LOG(INFO) << "Simpleperf version " << GetSimpleperfVersion();
- return 0;
- } else {
- args.push_back(argv[i]);
- }
- }
- android::base::ScopedLogSeverity severity(log_severity);
-
- if (args.empty()) {
- args.push_back("help");
- }
- std::unique_ptr<Command> command = CreateCommandInstance(args[0]);
- if (command == nullptr) {
- LOG(ERROR) << "malformed command line: unknown command " << args[0];
- return 1;
- }
- std::string command_name = args[0];
- args.erase(args.begin());
-
- LOG(DEBUG) << "command '" << command_name << "' starts running";
- bool result = command->Run(args);
- LOG(DEBUG) << "command '" << command_name << "' "
- << (result ? "finished successfully" : "failed");
- return result ? 0 : 1;
+ return RunSimpleperfCmd(argc, argv) ? 0 : 1;
}