Browse Source

test: Ignore some grub.cfg differences in `00_header` section.

Ubuntu 22.04 Jammy can trigger differences in searching for the root
device when running live as opposed to mender-convert's jailroot.
Since we have grub scripts which later set root back to the value it
should be, it is safe to ignore these differences. However, since it
is dangerous to ignore these differences *outside* `00_header`, make
the sed script fairly specific so that it is only ignored inside this
section.

Ticket: QA-554

Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
master
Kristian Amlie 2 years ago
parent
commit
5a68cecb3a
No known key found for this signature in database GPG Key ID: F464407C996AF03F
  1. 68
      tests/test_grub_integration.py

68
tests/test_grub_integration.py

@ -152,12 +152,22 @@ class TestGrubIntegration:
connection.run("rm -f /data/new-grub-efi-modified.cfg") connection.run("rm -f /data/new-grub-efi-modified.cfg")
# Another few differences we work around in the main grub files: # Another few differences we work around in the main grub files:
#
# * `--hint` parameters are not generated in offline copy. # * `--hint` parameters are not generated in offline copy.
#
# * `root` variable is not set in offline copy. # * `root` variable is not set in offline copy.
#
# * `fwsetup` is added somewhat randomly depending on availability both # * `fwsetup` is added somewhat randomly depending on availability both
# on build host and device. # on build host and device.
#
# * locale, lang and gettext settings and module may or may not be # * locale, lang and gettext settings and module may or may not be
# present depending on test host. # present depending on test host.
#
# * Inside the `00_header` section, ignore the `search` functions which
# set the root variable. This is safe because we have a later script
# which sets the root again (`07_mender_choose_partitions_grub.cfg` at
# the time of writing). These are sometimes inside an if condition
# using `feature_platform_search_hint`, which we also need to ignore.
try: try:
connection.run("cp /data/grub-main.cfg /data/old-grub-modified.cfg") connection.run("cp /data/grub-main.cfg /data/old-grub-modified.cfg")
connection.run("cp /boot/grub/grub.cfg /data/new-grub-modified.cfg") connection.run("cp /boot/grub/grub.cfg /data/new-grub-modified.cfg")
@ -169,7 +179,36 @@ class TestGrubIntegration:
"-e p " "-e p "
"/data/old-grub-modified.cfg /data/new-grub-modified.cfg" "/data/old-grub-modified.cfg /data/new-grub-modified.cfg"
) )
connection.run("diff -u /data/old-grub-modified.cfg /data/new-grub-modified.cfg") connection.run(
"sed -i -En -e '"
r"""
\%BEGIN /etc/grub.d/00_header% {
:header_loop;
/if .*feature_platform_search_hint/ {
:hint_loop;
/^ *fi *$/ ! {
n;
b hint_loop;
};
n;
};
/^ *search .*--set=root/ {
n;
b header_loop;
};
\%END /etc/grub.d/00_header% ! {
p;
n;
b header_loop;
};
};
p;
' """
"/data/old-grub-modified.cfg /data/new-grub-modified.cfg"
)
connection.run(
"diff -u /data/old-grub-modified.cfg /data/new-grub-modified.cfg"
)
finally: finally:
connection.run("rm -f /data/old-grub-modified.cfg /data/new-grub-modified.cfg") connection.run("rm -f /data/old-grub-modified.cfg /data/new-grub-modified.cfg")
@ -185,6 +224,33 @@ class TestGrubIntegration:
"-e p " "-e p "
"/data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg" "/data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg"
) )
connection.run(
"sed -i -En -e '"
r"""
\%BEGIN /etc/grub.d/00_header% {
:header_loop;
/if .*feature_platform_search_hint/ {
:hint_loop;
/^ *fi *$/ ! {
n;
b hint_loop;
};
n;
};
/^ *search .*--set=root/ {
n;
b header_loop;
};
\%END /etc/grub.d/00_header% ! {
p;
n;
b header_loop;
};
};
p;
' """
"/data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg"
)
connection.run( connection.run(
"diff -u /data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg" "diff -u /data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg"
) )

Loading…
Cancel
Save