author | tschatzl |
Wed, 24 Jul 2019 11:49:39 +0200 | |
changeset 57508 | 28ab01c06755 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
21824
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
1 |
/* |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
4 |
* |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
8 |
* |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
13 |
* accompanied this code). |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
14 |
* |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
18 |
* |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
21 |
* questions. |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
22 |
*/ |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
23 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
24 |
/* @test |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
25 |
@bug 4035924 4095767 |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
26 |
@summary General exhaustive test of solaris pathname handling |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
27 |
@author Mark Reinhold |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
28 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
29 |
@build General GeneralSolaris |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
30 |
@run main GeneralSolaris |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
31 |
*/ |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
32 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
33 |
import java.io.*; |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
34 |
import java.util.*; |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
35 |
import java.nio.file.*; |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
36 |
import java.nio.file.attribute.*; |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
37 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
38 |
public class GeneralSolaris extends General { |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
39 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
40 |
private static void checkUnreadable() throws Exception { |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
41 |
Path file = Paths.get(baseDir, "unreadableFile"); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
42 |
Path dir = Paths.get(baseDir, "unreadableDir"); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
43 |
Set<PosixFilePermission> perms = PosixFilePermissions.fromString("---------"); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
44 |
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
45 |
Files.createFile(file, attr); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
46 |
Files.createDirectory(dir, attr); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
47 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
48 |
String unreadableFile = file.toString(); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
49 |
String unreadableDir = dir.toString(); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
50 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
51 |
checkSlashes(2, false, unreadableDir, unreadableDir); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
52 |
checkSlashes(2, false, unreadableFile, unreadableFile); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
53 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
54 |
Files.delete(file); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
55 |
Files.delete(dir); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
56 |
} |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
57 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
58 |
private static void checkPaths() throws Exception { |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
59 |
// Make sure that an empty relative path is tested |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
60 |
checkNames(1, true, userDir + File.separator, ""); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
61 |
checkNames(3, true, baseDir + File.separator, |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
62 |
relative + File.separator); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
63 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
64 |
checkSlashes(2, true, baseDir, baseDir); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
65 |
} |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
66 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
67 |
public static void main(String[] args) throws Exception { |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
68 |
if (File.separatorChar != '/') { |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
69 |
/* This test is only valid on Unix systems */ |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
70 |
return; |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
71 |
} |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
72 |
if (args.length > 0) debug = true; |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
73 |
|
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
74 |
initTestData(3); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
75 |
checkUnreadable(); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
76 |
checkPaths(); |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
77 |
} |
123a828f30dc
8028631: Improve the test coverage to the pathname handling on unix-like platforms
dxu
parents:
diff
changeset
|
78 |
} |