summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYi Zhao <yi.zhao@windriver.com>2020-03-13 11:51:06 +0800
committerJia Zhang <zhang.jia@linux.alibaba.com>2020-03-13 20:29:08 +0800
commit6faa08370654d66255822a3adf2d1d4b99f010fa (patch)
tree0208a3e0a68c583c45e08d661f0750ead75c7008
parentb0d0273ae273f2052a40f6ddcfee28df6179adfd (diff)
downloadmeta-secure-core-6faa08370654d66255822a3adf2d1d4b99f010fa.tar.gz
tpm2-tools: only support python3 in test scripts
The python2 is removed from oe-core and there is no python symblic link by default which will cause an error when running test scripts: $ ./test_tpm2_activecredential.sh: line 66: python: command not found So drop python2 support and only keep python3. Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
-rw-r--r--meta-tpm2/recipes-tpm/tpm2-tools/files/0002-test-only-support-python3.patch141
-rw-r--r--meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.2.1.bb1
2 files changed, 142 insertions, 0 deletions
diff --git a/meta-tpm2/recipes-tpm/tpm2-tools/files/0002-test-only-support-python3.patch b/meta-tpm2/recipes-tpm/tpm2-tools/files/0002-test-only-support-python3.patch
new file mode 100644
index 0000000..d2f2cd2
--- /dev/null
+++ b/meta-tpm2/recipes-tpm/tpm2-tools/files/0002-test-only-support-python3.patch
@@ -0,0 +1,141 @@
1From 519e70785b56a10a6c326730cda90354ed48d2cb Mon Sep 17 00:00:00 2001
2From: Yi Zhao <yi.zhao@windriver.com>
3Date: Wed, 11 Mar 2020 16:31:01 +0800
4Subject: [PATCH] test: only support python3
5
6The python2 is EOL and in some distributions (e.g. CentOS 8/RHEL 8),
7there is no python symbolic link by default which will cause an error
8when running the test scripts:
9$ ./test_tpm2_activecredential.sh: line 66: python: command not found
10
11See: https://developers.redhat.com/blog/2018/11/14/python-in-rhel-8/
12So drop python2 support and only keep python3.
13
14Upstream-Status: Submitted [https://github.com/tpm2-software/tpm2-tools/pull/1952]
15
16Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
17---
18 configure.ac | 19 ++++++++++---------
19 test/system/test_tpm2_activecredential.sh | 3 +--
20 test/system/test_tpm2_create.sh | 4 +---
21 test/system/test_tpm2_createprimary.sh | 4 +---
22 test/system/test_tpm2_nv.sh | 4 +---
23 test/system/test_tpm2_pcrevent.sh | 4 +---
24 6 files changed, 15 insertions(+), 23 deletions(-)
25
26diff --git a/configure.ac b/configure.ac
27index 0bfd5196..129d37c6 100644
28--- a/configure.ac
29+++ b/configure.ac
30@@ -121,24 +121,25 @@ AS_IF(
31 [],
32 [AC_MSG_WARN([Required executable bash not found, system tests require a bash shell!])])
33
34-AC_CHECK_PROG([PYTHON],[python],[yes])
35+AC_CHECK_PROG([PYTHON3],[python3],[yes])
36 AS_IF(
37- [test "x${PYTHON}" = x"yes"],
38+ [test "x${PYTHON3}" = x"yes"],
39 [],
40- [AC_MSG_WARN([Required executable python not found, some system tests will fail!])])
41+ [AC_MSG_WARN([Required executable python3 not found, some system tests will fail!])])
42
43-dnl macro that checks for specific modules in python
44-AC_DEFUN([AC_PYTHON_MODULE],
45-[AC_MSG_CHECKING([for module $1 in python])
46- echo "import $1" | python -
47+dnl macro that checks for specific modules in python3
48+AC_DEFUN([AC_PYTHON3_MODULE],
49+[AC_MSG_CHECKING([for module $1 in python3])
50+ echo "import $1" | python3 -
51 if test $? -ne 0 ; then
52 AC_MSG_RESULT([not found])
53 AC_MSG_WARN([System tests require pyyaml, some tests will fail!])
54+ else
55+ AC_MSG_RESULT(found)
56 fi
57-AC_MSG_RESULT(found)
58 ])
59
60-AC_PYTHON_MODULE([yaml])
61+AC_PYTHON3_MODULE([yaml])
62
63 AC_SUBST([EXTRA_CFLAGS])
64 AC_SUBST([EXTRA_LDFLAGS])
65diff --git a/test/system/test_tpm2_activecredential.sh b/test/system/test_tpm2_activecredential.sh
66index d8cadf53..f69576d1 100755
67--- a/test/system/test_tpm2_activecredential.sh
68+++ b/test/system/test_tpm2_activecredential.sh
69@@ -56,8 +56,7 @@ tpm2_getpubek -Q -H 0x81010009 -g rsa -f ek.pub
70 tpm2_getpubak -E 0x81010009 -k 0x8101000a -g rsa -D sha256 -s rsassa -f ak.pub -n ak.name > ak.out
71
72 # Capture the yaml output and verify that its the same as the name output
73-loaded_key_name_yaml=`python << pyscript
74-from __future__ import print_function
75+loaded_key_name_yaml=`python3 << pyscript
76 import yaml
77
78 with open('ak.out', 'r') as f:
79diff --git a/test/system/test_tpm2_create.sh b/test/system/test_tpm2_create.sh
80index d0bf0317..f31d6486 100755
81--- a/test/system/test_tpm2_create.sh
82+++ b/test/system/test_tpm2_create.sh
83@@ -51,9 +51,7 @@ trap cleanup EXIT
84
85 function yaml_get() {
86
87-python << pyscript
88-from __future__ import print_function
89-
90+python3 << pyscript
91 import sys
92 import yaml
93
94diff --git a/test/system/test_tpm2_createprimary.sh b/test/system/test_tpm2_createprimary.sh
95index 83bdad44..a2590f68 100755
96--- a/test/system/test_tpm2_createprimary.sh
97+++ b/test/system/test_tpm2_createprimary.sh
98@@ -65,9 +65,7 @@ done
99
100 function yaml_get() {
101
102-python << pyscript
103-from __future__ import print_function
104-
105+python3 << pyscript
106 import sys
107 import yaml
108
109diff --git a/test/system/test_tpm2_nv.sh b/test/system/test_tpm2_nv.sh
110index 2db6522a..5f72f264 100755
111--- a/test/system/test_tpm2_nv.sh
112+++ b/test/system/test_tpm2_nv.sh
113@@ -61,9 +61,7 @@ trap onerror ERR
114
115 function yaml_get() {
116
117-python << pyscript
118-from __future__ import print_function
119-
120+python3 << pyscript
121 import sys
122 import yaml
123
124diff --git a/test/system/test_tpm2_pcrevent.sh b/test/system/test_tpm2_pcrevent.sh
125index 30ec9320..f382387d 100755
126--- a/test/system/test_tpm2_pcrevent.sh
127+++ b/test/system/test_tpm2_pcrevent.sh
128@@ -50,9 +50,7 @@ trap cleanup EXIT
129
130 function yaml_get() {
131
132-python << pyscript
133-from __future__ import print_function
134-
135+python3 << pyscript
136 import sys
137 import yaml
138
139--
1402.17.1
141
diff --git a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.2.1.bb b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.2.1.bb
index 77811a5..e2284d7 100644
--- a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.2.1.bb
+++ b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.2.1.bb
@@ -3,6 +3,7 @@ include ${BPN}.inc
3SRC_URI = "\ 3SRC_URI = "\
4 https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \ 4 https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \
5 file://0001-test-fix-yaml.load-warning.patch \ 5 file://0001-test-fix-yaml.load-warning.patch \
6 file://0002-test-only-support-python3.patch \
6" 7"
7SRC_URI[md5sum] = "17f22e9b47682f4601eb55324282ad6e" 8SRC_URI[md5sum] = "17f22e9b47682f4601eb55324282ad6e"
8SRC_URI[sha256sum] = "568ff32f99e0835db5d8cea2dce781b6cd6c1034026514240995dae5d9e728b0" 9SRC_URI[sha256sum] = "568ff32f99e0835db5d8cea2dce781b6cd6c1034026514240995dae5d9e728b0"