grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] tests: Add efienv_test for testing efi-export-env and efi-lo


From: Glenn Washburn
Subject: [PATCH 3/4] tests: Add efienv_test for testing efi-export-env and efi-load-env
Date: Wed, 26 Jul 2023 16:00:01 -0500

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 Makefile.util.def    |  6 +++++
 tests/efienv_test.in | 57 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 tests/efienv_test.in

diff --git a/Makefile.util.def b/Makefile.util.def
index 1e9a13d3e348..a7cf53111221 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -1172,6 +1172,12 @@ script = {
   common = tests/help_test.in;
 };
 
+script = {
+  testcase = nonnative;
+  name = efienv_test;
+  common = tests/efienv_test.in;
+};
+
 script = {
   testcase = nonnative;
   name = grub_script_gettext;
diff --git a/tests/efienv_test.in b/tests/efienv_test.in
new file mode 100644
index 000000000000..8ae8c2893d53
--- /dev/null
+++ b/tests/efienv_test.in
@@ -0,0 +1,57 @@
+#! @BUILD_SHEBANG@
+# Copyright (C) 2023  Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+grubshell=@builddir@/grub-shell
+
+. "@builddir@/grub-core/modinfo.sh"
+
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
+    *-efi)
+       ;;
+    # Skip Non-EFI platforms, as this test does not apply
+    *)
+       exit 77;;
+esac
+
+test_script() {
+  cat <<'EOF'
+  efienv_test_var_val="#1 some \\$test value."
+
+  if [ "$efienv_test_var" == "$efienv_test_var_val" ]; then
+    echo TEST PASSED
+  else
+    efienv_test_var="XXX${efienv_test_var_val}"
+    efi-export-env efienv_test_var
+    efienv_test_var=erased
+    efi-load-env
+
+    if [ "$efienv_test_var" != "XXX${efienv_test_var_val}" ]; then
+      echo TEST FAILED
+      halt
+    fi
+
+    efienv_test_var="${efienv_test_var_val}"
+    efi-export-env efienv_test_var
+    reboot
+  fi
+EOF
+}
+
+output=$(test_script | "${grubshell}" --modules="efienv,halt" | tail -n1)
+if [ "$output" != "TEST PASSED" ]; then
+   exit 1
+fi
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]