Merge "init: Check onrestart commands"

am: 980cbef0c5

Change-Id: Ie0a36c3a803dc30697b0f8da2324c99c0db1770d
This commit is contained in:
Tom Cherry 2019-08-06 08:44:25 -07:00 committed by android-build-merger
commit fe837fe0ee
4 changed files with 11 additions and 1 deletions

View file

@ -239,7 +239,7 @@ int main(int argc, char** argv) {
LOG(ERROR) << "Failed to open init rc script '" << *argv << "'";
return EXIT_FAILURE;
}
size_t failures = parser.parse_error_count() + am.CheckAllCommands();
size_t failures = parser.parse_error_count() + am.CheckAllCommands() + sl.CheckAllCommands();
if (failures > 0) {
LOG(ERROR) << "Failed to parse init script '" << *argv << "' with " << failures
<< " errors";

View file

@ -97,6 +97,7 @@ class Service {
void AddReapCallback(std::function<void(const siginfo_t& siginfo)> callback) {
reap_callbacks_.emplace_back(std::move(callback));
}
size_t CheckAllCommands() const { return onrestart_.CheckAllCommands(); }
static bool is_exec_service_running() { return is_exec_service_running_; }

View file

@ -28,6 +28,14 @@ ServiceList& ServiceList::GetInstance() {
return instance;
}
size_t ServiceList::CheckAllCommands() {
size_t failures = 0;
for (const auto& service : services_) {
failures += service->CheckAllCommands();
}
return failures;
}
void ServiceList::AddService(std::unique_ptr<Service> service) {
services_.emplace_back(std::move(service));
}

View file

@ -30,6 +30,7 @@ class ServiceList {
// Exposed for testing
ServiceList();
size_t CheckAllCommands();
void AddService(std::unique_ptr<Service> service);
void RemoveService(const Service& svc);