|
| 1 | +# Jumpstarter SOC testing with pytest example |
| 2 | + |
| 3 | +This example aims to demonstrate Jumpstarter in an a simple |
| 4 | +SOC testing scenario using pytest. |
| 5 | + |
| 6 | +The following drivers will be utilized: |
| 7 | +- DUTLink: for power, storage and console control of the target |
| 8 | +- UStreamer: with an hdmi capture card plus a webcam for video snapshits |
| 9 | + |
| 10 | +This example requires the following hardware: |
| 11 | +- 1x Raspberry Pi 4 |
| 12 | +- 1x dutlink (DUTLink could be replaced by a composite set of power, storage mux and serial port interface) |
| 13 | +- 1x HDMI Capture card |
| 14 | +- 1x Webcam |
| 15 | + |
| 16 | +# Running the example (distributed env) |
| 17 | + |
| 18 | +1) Setup an environment with the required hardware, and customize the exporter.yaml |
| 19 | +2) Setup the exporter to be run from a container (TODO: link) |
| 20 | +3) Label the exporter in k8s with the `board=rpi4` label |
| 21 | +4) Prepare the images by running `make` in the `image` directory |
| 22 | +5) Run the tests in this directory by running: |
| 23 | +```bash |
| 24 | +$ cd jumpstarter_example_soc_pytest |
| 25 | +$ uv run pytest -s |
| 26 | +================================================================== test session starts =================================================================== |
| 27 | +platform linux -- Python 3.12.3, pytest-8.3.3, pluggy-1.5.0 |
| 28 | +rootdir: /home/majopela/jumpstarter/examples/soc-pytest |
| 29 | +configfile: pyproject.toml |
| 30 | +plugins: anyio-4.6.2.post1, cov-5.0.0 |
| 31 | +collected 6 items |
| 32 | + |
| 33 | +test_on_rpi4.py::TestResource::test_setup_device |
| 34 | +--------------------------------------------------------------------- live log setup --------------------------------------------------------------------- |
| 35 | +INFO jumpstarter.client.lease:lease.py:35 Leasing Exporter matching labels {'board': 'rpi4'} for seconds: 1800 |
| 36 | + |
| 37 | +INFO jumpstarter.client.lease:lease.py:42 Lease c33b74ff-ad92-42a6-aa88-2c8a944a297c created |
| 38 | +INFO jumpstarter.client.lease:lease.py:46 Polling Lease c33b74ff-ad92-42a6-aa88-2c8a944a297c |
| 39 | +INFO jumpstarter.client.lease:lease.py:51 Lease c33b74ff-ad92-42a6-aa88-2c8a944a297c acquired |
| 40 | +INFO jumpstarter.client.lease:lease.py:73 Connecting to Lease with name c33b74ff-ad92-42a6-aa88-2c8a944a297c |
| 41 | +--------------------------------------------------------------------- live log call ---------------------------------------------------------------------- |
| 42 | +INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:51 Setting up device |
| 43 | +read: 2.45GB [00:49, 52.8MB/s] |
| 44 | +INFO jumpstarter.testing.utils:utils.py:15 Waiting for login prompt |
| 45 | + |
| 46 | +RPi: BOOTLOADER release VERSION:817717 DATE: 2023/01/11 TIME: 17:40:52 |
| 47 | +BOOTMODE: 0x06 partition 1 build-ts BUILD_TIMESTAMP=1673458852 serial c3656a7d boardrev d03114 stc 608563 |
| 48 | +.. |
| 49 | +Starting start4.elf @ 0xfeb00200 partition 1 |
| 50 | ++ |
| 51 | +[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083] |
| 52 | +... |
| 53 | +... |
| 54 | + |
| 55 | +Raspbian GNU/Linux 12 rpitest ttyS0 |
| 56 | + |
| 57 | +rpitest login: root |
| 58 | +Password: |
| 59 | +Linux rpitest 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 |
| 60 | + |
| 61 | +The programs included with the Debian GNU/Linux system are free software; |
| 62 | +the exact distribution terms for each program are described in the |
| 63 | +individual files in /usr/share/doc/*/copyright. |
| 64 | + |
| 65 | +Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent |
| 66 | +permitted by applicable law. |
| 67 | +root@rpitest:~#INFO jumpstarter.testing.utils:utils.py:21 Logged in |
| 68 | +INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:112 Attempting a soft power off |
| 69 | + poweroff |
| 70 | +root@rpitest:~# Stopping session-1.scope - Session 1 of User root... |
| 71 | +... |
| 72 | +[ 28.964752] reboot: Power down |
| 73 | +PASSED |
| 74 | +test_on_rpi4.py::TestResource::test_tpm2_device |
| 75 | +--------------------------------------------------------------------- live log setup --------------------------------------------------------------------- |
| 76 | +INFO jumpstarter.testing.utils:utils.py:15 Waiting for login prompt |
| 77 | +INFO jumpstarter.testing.utils:utils.py:21 Logged in |
| 78 | +--------------------------------------------------------------------- live log call ---------------------------------------------------------------------- |
| 79 | +INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: apt-get install -y tpm2-tools |
| 80 | +apt-get install -y tpm2-tools |
| 81 | +... |
| 82 | +root@rpitest:~# INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: tpm2_createprimary -C e -c primary.ctx |
| 83 | +tpm2_createprimary -C e -c primary.ctx |
| 84 | +name-alg: |
| 85 | + value: sha256 |
| 86 | + raw: 0xb |
| 87 | +attributes: |
| 88 | + value: fixedtpm|fixedparent|sensitivedataorigin|userwithauth|restricted|decrypt |
| 89 | + raw: 0x30072 |
| 90 | +type: |
| 91 | + value: rsa |
| 92 | + raw: 0x1 |
| 93 | +exponent: 65537 |
| 94 | +bits: 2048 |
| 95 | +scheme: |
| 96 | + value: null |
| 97 | + raw: 0x10 |
| 98 | +scheme-halg: |
| 99 | + value: (null) |
| 100 | + raw: 0x0 |
| 101 | +sym-alg: |
| 102 | + value: aes |
| 103 | + raw: 0x6 |
| 104 | +sym-mode: |
| 105 | + value: cfb |
| 106 | + raw: 0x43 |
| 107 | +sym-keybits: 128 |
| 108 | +rsa: efe8d8387679d50d7cea501f4302834eebd4c4b3ec7f7b6a40128c63f3e9fb6e9203429dba4e1221d4d40039ff757dc3cbec638c79e11fe5cb4cc159a5e15a3d785b179f3081ada24f6370bad9b81ad2ddcba2e137bb62a454069d37da7cd1e3a06cb7fe03fc8386b055746b5396ee3b44aa1e40dae4e6257c763a53f7eb60a29df18ee14bce38d376434d89e9c95a79d1563833a48db8016c130f6246f24e023b8874e6f2f8bb1fbfe8ad9a1a0ef71b7fc0ed412056a40a225b6f352ea32aa9564c56bef09df7107b871db136aa530ae479b0b09256373479716416bc18fc7544df8c5de99383c37193f5e016bca7ab39231a69c6d4255d93aed66527bb261d |
| 109 | +root@rpitest:~# INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: tpm2_create -G rsa -u key.pub -r key.priv -C primary.ctx |
| 110 | +tpm2_create -G rsa -u key.pub -r key.priv -C primary.ctx |
| 111 | +name-alg: |
| 112 | + value: sha256 |
| 113 | + raw: 0xb |
| 114 | +attributes: |
| 115 | + value: fixedtpm|fixedparent|sensitivedataorigin|userwithauth|decrypt|sign |
| 116 | + raw: 0x60072 |
| 117 | +type: |
| 118 | + value: rsa |
| 119 | + raw: 0x1 |
| 120 | +exponent: 65537 |
| 121 | +bits: 2048 |
| 122 | +scheme: |
| 123 | + value: null |
| 124 | + raw: 0x10 |
| 125 | +scheme-halg: |
| 126 | + value: (null) |
| 127 | + raw: 0x0 |
| 128 | +sym-alg: |
| 129 | + value: null |
| 130 | + raw: 0x10 |
| 131 | +sym-mode: |
| 132 | + value: (null) |
| 133 | + raw: 0x0 |
| 134 | +sym-keybits: 0 |
| 135 | +rsa: c8cebe46344bbed17c39a497c3e5c53406be142ce741697641d940b77a835b3956c4ce0c5949688ff44a5d8ef847097e1870589ff4afcd401d2b7814b9a57ecc1f750b8a759b4e4f59915d8dda68c5463c8392870a59e21a02481e4d9b8d7ad27dd915850a587b6ff1a87fa98c578a0188e74c2731e39456c4e2e7f3158a878a294f82105a6ead9e397c15cd80c8b587c9a3f47513680cbe5f5fb5a0a41830566e5b70f312fa5e28fc780f45e72d4c8aa42fc2ea9d19e1068815493e2acda90cd6f7dabede223b494f916bd0c67682d4d5b4073b80954c0bab0ac612ae243f92c1d85ab3a7840d1d4aa7390f6155edb3341f229fbc015a8637d16230da03920f |
| 136 | +root@rpitest:~# INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: tpm2_load -C primary.ctx -u key.pub -r key.priv -c key.ctx |
| 137 | +tpm2_load -C primary.ctx -u key.pub -r key.priv -c key.ctx |
| 138 | +name: 000b0395380f392a3ef0773853ed245ed1a2ba94d26261d846268146f2f4de148cf0 |
| 139 | +root@rpitest:~# INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: echo my message > message.dat |
| 140 | +echo my message > message.dat |
| 141 | +root@rpitest:~# INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: tpm2_sign -c key.ctx -g sha256 -o sig.rssa message.dat |
| 142 | +tpm2_sign -c key.ctx -g sha256 -o sig.rssa message.dat |
| 143 | +root@rpitest:~# INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:78 Running command: tpm2_verifysignature -c key.ctx -g sha256 -s sig.rssa -m message.dat |
| 144 | +.dat_verifysignature -c key.ctx -g sha256 -s sig.rssa -m message |
| 145 | +root@rpitest:~# echo result: $? |
| 146 | +result: 0 |
| 147 | +PASSED |
| 148 | +------------------------------------------------------------------- live log teardown -------------------------------------------------------------------- |
| 149 | +INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:112 Attempting a soft power off |
| 150 | +poweroff |
| 151 | +root@rpitest:~# poweroff |
| 152 | +... |
| 153 | +[ 80.068761] reboot: Power down |
| 154 | + |
| 155 | +test_on_rpi4.py::TestResource::test_power_off_camera PASSED |
| 156 | +test_on_rpi4.py::TestResource::test_power_on_camera PASSED |
| 157 | +test_on_rpi4.py::TestResource::test_power_on_hdmi |
| 158 | +--------------------------------------------------------------------- live log call ---------------------------------------------------------------------- |
| 159 | +INFO imagehash:imagehash.py:79 video comparing snapshot test_booting_empty_ok.jpeg: snapshot f0f0f0f0f0f0f0f0, ref f0f0f0f0f0f0f0f0, diff: 0 |
| 160 | +INFO imagehash:imagehash.py:79 video comparing snapshot test_booting_rainbow_ok.jpeg: snapshot 3c3c3c1c1c1c1c1c, ref 3c3c3c1c1c1c1c1c, diff: 0 |
| 161 | +INFO imagehash:imagehash.py:79 video comparing snapshot test_booting_raspberries_ok.jpeg: snapshot c000000000000000, ref c000000000000000, diff: 0 |
| 162 | +PASSED |
| 163 | +test_on_rpi4.py::TestResource::test_login_console_hdmi |
| 164 | +--------------------------------------------------------------------- live log setup --------------------------------------------------------------------- |
| 165 | +INFO jumpstarter.testing.utils:utils.py:15 Waiting for login prompt |
| 166 | +INFO jumpstarter.testing.utils:utils.py:21 Logged in |
| 167 | +--------------------------------------------------------------------- live log call ---------------------------------------------------------------------- |
| 168 | +INFO imagehash:imagehash.py:79 video comparing snapshot test_booted_ok.jpeg: snapshot c0c0000000000000, ref c0c0000000000000, diff: 0 |
| 169 | +PASSED |
| 170 | +------------------------------------------------------------------- live log teardown -------------------------------------------------------------------- |
| 171 | +INFO /home/majopela/jumpstarter/examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py:test_on_rpi4.py:112 Attempting a soft power off |
| 172 | +INFO jumpstarter.client.lease:lease.py:63 Releasing Lease c33b74ff-ad92-42a6-aa88-2c8a944a297c |
| 173 | + |
| 174 | + |
| 175 | +============================================================= 6 passed in 303.59s (0:05:03) ============================================================== |
| 176 | +``` |
0 commit comments