Hello Andrew,

It appeared the test required a minor adjustment for windows/cygwin. It was done and passed on all platform I've used including windows/cygwin.

I've attached the patch.6802962 and two actual test's files.

Thanks for turning attention to the particular detail. Please let me know if some point might missed.

Valerii


On 01/10/12 03:12 PM, [email protected] wrote:
Hi Andrew,

I see your concern about shell launcher usage for this case.
I'll re-check how it works under cygwin and will send results how it went.

> could you please provide some explanations for suggested changes?

Below is my understanding. I am really sorry if some points are well known, I just had to include them for a consistency reason.

The fix version is following a workaround that was implemented already for jdk5 as a simplest way to resolve a known issue. Otherwise it appears as a showstopper for a whole testing session invocation in particular for "jdk_awt" target under jtreg (it is not in the ProblemList.txt file at present).

The jtreg invokes the own main method and the codebase (not the codebase of the test class file) when the test case is executed under jtreg.jar (that includes the underlying javatest.jar libraries invocation also).

As a result, the system class loader is initialized at a very early point in the startup sequence; it copies the classpath into its own data structures, and the classpath property is not read again.

A wrapper file is a solution that is used for jtreg based invocations for the tests with a "sensitive" functionality (the security manager in this case). It separates a "system/harness" level invocation from an actual test functions and implement a sort of "emulation" of a manual *class file invocation.

A convenience of such approach is - we have a shell wrapper template that serves such "separation" in a transparent way and it's a part of "The JDK Test Framework: Tag Language Specification". It also supports all jtreg/javatest tags in a unified way. We formally can use the java file wrapper script (instead of the shell ) for the tests like this one and avoid a potential necessity to adjust it for the cygwin particularity. A wrapper script is the only solution that is currently seen.

But wouldn't be it better if the "java file wrippers usage" be unified (on the level of The JDK Test Framework specification) in the same way as currently the shell script wrapper is. Otherwise the shell scripts wrappers are still used (when they are required) for most for the others test cases in WS anyway.

Please suggest if you see a necessity to replace the shell script by the java wrapper for the particular test case. Also if I have missed some points. I'll take care about this. As I mentioned earlier, I'll re-check how the current version works on windows under cygwin and let you know if any adjustments is required.

Thanks for looking in this,
Valerii


On 01/10/12 01:35 PM, Andrew Brygin wrote:
Hello Valerii,

 could you please provide some explanations for suggested changes?

 The main concern regarding suggested shell launcher is that a list of
 supported OS names is too limited. In particular, it does not include
 Cygwin* which likely makes this test failed on windows under cygwin
 environment (which is default for openjdk). Could you please make sure
 that modified test can be executed under cygwin?

Thanks,
Andrew

On 10.01.2012 15:36, [email protected] wrote:
Hi All,

I've attached a patch for 2d-dev category test fix.
The fix is related to openjdk8 (also to openjdk7).

test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java

The failure is a showstopper, it causes a hang of test execution when launched using "make jdk_awt".

The reason of failure is known and has been fixed already in jdk6.

It has a corresponding CR 6802962 in the Bugster.

I am requesting a sponsor to review and to integrate the fix.

Regards,
Valerii



diff -r dda27c73d8db test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java
--- a/test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java       Fri Jan 
13 10:05:45 2012 -0800
+++ b/test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java       Mon Jan 
16 12:43:22 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2012, 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
@@ -25,6 +25,16 @@
  * @test
  * @bug 6652929
  * @summary verify handling of File.getPath()
+ * @compile FontFile.java
+ * @run shell TestFontFile.sh
+ */
+
+/*
+ * When using jtreg this test needs to be run by shell script,
+ * since otherwise jtreg reflectively invokes the main method
+ * and the codebase for the purposes of the security manager
+ * is that of the jtreg harness, not the codebase (class file location)
+ * of this program, thus access to read to that location is not available.
  */
 
 import java.awt.*;
