@@ -131,6 +131,8 @@ ZTEST_F(stepper, test_actual_position)
131
131
ZTEST_F (stepper , test_move_to_positive_step_count )
132
132
{
133
133
int32_t pos = 10u ;
134
+ int32_t actual_steps ;
135
+ bool moving = false;
134
136
int ret ;
135
137
136
138
ret = stepper_set_microstep_interval (fixture -> dev , 100 * USEC_PER_SEC );
@@ -139,42 +141,73 @@ ZTEST_F(stepper, test_move_to_positive_step_count)
139
141
}
140
142
141
143
zassert_ok (stepper_move_to (fixture -> dev , pos ));
144
+ zassert_ok (stepper_is_moving (fixture -> dev , & moving ));
145
+ zassert_true (moving , "%s reported not moving after move_to" , fixture -> dev -> name );
142
146
143
147
POLL_AND_CHECK_SIGNAL (
144
148
stepper_signal , stepper_event , STEPPER_EVENT_STEPS_COMPLETED ,
145
149
K_MSEC (pos * (100 + CONFIG_STEPPER_TEST_TIMING_TIMEOUT_TOLERANCE_PCT )));
146
150
147
- zassert_ok (stepper_get_actual_position (fixture -> dev , & pos ));
148
- zassert_equal (pos , 10u , "Target position should be %d but is %d" , 10u , pos );
151
+ zassert_ok (stepper_get_actual_position (fixture -> dev , & actual_steps ));
152
+ zassert_equal (pos , actual_steps , "Position should be %d but is %d" , pos , actual_steps );
149
153
zassert_equal (user_data_received , fixture -> dev , "User data not received" );
154
+ zassert_ok (stepper_is_moving (fixture -> dev , & moving ));
155
+ zassert_false (moving , "%s reported moving even after completion of steps" ,
156
+ fixture -> dev -> name );
150
157
}
151
158
152
159
ZTEST_F (stepper , test_move_by_positive_step_count )
153
160
{
154
161
int32_t steps = 20 ;
162
+ int32_t actual_steps ;
163
+ bool moving = false;
164
+ int ret ;
155
165
156
- (void )stepper_set_microstep_interval (fixture -> dev , 100 * USEC_PER_SEC );
157
- (void )stepper_move_by (fixture -> dev , steps );
166
+ ret = stepper_set_microstep_interval (fixture -> dev , 100 * USEC_PER_SEC );
167
+ if (ret == - ENOSYS ) {
168
+ ztest_test_skip ();
169
+ }
170
+
171
+ zassert_ok (stepper_move_by (fixture -> dev , steps ));
172
+ zassert_ok (stepper_is_moving (fixture -> dev , & moving ));
173
+ zassert_true (moving , "%s reported not moving after move_by" , fixture -> dev -> name );
158
174
159
175
POLL_AND_CHECK_SIGNAL (
160
176
stepper_signal , stepper_event , STEPPER_EVENT_STEPS_COMPLETED ,
161
177
K_MSEC (steps * (100 + CONFIG_STEPPER_TEST_TIMING_TIMEOUT_TOLERANCE_PCT )));
162
- (void )stepper_get_actual_position (fixture -> dev , & steps );
163
- zassert_equal (steps , 20u , "Target position should be %d but is %d" , 20u , steps );
178
+
179
+ zassert_ok (stepper_get_actual_position (fixture -> dev , & actual_steps ));
180
+ zassert_equal (steps , actual_steps , "Position should be %d but is %d" , steps , actual_steps );
181
+ zassert_ok (stepper_is_moving (fixture -> dev , & moving ));
182
+ zassert_false (moving , "%s reported moving even after completion of steps" ,
183
+ fixture -> dev -> name );
164
184
}
165
185
166
186
ZTEST_F (stepper , test_move_by_negative_step_count )
167
187
{
168
188
int32_t steps = -20 ;
189
+ int32_t actual_steps ;
190
+ bool moving = false;
191
+ int ret ;
192
+
193
+ ret = stepper_set_microstep_interval (fixture -> dev , 100 * USEC_PER_SEC );
194
+ if (ret == - ENOSYS ) {
195
+ ztest_test_skip ();
196
+ }
169
197
170
- (void )stepper_set_microstep_interval (fixture -> dev , 100 * USEC_PER_SEC );
171
- (void )stepper_move_by (fixture -> dev , steps );
198
+ zassert_ok (stepper_move_by (fixture -> dev , steps ));
199
+ zassert_ok (stepper_is_moving (fixture -> dev , & moving ));
200
+ zassert_true (moving , "%s reported not moving after move_by" , fixture -> dev -> name );
172
201
173
202
POLL_AND_CHECK_SIGNAL (
174
203
stepper_signal , stepper_event , STEPPER_EVENT_STEPS_COMPLETED ,
175
204
K_MSEC (- steps * (100 + CONFIG_STEPPER_TEST_TIMING_TIMEOUT_TOLERANCE_PCT )));
176
- (void )stepper_get_actual_position (fixture -> dev , & steps );
177
- zassert_equal (steps , -20u , "Target position should be %d but is %d" , -20u , steps );
205
+
206
+ zassert_ok (stepper_get_actual_position (fixture -> dev , & actual_steps ));
207
+ zassert_equal (steps , actual_steps , "Position should be %d but is %d" , steps , actual_steps );
208
+ zassert_ok (stepper_is_moving (fixture -> dev , & moving ));
209
+ zassert_false (moving , "%s reported moving even after completion of steps" ,
210
+ fixture -> dev -> name );
178
211
}
179
212
180
213
ZTEST_F (stepper , test_stop )
0 commit comments