[114796] users/landonf/openjdk7/dports/java/openjdk7
landonf at macports.org
landonf at macports.org
Sun Dec 15 09:24:39 PST 2013
Revision: 114796
https://trac.macports.org/changeset/114796
Author: landonf at macports.org
Date: 2013-12-15 09:24:39 -0800 (Sun, 15 Dec 2013)
Log Message:
-----------
Add a test harness and tests to validate the OpenJDK build.
Currently, we validate that the follow local patches were applied correctly:
- Rhino support.
- Correct JCE policy file bundled (either limited or unlimited).
Modified Paths:
--------------
users/landonf/openjdk7/dports/java/openjdk7/Portfile
Added Paths:
-----------
users/landonf/openjdk7/dports/java/openjdk7/files/tests/
users/landonf/openjdk7/dports/java/openjdk7/files/tests/RhinoTest.java
users/landonf/openjdk7/dports/java/openjdk7/files/tests/UnlimitedJCETest.java
Modified: users/landonf/openjdk7/dports/java/openjdk7/Portfile
===================================================================
--- users/landonf/openjdk7/dports/java/openjdk7/Portfile 2013-12-15 17:17:43 UTC (rev 114795)
+++ users/landonf/openjdk7/dports/java/openjdk7/Portfile 2013-12-15 17:24:39 UTC (rev 114796)
@@ -16,7 +16,7 @@
set jdk_build_date 26_aug_2013
version ${jdk_major_version}.${jport_minor_version}.${jport_build_number}
-revision 4
+revision 5
categories java
maintainers landonf openmaintainer
@@ -85,6 +85,11 @@
port:ghc \
port:ruby
+set cryptoflag "UNLIMITED_CRYPTO=true"
+variant limited_strength_jce description {Use the limited stength JCE policy files. By default, the unlimited strength policy files will be included.} {
+ build.args-delete ${cryptoflag}
+}
+
# Find a usable bootstrap VM
if {[file exists ${prefix}/share/java/openjdk7/bin/java]} {
# A previous OpenJDK7 release is already installed
@@ -162,6 +167,7 @@
EXTRA_CFLAGS="-Wno-deprecated-declarations -I\"${filespath}/clang-compat-headers\"" \
LANG="C" \
"${bootflags}" \
+ "${cryptoflag}" \
ALT_BOOTDIR="${bootstrapvm}" \
ALT_COMPILER_PATH="${prefix}" \
ANT_HOME="${workpath}/apache-ant-${ant_version}" \
@@ -186,6 +192,29 @@
BUNDLE_VENDOR="MacPorts" \
HOTSPOT_BUILD_JOBS="${build.jobs}"
+test {
+ set testpath "${workpath}/tests"
+ set build "${worksrcpath}/build/macosx-${openjdk_build_arch}"
+
+ # Buld the tests
+ file mkdir ${testpath}
+ exec ${build}/bin/javac -d ${testpath} {*}[glob ${filespath}/tests/*.java]
+
+ # Create the variant list we'll pass to our test cases
+ set variants {}
+ foreach v $PortInfo(variants) {
+ if {[variant_isset $v]} {
+ lappend variants $v
+ }
+ }
+
+ # Execute
+ foreach class_file [glob -tails -directory ${testpath} *Test.class] {
+ set class [file rootname $class_file]
+ exec ${build}/bin/java -cp ${testpath} ${class} {*}$variants
+ }
+}
+
# We violate mtree in two ways:
# - We install in $prefix/<name><major>. This has long been a standard path for installed JVMs
# and models the approach taken by the FreeBSD Java ports.
Added: users/landonf/openjdk7/dports/java/openjdk7/files/tests/RhinoTest.java
===================================================================
--- users/landonf/openjdk7/dports/java/openjdk7/files/tests/RhinoTest.java (rev 0)
+++ users/landonf/openjdk7/dports/java/openjdk7/files/tests/RhinoTest.java 2013-12-15 17:24:39 UTC (rev 114796)
@@ -0,0 +1,28 @@
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import java.util.Set;
+
+public class RhinoTest extends Base {
+ public static void main (String[] args) {
+ new RhinoTest().dispatch(args);
+ }
+
+ protected void run (Set<Variant> variants) {
+ ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
+ if (engine == null)
+ throw fail("Missing JavaScript engine");
+
+ Object result;
+ try {
+ result = engine.eval("1+1");
+ } catch (ScriptException e) {
+ throw fail("Failed to evaluate JS: " + e);
+ }
+
+ if (!result.equals(new Double(2.0)))
+ throw fail("Unexpected result: " + result);
+
+ pass("Computed result: " + result);
+ }
+}
Added: users/landonf/openjdk7/dports/java/openjdk7/files/tests/UnlimitedJCETest.java
===================================================================
--- users/landonf/openjdk7/dports/java/openjdk7/files/tests/UnlimitedJCETest.java (rev 0)
+++ users/landonf/openjdk7/dports/java/openjdk7/files/tests/UnlimitedJCETest.java 2013-12-15 17:24:39 UTC (rev 114796)
@@ -0,0 +1,30 @@
+import javax.crypto.Cipher;
+import java.security.NoSuchAlgorithmException;
+import java.util.Set;
+
+public class UnlimitedJCETest extends Base {
+ public static void main (String[] args) {
+ new UnlimitedJCETest().dispatch(args);
+ }
+
+ protected void run (Set<Variant> variants) {
+ int allowedKeyLength = 0;
+
+ try {
+ allowedKeyLength = Cipher.getMaxAllowedKeyLength("AES");
+ } catch (NoSuchAlgorithmException e) {
+ System.out.println("AES cipher not found");
+ System.exit(1);
+ }
+
+ if (variants.contains(Variant.limited_strength_jce)) {
+ if (allowedKeyLength > 128)
+ throw fail("The allowed key length for AES is too high: " + allowedKeyLength);
+ } else {
+ if (allowedKeyLength <= 128)
+ throw fail("The allowed key length for AES is too low: " + allowedKeyLength);
+ }
+
+ pass("The allowed key length for AES is " + allowedKeyLength);
+ }
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20131215/4a2b8132/attachment.html>
More information about the macports-changes
mailing list