diff options
Diffstat (limited to 'libperfmgr/tools/ConfigVerifier.cc')
-rw-r--r-- | libperfmgr/tools/ConfigVerifier.cc | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/libperfmgr/tools/ConfigVerifier.cc b/libperfmgr/tools/ConfigVerifier.cc index 2e25e950..af3a7146 100644 --- a/libperfmgr/tools/ConfigVerifier.cc +++ b/libperfmgr/tools/ConfigVerifier.cc @@ -44,6 +44,23 @@ class NodeVerifier : public HintManager { return false; } + for (const auto& node : nodes) { + std::vector<std::string> values = node->GetValues(); + std::string default_value = values[node->GetDefaultIndex()]; + // Always set to default first + values.insert(values.begin(), default_value); + // And reset to default after test + values.push_back(default_value); + for (const auto& value : values) { + if (!android::base::WriteStringToFile(value, node->GetPath())) { + LOG(ERROR) << "Failed to write to node: " << node->GetPath() + << " with value: " << value; + return false; + } + LOG(VERBOSE) << "Wrote to node: " << node->GetPath() + << " with value: " << value; + } + } return true; } @@ -67,14 +84,10 @@ static void printUsage(const char* exec_name) { " [options]\n" "\n" "Options:\n" - " --config, -c [PATH]\n" + " --config [PATH], -c\n" " path to Json config file\n\n" " --exec_hint, -e\n" " do hints in Json config\n\n" - " --hint_name, -i\n" - " do only the specific hint\n\n" - " --hint_duration, -d [duration]\n" - " duration in ms for each hint\n\n" " --help, -h\n" " print this message\n\n" " --verbose, -v\n" @@ -83,7 +96,7 @@ static void printUsage(const char* exec_name) { LOG(INFO) << usage; } -static void execConfig(const std::string& json_file, const std::string& hint_name, unsigned long hint_duration) { +static void execConfig(const std::string& json_file) { std::unique_ptr<android::perfmgr::HintManager> hm = android::perfmgr::HintManager::GetFromJSON(json_file); if (!hm.get() || !hm->IsRunning()) { @@ -91,43 +104,37 @@ static void execConfig(const std::string& json_file, const std::string& hint_nam } std::vector<std::string> hints = hm->GetHints(); for (const auto& hint : hints) { - if (!hint_name.empty() && hint_name != hint) - continue; LOG(INFO) << "Do hint: " << hint; - hm->DoHint(hint, std::chrono::milliseconds(hint_duration)); + hm->DoHint(hint); std::this_thread::yield(); - std::this_thread::sleep_for(std::chrono::milliseconds(hint_duration)); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); LOG(INFO) << "End hint: " << hint; hm->EndHint(hint); std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); } } int main(int argc, char* argv[]) { - android::base::InitLogging(argv, android::base::StdioLogger); + android::base::InitLogging(argv, android::base::StderrLogger); if (getuid() == 0) { LOG(WARNING) << "Running as root might mask node permission"; } std::string config_path; - std::string hint_name; bool exec_hint = false; - unsigned long hint_duration = 100; - while (true) { static struct option opts[] = { {"config", required_argument, nullptr, 'c'}, {"exec_hint", no_argument, nullptr, 'e'}, - {"hint_name", required_argument, nullptr, 'i'}, - {"hint_duration", required_argument, nullptr, 'd'}, {"help", no_argument, nullptr, 'h'}, {"verbose", no_argument, nullptr, 'v'}, {0, 0, 0, 0} // termination of the option list }; int option_index = 0; - int c = getopt_long(argc, argv, "c:ei:d:hv", opts, &option_index); + int c = getopt_long(argc, argv, "c:ehv", opts, &option_index); if (c == -1) { break; } @@ -139,12 +146,6 @@ int main(int argc, char* argv[]) { case 'e': exec_hint = true; break; - case 'i': - hint_name = optarg; - break; - case 'd': - hint_duration = strtoul(optarg, NULL, 10); - break; case 'v': android::base::SetMinimumLogSeverity(android::base::VERBOSE); break; @@ -164,7 +165,7 @@ int main(int argc, char* argv[]) { } if (exec_hint) { - execConfig(config_path, hint_name, hint_duration); + execConfig(config_path); return 0; } |