Blame SOURCES/0038-Add-some-test-cases-for-efivar-export-import.patch

a43681
From 693dbef8d7d6287b438ad7e385b383f60df74a8c Mon Sep 17 00:00:00 2001
a43681
From: Peter Jones <pjones@redhat.com>
a43681
Date: Tue, 18 Jun 2019 13:21:45 -0400
a43681
Subject: [PATCH 38/63] Add some test cases for efivar export/import
a43681
a43681
Signed-off-by: Peter Jones <pjones@redhat.com>
a43681
---
a43681
 Makefile              |   3 ++
a43681
 tests/.gitignore      |   2 +
a43681
 tests/Makefile        |  86 ++++++++++++++++++++++++++++++++++++++++++
a43681
 tests/test.0.goal.var | Bin 0 -> 562 bytes
a43681
 tests/test.1.goal.var | Bin 0 -> 574 bytes
a43681
 tests/test.3.goal.var | Bin 0 -> 66 bytes
a43681
 tests/test.4.goal.var | Bin 0 -> 365 bytes
a43681
 7 files changed, 91 insertions(+)
a43681
 create mode 100644 tests/.gitignore
a43681
 create mode 100644 tests/Makefile
a43681
 create mode 100644 tests/test.0.goal.var
a43681
 create mode 100644 tests/test.1.goal.var
a43681
 create mode 100644 tests/test.3.goal.var
a43681
 create mode 100644 tests/test.4.goal.var
a43681
a43681
diff --git a/Makefile b/Makefile
a43681
index 9c2620cb485..2d134ea9d6f 100644
a43681
--- a/Makefile
a43681
+++ b/Makefile
a43681
@@ -51,6 +51,9 @@ clean :
a43681
 	done
a43681
 	@rm -vf efivar.spec vgcore.* core.*
a43681
 
a43681
+test : all
a43681
+	@$(MAKE) -C tests
a43681
+
a43681
 test-archive: abicheck efivar.spec
a43681
 	@rm -rf /tmp/efivar-$(GITTAG) /tmp/efivar-$(GITTAG)-tmp
a43681
 	@mkdir -p /tmp/efivar-$(GITTAG)-tmp
