Skip to content

Commit

Permalink
Removal of SM from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Jan 2, 2025
1 parent 12fce60 commit c99e222
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 180 deletions.
179 changes: 10 additions & 169 deletions make/nashorn/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,134 +346,6 @@

</target>

<target name="generate-security-config" depends="generate-policy-file, generate-security-properties-file"/>

<target name="generate-security-properties-file" depends="prepare">
<echo file="${build.dir}/nashorn.security.properties">

package.access=sun.misc.,\
sun.reflect.,\
org.openjdk.nashorn.internal.test

</echo>
</target>

<target name="generate-policy-file" depends="prepare">
<property name="nashorn.jar.resolved" location="${nashorn.jar}"/>
<property name="jjs.jar.resolved" location="${jjs.jar}"/>
<echo file="${build.dir}/nashorn.policy">

grant codeBase "file:/${basedir}/${nashorn.jar}" {
permission java.security.AllPermission;
};

grant codeBase "file:/${basedir}/${jjs.jar}" {
permission java.security.AllPermission;
};

grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" {
permission java.security.AllPermission;
};

grant codeBase "file:/${basedir}/${nashorn.api.tests.jar}" {
permission java.util.PropertyPermission "parserapitest.*", "read";
permission java.util.PropertyPermission "test.*", "read";
permission java.util.PropertyPermission "test262.*", "read";
permission java.io.FilePermission "${basedir}/test/nashorn/-","read";
permission java.io.FilePermission "$${user.dir}", "read";
permission java.util.PropertyPermission "user.dir", "read";
};

grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
permission java.security.AllPermission;
};
grant codeBase "file:/${basedir}/${file.reference.jcommander.jar}" {
permission java.security.AllPermission;
};
grant codeBase "file:/${basedir}/${file.reference.bsh.jar}" {
permission java.security.AllPermission;
};
grant codeBase "file:/${basedir}/${file.reference.snakeyaml.jar}" {
permission java.security.AllPermission;
};
//// in case of absolute path:
grant codeBase "file:/${nashorn.internal.tests.jar}" {
permission java.security.AllPermission;
};

grant codeBase "file:/${file.reference.testng.jar}" {
permission java.security.AllPermission;
};
grant codeBase "file:/${file.reference.jcommander.jar}" {
permission java.security.AllPermission;
};
grant codeBase "file:/${file.reference.bsh.jar}" {
permission java.security.AllPermission;
};
grant codeBase "file:/${file.reference.snakeyaml.jar}" {
permission java.security.AllPermission;
};

grant codeBase "file:/${basedir}/${test.script.dir}/trusted/*" {
permission java.security.AllPermission;
};

