debian-forge/test/run
Michael Vogt 2e6d49fbef tests: update test_assemblers.py for f38 changes
The `test_assemblers.py` has an `assertGRUB2` helper that ensures
that the data written in the mbr and first megabyte is unchanged
by the `org.osbuild.qemu` assembler.

With the move to f38 the digests change. The mbr digest is
computed via the following python code and it matches that value
used in the test (440 byte only because the rest is the partition
table).
```
$ python3 -c 'import hashlib,sys; f=open(sys.argv[1], "rb"); m1=hashlib.sha256();m1.update(f.read()[:440]);print(m1.hexdigest())' ./f34/usr/lib/grub/i386-pc/boot.img
26e3327c6b5ac9b5e21d8b86f19ff7cb4d12fb2d0406713f936997d9d89de3ee
```

So with that code we can update the f38 mbr value now.
```
$ python3 -c 'import hashlib,sys; f=open(sys.argv[1], "rb"); m1=hashlib.sha256();m1.update(f.read()[:440]);print(m1.hexdigest())' ./f38/usr/lib/grub/i386-pc/boot.img
b8cea7475422d35cd6f85ad099fb4f921557fd1b25db62cd2a92709ace21cf0f

However computing the second sha256 for the `512:1024*1024` is much
harder to do from first principles because the value depends on the
image generated via `grub2-mkimage` and the hash changes with each
different module or config option. This means one needs to replicate
the exact inputs of:
```
    subprocess.run(["grub2-mkimage",
                    "--verbose",
                    "--directory", f"/usr/lib/grub/{platform}",
                    "--prefix", f"(,{partid})/{grub_path}",
                    "--format", platform,
                    "--compression", "auto",
                    "--output", core_path] +
                   modules,
                   check=True)
```
in the test. At this point I cheated and just update to the computed
value inside the test.
2023-11-14 10:45:44 -08:00
..
__init__.py test: '{. -> ./run}/test_sources.py' 2020-04-24 15:50:44 +02:00
test_assemblers.py tests: update test_assemblers.py for f38 changes 2023-11-14 10:45:44 -08:00
test_boot.py test/run/boot: migrate to a v2 manifest 2023-11-14 10:45:44 -08:00
test_devices.py loop: use LOOP_CONFIGURE instead of LOOP_SET_FD 2023-05-05 15:42:47 +02:00
test_executable.py test: fix executable test 2022-02-15 13:25:23 +00:00
test_mount.py autopep8: Update with changes to make autopep8 -a -a -a happy 2023-08-10 13:04:14 +02:00
test_noop.py osbuild: run isort on all files 2022-09-12 13:32:51 +02:00
test_sources.py autopep8: Update with changes to make autopep8 -a -a -a happy 2023-08-10 13:04:14 +02:00
test_stages.py test/run/stages: convert test_selinux to a v2 manifest 2023-11-14 10:45:44 -08:00