diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-10-23 00:52:13 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-10-23 00:52:13 +0000 |
commit | 99d37b48bbfee9955a8b2f71ea59fe42cc1e2e49 (patch) | |
tree | d1f8ed49ebc284684e5c9e7ee9c7f07a09bfd71c | |
parent | d790ec4c377589d8ea1f857964d8d7e60d326235 (diff) | |
parent | a9786b6c176f50000cdf52b17cf6b0b1a7c48159 (diff) | |
download | extras-99d37b48bbfee9955a8b2f71ea59fe42cc1e2e49.tar.gz |
Merge "libperfmgr: clean up log format"
-rw-r--r-- | libperfmgr/FileNode.cc | 3 | ||||
-rw-r--r-- | libperfmgr/HintManager.cc | 35 | ||||
-rw-r--r-- | libperfmgr/PropertyNode.cc | 3 | ||||
-rw-r--r-- | libperfmgr/tests/HintManagerTest.cc | 17 |
4 files changed, 37 insertions, 21 deletions
diff --git a/libperfmgr/FileNode.cc b/libperfmgr/FileNode.cc index 1d051977..d45cda2e 100644 --- a/libperfmgr/FileNode.cc +++ b/libperfmgr/FileNode.cc @@ -52,7 +52,8 @@ std::chrono::milliseconds FileNode::Update(bool log_error) { // Update node only if request index changes if (value_index != current_val_index_) { - const std::string& req_value = req_sorted_[value_index].GetRequestValue(); + const std::string& req_value = + req_sorted_[value_index].GetRequestValue(); fd_.reset(TEMP_FAILURE_RETRY( open(node_path_.c_str(), O_WRONLY | O_CLOEXEC | O_TRUNC))); diff --git a/libperfmgr/HintManager.cc b/libperfmgr/HintManager.cc index caa75758..c8ad6adb 100644 --- a/libperfmgr/HintManager.cc +++ b/libperfmgr/HintManager.cc @@ -186,7 +186,7 @@ std::vector<std::unique_ptr<Node>> HintManager::ParseNodes( std::string value = values[j].asString(); LOG(VERBOSE) << "Node[" << i << "]'s Value[" << j << "]: " << value; if (value.empty()) { - LOG(ERROR) << "Failed to read Node" << i << "'s Value[" << j + LOG(ERROR) << "Failed to read Node[" << i << "]'s Value[" << j << "]"; nodes_parsed.clear(); return nodes_parsed; @@ -194,7 +194,7 @@ std::vector<std::unique_ptr<Node>> HintManager::ParseNodes( values_parsed.emplace_back(value); } if (values_parsed.size() < 1) { - LOG(ERROR) << "Failed to read Node" << i << "'s Values"; + LOG(ERROR) << "Failed to read Node[" << i << "]'s Values"; nodes_parsed.clear(); return nodes_parsed; } @@ -202,15 +202,16 @@ std::vector<std::unique_ptr<Node>> HintManager::ParseNodes( Json::UInt64 default_index = values_parsed.size() - 1; if (nodes[i]["DefaultIndex"].empty() || !nodes[i]["DefaultIndex"].isUInt64()) { - LOG(INFO) << "Failed to read Node" << i - << "'s DefaultIndex, set to last index: " << default_index; + LOG(INFO) << "Failed to read Node[" << i + << "]'s DefaultIndex, set to last index: " + << default_index; } else { default_index = nodes[i]["DefaultIndex"].asUInt64(); } if (default_index > values_parsed.size() - 1) { default_index = values_parsed.size() - 1; - LOG(ERROR) << "Node" << i - << "'s DefaultIndex out of bound, max value index: " + LOG(ERROR) << "Node[" << i + << "]'s DefaultIndex out of bound, max value index: " << default_index; nodes_parsed.clear(); return nodes_parsed; @@ -220,20 +221,20 @@ std::vector<std::unique_ptr<Node>> HintManager::ParseNodes( bool reset = false; if (nodes[i]["ResetOnInit"].empty() || !nodes[i]["ResetOnInit"].isBool()) { - LOG(INFO) << "Failed to read Node" << i - << "'s ResetOnInit, set to 'false'"; + LOG(INFO) << "Failed to read Node[" << i + << "]'s ResetOnInit, set to 'false'"; } else { reset = nodes[i]["ResetOnInit"].asBool(); } - LOG(VERBOSE) << "Node[" << i - << "]'s ResetOnInit: " << (reset ? "true" : "false"); + LOG(VERBOSE) << "Node[" << i << "]'s ResetOnInit: " << std::boolalpha + << reset << std::noboolalpha; bool is_file = true; std::string node_type = nodes[i]["Type"].asString(); LOG(VERBOSE) << "Node[" << i << "]'s Type: " << node_type; if (node_type.empty()) { LOG(ERROR) << "Failed to read " - << "Node[" << i << "]'s Type, set to File as default"; + << "Node[" << i << "]'s Type, set to 'File' as default"; } else if (node_type == "File") { is_file = true; } else if (node_type == "Property") { @@ -248,8 +249,8 @@ std::vector<std::unique_ptr<Node>> HintManager::ParseNodes( if (is_file) { bool hold_fd = false; if (nodes[i]["HoldFd"].empty() || !nodes[i]["HoldFd"].isBool()) { - LOG(INFO) << "Failed to read Node" << i - << "'s HoldFd, set to 'false'"; + LOG(INFO) << "Failed to read Node[" << i + << "]'s HoldFd, set to 'false'"; } else { hold_fd = nodes[i]["HoldFd"].asBool(); } @@ -305,8 +306,8 @@ std::map<std::string, std::vector<NodeAction>> HintManager::ParseActions( if (nodes_index.find(node_name) == nodes_index.end()) { LOG(ERROR) << "Failed to find " - << "Action" << i - << "'s Node from Nodes section: " << node_name; + << "Action[" << i + << "]'s Node from Nodes section: " << node_name; actions_parsed.clear(); return actions_parsed; } @@ -317,7 +318,7 @@ std::map<std::string, std::vector<NodeAction>> HintManager::ParseActions( std::size_t value_index = 0; if (!nodes[node_index]->GetValueIndex(value_name, &value_index)) { - LOG(ERROR) << "Failed to read Action" << i << "'s Value"; + LOG(ERROR) << "Failed to read Action[" << i << "]'s Value"; LOG(ERROR) << "Action[" << i << "]'s Value " << value_name << " is not defined in Node[" << node_name; actions_parsed.clear(); @@ -328,7 +329,7 @@ std::map<std::string, std::vector<NodeAction>> HintManager::ParseActions( Json::UInt64 duration = 0; if (actions[i]["Duration"].empty() || !actions[i]["Duration"].isUInt64()) { - LOG(ERROR) << "Failed to read Action" << i << "'s Duration"; + LOG(ERROR) << "Failed to read Action[" << i << "]'s Duration"; actions_parsed.clear(); return actions_parsed; } else { diff --git a/libperfmgr/PropertyNode.cc b/libperfmgr/PropertyNode.cc index cf07b3cc..0f2f557b 100644 --- a/libperfmgr/PropertyNode.cc +++ b/libperfmgr/PropertyNode.cc @@ -51,7 +51,8 @@ std::chrono::milliseconds PropertyNode::Update(bool) { // Update node only if request index changes if (value_index != current_val_index_) { - const std::string& req_value = req_sorted_[value_index].GetRequestValue(); + const std::string& req_value = + req_sorted_[value_index].GetRequestValue(); if (!android::base::SetProperty(node_path_, req_value)) { LOG(WARNING) << "Failed to set property to : " << node_path_ diff --git a/libperfmgr/tests/HintManagerTest.cc b/libperfmgr/tests/HintManagerTest.cc index 33a3ad16..09fd8a0f 100644 --- a/libperfmgr/tests/HintManagerTest.cc +++ b/libperfmgr/tests/HintManagerTest.cc @@ -377,8 +377,8 @@ TEST_F(HintManagerTest, ParseActionsTest) { actions["LAUNCH"][2].timeout_ms.count()); } -// Test parsing actions with duplicate node -TEST_F(HintManagerTest, ParseActionDuplicateNodeTest) { +// Test parsing actions with duplicate File node +TEST_F(HintManagerTest, ParseActionDuplicateFileNodeTest) { std::string from = "\"Node\":\"CPUCluster0MinFreq\""; size_t start_pos = json_doc_.find(from); json_doc_.replace(start_pos, from.length(), @@ -391,6 +391,19 @@ TEST_F(HintManagerTest, ParseActionDuplicateNodeTest) { EXPECT_EQ(0u, actions.size()); } +// Test parsing actions with duplicate Property node +TEST_F(HintManagerTest, ParseActionDuplicatePropertyNodeTest) { + std::string from = "\"Node\":\"CPUCluster0MinFreq\""; + size_t start_pos = json_doc_.find(from); + json_doc_.replace(start_pos, from.length(), "\"Node\":\"ModeProperty\""); + std::vector<std::unique_ptr<Node>> nodes = + HintManager::ParseNodes(json_doc_); + EXPECT_EQ(3u, nodes.size()); + std::map<std::string, std::vector<NodeAction>> actions = + HintManager::ParseActions(json_doc_, nodes); + EXPECT_EQ(0u, actions.size()); +} + // Test parsing invalid json for actions TEST_F(HintManagerTest, ParseBadActionsTest) { std::vector<std::unique_ptr<Node>> nodes = |