Add test for untrimmed MCUs
Add a test that verifies that programming untrimmed MCUs results in an error.
This commit is contained in:
parent
7d9f512b6d
commit
4fe0a30072
5
tests/stc8f2k08s2-untrimmed.yml
Normal file
5
tests/stc8f2k08s2-untrimmed.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
name: STC8F2K08S2 untrimmed programming test
|
||||||
|
protocol: stc8
|
||||||
|
code_data: [49, 50, 51, 52, 53, 54, 55, 56, 57]
|
||||||
|
responses:
|
||||||
|
- [0x50, 0xFF, 0xFF, 0xFF, 0xFF, 0x8F, 0x00, 0x04, 0xFF, 0xFF, 0x8B, 0xFD, 0xFF, 0x27, 0x38, 0xF5, 0x73, 0x73, 0x55, 0x00, 0xF6, 0x41, 0x0A, 0x88, 0x86, 0x6F, 0x8F, 0x08, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x20, 0x05, 0x3C, 0x18, 0x05, 0x22, 0x32, 0xFF]
|
@ -27,6 +27,7 @@ from unittest.mock import patch
|
|||||||
import yaml
|
import yaml
|
||||||
import stcgal.frontend
|
import stcgal.frontend
|
||||||
import stcgal.protocols
|
import stcgal.protocols
|
||||||
|
from stcgal.protocols import StcProtocolException
|
||||||
|
|
||||||
def convert_to_bytes(list_of_lists):
|
def convert_to_bytes(list_of_lists):
|
||||||
"""Convert lists of integer lists to list of byte lists"""
|
"""Convert lists of integer lists to list of byte lists"""
|
||||||
@ -128,6 +129,24 @@ class ProgramTests(unittest.TestCase):
|
|||||||
"""Test a programming cycle with STC15 protocol, L1 series"""
|
"""Test a programming cycle with STC15 protocol, L1 series"""
|
||||||
self._program_yml("./tests/stc15l104w.yml", serial_mock, read_mock)
|
self._program_yml("./tests/stc15l104w.yml", serial_mock, read_mock)
|
||||||
|
|
||||||
|
@patch("stcgal.protocols.StcBaseProtocol.read_packet")
|
||||||
|
@patch("stcgal.protocols.Stc89Protocol.write_packet")
|
||||||
|
@patch("stcgal.protocols.serial.Serial", autospec=True)
|
||||||
|
@patch("stcgal.protocols.time.sleep")
|
||||||
|
@patch("sys.stdout")
|
||||||
|
def test_program_stc8_untrimmed(self, out, sleep_mock, serial_mock, write_mock, read_mock):
|
||||||
|
"""Test error with untrimmed MCU"""
|
||||||
|
with open("./tests/stc8f2k08s2-untrimmed.yml") as test_file:
|
||||||
|
test_data = yaml.load(test_file.read())
|
||||||
|
opts = get_default_opts()
|
||||||
|
opts.trim = 0.0
|
||||||
|
opts.protocol = test_data["protocol"]
|
||||||
|
opts.code_image.read.return_value = bytes(test_data["code_data"])
|
||||||
|
serial_mock.return_value.inWaiting.return_value = 1
|
||||||
|
read_mock.side_effect = convert_to_bytes(test_data["responses"])
|
||||||
|
gal = stcgal.frontend.StcGal(opts)
|
||||||
|
self.assertEqual(gal.run(), 1)
|
||||||
|
|
||||||
def test_program_stc15w4_usb(self):
|
def test_program_stc15w4_usb(self):
|
||||||
"""Test a programming cycle with STC15W4 USB protocol"""
|
"""Test a programming cycle with STC15W4 USB protocol"""
|
||||||
self.skipTest("USB not supported yet, trace missing")
|
self.skipTest("USB not supported yet, trace missing")
|
||||||
|
Loading…
Reference in New Issue
Block a user