From e318a9f9c103e4e1ca595fee9d03381ae07d0191 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 31 Jan 2022 01:18:40 +0100 Subject: [PATCH] tests/motion:: ensure stepTimerQuantum is always respected This catches motion stutters as fixed in 502f42b7bec4477414f2275fad4d76fb8ca00753 --- tests/unit/modules/motion/rampgen.cpp | 3 ++- tests/unit/modules/motion/test_motion_ramp.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/unit/modules/motion/rampgen.cpp b/tests/unit/modules/motion/rampgen.cpp index 940fe0f..d687626 100644 --- a/tests/unit/modules/motion/rampgen.cpp +++ b/tests/unit/modules/motion/rampgen.cpp @@ -34,7 +34,8 @@ int main(int argc, const char *argv[]) { const int maxJerk = 1; // write common parameters - fprintf(fd, "{\"timebase\": %lu}\n", F_CPU / config::stepTimerFrequencyDivider); + fprintf(fd, "{\"timebase\": %lu, \"quantum\": %u}\n", + F_CPU / config::stepTimerFrequencyDivider, config::stepTimerQuantum); for (int ax_cnt = 0; ax_cnt != 2; ++ax_cnt) { for (int accel = 2000; accel <= 50000; accel *= 2) { diff --git a/tests/unit/modules/motion/test_motion_ramp.py b/tests/unit/modules/motion/test_motion_ramp.py index cdd02ed..959cc4f 100755 --- a/tests/unit/modules/motion/test_motion_ramp.py +++ b/tests/unit/modules/motion/test_motion_ramp.py @@ -156,6 +156,15 @@ def check_run(info, run): ax_info, data = run ax_count = len(ax_info) + # first and last interval should always be zero + assert (data[0][1] == 0) + assert (data[-1][1] == 0) + + # ensure no interval is shorter than the specified quantum + for i in range(1, len(data) - 2): + interval = data[i][1] + assert (interval >= info['quantum']) + # split axis information ax_data = [] for ax in range(ax_count):