blob: d3989c1a2ebc920265611cb2863a2949580b3cda [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#!/bin/sh
2
3#
4# Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
5# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6#
7# This code is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 2 only, as
9# published by the Free Software Foundation.
10#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22# CA 95054 USA or visit www.sun.com if you need additional information or
23# have any questions.
24#
25
26
27# @test
28# @bug 6364894
29# @run shell FileOpen.sh
30# @summary Test to ensure that opening of hidden Vs non-hidden,
31# read/write Vs read-only files for writing works as expected.
32
33
34# We use a TMP directory on a local disk because this test
35# requires that the file to be tested be present on the local disk,
36# not on a samba mounted drive or on a drive that is mapped.
37# The cmd 'attrib' works only on the local files.
38TMP="C:\TEMP"
39hfile=${TMP}"\random_file1.txt"
40ATTRIB=${SystemRoot}"\system32\attrib.exe"
41
42OS=`uname -s`
43case "$OS" in
44 Windows_* )
45 if [ ! -d ${TMP} ] ; then
46 echo "Could not find the directory-" ${TMP} "- passing test"
47 exit 0;
48 fi
49 ${TESTJAVA}/bin/javac -d . ${TESTSRC}\\FileOpenPos.java
50 ${TESTJAVA}/bin/javac -d . ${TESTSRC}\\FileOpenNeg.java
51
52 echo "Opening Writable Normal File.."
53 ${TESTJAVA}/bin/java FileOpenPos ${hfile}
54
55 echo "Opening Writable Hidden File.."
56 ${ATTRIB} +h ${hfile}
57 ${TESTJAVA}/bin/java FileOpenNeg ${hfile}
58
59 echo "Opening Read-Only Normal File.."
60 ${ATTRIB} -h ${hfile}
61 ${ATTRIB} +r ${hfile}
62 ${TESTJAVA}/bin/java FileOpenNeg ${hfile}
63
64 echo "Opening Read-Only Hidden File.."
65 ${ATTRIB} +h ${hfile}
66 ${TESTJAVA}/bin/java FileOpenNeg ${hfile}
67
68 rm -f ${hfile}
69 exit
70 ;;
71
72 * )
73 echo "This test is not intended for this OS - passing test"
74 exit 0
75 ;;
76esac