python3-cryptography: backport fix for leaky test

Message ID 20220408133821.469964-1-ross.burton@arm.com
State Accepted, archived
Commit 4705b8a724fe288a20f1a080e2796ea90f46c9fb
Headers show
Series python3-cryptography: backport fix for leaky test | expand

Commit Message

Ross Burton April 8, 2022, 1:38 p.m. UTC
The leaking test case has been fixed upstream, so backport the patch.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../fix-leak-metric.patch                     | 36 +++++++++++++++++++
 .../skip-leaky-test.patch                     | 19 ----------
 .../python/python3-cryptography_36.0.2.bb     |  2 +-
 3 files changed, 37 insertions(+), 20 deletions(-)
 create mode 100644 meta/recipes-devtools/python/python3-cryptography/fix-leak-metric.patch
 delete mode 100644 meta/recipes-devtools/python/python3-cryptography/skip-leaky-test.patch

Patch

diff --git a/meta/recipes-devtools/python/python3-cryptography/fix-leak-metric.patch b/meta/recipes-devtools/python/python3-cryptography/fix-leak-metric.patch
new file mode 100644
index 00000000000..904984f43d7
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-cryptography/fix-leak-metric.patch
@@ -0,0 +1,36 @@ 
+Trigger hashlib initialisation so that the test_create_certificate_with_extensions
+test doesn't fail.
+
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+From dc989d563ab6a078651160e5e6d4ee3df8cb08d7 Mon Sep 17 00:00:00 2001
+From: Alex Gaynor <alex.gaynor@gmail.com>
+Date: Thu, 7 Apr 2022 03:15:09 -0400
+Subject: [PATCH] Added Ubuntu Jammy to CI (#7047)
+
+* Added Ubuntu Jammy to CI
+
+* try thing
+---
+ .github/workflows/ci.yml                      | 1 +
+ docs/installation.rst                         | 2 +-
+ tests/hazmat/backends/test_openssl_memleak.py | 3 +++
+ 3 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py
+index 835c9256a6..2605566bd5 100644
+--- a/tests/hazmat/backends/test_openssl_memleak.py
++++ b/tests/hazmat/backends/test_openssl_memleak.py
+@@ -82,8 +82,11 @@ def free(ptr, path, line):
+     assert result == 1
+ 
+     # Trigger a bunch of initialization stuff.
++    import hashlib
+     from cryptography.hazmat.backends.openssl.backend import backend
+ 
++    hashlib.sha256()
++
+     start_heap = set(heap)
+ 
+     try:
diff --git a/meta/recipes-devtools/python/python3-cryptography/skip-leaky-test.patch b/meta/recipes-devtools/python/python3-cryptography/skip-leaky-test.patch
deleted file mode 100644
index 64248d57bd9..00000000000
--- a/meta/recipes-devtools/python/python3-cryptography/skip-leaky-test.patch
+++ /dev/null
@@ -1,19 +0,0 @@ 
-Mark as test as expected-failure, OpenSSL is leaking memory.
-
-xfail not skip so we can remove this when OpenSSL doesn't leak anymore.
-
-Upstream-Status: Inappropriate
-Signed-off-by: Ross Burton <ross.burton@arm.com>
-
-diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py
-index 835c9256..639f6ba2 100644
---- a/tests/hazmat/backends/test_openssl_memleak.py
-+++ b/tests/hazmat/backends/test_openssl_memleak.py
-@@ -466,6 +466,7 @@ class TestOpenSSLMemoryLeaks:
-             )
-         )
- 
-+    @pytest.mark.xfail(reason="has memory leaks")
-     def test_create_certificate_with_extensions(self):
-         assert_no_memory_leaks(
-             textwrap.dedent(
diff --git a/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb b/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb
index cb3acdf7e28..9ef5ff39c82 100644
--- a/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb
+++ b/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb
@@ -16,7 +16,7 @@  SRC_URI += " \
     file://check-memfree.py \
     file://0001-Cargo.toml-specify-pem-version.patch \
     file://0002-Cargo.toml-edition-2018-2021.patch \
-    file://skip-leaky-test.patch \
+    file://fix-leak-metric.patch \
 "
 
 inherit pypi python_setuptools3_rust