grant codeBase "file:/${basedir}/${test.script.dir}/maptests/*" {
permission java.io.FilePermission "${basedir}/${test.script.dir}/maptests/*","read";
permission java.lang.RuntimePermission "nashorn.debugMode";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/*" {
permission java.io.FilePermission "${basedir}/${test.script.dir}/-", "read";
permission java.io.FilePermission "$${user.dir}", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "nashorn.test.*", "read";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/apply_to_call/*" {
permission java.io.FilePermission "${basedir}/${test.script.dir}/-", "read";
permission java.io.FilePermission "$${user.dir}", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "nashorn.test.*", "read";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/parser/*" {
permission java.io.FilePermission "${basedir}/${test.script.dir}/-", "read";
permission java.io.FilePermission "$${user.dir}", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "nashorn.test.*", "read";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/es6/*" {
permission java.io.FilePermission "${basedir}/${test.script.dir}/-", "read";
permission java.io.FilePermission "$${user.dir}", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "nashorn.test.*", "read";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8010946-privileged.js" {
permission java.util.PropertyPermission "java.security.policy", "read";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/classloader.js" {
permission java.lang.RuntimePermission "nashorn.JavaReflection";
};

grant codeBase "file:/${basedir}/${test.script.dir}/markdown.js" {
permission java.io.FilePermission "${basedir}/${test.script.dir}/external/showdown/-", "read";
};

grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {
permission java.lang.RuntimePermission "nashorn.setConfig";
};

</echo>

<replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators -->
<replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Unix - to avoid leading // in URLs -->

</target>

<target name="check-external-tests">
<available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/>
<available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/>
Expand Down Expand Up @@ -529,34 +401,11 @@ grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {
<propertyset>
<propertyref prefix="nashorn."/>
</propertyset>
<propertyset>
<propertyref prefix="test-sys-prop-no-security."/>
<mapper from="test-sys-prop-no-security.*" to="*" type="glob"/>
</propertyset>
<sysproperty key="optimistic.override" value="${optimistic}"/>
<classpath>
<pathelement path="${run.test.classpath}"/>
</classpath>
</testng>
</target>

<!-- only to be invoked as dependency of "test" target -->
<target name="-test-security">
<delete dir="${build.dir}/nashorn_code_cache"/>
<property name="debug.test.jvmargs" value=""/>
<testng outputdir="${build.test.results.dir}/${testResultsSubDir}" classfilesetref="test.classes"
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
<jvmarg line="${debug.test.jvmargs}"/>
<propertyset>
<propertyref prefix="nashorn."/>
</propertyset>
<propertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</propertyset>
<sysproperty key="optimistic.override" value="${optimistic}"/>
<sysproperty key="test.js.excludes.file" value="${exclude.list}"/>
<classpath>
<pathelement path="${run.test.classpath}"/>
</classpath>
Expand All @@ -565,28 +414,20 @@ grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {

<target name="test" depends="prepare, javadoc, test-pessimistic, test-optimistic"/>

<target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
<target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test" if="testng.available">
<echo message="Running test suite in OPTIMISTIC mode..."/>
<antcall target="-test-nosecurity" inheritRefs="true">
<param name="optimistic" value="true"/>
<param name="testResultsSubDir" value="optimistic"/>
</antcall>
<antcall target="-test-security" inheritRefs="true">
<param name="optimistic" value="true"/>
<param name="testResultsSubDir" value="optimistic"/>
</antcall>
</target>

<target name="test-pessimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
<target name="test-pessimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test" if="testng.available">
<echo message="Running test suite in PESSIMISTIC mode..."/>
<antcall target="-test-nosecurity" inheritRefs="true">
<param name="optimistic" value="false"/>
<param name="testResultsSubDir" value="pessimistic"/>
</antcall>
<antcall target="-test-security" inheritRefs="true">
<param name="optimistic" value="false"/>
<param name="testResultsSubDir" value="pessimistic"/>
</antcall>
</target>

<target name="check-jemmy.jfx.testng" unless="jemmy.jfx.testng.available">
Expand Down Expand Up @@ -620,14 +461,14 @@ grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {
</testng>
</target>

<target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
<target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available">
<fileset id="test.classes" dir="${build.test.classes.dir}">
<include name="**/framework/*Test.class"/>
</fileset>

<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
<propertyset>
<propertyref prefix="testmarkdown-test-sys-prop."/>
<mapper from="testmarkdown-test-sys-prop.*" to="*" type="glob"/>
Expand All @@ -638,14 +479,14 @@ grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {
</testng>
</target>

<target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
<target name="test262" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available">
<fileset id="test.classes" dir="${build.test.classes.dir}">
<include name="**/framework/*Test.class"/>
</fileset>

<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
<propertyset>
<propertyref prefix="nashorn."/>
</propertyset>
Expand All @@ -661,10 +502,10 @@ grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {

<target name="test262parallel" depends="test262-parallel"/>

<target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
<target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available">
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
<java classname="${parallel.test.runner}" dir="${basedir}" fork="true" failonerror="true">
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
<!-- avoid too many typeinfo cache files. Each script is run only once anyway -->
<jvmarg line="-Dnashorn.typeInfo.disabled=true"/>
<classpath>
Expand All @@ -679,12 +520,12 @@ grant codeBase "file:/${basedir}/${test.script.dir}/basic/JDK-8158467.js" {

<target name="testparallel" depends="test-parallel"/>

<target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
<target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available">
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
<java classname="${parallel.test.runner}" dir="${basedir}"
failonerror="true"
fork="true">
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
<classpath>
<pathelement path="${run.test.classpath}"/>
<pathelement path="${build.test.classes.dir}"/>
Expand Down
13 changes: 2 additions & 11 deletions make/nashorn/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ testjfx.dir=${test.script.dir}/jfx
testmarkdown.dir=${test.script.dir}/markdown

test-sys-prop.test.dir=${test.dir}
test-sys-prop.test.js.roots=${test.basic.dir} ${test.maptests.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir}
test-sys-prop.test.js.roots=${test.basic.dir} ${test.maptests.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir} ${test.nosecurity.dir}
test-sys-prop.test262.suite.dir=${test262.suite.dir}
test-sys-prop.es5conform.testcases.dir=${test.external.dir}/ES5Conform/TestCases
test-sys-prop.test.basic.dir=${test.basic.dir}
Expand All @@ -204,12 +204,8 @@ test-sys-prop.test.maptests.dir=${test.maptests.dir}
test-sys-prop.test.sandbox.dir=${test.sandbox.dir}
test-sys-prop.test.trusted.dir=${test.trusted.dir}

test-sys-prop-no-security.test.dir=${test.dir}
test-sys-prop-no-security.test.js.roots=${test.nosecurity.dir}

# framework root for our script tests
test-sys-prop.test.js.framework=${test.script.dir}/assert.js
test-sys-prop-no-security.test.js.framework=${test.script.dir}/assert.js

# Control the verbosity of ParserTest
test-sys-prop.parsertest.verbose=false
Expand Down Expand Up @@ -422,13 +418,8 @@ run.test.jvmargs.main=${run.test.jvmargs.common} -esa -ea
# Use best known performance options for octane
run.test.jvmargs.octane.main=${run.test.jvmargs.common} -XX:TypeProfileLevel=222

# Security manager args - make sure that we run with the nashorn.policy that the build creates
run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${build.dir}/nashorn.policy -Djava.security.properties=${build.dir}/nashorn.security.properties

# VM options for script tests with @fork option
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath}
# VM options for no-security script tests with @fork option - same as above but without jvmsecurityargs
test-sys-prop-no-security.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${run.test.classpath}
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${run.test.classpath}

# path of rhino.jar for benchmarks
rhino.dir=
Expand Down

0 comments on commit c99e222

Please sign in to comment.