@@ -34,10 +44,21 @@
     public static void main(String[] args) throws Exception {
         String sep = System.getProperty("file.separator");
         String fname = ".." + sep + "A.ttf";
-        String dir = System.getProperty("test.src");
+        //String dir = System.getProperty("test.src");
+        String dir = System.getenv("TESTSRC");
         if (dir != null) {
             fname = dir + sep + fname;
         }
+        //String classesDir = System.getProperty("test.classes");
+        String classesDir = System.getenv("TESTCLASSES");
+        System.out.println("classesDir="+classesDir);
+        String testfile = "somefile";
+        if (classesDir != null) {
+            testfile = classesDir + sep + testfile;
+        }
+        final String somefile = testfile;
+        System.out.println("somefile="+somefile);
+        System.out.println("userdir="+System.getProperty("user.dir"));
         final String name = fname;
         System.out.println("Will try to access " + name);
         if (!(new File(name)).canRead()) {
@@ -66,7 +87,7 @@
                             return name;
                         } else {
                             read = true;
-                            return "somefile";
+                            return somefile;
                         }
                     }
                     @Override public boolean canRead() {
diff -r dda27c73d8db 
test/java/awt/FontClass/CreateFont/fileaccess/TestFontFile.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FontClass/CreateFont/fileaccess/TestFontFile.sh     Mon Jan 
16 12:43:22 2012 +0000
@@ -0,0 +1,84 @@
+#
+# Copyright (c) 2012, 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#!/bin/sh
+
+if [ "${TESTSRC}" = "" ]
+then TESTSRC=.
+fi
+
+if [ "${TESTJAVA}" = "" ]
+then
+  PARENT=`dirname \`which java\``
+  TESTJAVA=`dirname ${PARENT}`
+  echo "TESTJAVA not set, selecting " ${TESTJAVA}
+  echo "If this is incorrect, try setting the variable manually."
+fi
+
+if [ "${TESTCLASSES}" = "" ]
+then
+  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+
+BIT_FLAG=""
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  SunOS | Linux )
+    NULL=/dev/null
+    PS=":"
+    FS="/"
+    ## for solaris, linux it's HOME
+    FILE_LOCATION=$HOME
+    if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
+    then
+        BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT`
+    fi
+    ;;
+  Windows_* | CYGWIN* )
+    NULL=NUL
+    PS=";"
+    FS="\\"
+    ;;
+  * )
+    echo "Unrecognized system!"
+    exit 1;
+    ;;
+esac
+
+JEMMYPATH=${CPAPPEND}
+CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH
+
+THIS_DIR=`pwd`
+
+${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version
+
+${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} FontFile > test.out 2>&1
+
+STATUS=$?
+
+cat test.out
+
+exit $STATUS
/*
 * Copyright (c) 2008, 2012, 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
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

/*
 * @test
 * @bug 6652929
 * @summary verify handling of File.getPath()
 * @compile FontFile.java
 * @run shell TestFontFile.sh
 */

/*
 * When using jtreg this test needs to be run by shell script,
 * since otherwise jtreg reflectively invokes the main method
 * and the codebase for the purposes of the security manager
 * is that of the jtreg harness, not the codebase (class file location)
 * of this program, thus access to read to that location is not available.
 */

import java.awt.*;
import java.io.*;

public class FontFile {
    public static void main(String[] args) throws Exception {
        String sep = System.getProperty("file.separator");
        String fname = ".." + sep + "A.ttf";
        //String dir = System.getProperty("test.src");
        String dir = System.getenv("TESTSRC");
        if (dir != null) {
            fname = dir + sep + fname;
        }
        //String classesDir = System.getProperty("test.classes");
        String classesDir = System.getenv("TESTCLASSES");
        System.out.println("classesDir="+classesDir);
        String testfile = "somefile";
        if (classesDir != null) {
            testfile = classesDir + sep + testfile;
        }
        final String somefile = testfile;
        System.out.println("somefile="+somefile);
        System.out.println("userdir="+System.getProperty("user.dir"));
        final String name = fname;
        System.out.println("Will try to access " + name);
        if (!(new File(name)).canRead()) {
           System.out.println("File not available : can't run test");
           return;
        }
        System.out.println("File is available. Verify no access under SM");

        System.setSecurityManager(new SecurityManager());


        // Check cannot read file.
        try {
            new FileInputStream(name);
            throw new Error("Something wrong with test environment");
        } catch (SecurityException exc) {
            // Good.
        }

        try {
            Font font = Font.createFont(Font.TRUETYPE_FONT,
            new File("nosuchfile") {
                    private boolean read;
                    @Override public String getPath() {
                        if (read) {
                            return name;
                        } else {
                            read = true;
                            return somefile;
                        }
                    }
                    @Override public boolean canRead() {
                        return true;
                    }
               }
            );
          System.err.println(font.getFontName());
          throw new RuntimeException("No expected exception");
        }  catch (IOException e) {
          System.err.println("Test passed.");
        }
    }
}
#
# Copyright (c) 2012, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

#!/bin/sh

if [ "${TESTSRC}" = "" ]
then TESTSRC=.
fi

if [ "${TESTJAVA}" = "" ]
then
  PARENT=`dirname \`which java\``
  TESTJAVA=`dirname ${PARENT}`
  echo "TESTJAVA not set, selecting " ${TESTJAVA}
  echo "If this is incorrect, try setting the variable manually."
fi

if [ "${TESTCLASSES}" = "" ]
then
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  exit 1
fi

BIT_FLAG=""

# set platform-dependent variables
OS=`uname -s`
case "$OS" in
  SunOS | Linux )
    NULL=/dev/null
    PS=":"
    FS="/"
    ## for solaris, linux it's HOME
    FILE_LOCATION=$HOME
    if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
    then
        BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT`
    fi
    ;;
  Windows_* | CYGWIN* )
    NULL=NUL
    PS=";"
    FS="\\"
    ;;
  * )
    echo "Unrecognized system!"
    exit 1;
    ;;
esac

JEMMYPATH=${CPAPPEND}
CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH

THIS_DIR=`pwd`

${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version

${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} FontFile > test.out 2>&1

STATUS=$?

cat test.out

exit $STATUS

Reply via email to