File tree Expand file tree Collapse file tree
src/test/com/wolfssl/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121
2222package com .wolfssl .test ;
2323
24+ import org .junit .BeforeClass ;
2425import org .junit .runner .RunWith ;
2526import org .junit .runners .Suite ;
2627
28+ import com .wolfssl .WolfSSL ;
29+ import com .wolfssl .WolfSSLException ;
30+
2731@ RunWith (Suite .class )
2832@ Suite .SuiteClasses ({
2933 WolfSSLTest .class ,
3842
3943
4044public class WolfSSLTestSuite {
41- /* this class remains empty,
42- * only used as a holder for the above
43- * annotations */
45+
46+ /* Static WolfSSL reference to keep library initialized for the duration
47+ * of the entire test suite. Without this, a WolfSSL object created by
48+ * an individual test class could be garbage collected after that test
49+ * class finishes, triggering wolfSSL_Cleanup() in the finalizer and
50+ * freeing session cache locks (and other items) while subsequent test
51+ * classes are still running. This caused crashes on Windows when the
52+ * garbage collector ran between test classes.
53+ *
54+ * We intentionally do not call cleanup() in @AfterClass because on
55+ * Android all tests run in a single process and multiple test suites
56+ * may be active. Cleanup will happen via the finalizer when the
57+ * process exits. */
58+ private static WolfSSL sslLib = null ;
59+
60+ @ BeforeClass
61+ public static void initializeLibrary () throws WolfSSLException {
62+ WolfSSL .loadLibrary ();
63+ sslLib = new WolfSSL ();
64+ }
4465}
4566
You can’t perform that action at this time.
0 commit comments