Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java
41152 views
1
/*
2
* Copyright (c) 2021, 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
import java.util.HashMap;
25
import java.util.List;
26
import java.util.Map;
27
28
import jdk.test.lib.apps.LingeredApp;
29
import jdk.test.lib.Utils;
30
import jtreg.SkippedException;
31
32
/**
33
* @test
34
* @bug 8190198
35
* @bug 8217612
36
* @bug 8217845
37
* @summary Test clhsdb command line history support
38
* @requires vm.hasSA
39
* @library /test/lib
40
* @run main/othervm ClhsdbHistory
41
*/
42
43
public class ClhsdbHistory {
44
45
public static void testHistory() throws Exception {
46
System.out.println("Starting ClhsdbHistory basic test");
47
48
LingeredApp theApp = null;
49
try {
50
ClhsdbLauncher test = new ClhsdbLauncher();
51
theApp = LingeredApp.startApp();
52
System.out.println("Started LingeredApp with pid " + theApp.getPid());
53
54
List<String> cmds = List.of(
55
"echo true",
56
"assert false",
57
"!!", // !! repeats previous command
58
"versioncheck !$", // !$ is last argument from previous command
59
"assert foo bar baz",
60
"versioncheck !*", // !* is all arguments from previous command
61
"versioncheck !$ !$", // !$ !$ should result in "baz baz"
62
"assert maybe never",
63
"!!- !*", // !!- is the previous command, minus the last arg
64
"!echo", // match previous echo command, with args
65
"assert \\!foo", // quote the ! so it is not used for command history expansion
66
"!10", // match the 10th command in the history, with args
67
"history");
68
69
// Unfortunately we can't create a map table that maps the clhsdb commands above
70
// to the expected output because the commands as you see them above won't be in
71
// the output. Instead their expanded forms will. So instead we just rely on
72
// the history output looking as expected.
73
Map<String, List<String>> expStrMap = new HashMap<>();
74
expStrMap.put("history", List.of(
75
"0 echo true", // issued by ClhsdbLauncher
76
"1 verbose true", // issued by ClhsdbLauncher
77
"2 echo true",
78
"3 assert false",
79
"4 assert false",
80
"5 versioncheck false",
81
"6 assert foo bar baz",
82
"7 versioncheck foo bar baz",
83
"8 versioncheck baz baz",
84
"9 assert maybe never",
85
"10 assert maybe maybe never",
86
"11 echo true",
87
"12 assert !foo",
88
"13 assert maybe maybe never",
89
"14 history"));
90
91
test.run(theApp.getPid(), cmds, expStrMap, null);
92
} catch (SkippedException se) {
93
throw se;
94
} catch (Exception ex) {
95
throw new RuntimeException("Test ERROR " + ex, ex);
96
} finally {
97
LingeredApp.stopApp(theApp);
98
}
99
System.out.println("Test PASSED");
100
}
101
102
public static void main(String[] args) throws Exception {
103
testHistory();
104
}
105
}
106
107