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

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