summaryrefslogtreecommitdiffstats
path: root/test/parser
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javierm@redhat.com>2018-06-12 12:18:34 +0200
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-06-18 10:56:33 +1000
commit78a98b9ebc789d9c9c701af95e65292d768eee59 (patch)
tree9a3664761d2a27c65572053ffb9380071c8cd1d2 /test/parser
parent6d06f0dbe1195cd8be7d3c54d02012ff16466d0c (diff)
downloadtalos-petitboot-78a98b9ebc789d9c9c701af95e65292d768eee59.tar.gz
talos-petitboot-78a98b9ebc789d9c9c701af95e65292d768eee59.zip
discover/grub: Improve BLS grub environment variables expansion
The fields from a BootLoaderSpec file can contain environment variables, in GRUB 2 these are show verbatim and are evaluated later when an entry is selected. But on Petitboot these have to be expanded before creating the GRUB 2 resources and show in the UI the values after the evaluation. The current blscfg handler had a very limited support for variables, it only had support for the options field and also didn't take into account that variables could be mixed with literal values. So for example the following fields were not expanded correctly: linux $bootprefix/vmlinuz options $kernelopts foo=bar options foo=bar $kernelopts options $kernelopts $debugopts Also change some of the tests to cover mixing variables and literals. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'test/parser')
-rw-r--r--test/parser/test-grub2-blscfg-multiple-bls.c5
-rw-r--r--test/parser/test-grub2-blscfg-opts-grubenv.c4
2 files changed, 5 insertions, 4 deletions
diff --git a/test/parser/test-grub2-blscfg-multiple-bls.c b/test/parser/test-grub2-blscfg-multiple-bls.c
index 94f40d1..d15fb24 100644
--- a/test/parser/test-grub2-blscfg-multiple-bls.c
+++ b/test/parser/test-grub2-blscfg-multiple-bls.c
@@ -1,6 +1,7 @@
#include "parser-test.h"
#if 0 /* PARSER_EMBEDDED_CONFIG */
+set os_name=Fedora
blscfg
#endif
@@ -13,14 +14,14 @@ void run_test(struct parser_test *test)
test_add_file_string(test, test->ctx->device,
"/loader/entries/6c063c8e48904f2684abde8eea303f41-4.15.2-302.fc28.x86_64.conf",
- "title Fedora (4.15.2-302.fc28.x86_64) 28 (Twenty Eight)\n"
+ "title $os_name (4.15.2-302.fc28.x86_64) 28 (Twenty Eight)\n"
"linux /vmlinuz-4.15.2-302.fc28.x86_64\n"
"initrd /initramfs-4.15.2-302.fc28.x86_64.img\n"
"options root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root\n\n");
test_add_file_string(test, test->ctx->device,
"/loader/entries/6c063c8e48904f2684abde8eea303f41-4.14.18-300.fc28.x86_64.conf",
- "title Fedora (4.14.18-300.fc28.x86_64) 28 (Twenty Eight)\n"
+ "title $os_name (4.14.18-300.fc28.x86_64) 28 (Twenty Eight)\n"
"linux /vmlinuz-4.14.18-300.fc28.x86_64\n"
"initrd /initramfs-4.14.18-300.fc28.x86_64.img\n"
"options root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root\n");
diff --git a/test/parser/test-grub2-blscfg-opts-grubenv.c b/test/parser/test-grub2-blscfg-opts-grubenv.c
index 544a5de..2dffd1b 100644
--- a/test/parser/test-grub2-blscfg-opts-grubenv.c
+++ b/test/parser/test-grub2-blscfg-opts-grubenv.c
@@ -22,7 +22,7 @@ void run_test(struct parser_test *test)
"title Fedora (4.15.2-302.fc28.x86_64) 28 (Twenty Eight)\n"
"linux /vmlinuz-4.15.2-302.fc28.x86_64\n"
"initrd /initramfs-4.15.2-302.fc28.x86_64.img\n"
- "options $kernelopts\n");
+ "options $kernelopts debug\n");
test_read_conf_embedded(test, "/boot/grub2/grub.cfg");
@@ -32,5 +32,5 @@ void run_test(struct parser_test *test)
opt = get_boot_option(ctx, 0);
- check_args(opt, "root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root");
+ check_args(opt, "root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root debug");
}
OpenPOWER on IntegriCloud