From 1f7d7b3263c36734323da5307edfc310764a5e56 Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Tue, 23 Jul 2024 07:01:12 +0800 Subject: [PATCH] tests(*) unload provider to make valgrind happy --- t/openssl/pkcs12.t | 35 ++++++++++++++++++++++++++++++----- t/openssl/provider.t | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/t/openssl/pkcs12.t b/t/openssl/pkcs12.t index a1d4afd3..47654c6b 100644 --- a/t/openssl/pkcs12.t +++ b/t/openssl/pkcs12.t @@ -29,9 +29,10 @@ __DATA__ --- config location =/t { content_by_lua_block { + local p if require("resty.openssl.version").OPENSSL_3X then local pro = require "resty.openssl.provider" - myassert(pro.load("legacy")) + p = myassert(pro.load("legacy")) end local pkcs12 = require "resty.openssl.pkcs12" @@ -42,6 +43,10 @@ __DATA__ ngx.say(r.key:get_parameters().d:to_hex()) ngx.say(r.cert:get_serial_number():to_hex()) + + if p then + myassert(p:unload()) + end } } --- request @@ -59,9 +64,10 @@ __DATA__ --- config location =/t { content_by_lua_block { + local p if require("resty.openssl.version").OPENSSL_3X then local pro = require "resty.openssl.provider" - myassert(pro.load("legacy")) + p = myassert(pro.load("legacy")) end local pkcs12 = require "resty.openssl.pkcs12" @@ -75,6 +81,10 @@ __DATA__ local r, err = pkcs12.decode(pp) ngx.say(r == nil) ngx.say(err) + + if p then + myassert(p:unload()) + end } } --- request @@ -95,9 +105,10 @@ pkcs12.decode.+mac verify failure.* --- config location =/t { content_by_lua_block { + local p if require("resty.openssl.version").OPENSSL_3X then local pro = require "resty.openssl.provider" - myassert(pro.load("legacy")) + p = myassert(pro.load("legacy")) end local pkcs12 = require "resty.openssl.pkcs12" @@ -133,6 +144,10 @@ pkcs12.decode.+mac verify failure.* cert = cert, })) ngx.say(#r) + + if p then + myassert(p:unload()) + end } } --- request @@ -153,9 +168,10 @@ pkcs12.decode.+mac verify failure.* --- config location =/t { content_by_lua_block { + local p if require("resty.openssl.version").OPENSSL_3X then local pro = require "resty.openssl.provider" - myassert(pro.load("legacy")) + p = myassert(pro.load("legacy")) end local pkcs12 = require "resty.openssl.pkcs12" @@ -183,6 +199,10 @@ pkcs12.decode.+mac verify failure.* local r, err = pkcs12.decode(p12, "extrapassword") ngx.say(r == nil) ngx.say(err) + + if p then + myassert(p:unload()) + end } } --- request @@ -205,9 +225,10 @@ pkcs12.decode.+mac verify failure.* --- config location =/t { content_by_lua_block { + local p if require("resty.openssl.version").OPENSSL_3X then local pro = require "resty.openssl.provider" - myassert(pro.load("legacy")) + p = myassert(pro.load("legacy")) end local pkcs12 = require "resty.openssl.pkcs12" @@ -221,6 +242,10 @@ pkcs12.decode.+mac verify failure.* cacerts = { ca1, ca2 } }, "test-pkcs12") ngx.say(r == nil, err) + + if p then + myassert(p:unload()) + end } } --- request diff --git a/t/openssl/provider.t b/t/openssl/provider.t index b226afec..33e6009b 100644 --- a/t/openssl/provider.t +++ b/t/openssl/provider.t @@ -137,6 +137,7 @@ true local p = myassert(pro.load("default")) local a = assert(p:get_params("name", "version", "buildinfo", "status")) ngx.say(encode_sorted_json(a)) + myassert(p:unload()) } } --- request