Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/gctests/fileTest/fileTest.java
41155 views
1
/*
2
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @key stress
27
*
28
* @summary converted from VM Testbase gc/gctests/fileTest.
29
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent]
30
*
31
* @library /vmTestbase
32
* /test/lib
33
* @run main/othervm gc.gctests.fileTest.fileTest -Filename fileTest.java -iterations 500
34
*/
35
36
package gc.gctests.fileTest;
37
38
import java.io.*;
39
import java.util.*;
40
import jdk.test.lib.Utils;
41
import nsk.share.test.*;
42
import nsk.share.gc.*;
43
import nsk.share.TestBug;
44
import nsk.share.TestFailure;
45
46
public class fileTest extends GCTestBase {
47
private File [] fileArray;
48
private FileInputStream [] fileInputArray;
49
private final static int fileNumber = 10000;
50
// The number of open file descriptors per process varies from one
51
// system to another. lets expermiment with just 20 open fd's.
52
private final static int inputStreamNumber = 20;
53
private String fileName;
54
55
public fileTest(String fileName) {
56
this.fileName = fileName;
57
fileArray = new File[fileNumber];
58
fileInputArray = new FileInputStream[inputStreamNumber];
59
}
60
61
public void runIteration() throws IOException {
62
for (int i = 0; i < fileNumber; ++i)
63
fileArray[i] = new File(Utils.TEST_SRC, fileName);
64
for (int i = 0; i < inputStreamNumber; ++i)
65
fileInputArray[i] = new FileInputStream(Utils.TEST_SRC + File.separator + fileName);
66
for (int i = 0; i < inputStreamNumber; ++i)
67
fileInputArray[i].close();
68
}
69
70
public void run() {
71
try {
72
Stresser stresser = new Stresser(runParams.getStressOptions());
73
stresser.start(runParams.getIterations());
74
try {
75
while (stresser.iteration())
76
runIteration();
77
} finally {
78
stresser.finish();
79
}
80
} catch (IOException e) {
81
throw new TestFailure(e);
82
}
83
}
84
85
public static void main(String args[]) {
86
String fileName = null;
87
for (int i = 0 ; i < args.length ; i++) {
88
if( args[i].equals("-Filename"))
89
fileName = args[++i];
90
}
91
if (fileName == null)
92
throw new TestBug("No -Filename option is specified");
93
GC.runTest(new fileTest(fileName), args);
94
}
95
}
96
97