Skip to content

Commit 2ebb052

Browse files
committed
Tests: Replace passed/failed/skipped status with per-method timing
1 parent ac511b5 commit 2ebb052

25 files changed

Lines changed: 712 additions & 3351 deletions

src/test/com/wolfssl/provider/jsse/test/WolfSSLContextTest.java

Lines changed: 10 additions & 91 deletions
Large diffs are not rendered by default.

src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineMemoryLeakTest.java

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121

2222
package com.wolfssl.provider.jsse.test;
2323

24+
import org.junit.Assume;
2425
import org.junit.Test;
2526
import org.junit.BeforeClass;
2627
import org.junit.Rule;
28+
import org.junit.rules.TestRule;
2729
import org.junit.rules.Timeout;
2830
import static org.junit.Assert.*;
2931

@@ -35,6 +37,7 @@
3537
import javax.net.ssl.SSLException;
3638

3739
import com.wolfssl.provider.jsse.WolfSSLProvider;
40+
import com.wolfssl.test.TimedTestWatcher;
3841

3942
/**
4043
* Memory leak regression test for WolfSSLEngine.
@@ -49,6 +52,9 @@
4952
*/
5053
public class WolfSSLEngineMemoryLeakTest {
5154

55+
@Rule
56+
public TestRule testWatcher = TimedTestWatcher.create();
57+
5258
/**
5359
* Global timeout for all tests in this class. The 500-engine test
5460
* plus multiple GC/finalization rounds can run 60+ seconds on slower
@@ -66,14 +72,6 @@ public static void setupProvider() {
6672
Security.addProvider(new WolfSSLProvider());
6773
}
6874

69-
private void pass(String msg) {
70-
WolfSSLTestFactory.pass(msg);
71-
}
72-
73-
private void error(String msg) {
74-
WolfSSLTestFactory.fail(msg);
75-
}
76-
7775
/**
7876
* Test that abandoned SSLEngine instances can be garbage collected.
7977
*
@@ -87,10 +85,7 @@ private void error(String msg) {
8785
public void testEngineMemoryLeakWithAbandonedEngines() throws Exception {
8886

8987
/* Skip on Android due to performance and timeout issues */
90-
if (WolfSSLTestFactory.isAndroid()) {
91-
System.out.println("\tmem leak test\t\t\t... skipped (Android)");
92-
return;
93-
}
88+
Assume.assumeFalse(WolfSSLTestFactory.isAndroid());
9489

9590
/* Number of engines to create. Use a smaller number for unit tests
9691
* to keep test time reasonable (few seconds). */
@@ -106,9 +101,6 @@ public void testEngineMemoryLeakWithAbandonedEngines() throws Exception {
106101
* accounting for JVM differences. */
107102
final double maxAcceptableGrowthMB = 80.0;
108103

109-
String javaVersion = System.getProperty("java.version");
110-
System.out.print("\tmem leak test with " + numEngines + " engines");
111-
112104
/* Measure baseline memory - use aggressive GC */
113105
for (int i = 0; i < 3; i++) {
114106
System.gc();
@@ -145,11 +137,8 @@ public void testEngineMemoryLeakWithAbandonedEngines() throws Exception {
145137
numEngines, memoryGrowthMB, maxAcceptableGrowthMB);
146138

147139
if (memoryGrowthMB > maxAcceptableGrowthMB) {
148-
error("\t... failed");
149140
fail(message);
150141
}
151-
152-
pass("\t... passed");
153142
}
154143

155144
/**
@@ -167,8 +156,6 @@ public void testEngineMemoryLeakWithProperClose() throws Exception {
167156
Thread.sleep(100);
168157
long baselineMemory = getUsedMemoryBytes();
169158

170-
System.out.print("\tmem leak test closed engines");
171-
172159
/* Create engines and explicitly close them */
173160
for (int i = 0; i < numEngines; i++) {
174161
SSLContext sslContext =
@@ -204,11 +191,8 @@ public void testEngineMemoryLeakWithProperClose() throws Exception {
204191
numEngines, memoryGrowthMB, maxAcceptableGrowthMB);
205192

206193
if (memoryGrowthMB > maxAcceptableGrowthMB) {
207-
error("\t... failed");
208194
fail(message);
209195
}
210-
211-
pass("\t... passed");
212196
}
213197

214198
/**

0 commit comments

Comments
 (0)