Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/nio/file/Files/walkFileTree/find.sh
38886 views
#1# Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 4313887 690773725# @summary Tests that walkFileTree is consistent with the native find program26# @build CreateFileTree PrintFileTree27# @run shell find.sh2829# if TESTJAVA isn't set then we assume an interactive run.3031if [ -z "$TESTJAVA" ]; then32TESTSRC=.33TESTCLASSES=.34JAVA=java35else36JAVA="${TESTJAVA}/bin/java"37fi3839OS=`uname -s`40case "$OS" in41Windows_* | CYGWIN* )42echo "This test does not run on Windows"43exit 044;;45AIX )46CLASSPATH=${TESTCLASSES}:${TESTSRC}47# On AIX "find -follow" may core dump on recursive links without '-L'48# see: http://www-01.ibm.com/support/docview.wss?uid=isg1IV2814349FIND_FOLLOW_OPT="-L"50;;51* )52FIND_FOLLOW_OPT=53CLASSPATH=${TESTCLASSES}:${TESTSRC}54;;55esac56export CLASSPATH5758# create the file tree59ROOT=`$JAVA CreateFileTree`60if [ $? != 0 ]; then exit 1; fi6162failures=06364# print the file tree and compare output with find(1)65$JAVA ${TESTVMOPTS} PrintFileTree "$ROOT" > out166find "$ROOT" > out267diff out1 out268if [ $? != 0 ]; then failures=`expr $failures + 1`; fi6970# repeat test following links. Some versions of find(1) output71# cycles (sym links to ancestor directories), other versions do72# not. For that reason we run PrintFileTree with the -printCycles73# option when the output without this option differs to find(1).74find $FIND_FOLLOW_OPT "$ROOT" -follow > out175$JAVA ${TESTVMOPTS} PrintFileTree -follow "$ROOT" > out276diff out1 out277if [ $? != 0 ];78then79# re-run printing cycles to stdout80$JAVA ${TESTVMOPTS} PrintFileTree -follow -printCycles "$ROOT" > out281diff out1 out282if [ $? != 0 ]; then failures=`expr $failures + 1`; fi83fi8485# clean-up86rm -r "$ROOT"8788echo ''89if [ $failures -gt 0 ];90then echo "$failures test(s) failed";91else echo "Test passed"; fi92exit $failures939495