moved to private
Change-Id: I7a8dba6a1bf454fa29737917ff5e4b8fc991cfd1
diff --git a/zircon/system/core/devmgr/devcoordinator/coordinator.cpp b/zircon/system/core/devmgr/devcoordinator/coordinator.cpp
index 97e1b2f..6ce4033 100644
--- a/zircon/system/core/devmgr/devcoordinator/coordinator.cpp
+++ b/zircon/system/core/devmgr/devcoordinator/coordinator.cpp
@@ -708,7 +708,7 @@
// more tied to devhost teardown than it is.
if (parent->test_state() == Device::TestStateMachine::kTestUnbindSent) {
- parent->test_event.signal(0, TEST_REMOVE_DONE_SIGNAL);
+ parent->test_event().signal(0, TEST_REMOVE_DONE_SIGNAL);
if (!(dev->flags & DEV_CTX_PROXY)) {
// remove from list of all devices
devices_.erase(*dev);
diff --git a/zircon/system/core/devmgr/devcoordinator/device.cpp b/zircon/system/core/devmgr/devcoordinator/device.cpp
index 19bf310..0eff1fa 100644
--- a/zircon/system/core/devmgr/devcoordinator/device.cpp
+++ b/zircon/system/core/devmgr/devcoordinator/device.cpp
@@ -409,7 +409,7 @@
real_parent->DriverCompatibiltyTest(drivername);
break;
} else if (real_parent->test_state() == Device::TestStateMachine::kTestBindSent) {
- real_parent->test_event.signal(0, TEST_BIND_DONE_SIGNAL);
+ real_parent->test_event().signal(0, TEST_BIND_DONE_SIGNAL);
break;
}
}
@@ -481,7 +481,7 @@
zx_status_t Device::DriverCompatibiltyTest(const char* drivername) {
thrd_t t;
- strncpy(test_drivername, drivername, sizeof(test_drivername) - 1);
+ set_test_driver_name(drivername);
if (test_state() != TestStateMachine::kTestNotStarted) {
return ZX_ERR_ALREADY_EXISTS;
}
@@ -492,7 +492,7 @@
if (ret != thrd_success) {
log(ERROR,
"Driver Compatibility test failed for %s: "
- "Thread creation failed\n", test_drivername);
+ "Thread creation failed\n", test_driver_name());
return ZX_ERR_NO_RESOURCES;
}
thrd_detach(t);
@@ -500,27 +500,27 @@
}
int Device::RunCompatibilityTests() {
- log(INFO, "%s: Running ddk compatibility test for driver %s \n", __func__, test_drivername);
+ log(INFO, "%s: Running ddk compatibility test for driver %s \n", __func__, test_driver_name());
// Device should be bound for test to work
if (!(flags & DEV_CTX_BOUND)) {
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
"Parent Device not bound\n",
- test_drivername);
+ test_driver_name());
return ZX_ERR_INTERNAL;
}
- zx_status_t status = zx::event::create(0, &test_event);
+ zx_status_t status = zx::event::create(0, &test_event());
if (status != ZX_OK) {
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
"Event creation failed : %d\n",
- test_drivername, status);
+ test_driver_name(), status);
return -1;
}
auto cleanup = fbl::MakeAutoCall([this]() {
- test_event.reset();
+ test_event().reset();
set_test_state(Device::TestStateMachine::kTestDone);
});
@@ -533,7 +533,7 @@
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
"Sending unbind to %s failed\n",
- test_drivername, child.name().data());
+ test_driver_name(), child.name().data());
return -1;
}
}
@@ -541,7 +541,7 @@
this->set_test_state(Device::TestStateMachine::kTestUnbindSent);
zx_signals_t observed = 0;
// Now wait for the device to be removed.
- status = test_event.wait_one(TEST_REMOVE_DONE_SIGNAL,
+ status = test_event().wait_one(TEST_REMOVE_DONE_SIGNAL,
zx::time(zx_deadline_after(ZX_SEC(20))),
&observed);
if (status != ZX_OK) {
@@ -551,12 +551,12 @@
"devcoordinator: Driver Compatibility test failed for %s: "
"Timed out waiting for device to be removed. Check if device_remove was "
"called in the unbind routine of the driver: %d\n",
- test_drivername, status);
+ test_driver_name(), status);
} else {
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
"Error waiting for device to be removed.\n",
- test_drivername);
+ test_driver_name());
}
return -1;
}
@@ -564,7 +564,7 @@
observed = 0;
this->coordinator->HandleNewDevice(fbl::WrapRefPtr(this));
this->set_test_state(Device::TestStateMachine::kTestBindSent);
- status = test_event.wait_one(TEST_BIND_DONE_SIGNAL,
+ status = test_event().wait_one(TEST_BIND_DONE_SIGNAL,
zx::time(zx_deadline_after(ZX_SEC(20))),
&observed);
if (status != ZX_OK) {
@@ -574,12 +574,12 @@
"devcoordinator: Driver Compatibility test failed for %s: "
"Timed out waiting for driver to be bound. Check if Bind routine "
"of the driver is doing blocking I/O: %d\n",
- test_drivername, status);
+ test_driver_name(), status);
} else {
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
"Error waiting for driver to be bound: %d\n",
- test_drivername, status);
+ test_driver_name(), status);
}
return -1;
}
@@ -588,14 +588,14 @@
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
"Driver Bind routine did not add a child. Check if Bind routine "
- "Called DdkAdd() at the end.\n", test_drivername);
+ "Called DdkAdd() at the end.\n", test_driver_name());
return -1;
}
// TODO(ravoorir): Test Suspend and Resume hooks
log(ERROR, "%s: Driver Compatibility test %s for %s\n", __func__,
this->test_state() == Device::TestStateMachine::kTestBindDone ? "Succeeded" : "Failed",
- test_drivername);
+ test_driver_name());
return ZX_OK;
}
diff --git a/zircon/system/core/devmgr/devcoordinator/device.h b/zircon/system/core/devmgr/devcoordinator/device.h
index cd5bf55..d36d373 100644
--- a/zircon/system/core/devmgr/devcoordinator/device.h
+++ b/zircon/system/core/devmgr/devcoordinator/device.h
@@ -366,8 +366,13 @@
fbl::AutoLock<fbl::Mutex> lock(&test_state_lock_);
test_state_ = new_state;
}
- char test_drivername[fuchsia_device_MAX_DRIVER_NAME_LEN + 1] = {0};
- zx::event test_event;
+
+ zx::event& test_event() { return test_event_; }
+
+ const char* test_driver_name() {return test_driver_name_; }
+ void set_test_driver_name(const char* drivername) {
+ strncpy(test_driver_name_, drivername, sizeof(test_driver_name_) - 1);
+ }
private:
zx_status_t HandleRead();
int RunCompatibilityTests();
@@ -435,6 +440,8 @@
zx::channel client_remote_;
fbl::Mutex test_state_lock_;
TestStateMachine test_state_ = TestStateMachine::kTestNotStarted;
+ zx::event test_event_;
+ char test_driver_name_[fuchsia_device_MAX_DRIVER_NAME_LEN + 1] = {0};
};
} // namespace devmgr