shepherd-core 2023.12.1__py3-none-any.whl → 2024.4.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shepherd_core/__init__.py +5 -4
- shepherd_core/calibration_hw_def.py +9 -1
- shepherd_core/commons.py +2 -0
- shepherd_core/data_models/__init__.py +11 -0
- shepherd_core/data_models/base/__init__.py +4 -1
- shepherd_core/data_models/base/cal_measurement.py +18 -6
- shepherd_core/data_models/base/calibration.py +41 -16
- shepherd_core/data_models/base/content.py +20 -5
- shepherd_core/data_models/base/shepherd.py +23 -12
- shepherd_core/data_models/base/timezone.py +5 -0
- shepherd_core/data_models/base/wrapper.py +3 -3
- shepherd_core/data_models/content/__init__.py +5 -4
- shepherd_core/data_models/content/_external_fixtures.yaml +32 -16
- shepherd_core/data_models/content/energy_environment.py +7 -5
- shepherd_core/data_models/content/energy_environment_fixture.yaml +3 -0
- shepherd_core/data_models/content/firmware.py +12 -5
- shepherd_core/data_models/content/firmware_datatype.py +7 -0
- shepherd_core/data_models/content/virtual_harvester.py +25 -20
- shepherd_core/data_models/content/virtual_harvester_fixture.yaml +1 -0
- shepherd_core/data_models/content/virtual_source.py +40 -23
- shepherd_core/data_models/content/virtual_source_fixture.yaml +1 -0
- shepherd_core/data_models/experiment/__init__.py +5 -4
- shepherd_core/data_models/experiment/experiment.py +16 -15
- shepherd_core/data_models/experiment/observer_features.py +18 -12
- shepherd_core/data_models/experiment/target_config.py +11 -7
- shepherd_core/data_models/readme.md +88 -0
- shepherd_core/data_models/task/__init__.py +10 -3
- shepherd_core/data_models/task/emulation.py +9 -6
- shepherd_core/data_models/task/firmware_mod.py +4 -2
- shepherd_core/data_models/task/harvest.py +5 -4
- shepherd_core/data_models/task/observer_tasks.py +4 -2
- shepherd_core/data_models/task/programming.py +3 -1
- shepherd_core/data_models/task/testbed_tasks.py +10 -4
- shepherd_core/data_models/testbed/__init__.py +5 -2
- shepherd_core/data_models/testbed/cape.py +8 -6
- shepherd_core/data_models/testbed/gpio.py +11 -9
- shepherd_core/data_models/testbed/mcu.py +10 -10
- shepherd_core/data_models/testbed/observer.py +10 -5
- shepherd_core/data_models/testbed/observer_fixture.yaml +23 -22
- shepherd_core/data_models/testbed/target.py +5 -3
- shepherd_core/data_models/testbed/target_fixture.yaml +11 -11
- shepherd_core/data_models/testbed/testbed.py +6 -3
- shepherd_core/decoder_waveform/__init__.py +2 -0
- shepherd_core/decoder_waveform/uart.py +44 -25
- shepherd_core/fw_tools/__init__.py +2 -0
- shepherd_core/fw_tools/converter.py +20 -9
- shepherd_core/fw_tools/converter_elf.py +3 -0
- shepherd_core/fw_tools/patcher.py +16 -4
- shepherd_core/fw_tools/validation.py +25 -5
- shepherd_core/inventory/__init__.py +66 -6
- shepherd_core/inventory/python.py +4 -0
- shepherd_core/inventory/system.py +13 -1
- shepherd_core/inventory/target.py +4 -0
- shepherd_core/logger.py +5 -0
- shepherd_core/reader.py +44 -26
- shepherd_core/testbed_client/__init__.py +2 -0
- shepherd_core/testbed_client/cache_path.py +17 -0
- shepherd_core/testbed_client/client.py +14 -8
- shepherd_core/testbed_client/fixtures.py +30 -11
- shepherd_core/testbed_client/user_model.py +13 -6
- shepherd_core/vsource/__init__.py +2 -0
- shepherd_core/vsource/virtual_converter_model.py +11 -4
- shepherd_core/vsource/virtual_harvester_model.py +8 -1
- shepherd_core/vsource/virtual_source_model.py +10 -5
- shepherd_core/writer.py +28 -20
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/METADATA +50 -34
- shepherd_core-2024.4.2.dist-info/RECORD +75 -0
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/WHEEL +1 -1
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/top_level.txt +0 -1
- shepherd_core-2023.12.1.dist-info/RECORD +0 -117
- tests/__init__.py +0 -0
- tests/conftest.py +0 -64
- tests/data_models/__init__.py +0 -0
- tests/data_models/conftest.py +0 -14
- tests/data_models/example_cal_data.yaml +0 -31
- tests/data_models/example_cal_data_faulty.yaml +0 -29
- tests/data_models/example_cal_meas.yaml +0 -178
- tests/data_models/example_cal_meas_faulty1.yaml +0 -142
- tests/data_models/example_cal_meas_faulty2.yaml +0 -136
- tests/data_models/example_config_emulator.yaml +0 -41
- tests/data_models/example_config_experiment.yaml +0 -16
- tests/data_models/example_config_experiment_alternative.yaml +0 -14
- tests/data_models/example_config_harvester.yaml +0 -15
- tests/data_models/example_config_testbed.yaml +0 -26
- tests/data_models/example_config_virtsource.yaml +0 -78
- tests/data_models/test_base_models.py +0 -205
- tests/data_models/test_content_fixtures.py +0 -41
- tests/data_models/test_content_models.py +0 -282
- tests/data_models/test_examples.py +0 -48
- tests/data_models/test_experiment_models.py +0 -277
- tests/data_models/test_task_generation.py +0 -52
- tests/data_models/test_task_models.py +0 -131
- tests/data_models/test_testbed_fixtures.py +0 -47
- tests/data_models/test_testbed_models.py +0 -187
- tests/decoder_waveform/__init__.py +0 -0
- tests/decoder_waveform/test_decoder.py +0 -34
- tests/fw_tools/__init__.py +0 -0
- tests/fw_tools/conftest.py +0 -5
- tests/fw_tools/test_converter.py +0 -76
- tests/fw_tools/test_patcher.py +0 -66
- tests/fw_tools/test_validation.py +0 -56
- tests/inventory/__init__.py +0 -0
- tests/inventory/test_inventory.py +0 -20
- tests/test_cal_hw.py +0 -34
- tests/test_examples.py +0 -40
- tests/test_logger.py +0 -15
- tests/test_reader.py +0 -283
- tests/test_writer.py +0 -169
- tests/testbed_client/__init__.py +0 -0
- tests/vsource/__init__.py +0 -0
- tests/vsource/conftest.py +0 -49
- tests/vsource/test_converter.py +0 -161
- tests/vsource/test_harvester.py +0 -73
- tests/vsource/test_z.py +0 -5
- /shepherd_core/data_models/{doc_virtual_source.py → virtual_source_doc.txt} +0 -0
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/zip-safe +0 -0
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Union
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
from shepherd_core.data_models import Experiment
|
|
7
|
-
from shepherd_core.data_models import FirmwareDType
|
|
8
|
-
from shepherd_core.data_models import GpioActuation
|
|
9
|
-
from shepherd_core.data_models import GpioEvent
|
|
10
|
-
from shepherd_core.data_models.task import ObserverTasks
|
|
11
|
-
from shepherd_core.data_models.task.emulation import EmulationTask
|
|
12
|
-
from shepherd_core.data_models.task.firmware_mod import FirmwareModTask
|
|
13
|
-
from shepherd_core.data_models.task.harvest import HarvestTask
|
|
14
|
-
from shepherd_core.data_models.task.programming import ProgrammingTask
|
|
15
|
-
from shepherd_core.data_models.testbed import GPIO
|
|
16
|
-
from shepherd_core.data_models.testbed import ProgrammerProtocol
|
|
17
|
-
from shepherd_core.data_models.testbed import Testbed as TasteBad
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def test_task_model_emu_min() -> None:
|
|
21
|
-
EmulationTask(
|
|
22
|
-
input_path="./here",
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def test_task_model_emu_fault_in_past() -> None:
|
|
27
|
-
with pytest.raises(ValueError):
|
|
28
|
-
EmulationTask(
|
|
29
|
-
input_path="./here",
|
|
30
|
-
time_start="1984-01-01 11:12:13",
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@pytest.mark.parametrize("value", [0, 1, 2, 3, 4, 4.5, "buffer", "main"])
|
|
35
|
-
def test_task_model_emu_custom_aux(value: Union[float, str]) -> None:
|
|
36
|
-
EmulationTask(
|
|
37
|
-
input_path="./here",
|
|
38
|
-
voltage_aux=value,
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@pytest.mark.parametrize("value", [-1.0, 5, "max", "something"])
|
|
43
|
-
def test_task_model_emu_fault_aux(value: Union[float, str]) -> None:
|
|
44
|
-
with pytest.raises(ValueError):
|
|
45
|
-
EmulationTask(
|
|
46
|
-
input_path="./here",
|
|
47
|
-
voltage_aux=value,
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_task_model_emu_fault_gpio_actuation() -> None:
|
|
52
|
-
with pytest.raises(ValueError):
|
|
53
|
-
EmulationTask(
|
|
54
|
-
input_path="./here",
|
|
55
|
-
gpio_actuation=GpioActuation(
|
|
56
|
-
events=[GpioEvent(delay=5, gpio=GPIO(name="GPIO5"))],
|
|
57
|
-
),
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def test_task_model_fw_min() -> None:
|
|
62
|
-
FirmwareModTask(
|
|
63
|
-
data=Path("/"),
|
|
64
|
-
data_type=FirmwareDType.path_elf,
|
|
65
|
-
custom_id=42,
|
|
66
|
-
firmware_file=Path("fw_to_be.elf"),
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_task_model_fw_fault_hex() -> None:
|
|
71
|
-
# just a warning for now
|
|
72
|
-
FirmwareModTask(
|
|
73
|
-
data=Path("/"),
|
|
74
|
-
data_type=FirmwareDType.path_hex,
|
|
75
|
-
custom_id=42,
|
|
76
|
-
firmware_file=Path("fw_to_be.hex"),
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def test_task_model_hrv_min() -> None:
|
|
81
|
-
HarvestTask(
|
|
82
|
-
output_path="./here",
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def test_task_model_hrv_duration() -> None:
|
|
87
|
-
hrv = HarvestTask(
|
|
88
|
-
output_path="./here",
|
|
89
|
-
duration=42,
|
|
90
|
-
)
|
|
91
|
-
assert hrv.duration.total_seconds() == 42
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def test_task_model_hrv_too_late() -> None:
|
|
95
|
-
with pytest.raises(ValueError):
|
|
96
|
-
HarvestTask(
|
|
97
|
-
output_path="./here",
|
|
98
|
-
time_start="1984-01-01 11:12:13",
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def test_task_model_observer_min1() -> None:
|
|
103
|
-
ObserverTasks(
|
|
104
|
-
observer="peeping tom",
|
|
105
|
-
owner_id=666,
|
|
106
|
-
time_prep="2044-01-01 12:13:14",
|
|
107
|
-
root_path="/usr",
|
|
108
|
-
abort_on_error=False,
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def test_task_model_observer_min2() -> None:
|
|
113
|
-
path = Path(__file__).with_name("example_config_experiment.yaml")
|
|
114
|
-
xp = Experiment.from_file(path)
|
|
115
|
-
ObserverTasks.from_xp(xp=xp, tb=TasteBad(name="shepherd_tud_nes"), tgt_id=1)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def test_task_model_prog_min() -> None:
|
|
119
|
-
ProgrammingTask(
|
|
120
|
-
firmware_file=Path("fw_to_load.hex"),
|
|
121
|
-
protocol=ProgrammerProtocol.SWD,
|
|
122
|
-
mcu_type="nrf52",
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def test_task_model_prog_fault_elf() -> None:
|
|
127
|
-
ProgrammingTask(
|
|
128
|
-
firmware_file=Path("fw_to_load.elf"),
|
|
129
|
-
protocol=ProgrammerProtocol.SWD,
|
|
130
|
-
mcu_type="nrf52",
|
|
131
|
-
)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from shepherd_core.data_models.content.firmware import Firmware
|
|
2
|
-
from shepherd_core.data_models.testbed.cape import Cape
|
|
3
|
-
from shepherd_core.data_models.testbed.gpio import GPIO
|
|
4
|
-
from shepherd_core.data_models.testbed.mcu import MCU
|
|
5
|
-
from shepherd_core.data_models.testbed.observer import Observer
|
|
6
|
-
from shepherd_core.data_models.testbed.target import Target
|
|
7
|
-
from shepherd_core.data_models.testbed.testbed import Testbed as TasteBad
|
|
8
|
-
from shepherd_core.testbed_client.fixtures import Fixtures
|
|
9
|
-
|
|
10
|
-
# ⤷ TasteBad avoids pytest-warning
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_testbed_fixture_cape() -> None:
|
|
14
|
-
for fix in Fixtures()["Cape"]:
|
|
15
|
-
Cape(name=fix["name"])
|
|
16
|
-
Cape(id=fix["id"])
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def test_testbed_fixture_gpio() -> None:
|
|
20
|
-
for fix in Fixtures()["GPIO"]:
|
|
21
|
-
GPIO(name=fix["name"])
|
|
22
|
-
GPIO(id=fix["id"])
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def test_testbed_fixture_mcu() -> None:
|
|
26
|
-
for fix in Fixtures()["MCU"]:
|
|
27
|
-
MCU(name=fix["name"])
|
|
28
|
-
mcu = MCU(id=fix["id"])
|
|
29
|
-
Firmware(name=mcu.fw_name_default)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_testbed_fixture_observer() -> None:
|
|
33
|
-
for fix in Fixtures()["Observer"]:
|
|
34
|
-
Observer(name=fix["name"])
|
|
35
|
-
Observer(id=fix["id"])
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def test_testbed_fixture_target() -> None:
|
|
39
|
-
for fix in Fixtures()["Target"]:
|
|
40
|
-
Target(name=fix["name"])
|
|
41
|
-
Target(id=fix["id"])
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def test_testbed_fixture_tb() -> None:
|
|
45
|
-
for fix in Fixtures()["Testbed"]:
|
|
46
|
-
TasteBad(name=fix["name"])
|
|
47
|
-
TasteBad(id=fix["id"])
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from shepherd_core.data_models.testbed import GPIO
|
|
4
|
-
from shepherd_core.data_models.testbed import MCU
|
|
5
|
-
from shepherd_core.data_models.testbed import Cape
|
|
6
|
-
from shepherd_core.data_models.testbed import Direction
|
|
7
|
-
from shepherd_core.data_models.testbed import Observer
|
|
8
|
-
from shepherd_core.data_models.testbed import ProgrammerProtocol
|
|
9
|
-
from shepherd_core.data_models.testbed import Target
|
|
10
|
-
from shepherd_core.data_models.testbed import Testbed as TasteBad
|
|
11
|
-
|
|
12
|
-
# ⤷ TasteBad avoids pytest-warning
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_testbed_model_cape_min() -> None:
|
|
16
|
-
cape = Cape(
|
|
17
|
-
id=9999,
|
|
18
|
-
name="cappi",
|
|
19
|
-
version="1.0.0",
|
|
20
|
-
description="lorem",
|
|
21
|
-
)
|
|
22
|
-
print(cape)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def test_testbed_model_gpio_min() -> None:
|
|
26
|
-
gpio = GPIO(
|
|
27
|
-
id=9999,
|
|
28
|
-
name="gippi",
|
|
29
|
-
reg_pru="ABCD",
|
|
30
|
-
pin_pru="EFGH",
|
|
31
|
-
)
|
|
32
|
-
print(gpio)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_testbed_model_gpio_fault() -> None:
|
|
36
|
-
with pytest.raises(ValueError):
|
|
37
|
-
GPIO(
|
|
38
|
-
id=9999,
|
|
39
|
-
name="gippi",
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def test_testbed_model_gpio_var() -> None:
|
|
44
|
-
GPIO(
|
|
45
|
-
id=9999,
|
|
46
|
-
name="gippi",
|
|
47
|
-
direction=Direction.Bidirectional,
|
|
48
|
-
reg_pru="ABCD",
|
|
49
|
-
pin_pru="EFGH",
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def test_testbed_model_mcu_min() -> None:
|
|
54
|
-
mcu = MCU(
|
|
55
|
-
id=9922,
|
|
56
|
-
name="controller2",
|
|
57
|
-
description="lorem",
|
|
58
|
-
platform="arm32",
|
|
59
|
-
core="STM32F7",
|
|
60
|
-
prog_protocol=ProgrammerProtocol.SWD,
|
|
61
|
-
fw_name_default="nananana",
|
|
62
|
-
)
|
|
63
|
-
print(mcu)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def test_testbed_model_observer_min() -> None:
|
|
67
|
-
obs = Observer(
|
|
68
|
-
id=9933,
|
|
69
|
-
name="sheep120",
|
|
70
|
-
description="not existing",
|
|
71
|
-
ip="127.0.0.1",
|
|
72
|
-
mac="FF:FF:FF:FF:FF:FF",
|
|
73
|
-
room="IIE72",
|
|
74
|
-
eth_port="375b2",
|
|
75
|
-
cape=Cape(name="cape53"),
|
|
76
|
-
)
|
|
77
|
-
print(obs)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def test_testbed_model_observer_fault_cape_a() -> None:
|
|
81
|
-
with pytest.raises(ValueError):
|
|
82
|
-
Observer(
|
|
83
|
-
id=9933,
|
|
84
|
-
name="sheep120",
|
|
85
|
-
description="not existing",
|
|
86
|
-
ip="127.0.0.1",
|
|
87
|
-
mac="FF:FF:FF:FF:FF:FF",
|
|
88
|
-
room="IIE72",
|
|
89
|
-
eth_port="375b2",
|
|
90
|
-
target_a=Target(id=3),
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def test_testbed_model_observer_fault_cape_b() -> None:
|
|
95
|
-
with pytest.raises(ValueError):
|
|
96
|
-
Observer(
|
|
97
|
-
id=9933,
|
|
98
|
-
name="sheep120",
|
|
99
|
-
description="not existing",
|
|
100
|
-
ip="127.0.0.1",
|
|
101
|
-
mac="FF:FF:FF:FF:FF:FF",
|
|
102
|
-
room="IIE72",
|
|
103
|
-
eth_port="375b2",
|
|
104
|
-
target_b=Target(id=3),
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def test_testbed_model_observer_fault_target() -> None:
|
|
109
|
-
obs = Observer(
|
|
110
|
-
id=9933,
|
|
111
|
-
name="sheep120",
|
|
112
|
-
description="not existing",
|
|
113
|
-
ip="127.0.0.1",
|
|
114
|
-
mac="FF:FF:FF:FF:FF:FF",
|
|
115
|
-
room="IIE72",
|
|
116
|
-
eth_port="375b2",
|
|
117
|
-
cape=Cape(name="cape53"),
|
|
118
|
-
target_a=Target(id=3),
|
|
119
|
-
target_b=Target(id=2),
|
|
120
|
-
)
|
|
121
|
-
obs.get_target(2)
|
|
122
|
-
obs.get_target(3)
|
|
123
|
-
obs.get_target_port(2)
|
|
124
|
-
obs.get_target_port(3)
|
|
125
|
-
with pytest.raises(ValueError):
|
|
126
|
-
obs.get_target_port(123456)
|
|
127
|
-
with pytest.raises(ValueError):
|
|
128
|
-
obs.get_target(123456)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def test_testbed_model_target_min1() -> None:
|
|
132
|
-
tgt = Target(
|
|
133
|
-
id=9944,
|
|
134
|
-
name="TerraTarget",
|
|
135
|
-
version="v1.00",
|
|
136
|
-
description="lorem",
|
|
137
|
-
mcu1=MCU(name="MSP430FR"),
|
|
138
|
-
)
|
|
139
|
-
print(tgt)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def test_testbed_model_target_min2() -> None:
|
|
143
|
-
Target(
|
|
144
|
-
id=9944,
|
|
145
|
-
name="TerraTarget",
|
|
146
|
-
version="v1.00",
|
|
147
|
-
description="lorem",
|
|
148
|
-
mcu1="MSP430FR",
|
|
149
|
-
mcu2="MSP430FR",
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def test_testbed_model_tb_min() -> None:
|
|
154
|
-
tb = TasteBad(
|
|
155
|
-
name="shepherd",
|
|
156
|
-
id="9955",
|
|
157
|
-
description="lorem",
|
|
158
|
-
observers=[Observer(name="sheep02")],
|
|
159
|
-
data_on_server="/mnt/driveA",
|
|
160
|
-
data_on_observer="/mnt/driveB",
|
|
161
|
-
)
|
|
162
|
-
print(tb)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
def test_testbed_model_tb_fault_observer() -> None:
|
|
166
|
-
with pytest.raises(ValueError):
|
|
167
|
-
TasteBad(
|
|
168
|
-
name="shepherd",
|
|
169
|
-
id="9955",
|
|
170
|
-
description="lorem",
|
|
171
|
-
observers=[Observer(name="sheep02"), Observer(name="sheep02")],
|
|
172
|
-
data_on_server="/mnt/driveA",
|
|
173
|
-
data_on_observer="/mnt/driveB",
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def test_testbed_model_tb_fault_shared() -> None:
|
|
178
|
-
with pytest.raises(ValueError):
|
|
179
|
-
TasteBad(
|
|
180
|
-
name="shepherd",
|
|
181
|
-
id="9955",
|
|
182
|
-
description="lorem",
|
|
183
|
-
observers=[Observer(name="sheep02")],
|
|
184
|
-
data_on_server="/mnt/driveA",
|
|
185
|
-
data_on_observer="/mnt/driveB",
|
|
186
|
-
shared_storage=False,
|
|
187
|
-
)
|
|
File without changes
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_core.decoder_waveform import Uart
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@pytest.fixture
|
|
9
|
-
def example_path() -> Path:
|
|
10
|
-
return Path(__file__).resolve().parent.parent.parent / "examples"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_decode_uart(example_path: Path) -> None:
|
|
14
|
-
uwd = Uart(example_path / "uart_raw2.csv")
|
|
15
|
-
_ = uwd.get_symbols()
|
|
16
|
-
_ = uwd.get_lines()
|
|
17
|
-
_ = uwd.get_text()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def test_decode_speedup(example_path: Path) -> None:
|
|
21
|
-
uwd = Uart(example_path / "uart_raw2.csv")
|
|
22
|
-
_ = uwd.get_symbols(force_redo=True)
|
|
23
|
-
_ = uwd.get_lines(force_redo=True)
|
|
24
|
-
_ = uwd.get_text(force_redo=True)
|
|
25
|
-
|
|
26
|
-
# these now have cached the result
|
|
27
|
-
_ = uwd.get_symbols()
|
|
28
|
-
_ = uwd.get_lines()
|
|
29
|
-
_ = uwd.get_text()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_decode_chained(example_path: Path) -> None:
|
|
33
|
-
uwd = Uart(example_path / "uart_raw2.csv")
|
|
34
|
-
_ = uwd.get_text() # get_symbols() and get_lines() is executed automatically
|
tests/fw_tools/__init__.py
DELETED
|
File without changes
|
tests/fw_tools/conftest.py
DELETED
tests/fw_tools/test_converter.py
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_core import fw_tools
|
|
6
|
-
|
|
7
|
-
from .conftest import files_elf
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@pytest.fixture()
|
|
11
|
-
def path_hex(tmp_path: Path) -> Path:
|
|
12
|
-
path_elf = files_elf[0]
|
|
13
|
-
path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
|
|
14
|
-
return fw_tools.elf_to_hex(path_elf, path_hex)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@pytest.mark.converter
|
|
18
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
19
|
-
def test_elf_to_hex(path_elf: Path, tmp_path: Path) -> None:
|
|
20
|
-
path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
|
|
21
|
-
path_gen = fw_tools.elf_to_hex(path_elf, path_hex)
|
|
22
|
-
assert path_hex.exists()
|
|
23
|
-
assert path_hex.as_posix() == path_gen.as_posix()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@pytest.mark.elf
|
|
27
|
-
@pytest.mark.converter
|
|
28
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
29
|
-
def test_firmware_to_hex_w_elf(path_elf: Path) -> None:
|
|
30
|
-
path_gen = fw_tools.firmware_to_hex(path_elf)
|
|
31
|
-
assert path_gen.exists
|
|
32
|
-
assert path_gen.suffix.lower() == ".hex"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@pytest.mark.elf
|
|
36
|
-
@pytest.mark.converter
|
|
37
|
-
def test_firmware_to_hex_w_hex(path_hex: Path) -> None:
|
|
38
|
-
path_gen = fw_tools.firmware_to_hex(path_hex)
|
|
39
|
-
assert path_gen.exists
|
|
40
|
-
assert path_gen.suffix.lower() == ".hex"
|
|
41
|
-
assert path_gen.as_posix() == path_hex.as_posix()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@pytest.mark.elf
|
|
45
|
-
@pytest.mark.converter
|
|
46
|
-
def test_firmware_to_hex_w_fail() -> None:
|
|
47
|
-
path_some = Path(__file__).parent / "conftest.py"
|
|
48
|
-
with pytest.raises(ValueError):
|
|
49
|
-
_ = fw_tools.firmware_to_hex(path_some)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@pytest.mark.elf
|
|
53
|
-
@pytest.mark.converter
|
|
54
|
-
def test_hash() -> None:
|
|
55
|
-
hash_a = fw_tools.file_to_hash(files_elf[0])
|
|
56
|
-
hash_b = fw_tools.file_to_hash(files_elf[1])
|
|
57
|
-
hash_c = fw_tools.file_to_hash(files_elf[1])
|
|
58
|
-
assert hash_a != hash_b
|
|
59
|
-
assert hash_b == hash_c
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
@pytest.mark.elf
|
|
63
|
-
@pytest.mark.converter
|
|
64
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
65
|
-
def test_base64(path_elf: Path, tmp_path: Path) -> None:
|
|
66
|
-
b64_a = fw_tools.file_to_base64(path_elf)
|
|
67
|
-
path_b = (tmp_path / path_elf.name).resolve()
|
|
68
|
-
fw_tools.base64_to_file(b64_a, path_b)
|
|
69
|
-
b64_b = fw_tools.file_to_base64(path_b)
|
|
70
|
-
assert b64_a == b64_b
|
|
71
|
-
hash_a = fw_tools.file_to_hash(path_elf)
|
|
72
|
-
hash_b = fw_tools.file_to_hash(path_b)
|
|
73
|
-
assert hash_a == hash_b
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# extract_firmware() is indirectly tested with Firmware-Class
|
tests/fw_tools/test_patcher.py
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import shutil
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
from shepherd_core import fw_tools
|
|
7
|
-
|
|
8
|
-
from .conftest import files_elf
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@pytest.mark.elf
|
|
12
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
13
|
-
def test_sym_finding(path_elf: Path) -> None:
|
|
14
|
-
assert fw_tools.find_symbol(path_elf, "SHEPHERD_NODE_ID")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@pytest.mark.elf
|
|
18
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
19
|
-
def test_sym_reading(path_elf: Path) -> None:
|
|
20
|
-
assert fw_tools.read_symbol(path_elf, "SHEPHERD_NODE_ID")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@pytest.mark.elf
|
|
24
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
25
|
-
def test_sym_mod(path_elf: Path, tmp_path: Path) -> None:
|
|
26
|
-
value = 0xCAFE
|
|
27
|
-
sym = "SHEPHERD_NODE_ID"
|
|
28
|
-
path_new = tmp_path / path_elf.name
|
|
29
|
-
shutil.copy(path_elf, path_new)
|
|
30
|
-
path_gen = fw_tools.modify_symbol_value(path_new, sym, value, overwrite=False)
|
|
31
|
-
assert path_gen.is_file()
|
|
32
|
-
assert path_gen.as_posix() != path_new.as_posix()
|
|
33
|
-
value_new = fw_tools.read_symbol(path_gen, sym)
|
|
34
|
-
assert value == value_new
|
|
35
|
-
value_old = fw_tools.read_symbol(path_elf, sym)
|
|
36
|
-
assert value_new != value_old
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@pytest.mark.elf
|
|
40
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
41
|
-
def test_sym_mod_overwrite(path_elf: Path, tmp_path: Path) -> None:
|
|
42
|
-
value = 0xCAFE
|
|
43
|
-
sym = "SHEPHERD_NODE_ID"
|
|
44
|
-
path_new = tmp_path / path_elf.name
|
|
45
|
-
shutil.copy(path_elf, path_new)
|
|
46
|
-
path_gen = fw_tools.modify_symbol_value(
|
|
47
|
-
path_new, sym, value, overwrite=True
|
|
48
|
-
) # TODO: WinOS-trouble
|
|
49
|
-
assert path_gen.is_file()
|
|
50
|
-
assert path_gen.as_posix() == path_new.as_posix()
|
|
51
|
-
value_new = fw_tools.read_symbol(path_gen, sym)
|
|
52
|
-
assert value == value_new
|
|
53
|
-
value_old = fw_tools.read_symbol(path_elf, sym)
|
|
54
|
-
assert value_new != value_old
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@pytest.mark.elf
|
|
58
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
59
|
-
def test_id_mod(path_elf: Path, tmp_path: Path) -> None:
|
|
60
|
-
value = 0xCAFE
|
|
61
|
-
path_new = tmp_path / path_elf.name
|
|
62
|
-
shutil.copy(path_elf, path_new)
|
|
63
|
-
path_gen = fw_tools.modify_uid(path_new, value)
|
|
64
|
-
assert path_gen.as_posix() == path_new.as_posix()
|
|
65
|
-
value_new = fw_tools.read_symbol(path_gen, "SHEPHERD_NODE_ID")
|
|
66
|
-
assert value == value_new
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_core import fw_tools
|
|
6
|
-
from shepherd_core.data_models import FirmwareDType
|
|
7
|
-
|
|
8
|
-
from .conftest import files_elf
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@pytest.mark.elf
|
|
12
|
-
@pytest.mark.converter
|
|
13
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
14
|
-
def test_elf_detection(path_elf: Path) -> None:
|
|
15
|
-
assert fw_tools.is_elf(path_elf)
|
|
16
|
-
if "nrf" in path_elf.name:
|
|
17
|
-
assert fw_tools.is_elf_nrf52(path_elf)
|
|
18
|
-
elif "msp" in path_elf.name:
|
|
19
|
-
assert fw_tools.is_elf_msp430(path_elf)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@pytest.mark.elf
|
|
23
|
-
@pytest.mark.converter
|
|
24
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
25
|
-
def test_elf_determination(path_elf: Path) -> None:
|
|
26
|
-
assert fw_tools.determine_type(path_elf) == FirmwareDType.path_elf
|
|
27
|
-
if "nrf" in path_elf.name:
|
|
28
|
-
assert fw_tools.determine_arch(path_elf) == "nrf52"
|
|
29
|
-
elif "msp" in path_elf.name:
|
|
30
|
-
assert fw_tools.determine_arch(path_elf) == "msp430"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@pytest.mark.elf
|
|
34
|
-
@pytest.mark.converter
|
|
35
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
36
|
-
def test_hex_detection(path_elf: Path, tmp_path: Path) -> None:
|
|
37
|
-
path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
|
|
38
|
-
path_hex = fw_tools.elf_to_hex(path_elf, path_hex)
|
|
39
|
-
assert fw_tools.is_hex(path_hex)
|
|
40
|
-
if "nrf" in path_elf.name:
|
|
41
|
-
assert fw_tools.is_hex_nrf52(path_hex)
|
|
42
|
-
elif "msp" in path_elf.name:
|
|
43
|
-
assert fw_tools.is_hex_msp430(path_hex)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@pytest.mark.elf
|
|
47
|
-
@pytest.mark.converter
|
|
48
|
-
@pytest.mark.parametrize("path_elf", files_elf)
|
|
49
|
-
def test_hex_determination(path_elf: Path, tmp_path: Path) -> None:
|
|
50
|
-
path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
|
|
51
|
-
path_hex = fw_tools.elf_to_hex(path_elf, path_hex)
|
|
52
|
-
assert fw_tools.determine_type(path_hex) == FirmwareDType.path_hex
|
|
53
|
-
if "nrf" in path_elf.name:
|
|
54
|
-
assert fw_tools.determine_arch(path_hex) == "nrf52"
|
|
55
|
-
elif "msp" in path_elf.name:
|
|
56
|
-
assert fw_tools.determine_arch(path_hex) == "msp430"
|
tests/inventory/__init__.py
DELETED
|
File without changes
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_core.inventory import Inventory
|
|
6
|
-
from shepherd_core.inventory import InventoryList
|
|
7
|
-
from shepherd_core.inventory import PythonInventory
|
|
8
|
-
from shepherd_core.inventory import SystemInventory
|
|
9
|
-
from shepherd_core.inventory import TargetInventory
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@pytest.mark.parametrize("inv", [PythonInventory, SystemInventory, TargetInventory, Inventory])
|
|
13
|
-
def test_collect_data(inv: Inventory) -> None:
|
|
14
|
-
inv.collect()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def test_inventorize(tmp_path: Path) -> None:
|
|
18
|
-
inv = Inventory.collect()
|
|
19
|
-
inl = InventoryList(elements=[inv])
|
|
20
|
-
inl.to_csv(tmp_path / "some.csv")
|
tests/test_cal_hw.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from typing import Callable
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_core.calibration_hw_def import adc_current_to_raw
|
|
6
|
-
from shepherd_core.calibration_hw_def import adc_raw_to_current
|
|
7
|
-
from shepherd_core.calibration_hw_def import adc_raw_to_voltage
|
|
8
|
-
from shepherd_core.calibration_hw_def import adc_voltage_to_raw
|
|
9
|
-
from shepherd_core.calibration_hw_def import dac_raw_to_voltage
|
|
10
|
-
from shepherd_core.calibration_hw_def import dac_voltage_to_raw
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@pytest.mark.parametrize("fn", [adc_current_to_raw, adc_voltage_to_raw, dac_voltage_to_raw])
|
|
14
|
-
def test_convert_to_raw(fn: Callable) -> None:
|
|
15
|
-
values = [-1, -1e-6, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e-0]
|
|
16
|
-
value_prev = -1
|
|
17
|
-
for value in values:
|
|
18
|
-
value_raw = fn(value)
|
|
19
|
-
assert value_raw >= 0
|
|
20
|
-
assert value_raw < 2**18
|
|
21
|
-
assert value_raw >= value_prev
|
|
22
|
-
value_prev = value_raw
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@pytest.mark.parametrize("fn", [adc_raw_to_current, adc_raw_to_voltage, dac_raw_to_voltage])
|
|
26
|
-
def test_convert_to_si(fn: Callable) -> None:
|
|
27
|
-
values = [-100, -1, 0, 1, 2**6, 2**12, 2**18, 2**24]
|
|
28
|
-
value_prev = -1
|
|
29
|
-
for value in values:
|
|
30
|
-
value_si = fn(value)
|
|
31
|
-
assert value_si >= 0
|
|
32
|
-
assert value_si <= 6
|
|
33
|
-
assert value_si >= value_prev
|
|
34
|
-
value_prev = value_si
|