Skip to content

Commit 4c89edd

Browse files
committed
Cut the core test run time: split the QR-UOV, SNOVA, MQOM, SQIsign, SLH-DSA and XMSS^MT KAT suites into finer AllTests* suites so each runs as its own parallel fork, sample the ACVP SLH-DSA-sigGen.txt vectors the way the per-parameter-set sigGen files already are, generate the XMSSPrivateKeyTest keys at height 4, compute the OpenBSDBCryptTest root hashes once per salt rather than per candidate, and exclude the nested AllTest*$* TestCase classes from the Gradle test filter so they run only through their suite() rather than twice.
1 parent 73b7df4 commit 4c89edd

28 files changed

Lines changed: 533 additions & 28 deletions

‎ant/jdk13.xml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@
347347
<exclude name="**/pqc/crypto/test/AllTestsHawk.java" />
348348
<exclude name="**/pqc/crypto/test/AllTestsMQOM.java" />
349349
<exclude name="**/pqc/crypto/test/AllTestsQRUOV.java" />
350+
<exclude name="**/pqc/crypto/test/AllTestsQRUOVAes.java" />
351+
<exclude name="**/pqc/crypto/test/AllTestsQRUOVCat5.java" />
352+
<exclude name="**/pqc/crypto/test/AllTestsQRUOVAesCat5.java" />
353+
<exclude name="**/pqc/crypto/test/AllTestsSnovaSSK.java" />
354+
<exclude name="**/pqc/crypto/test/AllTestsSnovaShake.java" />
355+
<exclude name="**/pqc/crypto/test/AllTestsSnovaShakeSSK.java" />
356+
<exclude name="**/pqc/crypto/test/AllTestsMQOMCat3.java" />
357+
<exclude name="**/pqc/crypto/test/AllTestsMQOMCat5.java" />
358+
<exclude name="**/pqc/crypto/test/AllTestsSQIsign.java" />
359+
<exclude name="**/pqc/crypto/test/AllTestsSQIsignLvl5.java" />
360+
<exclude name="**/pqc/crypto/test/AllTestsSLHDSASigGen.java" />
361+
<exclude name="**/pqc/crypto/test/AllTestsXMSSMT.java" />
350362
<exclude name="**/pqc/crypto/test/AllTestsSLHDSA.java" />
351363
<exclude name="**/pqc/crypto/test/AllTestsSnova.java" />
352364
<exclude name="**/pqc/crypto/test/AllTestsXMSS.java" />

‎ant/jdk14.xml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,18 @@
164164
<exclude name="**/pqc/crypto/test/AllTestsSnova.java"/>
165165
<exclude name="**/pqc/crypto/test/AllTestsSLHDSA.java"/>
166166
<exclude name="**/pqc/crypto/test/AllTestsQRUOV.java"/>
167+
<exclude name="**/pqc/crypto/test/AllTestsQRUOVAes.java"/>
168+
<exclude name="**/pqc/crypto/test/AllTestsQRUOVCat5.java"/>
169+
<exclude name="**/pqc/crypto/test/AllTestsQRUOVAesCat5.java"/>
170+
<exclude name="**/pqc/crypto/test/AllTestsSnovaSSK.java"/>
171+
<exclude name="**/pqc/crypto/test/AllTestsSnovaShake.java"/>
172+
<exclude name="**/pqc/crypto/test/AllTestsSnovaShakeSSK.java"/>
173+
<exclude name="**/pqc/crypto/test/AllTestsMQOMCat3.java"/>
174+
<exclude name="**/pqc/crypto/test/AllTestsMQOMCat5.java"/>
175+
<exclude name="**/pqc/crypto/test/AllTestsSQIsign.java"/>
176+
<exclude name="**/pqc/crypto/test/AllTestsSQIsignLvl5.java"/>
177+
<exclude name="**/pqc/crypto/test/AllTestsSLHDSASigGen.java"/>
178+
<exclude name="**/pqc/crypto/test/AllTestsXMSSMT.java"/>
167179
<exclude name="**/crypto/test/AllTestsSlow.java"/>
168180
<exclude name="**/crypto/test/AllTestsOpenBSDBCrypt.java"/>
169181
<exclude name="**/crypto/test/AllTestsArgon.java"/>

