Skip to content

Commit

Permalink
Support testing against JDK17 (corretto#165)
Browse files Browse the repository at this point in the history
* Upgrade gradle wrapper to 7.2

* Fix test task on JDK17

* Fix javadoc task on JDK17

* Re-add legacy tests for sizes

* Upgrade jacoco to 0.8.7

* Add add-opens flag only on JDK17+ builds

* PR feedback

* Add test java major version var in build

* Remove unnecessary patch in build

* Upgrade BC used for testing

* Remove patch file

* Remove non-supported curves from evp tests
  • Loading branch information
lavaleri authored Sep 15, 2021
1 parent e695408 commit a72c6de
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 281 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ endif()

if (NOT DEFINED TEST_JAVA_HOME)
set(TEST_JAVA_EXECUTABLE ${Java_JAVA_EXECUTABLE})
set(TEST_JAVA_MAJOR_VERSION ${Java_VERSION_MAJOR})
else()
set(TEST_JAVA_EXECUTABLE ${TEST_JAVA_HOME}/bin/java)
endif()
Expand Down Expand Up @@ -590,8 +591,20 @@ add_custom_command(
add_custom_target(tests-jar DEPENDS ${TESTS_JAR})
set_property(TARGET tests-jar PROPERTY JAR_FILE ${TESTS_JAR})

# These flags are necessary in Java17+ in order for certain unit tests to
# perform deep reflection on nonpublic members
if (TEST_JAVA_MAJOR_VERSION VERSION_GREATER_EQUAL 17)
set(TEST_ADD_OPENS
--add-opens java.base/javax.crypto=ALL-UNNAMED
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
--add-opens java.base/java.security=ALL-UNNAMED
--add-exports jdk.crypto.ec/sun.security.ec=java.base
)
endif()

set(TEST_RUNNER_ARGUMENTS
-javaagent:${JACOCO_AGENT_JAR}=destfile=coverage/jacoco.exec,classdumpdir=coverage/classes
${TEST_ADD_OPENS}
-Djava.library.path=$<TARGET_FILE_DIR:amazonCorrettoCryptoProvider>
-Dcom.amazon.corretto.crypto.provider.inTestSuite=hunter2
-Dtest.data.dir=${TEST_DATA_DIR}
Expand Down
73 changes: 0 additions & 73 deletions arm.patch

This file was deleted.

18 changes: 7 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ repositories {

dependencies {
// Separate so we can extract the jar for the agent specifically
jacocoAgent group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.8.3', classifier: 'runtime'
jacocoAgent group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.8.7', classifier: 'runtime'

// Separate so we can extract the jar for the runner specifically
testRunner group: 'org.junit.platform', name: 'junit-platform-console-standalone', version: '1.6.2'

testDep 'org.junit.jupiter:junit-jupiter:5.6.2'
testDep 'org.junit.vintage:junit-vintage-engine:5.6.2'
testDep 'org.bouncycastle:bcprov-debug-jdk15on:1.65'
testDep 'org.bouncycastle:bcpkix-jdk15on:1.65'
testDep 'org.bouncycastle:bcprov-debug-jdk15on:1.69'
testDep 'org.bouncycastle:bcpkix-jdk15on:1.69'
testDep 'commons-codec:commons-codec:1.12'
testDep 'org.hamcrest:hamcrest:2.1'
testDep 'org.jacoco:org.jacoco.core:0.8.3'
Expand All @@ -83,13 +83,6 @@ task getOpensslSrc(type: Copy) {
def outputDir = file("${buildDir}/openssl/")
from tarTree(tarFile)
into outputDir

doLast {
// Remove this once the patch is incorporated into an official OpenSSL release
ant.patch(patchfile: "${projectDir}/arm.patch",
dir: opensslSrcPath,
strip: 1)
}
}

task buildOpenSsl {
Expand Down Expand Up @@ -160,6 +153,9 @@ task executeCmake(type: Exec) {
if (System.properties['TEST_JAVA_HOME'] != null) {
args '-DTEST_JAVA_HOME=' + System.properties['TEST_JAVA_HOME']
}
if (System.properties['TEST_JAVA_MAJOR_VERSION'] != null) {
args '-DTEST_JAVA_MAJOR_VERSION=' + System.properties['TEST_JAVA_MAJOR_VERSION']
}

if (System.properties['SINGLE_TEST'] != null) {
args '-DSINGLE_TEST=' + System.properties['SINGLE_TEST']
Expand Down Expand Up @@ -437,7 +433,7 @@ if (project.hasProperty('mavenUser') && project.hasProperty('jcecertAlias')) {
}
}

task sign(overwrite: true) {
task sign {
doFirst {
ant.fail('Insufficient configuration for signing')
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit a72c6de

Please sign in to comment.