42 Commits

Author SHA1 Message Date
Samuele Pedroni
54d5fa832c many: support extended classic models that omit kernel/gadget
redefine IsCoreBoot as the model having a kernel

there are at least tests that show we can seed such systems

the changes ind devicemgr.go prompted fixes for some remodel tests that were
confusingly running wiht OnClassic true though they were using Core models
2022-09-29 18:34:10 +02:00
Alfonso Sánchez-Beato
bd245c158a b/boottest: fix unit test panics 2022-08-18 12:06:19 +01:00
Alfonso Sánchez-Beato
e429312c3f boot/bootest: panic if mocks called with wrong args, small refactor 2022-08-18 10:00:45 +01:00
Alfonso Sánchez-Beato
2e51380382 many: add Is{Core,Classic}Boot() to DeviceContext
Is{Core,Classic}Boot() will be used to find if we are in a Ubuntu Core
device and if we are in a classic with modes (there is a modeenv file)
device respectively. That is determined by the information found in
the model assertion.
2022-08-17 13:06:51 +01:00
Alfonso Sánchez-Beato
fa2ea0c1f6 many: add Gadget() method to device interface
Same as we do for kernel and base snaps, as now gadget snaps are boot
participants.
2022-06-23 12:04:26 +02:00
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