diff options
author | Daniel Norman <danielnorman@google.com> | 2019-08-02 15:13:50 -0700 |
---|---|---|
committer | Daniel Norman <danielnorman@google.com> | 2019-08-06 11:10:42 -0700 |
commit | d2533c3395499a205e6dcddc729014a0ae715813 (patch) | |
tree | b99062408b6c5deeaa4a722faf031ff4bd4291d9 /init/service_parser.cpp | |
parent | 23a87716b57114e9b4f607042e3ec1af90d68c0a (diff) |
Adds check_interface_{restart,start,stop} check_builtins.
Includes refactoring out interface inheritance hierarchy logic to a new
interface_utils file.
Bug: 137397100
Test: 'm' with an init_rc that misspells an interface in an
interface_start, interface_restart, or interface_stop line.
Change-Id: I9f650289d64ae2b13435a81e1693c7ab5e6e9ecf
Diffstat (limited to 'init/service_parser.cpp')
-rw-r--r-- | init/service_parser.cpp | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/init/service_parser.cpp b/init/service_parser.cpp index e45e80415..dd552fb9f 100644 --- a/init/service_parser.cpp +++ b/init/service_parser.cpp @@ -568,33 +568,10 @@ Result<void> ServiceParser::EndSection() { } if (interface_inheritance_hierarchy_) { - std::set<std::string> interface_names; - for (const std::string& intf : service_->interfaces()) { - interface_names.insert(Split(intf, "/")[0]); - } - std::ostringstream error_stream; - for (const std::string& intf : interface_names) { - if (interface_inheritance_hierarchy_->count(intf) == 0) { - error_stream << "\nInterface is not in the known set of hidl_interfaces: '" << intf - << "'. Please ensure the interface is spelled correctly and built " - << "by a hidl_interface target."; - continue; - } - const std::set<std::string>& required_interfaces = - (*interface_inheritance_hierarchy_)[intf]; - std::set<std::string> diff; - std::set_difference(required_interfaces.begin(), required_interfaces.end(), - interface_names.begin(), interface_names.end(), - std::inserter(diff, diff.begin())); - if (!diff.empty()) { - error_stream << "\nInterface '" << intf << "' requires its full inheritance " - << "hierarchy to be listed in this init_rc file. Missing " - << "interfaces: [" << base::Join(diff, " ") << "]"; - } - } - const std::string& errors = error_stream.str(); - if (!errors.empty()) { - return Error() << errors; + if (const auto& check_hierarchy_result = CheckInterfaceInheritanceHierarchy( + service_->interfaces(), *interface_inheritance_hierarchy_); + !check_hierarchy_result) { + return Error() << check_hierarchy_result.error(); } } |