From d1825c7a86717faf518e0abd08f0f5c1e94c0ca8 Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Mon, 18 Jan 2016 16:39:27 -0500 Subject: [PATCH] openssl/ssl/context: test that we are refcounting correctly Not a perfect test, on failure it _might_ exit with this output: Process didn't exit successfully: `/home/cody/g/rust-openssl/openssl/target/debug/openssl-8e712036e3aac4fe` (signal: 11) But unclear if we can do any better. --- openssl/src/ssl/tests/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs index a763f496..f5a42536 100644 --- a/openssl/src/ssl/tests/mod.rs +++ b/openssl/src/ssl/tests/mod.rs @@ -1045,3 +1045,16 @@ fn flush_panic() { let mut stream = SslStream::connect(&ctx, stream).unwrap(); let _ = stream.flush(); } + +#[test] +fn refcount_ssl_context() { + let ssl = { + let ctx = SslContext::new(SslMethod::Sslv23).unwrap(); + ssl::Ssl::new(&ctx).unwrap() + }; + + { + let new_ctx_a = SslContext::new(SslMethod::Sslv23).unwrap(); + let _new_ctx_b = ssl.set_ssl_context(&new_ctx_a); + } +}