Skip to content

Commit 5117b77

Browse files
jilaypandyahenrikbrixandersen
authored andcommitted
tests: drv84xx: drop duplicate tests
test_actual_position_set, test_test_move_by_zero_steps_no_movement from drv84xx_api test-suite are already accounted for in stepper_api test suite through test_actual_position & test_move_by_zero_steps respectively. test_move_to_identical_current_and_target_position scenario from drv84xx_api is now covered in test_move_zero_steps in stepper_api test_move_to_positive_direction_movement from drv84xx_api test-suite is now test_move_to_positive_step_count in stepper test-suite Signed-off-by: Jilay Pandya <[email protected]>
1 parent ee909ef commit 5117b77

File tree

2 files changed

+17
-78
lines changed
  • tests/drivers/stepper

2 files changed

+17
-78
lines changed

tests/drivers/stepper/drv84xx/api/src/main.c

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -79,34 +79,6 @@ ZTEST_F(drv84xx_api, test_micro_step_res_set)
7979
res);
8080
}
8181

82-
ZTEST_F(drv84xx_api, test_actual_position_set)
83-
{
84-
int32_t pos = 100u;
85-
(void)stepper_set_reference_position(fixture->dev, pos);
86-
(void)stepper_get_actual_position(fixture->dev, &pos);
87-
zassert_equal(pos, 100u, "Actual position should be %u but is %u", 100u, pos);
88-
}
89-
90-
ZTEST_F(drv84xx_api, test_move_to_positive_direction_movement)
91-
{
92-
int32_t pos = 50;
93-
94-
(void)stepper_enable(fixture->dev);
95-
(void)stepper_set_microstep_interval(fixture->dev, 20000000);
96-
(void)stepper_set_event_callback(fixture->dev, fixture->callback, NULL);
97-
(void)stepper_move_to(fixture->dev, pos);
98-
(void)k_poll(&stepper_event, 1, K_SECONDS(5));
99-
unsigned int signaled;
100-
int result;
101-
102-
k_poll_signal_check(&stepper_signal, &signaled, &result);
103-
zassert_equal(signaled, 1, "No event detected");
104-
zassert_equal(result, STEPPER_EVENT_STEPS_COMPLETED,
105-
"Event was not STEPPER_EVENT_STEPS_COMPLETED event");
106-
(void)stepper_get_actual_position(fixture->dev, &pos);
107-
zassert_equal(pos, 50u, "Target position should be %d but is %d", 50u, pos);
108-
}
109-
11082
ZTEST_F(drv84xx_api, test_move_to_negative_direction_movement)
11183
{
11284
int32_t pos = -50;
@@ -127,26 +99,6 @@ ZTEST_F(drv84xx_api, test_move_to_negative_direction_movement)
12799
zassert_equal(pos, -50, "Target position should be %d but is %d", -50, pos);
128100
}
129101

130-
ZTEST_F(drv84xx_api, test_move_to_identical_current_and_target_position)
131-
{
132-
int32_t pos = 0;
133-
134-
(void)stepper_enable(fixture->dev);
135-
(void)stepper_set_microstep_interval(fixture->dev, 20000000);
136-
(void)stepper_set_event_callback(fixture->dev, fixture->callback, NULL);
137-
(void)stepper_move_to(fixture->dev, pos);
138-
(void)k_poll(&stepper_event, 1, K_SECONDS(5));
139-
unsigned int signaled;
140-
int result;
141-
142-
k_poll_signal_check(&stepper_signal, &signaled, &result);
143-
zassert_equal(signaled, 1, "No event detected");
144-
zassert_equal(result, STEPPER_EVENT_STEPS_COMPLETED,
145-
"Event was not STEPPER_EVENT_STEPS_COMPLETED event");
146-
(void)stepper_get_actual_position(fixture->dev, &pos);
147-
zassert_equal(pos, 0, "Target position should not have changed from %d but is %d", 0, pos);
148-
}
149-
150102
ZTEST_F(drv84xx_api, test_move_to_is_moving_true_while_moving)
151103
{
152104
int32_t pos = 50;
@@ -181,26 +133,6 @@ ZTEST_F(drv84xx_api, test_move_to_is_moving_false_when_completed)
181133
zassert_false(moving, "Driver should not be in state is_moving after finishing");
182134
}
183135