‎build.gradle‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ configure(subprojects.findAll {it.name != 'bom'}) {
248248

249249
filter {
250250
includeTestsMatching "AllTest*"
251+
// the pattern also matches the nested TestCase classes some suites declare
252+
// (AllTestsSlow$RegressionTestTest etc.), which would then run standalone as
253+
// well as through their suite() - only run them through the suite.
254+
excludeTestsMatching "*\$*"
251255
if (project.hasProperty('excludeTests')) {
252256
excludeTestsMatching "${excludeTests}"
253257
}

‎core/src/test/java/org/bouncycastle/crypto/test/OpenBSDBCryptTest.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ public void testPermutations()
142142

143143

144144

145+
// the root password's hash for each salt, computed once rather than per candidate
146+
String[] rootHashes = new String[salts.length];
147+
for (int k = 0; k != salts.length; k++)
148+
{
149+
rootHashes[k] = OpenBSDBCrypt.generate(rootPassword, salts[k], 4);
150+
}
151+
145152
//
146153
// Permutation, starting with a shorter array, same length then one longer.
147154
//
@@ -166,7 +173,7 @@ public void testPermutations()
166173
for (int k = 0; k != salts.length; k++)
167174
{
168175
byte[] salt = salts[k];
169-
String expected = OpenBSDBCrypt.generate(rootPassword, salt, 4);
176+
String expected = rootHashes[k];
170177
String testValue = OpenBSDBCrypt.generate(candidate, salt, 4);
171178

172179
//

‎core/src/test/java/org/bouncycastle/pqc/crypto/test/AllTests.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static Test suite()
5353
// Hawk tests split out into AllTestsHawk so they can run as a separate (parallel) fork.
5454
suite.addTestSuite(UOVTest.class);
5555
// MQOM tests split out into AllTestsMQOM so they can run as a separate (parallel) fork.
56-
suite.addTestSuite(SQIsignTest.class);
56+
// SQIsign tests split out into AllTestsSQIsign / AllTestsSQIsignLvl5 so they can run as separate (parallel) forks.
5757
suite.addTestSuite(HAETAETest.class);
5858
suite.addTestSuite(SDitHTest.class);
5959
suite.addTestSuite(AIMerTest.class);

‎core/src/test/java/org/bouncycastle/pqc/crypto/test/AllTestsMQOM.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public static Test suite()
1818
TestSuite suite = new TestSuite("Lightweight MQOM Tests");
1919

2020
suite.addTestSuite(MQOMTest.class);
21-
suite.addTestSuite(MQOMKatTest.class);
21+
// the category 3 and 5 MQOMKatTest KATs run from AllTestsMQOMCat3 / AllTestsMQOMCat5
22+
// so the three categories, each minutes of signing, run as separate (parallel) forks.
23+
suite.addTest(TestSuite.createTest(MQOMKatTest.class, "testCat1Variants"));
2224

2325
return new AllTests.BCTestSetup(suite);
2426
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.bouncycastle.pqc.crypto.test;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
import org.bouncycastle.test.PrintTestResult;
7+
8+
public class AllTestsMQOMCat3
9+
extends TestCase
10+
{
11+
public static void main(String[] args)
12+
{
13+
PrintTestResult.printResult(junit.textui.TestRunner.run(suite()));
14+
}
15+
16+
public static Test suite()
17+
{
18+
TestSuite suite = new TestSuite("Lightweight MQOM Tests (category 3)");
19+
20+
// one third of the MQOMKatTest KATs; see AllTestsMQOM.
21+
suite.addTest(TestSuite.createTest(MQOMKatTest.class, "testCat3Variants"));
22+
23+
return new AllTests.BCTestSetup(suite);
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.bouncycastle.pqc.crypto.test;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
import org.bouncycastle.test.PrintTestResult;
7+
8+
public class AllTestsMQOMCat5
9+
extends TestCase
10+
{
11+
public static void main(String[] args)
12+
{
13+
PrintTestResult.printResult(junit.textui.TestRunner.run(suite()));
14+
}
15+
16+
public static Test suite()
17+
{
18+
TestSuite suite = new TestSuite("Lightweight MQOM Tests (category 5)");
19+
20+
// one third of the MQOMKatTest KATs; see AllTestsMQOM.
21+
suite.addTest(TestSuite.createTest(MQOMKatTest.class, "testCat5Variants"));
22+
23+
return new AllTests.BCTestSetup(suite);
24+
}
25+
}

‎core/src/test/java/org/bouncycastle/pqc/crypto/test/AllTestsQRUOV.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public static void main(String[] args)
1515

1616
public static Test suite()
1717
{
18-
TestSuite suite = new TestSuite("Lightweight QR-UOV Tests");
18+
TestSuite suite = new TestSuite("Lightweight QR-UOV Tests (SHAKE PRG, categories 1 and 3)");
1919

20-
suite.addTestSuite(QRUOVTest.class);
20+
// the other QRUOVTest KAT methods run from AllTestsQRUOVCat5 / AllTestsQRUOVAes /
21+
// AllTestsQRUOVAesCat5 so the four halves, each minutes of KATs, run as separate (parallel) forks.
22+
suite.addTest(TestSuite.createTest(QRUOVTest.class, "testTestVectorsShake"));
2123

2224
return new AllTests.BCTestSetup(suite);
2325
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.bouncycastle.pqc.crypto.test;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
import org.bouncycastle.test.PrintTestResult;
7+
8+
public class AllTestsQRUOVAes
9+
extends TestCase
10+
{
11+
public static void main(String[] args)
12+
{
13+
PrintTestResult.printResult(junit.textui.TestRunner.run(suite()));
14+
}
15+
16+
public static Test suite()
17+
{
18+
TestSuite suite = new TestSuite("Lightweight QR-UOV Tests (AES PRG, categories 1 and 3)");
19+
20+
// one quarter of the QRUOVTest KATs; see AllTestsQRUOV.
21+
suite.addTest(TestSuite.createTest(QRUOVTest.class, "testTestVectorsAes"));
22+
23+
return new AllTests.BCTestSetup(suite);
24+
}
25+
}

0 commit comments

Comments
 (0)