Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: minor fixes #372

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions tests/analog_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,14 +1418,11 @@ def check_for_glitch(data, threshold=0.3):
if channel is None:
# Both channels should idle at 0V before push due to being reset
is_idle_ok = is_idle_ok and are_values_within_range(data[:, :2000], -0.20, 0.20, channel)
assert is_idle_ok, "STEP1: Both channels should idle low before push due to being reset"
elif channel == libm2k.ANALOG_IN_CHANNEL_1:
# CH2 should idle at 0V if we are testing CH1
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_2)
assert is_idle_ok, "STEP1: CH2 should idle at 0V if we are testing CH1"
elif channel == libm2k.ANALOG_IN_CHANNEL_2:
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_1)
assert is_idle_ok, "STEP1: CH1 should idle at 0V if we are testing CH2"
# Shoud hold last sample from new buffer for current channel config
is_idle_ok = is_idle_ok and are_values_within_range(data[:, -2000:], cfg["amplitude"] * 0.85, cfg["amplitude"] * 1.15, channel)

Expand All @@ -1448,10 +1445,8 @@ def check_for_glitch(data, threshold=0.3):
if channel == libm2k.ANALOG_IN_CHANNEL_1:
# CH2 should idle at 0V if we are testing CH1
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_2)
assert is_idle_ok, "STEP2: CH2 should idle at 0V if we are testing CH1"
elif channel == libm2k.ANALOG_IN_CHANNEL_2:
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_1)
assert is_idle_ok, "STEP2: CH1 should idle at 0V if we are testing CH2"
glitched = glitched or check_for_glitch(data)
if gen_reports:
plot_to_file(title=f"Last Sample Hold: {chn_str} - {sr_str} - Falling Ramp",
Expand All @@ -1472,10 +1467,8 @@ def check_for_glitch(data, threshold=0.3):
if channel == libm2k.ANALOG_IN_CHANNEL_1:
# CH2 should idle at 0V if we are testing CH1
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_2)
assert is_idle_ok, "STEP3: CH2 should idle at 0V if we are testing CH1"
elif channel == libm2k.ANALOG_IN_CHANNEL_2:
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_1)
assert is_idle_ok, "STEP3: CH1 should idle at 0V if we are testing CH2"
glitched = glitched or check_for_glitch(data)
if gen_reports:
plot_to_file(title=f"Last Sample Hold: {chn_str} - {sr_str} - Rising Ramp",
Expand All @@ -1496,10 +1489,8 @@ def check_for_glitch(data, threshold=0.3):
if channel == libm2k.ANALOG_IN_CHANNEL_1:
# CH2 should idle at 0V if we are testing CH1
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_2)
assert is_idle_ok, "STEP4: CH2 should idle at 0V if we are testing CH1"
elif channel == libm2k.ANALOG_IN_CHANNEL_2:
is_idle_ok = is_idle_ok and are_values_within_range(data, -0.20, 0.20, libm2k.ANALOG_IN_CHANNEL_1)
assert is_idle_ok, "STEP4: CH1 should idle at 0V if we are testing CH2"
glitched = glitched or check_for_glitch(data)
if gen_reports:
plot_to_file(title=f"Last Sample Hold: {chn_str} - {sr_str} - Falling Ramp",
Expand Down
1 change: 1 addition & 0 deletions tests/dual_board/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results*
14 changes: 11 additions & 3 deletions tests/m2k_digital_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import unittest
import libm2k
from digital_functions import set_digital_trigger, check_digital_channels_state, check_digital_output, \
check_digital_trigger, check_open_drain_mode, test_kernel_buffers, test_pattern_generator_pulse
from digital_functions import (
check_digital_channels_state,
check_digital_output,
check_digital_trigger,
check_open_drain_mode,
set_digital_trigger,
test_kernel_buffers,
test_last_sample_hold,
test_pattern_generator_pulse,
)
from digital_functions import test_digital_cyclic_buffer
import reset_def_values as reset
from open_context import ctx, dig, d_trig
Expand Down Expand Up @@ -81,4 +89,4 @@ def test_last_sample_hold(self):
# All channels
result_ok = test_last_sample_hold(dig, d_trig, ctx, None)
with self.subTest(msg="DIO all"):
self.assertEqual(result_ok, True, f"Failed to hold the last sample on all DIO test")
self.assertEqual(result_ok, True, f"Failed to hold the last sample on all DIO test")
Loading