tpm2-tools: fix yaml.load warning in test scripts

The yaml.load(f) is deprecated since pyyaml 5.1.
Use yaml.load(f, Loader=yaml.BaseLoader) instead of it.
See https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation

Fixes warning:
YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
This commit is contained in:
Yi Zhao
2020-03-13 11:48:42 +08:00
committed by Jia Zhang
parent 7db0fc79df
commit b0d0273ae2
2 changed files with 93 additions and 0 deletions
@@ -0,0 +1,92 @@
From 0de180698bc992420fa8670d1ecce24008a4e3b9 Mon Sep 17 00:00:00 2001
From: Yi Zhao <yi.zhao@windriver.com>
Date: Tue, 10 Mar 2020 11:18:51 +0800
Subject: [PATCH] test: fix yaml.load warning
The yaml.load(f) is deprecated since pyyaml 5.1.
Use yaml.load(f, Loader=yaml.BaseLoader) instead of it.
See https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
Fixes warning:
YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
Upstream-Status: Submitted [https://github.com/tpm2-software/tpm2-tools/pull/1944]
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
test/system/test_tpm2_activecredential.sh | 2 +-
test/system/test_tpm2_create.sh | 2 +-
test/system/test_tpm2_createprimary.sh | 2 +-
test/system/test_tpm2_nv.sh | 2 +-
test/system/test_tpm2_pcrevent.sh | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/system/test_tpm2_activecredential.sh b/test/system/test_tpm2_activecredential.sh
index d8cadf5..3c9cf6e 100755
--- a/test/system/test_tpm2_activecredential.sh
+++ b/test/system/test_tpm2_activecredential.sh
@@ -61,7 +61,7 @@ from __future__ import print_function
import yaml
with open('ak.out', 'r') as f:
- doc = yaml.load(f)
+ doc = yaml.load(f, Loader=yaml.BaseLoader)
print(doc['loaded-key']['name'])
pyscript`
diff --git a/test/system/test_tpm2_create.sh b/test/system/test_tpm2_create.sh
index d0bf031..ff192ca 100755
--- a/test/system/test_tpm2_create.sh
+++ b/test/system/test_tpm2_create.sh
@@ -59,7 +59,7 @@ import yaml
with open("$2") as f:
try:
- y = yaml.load(f)
+ y = yaml.load(f, Loader=yaml.BaseLoader)
found = "$1" in y
if (not found):
sys.stderr.write('Could not find index 0x%X\n' % ("$1"))
diff --git a/test/system/test_tpm2_createprimary.sh b/test/system/test_tpm2_createprimary.sh
index 83bdad4..cc4dce0 100755
--- a/test/system/test_tpm2_createprimary.sh
+++ b/test/system/test_tpm2_createprimary.sh
@@ -73,7 +73,7 @@ import yaml
with open("$2") as f:
try:
- y = yaml.load(f)
+ y = yaml.load(f, Loader=yaml.BaseLoader)
found = "$1" in y
if (not found):
sys.stderr.write('Could not find index 0x%X\n' % ("$1"))
diff --git a/test/system/test_tpm2_nv.sh b/test/system/test_tpm2_nv.sh
index 2db6522..756d7ea 100755
--- a/test/system/test_tpm2_nv.sh
+++ b/test/system/test_tpm2_nv.sh
@@ -69,7 +69,7 @@ import yaml
with open("$2") as f:
try:
- y = yaml.load(f)
+ y = yaml.load(f, Loader=yaml.BaseLoader)
found = $1 in y
if (not found):
sys.stderr.write('Could not find index 0x%X\n' % ($1))
diff --git a/test/system/test_tpm2_pcrevent.sh b/test/system/test_tpm2_pcrevent.sh
index 30ec932..74f640b 100755
--- a/test/system/test_tpm2_pcrevent.sh
+++ b/test/system/test_tpm2_pcrevent.sh
@@ -59,7 +59,7 @@ import yaml
with open("$1", 'r') as stream:
try:
- y = yaml.load(stream)
+ y = yaml.load(stream, Loader=yaml.BaseLoader)
alg = y["$2"]
value = alg[$3]
print(value)
--
2.7.4
@@ -2,6 +2,7 @@ include ${BPN}.inc
SRC_URI = "\
https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \
file://0001-test-fix-yaml.load-warning.patch \
"
SRC_URI[md5sum] = "17f22e9b47682f4601eb55324282ad6e"
SRC_URI[sha256sum] = "568ff32f99e0835db5d8cea2dce781b6cd6c1034026514240995dae5d9e728b0"