]> Repositories - Adafruit_Blinka-hackapet.git/blob - notes/index.md
bde75a307ff8fc8ff9100bb64bbf3c969f86711e
[Adafruit_Blinka-hackapet.git] / notes / index.md
1 This repository is structured around integration tests found in the python/testing
2 directory. The tests offer a procedural way to assert equivalence between 'native' CircuitPython (CP) behaviour and 
3 behaviour of the MicropythonCircuitPython (MCP) layer.
4
5
6 In particular, automated introspection of the python runtime combines with interactive prompts
7 to configure a scenario for testing (e.g. which platform, which board, what is wired to it) meaning that 
8 the same routines can be carried out on Micropython boards, dual boards running either CP or MCP
9 or dedicated CP boards. 
10
11 From a project-management point of view, tests can provide a strictly-interpreted way to 
12 communicate missing features, with the means of verifying that intended features for the 
13 MCP layer are in fact already served from the CP layer.
14
15 # Example
16
17 To take a minimal example, the following asserts the default behaviour of the DigitalInOut 
18 constructor, checks the behaviour of switch_to_input/output(), configures a pin as a pull-up button, a pull-down button and an LED.
19
20 ```python
21 import testing
22 testing.main()
23 ```
24
25 ## Comments
26
27 There is a routine in the top level of the repo called `upload_feather_m0_watch.py` which monitors the repo folder (on a regular 
28 filesystem) and selectively synchronizes it with the CIRCUITPY folder 
29 when any changes are saved, which assists with development.
30
31 Given the limited memory available, on the Feather M0 Express, running the test case requires that 
32 the [micropython-lib unittest library](https://github.com/micropython/micropython-lib/blob/master/unittest/unittest.py) 
33 is distributed as a compatible Micropython bytecode .mpy file 
34 pre-compiled under an mpy-cross version from the CircuitPython 2.2.3-tagged repository. Otherwise
35 simply loading the unittest module already busts the available memory. 
36
37 # Test Suite Structure
38
39 The structure of the testing modules is as follows, to permit test suites to be imported selectively
40 on different implementations, platforms and boards (see agnostic.py for definitions of these terms)...
41
42 * _testing_ - common function definitions for suite-execution
43 * _testing.mcp_ - test suite for hardware-agnostic elements of MCP layer (e.g. Enum)
44 * _testing.implementation_ - calculates implementation-specific parameters for test fixtures
45 * _testing.implementation.all_ - suites expected to run on all platforms
46 * _testing.implementation.micropython_ - suites testing MCP-specific classes and behaviours (under the hood of the hardware compatibility layer) and only 
47 expected to run on Micropython
48 * _testing.implementation.circuitpython - suites testing CircuitPython-specific 
49 classes and behaviours, and only expected to run in CircuitPython_
50
51 e.g.
52 * testing.implementation.all.digitalio - tests against the 
53 digitalio module regardless of platform
54 * testing.implementation.circuitpython.digitalio - tests of digitalio against a 
55 native circuitpython host
56 * testing.implementation.micropython.digitalio - tests of digitalio against the MCP
57 compatibility layer
58
59
60 # Next Steps 
61
62 To be able to run a substantial series of testing modules, a dedicated 
63 feather m0 express firmware image should be prepared with [frozen modules](https://learn.adafruit.com/micropython-for-samd21/frozen-modules) which 
64 minimises overhead by holding test definitions in flash instead of RAM.