184-
ZTEST_F(drv84xx_api, test_move_by_zero_steps_no_movement)
185-
{
186-
int32_t steps = 0;
187-
188-
(void)stepper_enable(fixture->dev);
189-
(void)stepper_set_microstep_interval(fixture->dev, 20000000);
190-
(void)stepper_set_event_callback(fixture->dev, fixture->callback, NULL);
191-
(void)stepper_move_by(fixture->dev, steps);
192-
(void)k_poll(&stepper_event, 1, K_SECONDS(5));
193-
unsigned int signaled;
194-
int result;
195-
196-
k_poll_signal_check(&stepper_signal, &signaled, &result);
197-
zassert_equal(signaled, 1, "No event detected");
198-
zassert_equal(result, STEPPER_EVENT_STEPS_COMPLETED,
199-
"Event was not STEPPER_EVENT_STEPS_COMPLETED event");
200-
(void)stepper_get_actual_position(fixture->dev, &steps);
201-
zassert_equal(steps, 0, "Target position should be %d but is %d", 0, steps);
202-
}
203-
204136
ZTEST_F(drv84xx_api, test_move_by_is_moving_true_while_moving)
205137
{
206138
int32_t steps = 50;

tests/drivers/stepper/stepper_api/src/main.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ ZTEST_F(stepper, test_actual_position)
128128
zassert_equal(pos, 100u, "Actual position not set correctly");
129129
}
130130

131-
ZTEST_F(stepper, test_target_position_w_fixed_step_interval)
131+
ZTEST_F(stepper, test_move_to_positive_step_count)
132132
{
133133
int32_t pos = 10u;
134134
int ret;
@@ -138,13 +138,13 @@ ZTEST_F(stepper, test_target_position_w_fixed_step_interval)
138138
ztest_test_skip();
139139
}
140140

141-
(void)stepper_move_to(fixture->dev, pos);
141+
zassert_ok(stepper_move_to(fixture->dev, pos));
142142

143143
POLL_AND_CHECK_SIGNAL(
144144
stepper_signal, stepper_event, STEPPER_EVENT_STEPS_COMPLETED,
145145
K_MSEC(pos * (100 + CONFIG_STEPPER_TEST_TIMING_TIMEOUT_TOLERANCE_PCT)));
146146

147-
(void)stepper_get_actual_position(fixture->dev, &pos);
147+
zassert_ok(stepper_get_actual_position(fixture->dev, &pos));
148148
zassert_equal(pos, 10u, "Target position should be %d but is %d", 10u, pos);
149149
zassert_equal(user_data_received, fixture->dev, "User data not received");
150150
}
@@ -203,21 +203,28 @@ ZTEST_F(stepper, test_stop)
203203
}
204204
}
205205

206-
ZTEST_F(stepper, test_move_by_zero_steps)
206+
ZTEST_F(stepper, test_move_zero_steps)
207207
{
208-
bool is_moving;
208+
bool moving;
209+
int32_t pos = 0;
210+
int32_t actual_steps;
209211
int err;
210212

211213
err = stepper_set_microstep_interval(fixture->dev, 100 * USEC_PER_SEC);
212214
if (err == -ENOSYS) {
213215
ztest_test_skip();
214216
}
215-
zassert_equal(err, 0, "Failed to set microstep interval");
217+
zassert_ok(err, "Failed to set microstep interval");
216218

217-
zassert_equal(stepper_move_by(fixture->dev, 0), 0, "Failed to move by zero steps");
219+
zassert_ok(stepper_move_by(fixture->dev, pos));
220+
POLL_AND_CHECK_SIGNAL(stepper_signal, stepper_event, STEPPER_EVENT_STEPS_COMPLETED,
221+
K_NO_WAIT);
222+
zassert_ok(stepper_is_moving(fixture->dev, &moving));
223+
zassert_false(moving, "%s reported moving even after completion of steps",
224+
fixture->dev->name);
225+
zassert_ok(stepper_move_to(fixture->dev, pos));
218226
POLL_AND_CHECK_SIGNAL(stepper_signal, stepper_event, STEPPER_EVENT_STEPS_COMPLETED,
219227
K_NO_WAIT);
220-
zassert_equal(stepper_is_moving(fixture->dev, &is_moving), 0,
221-
"Failed to check if stepper is moving");
222-
zassert_equal(is_moving, false, "Stepper is still moving");
228+
zassert_ok(stepper_get_actual_position(fixture->dev, &actual_steps));
229+
zassert_equal(pos, actual_steps, "Position should not have changed from %d", pos);
223230
}

0 commit comments

Comments
 (0)