37 Commits

Author SHA1 Message Date
Alfonso Sánchez-Beato
2543d2c2e3 Merge branch 'master' into piboot 2022-02-22 15:38:12 +01:00
Ian Johnson
af77b3fb0d many: move boot.Device to snap.Device
This is a purely mechanical change because it touches so many files, the real
interesting parts we need that prompted this will be followups.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-18 11:59:29 -06:00
Alfonso Sánchez-Beato
3dc10e83b3 b/boottest: add helpers for testing not scriptable bootloaders 2022-01-26 14:52:55 +01:00
Miguel Pires
aa623a49ea many: remove unused parameters and returns 2021-09-02 17:44:34 +01:00
Samuele Pedroni
76e808fb34 Merge branch 'uc20-boot-streamline-mock-device' into uc20-reseal-with-kernel-cleanup
fix conflicts, mockDevice.SetModel is not necessary anymore
2020-09-12 23:46:20 +02:00
Samuele Pedroni
0d4c7467bc boot: make MockUC20Device use a model and MockDevice more realistic
We will need to add Model to Device for UC20 cases, prepare for that
by forcing MockUC20Device to use one and produce output consistent
with it.

Make also the behavior of MockDevice a bit more consistent/realistic
though it has limited use for UC20, it allowed for mode != "run"
with HasModeenv false for example.
2020-09-12 23:17:09 +02:00
Samuele Pedroni
cb98729f5d boot: have the mock model helper in boottest, a bit more naming consistence 2020-09-12 22:36:53 +02:00
Maciej Borzecki
2066fff4d1 boot: reseal when changing kernels
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-09-12 20:12:43 +02:00
Maciej Borzecki
58e5be103d boot: add model to the Device
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-09-12 20:12:43 +02:00
Ian Johnson
6fbf33403b boot/bootstate16.go: clean snap_try_* vars when not in Trying status too
This is needed because the uc18/uc16 bootloader implementations do not actually
do this, and instead snapd needs to reset the value.

Also modify the bootenv bootloader logic simulation to not clean this anymore,
just as the real bootloaders do. 

This all requires some slight changes to the test logic, which since they are 
checking the BootVars map directly will see some additional empty keys in the 
map as markSuccessful will now write those empty keys. Eventually we should port
these tests to use GetBootVars and not use the map directly since empty 
string keys show up the same as missing keys with GetBootVars and that would 
have prevented needing to change these tests at all.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-06-02 18:18:39 -05:00
Ian Johnson
9e01639f22 boot/boottest/bootenv: add TODO on MockUC20EnvRefExtractedKernelRunBootenv
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-04-20 16:02:34 -05:00
Ian Johnson
f8180fa8f9 boot/boottest/bootenv: add MockUC20EnvRefExtractedKernelRunBootenv
This internally uses Bootenv16, with snap_mode usage replaced with kernel_status
which is what we have for UC20.

Also fix doc-comment on RunBootenv20.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-04-20 14:49:45 -05:00
Ian Johnson
8e3e4c7706 boot: simplify modeenv mocking to always write a modeenv
In a future refactor of the boot tests, we will always need to write out a new
modeenv in the tests and never just read it, so we don't need this mocking
utility anymore.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-04-02 10:45:42 -05:00
Samuele Pedroni
b86b891681 many: address lingering XXXs
* add missing doc comments
* make sure we indicate in tests which bits of bootenv (kernel or base)
  we are trying/rolling back
2020-03-11 11:48:52 +01:00
Samuele Pedroni
1177064a2f many: separate mocking of bootenvs vs bootloaders and among those
some XXX todos in doc comments, and difference in simulating
reboots between UC20 vs UC16/18
2020-03-05 18:08:58 +01:00
Ian Johnson
3f17704686 bootstate20: use "" instead of GlobalRootDir
This is more consistent and means the same thing everywhere else, except for one
test helper which is also updated here to now mean the same thing.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-02-17 10:54:45 -06:00
Ian Johnson
e275664270 boottest: re-format HasModeenv definition
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-01-27 12:00:04 -06:00
Ian Johnson
16541c7d4b tests/boottest: add tests for MockUC20Device
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-01-27 12:00:02 -06:00
Maciej Borzecki
4f36dd1f88 boot, boottest: tweak boot.Device mocks, update comments
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-01-14 14:49:59 +01:00
Maciej Borzecki
c108ff6d9a boot: tweak implementation mocking for better go doc output
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-01-14 13:14:27 +01:00
Ian Johnson
159b14d17b boot/modeenv: allow forcing a specific modeenv to always be read
This makes future tests simpler, and since it's all in memory is simpler than
writing out the files to the filesystem for each test, since restoring it is
just defer'ing the returned function.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-01-13 14:40:41 -06:00
Ian Johnson
53ffb3526d boot: add HasModeenv to Device
This will be used by bootStateFor in determining if a given device is a UC20
device and thus needs a different bootState implementation.

Adjust some tests to ensure that we have a modeenv when expected and don't when
expected.

This also requires refactoring the MockDevice in boottest to be slightly more
complicated to have devices that are in run mode, but are not uc20.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-01-13 14:40:34 -06:00
Samuele Pedroni
aa2759d2e8 follow-up: fix/improve doc comments (thanks @bboozzoo) 2019-12-13 13:10:43 +01:00
Samuele Pedroni
2113b5748a many: pass consistently boot.Device state to boot methods
instead of passing model and/or a classic flag to them
and adding operating mode now as well, pass a new interface
boot.Device that is implemented by DeviceContext
2019-12-12 18:52:38 +01:00
John R. Lenton
30d8deff77 many: refactor boot/boottest and move to bootloader/mockbootloader
all boottest had was MockBootloader, so moved it there.
2019-09-02 10:48:59 +01:00