8239928: ec/ECDSAJavaVerify.java failed due to timeout

Reviewed-by: valeriep
This commit is contained in:
Weijun Wang 2020-03-11 10:33:33 +08:00
parent 08c3b1fc8f
commit 80ca356e7e

View File

@ -48,11 +48,14 @@ import java.util.Random;
/* /*
* @test * @test
* @bug 8237218 * @bug 8237218 8239928
* @summary Support NIST Curves verification in java implementation
* @modules jdk.crypto.ec * @modules jdk.crypto.ec
* jdk.jdi * jdk.jdi
* @requires os.family != "windows"
* @run main ECDSAJavaVerify debug * @run main ECDSAJavaVerify debug
* @summary Support NIST Curves verification in java implementation.
* This test does not run stable on Windows. VMDisconnectedException
* might not be thrown at all.
*/ */
// ATTENTION: This test depends on method names inside the non-exported // ATTENTION: This test depends on method names inside the non-exported
@ -120,9 +123,15 @@ public class ECDSAJavaVerify {
} }
} }
// Test result, init as ' ', '-' if run, 'x' for unexpected. // Test result
// '.': not run yet
// '-': enter engineVerify
// 'v': expected impl called
// 'x': unexpected impl called
// Note: some error cases fail before any impl called. Ex: if there
// is a DER encoding error.
char[] result = new char[numberOfTests]; char[] result = new char[numberOfTests];
Arrays.fill(result, ' '); Arrays.fill(result, '.');
String stdout, stderr; String stdout, stderr;
@ -135,18 +144,13 @@ public class ECDSAJavaVerify {
MethodEntryEvent e = (MethodEntryEvent)event; MethodEntryEvent e = (MethodEntryEvent)event;
switch (e.method().name()) { switch (e.method().name()) {
case "engineVerify": case "engineVerify":
pos++; result[++pos] = '-';
result[pos] = '-';
break; break;
case "verifySignedDigestImpl": // the java impl case "verifySignedDigestImpl": // the java impl
if (expected[pos] != 'J') { result[pos] = expected[pos] != 'J' ? 'x' : 'v';
result[pos] = 'x';
}
break; break;
case "verifySignedDigest": case "verifySignedDigest": // the native impl
if (expected[pos] != 'N') { // the native impl result[pos] = expected[pos] != 'N' ? 'x' : 'v';
result[pos] = 'x';
}
break; break;
} }
} }
@ -160,19 +164,22 @@ public class ECDSAJavaVerify {
stdout = new String(vm.process().getInputStream().readAllBytes()); stdout = new String(vm.process().getInputStream().readAllBytes());
} }
int exitCode = vm.process().waitFor();
System.out.println(" exit: " + exitCode);
System.out.println("stderr:\n" + stderr); System.out.println("stderr:\n" + stderr);
System.out.println("stdout:\n" + stdout); System.out.println("stdout:\n" + stdout);
String sResult = new String(result); String sResult = new String(result);
System.out.println("Expected: " + new String(expected)); System.out.println(" Cases: " + new String(expected));
System.out.println(" Actual: " + sResult); System.out.println("Result: " + sResult);
if (pos != numberOfTests - 1 || sResult.contains("x")) { if (pos != numberOfTests - 1 || sResult.contains("x")
|| sResult.contains(".")) {
throw new Exception("Unexpected result"); throw new Exception("Unexpected result");
} }
if (stdout.contains("fail") || !stderr.isEmpty()) { if (stdout.contains("fail") || exitCode != 0) {
throw new Exception("Test failed"); throw new Exception("Test failed");
} }
} }