diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e11e6f2..2fcabf4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: uses: oracle-actions/setup-java@v1 with: website: oracle.com - release: 17 + release: 21 - name: 'Build JTReg' shell: bash diff --git a/make/build.sh b/make/build.sh index 7291e0e6..42fb71b3 100644 --- a/make/build.sh +++ b/make/build.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -395,6 +395,7 @@ sanity_check_java_home() { error "JDK 11 or newer is required to build jtreg" exit 1 fi + JAVA_SPECIFICATION_VERSION=${vnum} } checkJavaOSVersion() { @@ -778,6 +779,7 @@ make ASMTOOLS_JAR="${ASMTOOLS_JAR}" \\ BUILD_VERSION="${JTREG_VERSION}" \\ BUILD_VERSION_STRING="${JTREG_VERSION_STRING}" \\ JAVATEST_JAR="$(mixed_path "${JTHARNESS_JAVATEST_JAR}")" \\ + JAVA_SPECIFICATION_VERSION="${JAVA_SPECIFICATION_VERSION}" \\ JDKHOME="$(mixed_path ${JAVA_HOME})" \\ JTHARNESS_NOTICES="${JTHARNESS_NOTICES}" \\ JTREG_HOME="" \\ diff --git a/test/SecurityManager/SecurityManagerTests.gmk b/test/SecurityManager/SecurityManagerTests.gmk index 4d73b5e1..dffdd4ff 100644 --- a/test/SecurityManager/SecurityManagerTests.gmk +++ b/test/SecurityManager/SecurityManagerTests.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ # #---------------------------------------------------------------------- +# only run the test on Java version lesser than 18 +INCLUDE_SEC_MGR_TEST := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 1; else echo 0; fi) $(BUILDTESTDIR)/GoodSecurityManagerTest.ok: \ $(JTREG_IMAGEDIR)/lib/jtreg.jar \ @@ -35,8 +37,10 @@ $(BUILDTESTDIR)/GoodSecurityManagerTest.ok: \ $(TESTDIR)/SecurityManager/pass echo "test passed at `date`" > $@ +ifeq ($(INCLUDE_SEC_MGR_TEST),1) TESTS.jtreg += \ $(BUILDTESTDIR)/GoodSecurityManagerTest.ok +endif #---------------------------------------------------------------------- @@ -53,8 +57,10 @@ $(BUILDTESTDIR)/BadSecurityManagerTest.ok: \ grep "Cannot reset security manager" $(@:%.ok=%)/work/error/BadSecurityManagerTest.jtr echo "test passed at `date`" > $@ +ifeq ($(INCLUDE_SEC_MGR_TEST),1) TESTS.jtreg += \ $(BUILDTESTDIR)/BadSecurityManagerTest.ok +endif #---------------------------------------------------------------------- @@ -72,8 +78,10 @@ $(BUILDTESTDIR)/SecurityManagerTest_agentvm_forbid.ok: \ grep "Test results: failed: 5" $(@:%.ok=%)/out.txt echo "test passed at `date`" > $@ +ifeq ($(INCLUDE_SEC_MGR_TEST),1) TESTS.jtreg += \ $(BUILDTESTDIR)/SecurityManagerTest_agentvm_forbid.ok +endif #---------------------------------------------------------------------- @@ -87,8 +95,10 @@ $(BUILDTESTDIR)/SecurityManagerTest_othervm.ok: \ $(TESTDIR)/SecurityManager echo "test passed at `date`" > $@ +ifeq ($(INCLUDE_SEC_MGR_TEST),1) TESTS.jtreg += \ $(BUILDTESTDIR)/SecurityManagerTest_othervm.ok +endif #---------------------------------------------------------------------- diff --git a/test/SecurityManager/pass/SimpleSecurityManagerTest.java b/test/SecurityManager/pass/SimpleSecurityManagerTest.java index 3a8c4284..c4de6524 100644 --- a/test/SecurityManager/pass/SimpleSecurityManagerTest.java +++ b/test/SecurityManager/pass/SimpleSecurityManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test + * @requires jdk.version.major < 18 */ /* diff --git a/test/badtests/BadTests.gmk b/test/badtests/BadTests.gmk index 487a20b8..87b50443 100644 --- a/test/badtests/BadTests.gmk +++ b/test/badtests/BadTests.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,11 @@ $(BUILDTESTDIR)/BadTests.othervm.ok: \ $(TESTDIR)/badtests \ > $(@:%.ok=%/jt.log) 2>&1 || \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -s 'Test results: passed: 18; failed: 2' $(@:%.ok=%/jt.log) > /dev/null + if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then \ + $(GREP) -s 'Test results: passed: 18; failed: 2' $(@:%.ok=%/jt.log) > /dev/null ; \ + else \ + $(GREP) -s 'Test results: passed: 15; failed: 2' $(@:%.ok=%/jt.log) > /dev/null ; \ + fi echo "test passed at `date`" > $@ # Run bad tests in agentvm mode @@ -67,9 +71,18 @@ $(BUILDTESTDIR)/BadTests.agentvm.ok: \ $(TESTDIR)/badtests \ > $(@:%.ok=%/jt.log) 2>&1 || \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -s 'Test results: passed: 17; failed: 1; error: 2' $(@:%.ok=%/jt.log) > /dev/null agents=`$(GREP) '^\[[-0-9 :,]*\] Agent\[[0-9][0-9]*\]: Launching' $(@:%.ok=%/jt.log) | wc -l` ; \ - if [ $${agents} -ne 4 ]; then echo "Unexpected number of agents used: $${agents}" ; exit 1 ; fi + if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then \ + $(GREP) -s 'Test results: passed: 17; failed: 1; error: 2' $(@:%.ok=%/jt.log) > /dev/null ; \ + if [ $${agents} -ne 4 ]; then \ + echo "Unexpected number of agents used: $${agents}" ; exit 1 ; \ + fi \ + else \ + $(GREP) -s 'Test results: passed: 15; failed: 2' $(@:%.ok=%/jt.log) > /dev/null ; \ + if [ $${agents} -ne 2 ]; then \ + echo "Unexpected number of agents used: $${agents}" ; exit 1 ; \ + fi \ + fi echo "test passed at `date`" > $@ ifneq ($(OS_NAME), windows) diff --git a/test/badtests/ExitTest.java b/test/badtests/ExitTest.java index 769342a6..0f258949 100644 --- a/test/badtests/ExitTest.java +++ b/test/badtests/ExitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,16 +23,19 @@ /* * @test + * @requires jdk.version.major < 18 * @run main ExitTest pass */ /* * @test + * @requires jdk.version.major < 18 * @run main ExitTest fail */ /* * @test + * @requires jdk.version.major < 18 * @run main ExitTest pass */ diff --git a/test/basic/Basic.gmk b/test/basic/Basic.gmk index 92dd8c45..6d3174df 100644 --- a/test/basic/Basic.gmk +++ b/test/basic/Basic.gmk @@ -47,7 +47,11 @@ $(BUILDTESTDIR)/Basic.check.ok: \ $(TESTDIR)/share/basic \ > $(@:%.ok=%/log) 2>&1|| \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -s 'Test results: passed: 157; error: 84' $(@:%.ok=%/log) > /dev/null + if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then \ + $(GREP) -s 'Test results: passed: 157; error: 84' $(@:%.ok=%/log) > /dev/null ; \ + else \ + $(GREP) -s 'Test results: passed: 142; error: 84' $(@:%.ok=%/log) > /dev/null ; \ + fi echo $@ passed at `date` > $@ INITIAL_TESTS += \ diff --git a/test/basic/Basic.java b/test/basic/Basic.java index aea421fc..710d24c7 100644 --- a/test/basic/Basic.java +++ b/test/basic/Basic.java @@ -45,6 +45,14 @@ public class Basic { + private static final boolean IS_JAVA18_PLUS; + + static { + String javaSpecVersion = System.getProperty("java.specification.version"); + // use of Double.valueOf() allows for JDK 8, whose value is 1.8 + IS_JAVA18_PLUS = Double.valueOf(javaSpecVersion).intValue() >= 18; + } + public static void main(String[] args) { try { Basic basic = new Basic(args); @@ -227,6 +235,16 @@ private void setExpectedTestStats() { numMain += 2; numShell += 1; + if (IS_JAVA18_PLUS) { + // on Java versions 18 and higher we don't run some SecurityManager related tests. + // we adjust the counts for those here. + + // 2 less "Passed" expected in main/Exit.java and 1 less expected in driver/Exit.java + numPassed -= 3; + // 10 less "Failed" expected in main/Exit.java and 2 less expected in driver/Exit.java + numFailed -= 12; + numError += 0; // no change in error count + } actionTable.put("applet", Integer.valueOf(numApplet)); actionTable.put("build", Integer.valueOf(numBuild)); actionTable.put("clean", Integer.valueOf(numClean)); diff --git a/test/basic/ReportOnlyTest.gmk b/test/basic/ReportOnlyTest.gmk index 78a99482..2787d517 100644 --- a/test/basic/ReportOnlyTest.gmk +++ b/test/basic/ReportOnlyTest.gmk @@ -50,11 +50,21 @@ $(BUILDTESTDIR)/ReportOnlyTest.ok: $(BUILDTESTDIR)/Basic.othervm.ok \ $(CAT) $(@:%.ok=%.jt.log) $(GREP) headless $(BUILDTESTDIR)/Basic.othervm/log if $(GREP) "headless: *true" $(BUILDTESTDIR)/Basic.othervm/log > /dev/null ; then \ - EXPECT_PASS=92 ; \ - EXPECT_FAIL=40 ; \ + if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then \ + EXPECT_PASS=92 ; \ + EXPECT_FAIL=40 ; \ + else \ + EXPECT_PASS=89 ; \ + EXPECT_FAIL=28 ; \ + fi ; \ else \ - EXPECT_PASS=94 ; \ - EXPECT_FAIL=44 ; \ + if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then \ + EXPECT_PASS=94 ; \ + EXPECT_FAIL=44 ; \ + else \ + EXPECT_PASS=91 ; \ + EXPECT_FAIL=32 ; \ + fi ; \ fi ; \ echo "Expect: Test results: passed: $${EXPECT_PASS}; failed: $${EXPECT_FAIL}; error: 88" ; \ $(GREP) -s "Test results: passed: $${EXPECT_PASS}; failed: $${EXPECT_FAIL}; error: 88" $(@:%.ok=%.jt.log) > /dev/null diff --git a/test/share/basic/driver/Exit.java b/test/share/basic/driver/Exit.java index 1050e070..f1d5ce56 100644 --- a/test/share/basic/driver/Exit.java +++ b/test/share/basic/driver/Exit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,21 @@ /** * @test * @summary Passed: Execution successful + * @requires jdk.version.major < 18 * @run driver Exit */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 0] + * @requires jdk.version.major < 18 * @run driver Exit 0 */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 1] + * @requires jdk.version.major < 18 * @run driver Exit 1 */ public class Exit diff --git a/test/share/basic/main/Exit.java b/test/share/basic/main/Exit.java index b0231df0..f3e6c204 100644 --- a/test/share/basic/main/Exit.java +++ b/test/share/basic/main/Exit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,72 +24,84 @@ /** * @test * @summary Passed: Execution successful + * @requires jdk.version.major < 18 * @run main Exit */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 0] + * @requires jdk.version.major < 18 * @run main Exit 0 */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 1] + * @requires jdk.version.major < 18 * @run main Exit 1 */ /** * @test * @summary Passed: Execution successful + * @requires jdk.version.major < 18 * @run main/othervm Exit */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 0] + * @requires jdk.version.major < 18 * @run main/othervm Exit 0 */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 1] + * @requires jdk.version.major < 18 * @run main/othervm Exit 1 */ /** * @test * @summary Failed: Execution passed unexpectedly + * @requires jdk.version.major < 18 * @run main/fail Exit */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 0] + * @requires jdk.version.major < 18 * @run main/fail Exit 0 */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 1] + * @requires jdk.version.major < 18 * @run main/fail Exit 1 */ /** * @test * @summary Failed: Execution passed unexpectedly + * @requires jdk.version.major < 18 * @run main/othervm/fail Exit */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 0] + * @requires jdk.version.major < 18 * @run main/othervm/fail Exit 0 */ /** * @test * @summary Failed: Unexpected exit from test [exit code: 1] + * @requires jdk.version.major < 18 * @run main/othervm/fail Exit 1 */ diff --git a/test/statsTests/StatsTests.gmk b/test/statsTests/StatsTests.gmk index b768ced6..d4113455 100644 --- a/test/statsTests/StatsTests.gmk +++ b/test/statsTests/StatsTests.gmk @@ -43,6 +43,8 @@ ifneq ($(OS_NAME), windows) TESTS.jtreg += $(BUILDTESTDIR)/StatsTest.ok endif +STATS1_EXPECT_RUN := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 45; else echo 33; fi) +STATS1_EXPECT_FAIL := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 32; else echo 22; fi) # system test for format support in TestStats.java: see -Djtreg.stats.format $(BUILDTESTDIR)/StatsTxt.1.ok: \ $(JTREG_IMAGEDIR)/lib/javatest.jar \ @@ -58,14 +60,16 @@ $(BUILDTESTDIR)/StatsTxt.1.ok: \ $(TESTDIR)/share/basic/main \ > $(@:%.ok=%/jt.log) 2>&1 || \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -E -s '^TEST-STATS: StatsTxt run=45 failed=32 excluded=0\s?$$' \ + $(GREP) -E -s '^TEST-STATS: StatsTxt run=$(STATS1_EXPECT_RUN) failed=$(STATS1_EXPECT_FAIL) excluded=0\s?$$' \ $(@:%.ok=%/jt.log) > /dev/null - $(GREP) -E -s '^TEST-STATS: StatsTxt run=45 failed=32 excluded=0\s?$$' \ + $(GREP) -E -s '^TEST-STATS: StatsTxt run=$(STATS1_EXPECT_RUN) failed=$(STATS1_EXPECT_FAIL) excluded=0\s?$$' \ $(@:%.ok=%/report/text/stats.txt) > /dev/null echo "test passed at `date`" > $@ TESTS.jtreg += $(BUILDTESTDIR)/StatsTxt.1.ok +STATS2_EXPECT_PASS := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 13; else echo 11; fi) +STATS2_EXPECT_FAIL := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 32; else echo 22; fi) # system test for format support in TestStats.java: see -Djtreg.stats.format $(BUILDTESTDIR)/StatsTxt.2.ok: \ $(JTREG_IMAGEDIR)/lib/javatest.jar \ @@ -83,14 +87,16 @@ $(BUILDTESTDIR)/StatsTxt.2.ok: \ $(TESTDIR)/share/basic/ignore \ > $(@:%.ok=%/jt.log) 2>&1 || \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -E -s '^TEST-STATS: StatsTxt passed=13 failed=32 ignored=2\s?$$' \ + $(GREP) -E -s '^TEST-STATS: StatsTxt passed=$(STATS2_EXPECT_PASS) failed=$(STATS2_EXPECT_FAIL) ignored=2\s?$$' \ $(@:%.ok=%/jt.log) > /dev/null - $(GREP) -E -s '^TEST-STATS: StatsTxt passed=13 failed=32 ignored=2\s?$$' \ + $(GREP) -E -s '^TEST-STATS: StatsTxt passed=$(STATS2_EXPECT_PASS) failed=$(STATS2_EXPECT_FAIL) ignored=2\s?$$' \ $(@:%.ok=%/report/text/stats.txt) > /dev/null echo "test passed at `date`" > $@ TESTS.jtreg += $(BUILDTESTDIR)/StatsTxt.2.ok +STATS3_EXPECT_PASS := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 12; else echo 10; fi) +STATS3_EXPECT_FAIL := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 32; else echo 22; fi) # system test for format support in TestStats.java: see -Djtreg.stats.format # (includes skipped) $(BUILDTESTDIR)/StatsTxt.3.ok: \ @@ -109,14 +115,17 @@ $(BUILDTESTDIR)/StatsTxt.3.ok: \ $(TESTDIR)/share/basic/ignore \ > $(@:%.ok=%/jt.log) 2>&1 || \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -E -s '^TEST-STATS: StatsTxt passed=12 failed=32 ignored=2 skipped=1\s?$$' \ + $(GREP) -E -s '^TEST-STATS: StatsTxt passed=$(STATS3_EXPECT_PASS) failed=$(STATS3_EXPECT_FAIL) ignored=2 skipped=1\s?$$' \ $(@:%.ok=%/jt.log) > /dev/null - $(GREP) -E -s '^TEST-STATS: StatsTxt passed=12 failed=32 ignored=2 skipped=1\s?$$' \ + $(GREP) -E -s '^TEST-STATS: StatsTxt passed=$(STATS3_EXPECT_PASS) failed=$(STATS3_EXPECT_FAIL) ignored=2 skipped=1\s?$$' \ $(@:%.ok=%/report/text/stats.txt) > /dev/null echo "test passed at `date`" > $@ TESTS.jtreg += $(BUILDTESTDIR)/StatsTxt.3.ok +STATS4_EXPECT_PASS := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 13; else echo 11; fi) +STATS4_EXPECT_FAIL := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 19; else echo 9; fi) +STATS4_EXPECT_ERROR := $(shell if [ ${JAVA_SPECIFICATION_VERSION} -lt 18 ]; then echo 13; else echo 13; fi) # system test for default format support in TestStats.java: no -Djtreg.stats.format # (includes skipped) $(BUILDTESTDIR)/StatsTxt.4.ok: \ @@ -134,9 +143,9 @@ $(BUILDTESTDIR)/StatsTxt.4.ok: \ $(TESTDIR)/share/basic/ignore \ > $(@:%.ok=%/jt.log) 2>&1 || \ true "non-zero exit code from JavaTest intentionally ignored" - $(GREP) -E -s '^Test results: passed: 13; failed: 19; error: 13; skipped: 1; did not match keywords: 2\s?$$' \ + $(GREP) -E -s '^Test results: passed: $(STATS4_EXPECT_PASS); failed: $(STATS4_EXPECT_FAIL); error: $(STATS4_EXPECT_ERROR); skipped: 1; did not match keywords: 2.*?$$' \ $(@:%.ok=%/jt.log) > /dev/null - $(GREP) -E -s '^Test results: passed: 13; failed: 19; error: 13; skipped: 1; did not match keywords: 2\s?$$' \ + $(GREP) -E -s '^Test results: passed: $(STATS4_EXPECT_PASS); failed: $(STATS4_EXPECT_FAIL); error: $(STATS4_EXPECT_ERROR); skipped: 1; did not match keywords: 2.*?$$' \ $(@:%.ok=%/report/text/stats.txt) > /dev/null echo "test passed at `date`" > $@