a43681
diff --git a/tests/.gitignore b/tests/.gitignore
a43681
new file mode 100644
a43681
index 00000000000..a0149cf75de
a43681
--- /dev/null
a43681
+++ b/tests/.gitignore
a43681
@@ -0,0 +1,2 @@
a43681
+!*.var
a43681
+*.result.*
a43681
diff --git a/tests/Makefile b/tests/Makefile
a43681
new file mode 100644
a43681
index 00000000000..5e0c604e355
a43681
--- /dev/null
a43681
+++ b/tests/Makefile
a43681
@@ -0,0 +1,86 @@
a43681
+#
a43681
+# Makefile
a43681
+# Peter Jones, 2019-06-18 11:10
a43681
+#
a43681
+
a43681
+all: clean test0 test1 test2 test3 test4
a43681
+
a43681
+GRUB_PREFIX ?= grub2
a43681
+TOPDIR ?= ..
a43681
+EFIVAR ?= ../src/efivar
a43681
+
a43681
+clean:
a43681
+	@rm -f *.result.env *.result.var
a43681
+
a43681
+test0:
a43681
+	@echo testing export to DMPSTORE format
a43681
+	@$(GRUB_PREFIX)-editenv test.0.result.env create
a43681
+	@$(GRUB_PREFIX)-editenv test.0.result.env set debug=all,-scripting,-lexer
a43681
+	@truncate -s 512 test.0.result.env
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.0.result.env -D -e test.0.result.var
a43681
+	@cmp test.0.result.var test.0.goal.var
a43681
+	@rm test.0.result.*
a43681
+	@echo passed
a43681
+
a43681
+test1:
a43681
+	@echo testing export to libefivar format
a43681
+	@$(GRUB_PREFIX)-editenv test.1.result.env create
a43681
+	@$(GRUB_PREFIX)-editenv test.1.result.env set debug=all,-scripting,-lexer
a43681
+	@truncate -s 512 test.1.result.env
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.1.result.env -e test.1.result.var
a43681
+	@cmp test.1.result.var test.1.goal.var
a43681
+	@rm test.1.result.*
a43681
+	@echo passed
a43681
+
a43681
+test2:
a43681
+	@$(GRUB_PREFIX)-editenv test.2.result.env create
a43681
+	@$(GRUB_PREFIX)-editenv test.2.result.env set debug=all,-scripting,-lexer
a43681
+	@truncate -s 512 test.2.result.env
a43681
+	@echo test importing from DMPSTORE and exporting to DMPSTORE and symbolic guid-name validation
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.2.result.env -D -e test.2.0.goal.var
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.0.goal.var -e test.2.0.result.var -D
a43681
+	@cmp test.2.0.result.var test.2.0.result.var
a43681
+	@rm test.2.0.*
a43681
+	@echo passed
a43681
+	@echo test importing from DMPSTORE and exporting to libefivar
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.2.result.env -D -e test.2.1.goal.var
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.1.goal.var -e test.2.1.result.var
a43681
+	@cmp test.2.1.result.var test.2.1.result.var
a43681
+	@rm test.2.1.*
a43681
+	@echo passed
a43681
+	@echo test importing from libefivar and exporting to DMPSTORE and mixed-case guid-name validation
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n 91376aff-cBa6-42bE-949d-06fde81128e8-GRUB_ENV -f test.2.result.env -e test.2.2.goal.var
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.2.goal.var -e test.2.2.result.var -D
a43681
+	@cmp test.2.2.result.var test.2.2.result.var
a43681
+	@rm test.2.2.*
a43681
+	@echo passed
a43681
+	@echo test importing from libefivar and exporting to libefivar and guid-name validation
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n 91376aff-cba6-42be-949d-06fde81128e8-GRUB_ENV -f test.2.result.env -e test.2.3.goal.var
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.3.goal.var -e test.2.3.result.var
a43681
+	@cmp test.2.3.result.var test.2.3.result.var
a43681
+	@rm test.2.3.* test.2.result.env
a43681
+	@echo passed
a43681
+	@echo testing efivar -L
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -L | \
a43681
+		grep -q '^{91376aff-cba6-42be-949d-06fde81128e8} {grub} efi_guid_grub GRUB$$'
a43681
+	@echo passed
a43681
+
a43681
+test3:
a43681
+	@echo testing with BootOrder variable dmpstore generated
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.3.goal.var -e test.3.0.result.var
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.3.0.result.var -e test.3.1.result.var -D
a43681
+	@cmp test.3.goal.var test.3.1.result.var
a43681
+	@rm test.3.0.result.var test.3.1.result.var
a43681
+	@echo passed
a43681
+
a43681
+test4:
a43681
+	@echo testing with ConIn variable dmpstore generated
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.4.goal.var -e test.4.0.result.var
a43681
+	@LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.4.0.result.var -e test.4.1.result.var -D
a43681
+	@cmp test.4.goal.var test.4.1.result.var
a43681
+	@rm test.4.0.result.var test.4.1.result.var
a43681
+	@echo passed
a43681
+
a43681
+.PHONY: all clean test0
a43681
+# vim:ft=make
a43681
+#
a43681
diff --git a/tests/test.0.goal.var b/tests/test.0.goal.var
a43681
new file mode 100644
a43681
index 0000000000000000000000000000000000000000..a3bfb4db5ea49c8b26b0b9a0e118da4109969efb
a43681
GIT binary patch
a43681
literal 562
a43681
zcmWe)00Jfk26u)ahEN74hIj^720w-{py2;3^NGt&?{k_mm+kKhL5&yeKrv+n_n=TG
a43681
z1=qZ?%%c3f+|;}h1*e?+
a43681
Jz?Da0CID%RU7r8|
a43681
a43681
literal 0
a43681
HcmV?d00001
a43681
a43681
diff --git a/tests/test.1.goal.var b/tests/test.1.goal.var
a43681
new file mode 100644
a43681
index 0000000000000000000000000000000000000000..7f70c93317d996c429430ec434098c0417370970
a43681
GIT binary patch
a43681
literal 574
a43681
zcmbO(djB&c0|Ns)5QD(~Ec1!WPVaM?GMDY|3qg$+LLfmV1_pPAAcjx|Cx&
a43681
zFrc8af_qS?lY(nrS!PjwUT$h$iGov3esVTfN@`MRx@}@kj*f0|a#3bMNoHQUj&4qB
a43681
SMQRb3@+cTCAs{>T<#Pa%YGIxL
a43681
a43681
literal 0
a43681
HcmV?d00001
a43681
a43681
diff --git a/tests/test.3.goal.var b/tests/test.3.goal.var
a43681
new file mode 100644
a43681
index 0000000000000000000000000000000000000000..972dd553e2043e782b096c9a8ad509c07b73782d
a43681
GIT binary patch
a43681
literal 66
a43681
zcmWe(U|`?_Vkd@tAS_|<XDDJwVMqm%3=E0)pLCy^d`WN>FT;Zw%-TKdKru!JW+2JL
a43681
Pz{0@Fz{b#`@+=nsxhf5!
a43681
a43681
literal 0
a43681
HcmV?d00001
a43681
a43681
diff --git a/tests/test.4.goal.var b/tests/test.4.goal.var
a43681
new file mode 100644
a43681
index 0000000000000000000000000000000000000000..549ed5b717dd23843883d3d45f65f4dafeede870
a43681
GIT binary patch
a43681
literal 365
a43681
zcmWe)U|_IjWMFV+$Y;o7@C0HPhE#?!plIU#C*7weUlLr!%kW?Zvvv;~P>hj9gu%OZ
a43681
z#$~DL@y<Q#J=0$&6*)5V2?J$-U>bztU}R+G5@85-KlotZ&r5={co-(A+aL6;XJjEo
a43681
zduqb6`;uEO3(nFdOFQ@Rb=42T%Y6FU_2+4DG&_@MdqeKT+KtgYu1oqK#orBlKZQi?
a43681
e*A|Gbebas3YeDe^+2?h-9rgcN7(R2c?F0Zk6=943
a43681
a43681
literal 0
a43681
HcmV?d00001
a43681
a43681
-- 
a43681
2.26.2
a43681