@@ -132,8 +132,10 @@ ZTEST(focuser_app, test_initialise_requires_ready_stepper)
132132 " should not set reference position on failure" );
133133 zassert_equal (fake_stepper_set_microstep_interval_fake.call_count , 0U ,
134134 " should not update step interval on failure" );
135- zassert_equal (fake_stepper_drv_enable_fake.call_count , 1U ,
136- " only constructor enable should run" );
135+ zassert_equal (fake_stepper_drv_enable_fake.call_count , 0U ,
136+ " driver should not be enabled during startup" );
137+ zassert_equal (fake_stepper_drv_disable_fake.call_count , 0U ,
138+ " driver should not be touched when hardware is not ready" );
137139}
138140
139141ZTEST (focuser_app, test_initialise_configures_stepper_when_ready)
@@ -153,10 +155,10 @@ ZTEST(focuser_app, test_initialise_configures_stepper_when_ready)
153155 " step interval should be applied once" );
154156 zassert_equal (fake_stepper_set_microstep_interval_fake.arg1_val , 500000ULL ,
155157 " default speed uses 500us interval" );
156- zassert_equal (fake_stepper_drv_enable_fake.call_count , 2U ,
157- " constructor plus initialise enable calls expected " );
158- zassert_equal (fake_stepper_drv_disable_fake.call_count , 0U ,
159- " driver should remain enabled after init " );
158+ zassert_equal (fake_stepper_drv_enable_fake.call_count , 0U ,
159+ " driver should not be enabled during init " );
160+ zassert_equal (fake_stepper_drv_disable_fake.call_count , 1U ,
161+ " initialise should ensure the driver starts disabled " );
160162}
161163
162164ZTEST (focuser_app, test_initialise_restores_position_from_store)
@@ -260,14 +262,16 @@ ZTEST(focuser_app, test_initialise_ignores_ealready_from_driver)
260262 ZephyrFocuserStepper stepper (k_stepper_controller, k_stepper_driver);
261263 Focuser focuser (stepper, nullptr , kFirmwareVersion );
262264
263- int enable_results [] = {-EALREADY, -EALREADY};
264- SET_RETURN_SEQ (fake_stepper_drv_enable, enable_results, 2 );
265+ int disable_results [] = {-EALREADY};
266+ SET_RETURN_SEQ (fake_stepper_drv_disable, disable_results, 1 );
265267
266268 const int ret = focuser.initialise ();
267269
268270 zassert_equal (ret, 0 , " -EALREADY responses should not fail init" );
269- zassert_equal (fake_stepper_drv_enable_fake.call_count , 2U ,
270- " two enable attempts should have occurred" );
271+ zassert_equal (fake_stepper_drv_disable_fake.call_count , 1U ,
272+ " initialise should attempt to disable the driver once" );
273+ zassert_equal (fake_stepper_drv_enable_fake.call_count , 0U ,
274+ " initialise should not enable the driver" );
271275}
272276
273277ZTEST (focuser_app, test_eeprom_position_store_roundtrip)
0 commit comments