1
1
/*
2
- * Copyright (c) 2016, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2016, 2020 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
40
40
41
41
/**
42
42
* @test
43
+ * @bug 8253050
43
44
* @summary Test jfr split
44
45
* @key jfr
45
46
* @requires vm.hasJFR
@@ -55,13 +56,16 @@ public static void main(String[] args) throws Throwable {
55
56
Path recordingFileA = Paths .get ("many-chunks-A-" + dateText + ".jfr" );
56
57
Path recordingFileB = Paths .get ("many-chunks-B-" + dateText + ".jfr" );
57
58
Path recordingFileC = Paths .get ("many-chunks-C-" + dateText + ".jfr" );
59
+ Path recordingFileD = Paths .get ("many-chunks-D-" + dateText + ".jfr" );
58
60
makeRecordingWithChunks (6 , recordingFileA );
59
61
Files .copy (recordingFileA , recordingFileB );
60
62
Files .copy (recordingFileA , recordingFileC );
63
+ Files .copy (recordingFileA , recordingFileD );
61
64
62
65
String fileAText = recordingFileA .toAbsolutePath ().toString ();
63
66
String fileBText = recordingFileB .toAbsolutePath ().toString ();
64
67
String fileCText = recordingFileC .toAbsolutePath ().toString ();
68
+ String fileDText = recordingFileD .toAbsolutePath ().toString ();
65
69
66
70
OutputAnalyzer output = ExecuteHelper .jfr ("disassemble" );
67
71
output .shouldContain ("missing file" );
@@ -97,6 +101,15 @@ public static void main(String[] args) throws Throwable {
97
101
// sanity check
98
102
output = ExecuteHelper .jfr ("disassemble" , "--max-size" , "10000" , fileCText );
99
103
verifyRecording (fileCText .substring (0 , fileCText .length () - 4 ) + "_01.jfr" );
104
+
105
+ // test JDK-8253050
106
+ output = ExecuteHelper .jfr ("disassemble" , "--max-chunks" , "1" , fileDText );
107
+ String chunks = output .firstMatch ("File consists of (\\ d+) chunks" , 1 );
108
+ output .shouldContain ("The recording will be split into " + chunks + " files" );
109
+ String chunkFilePrefix = fileDText .substring (0 , fileDText .length () - 4 ) + "_" ;
110
+ for (long i = 0 ; i < Long .parseLong (chunks ); i ++) {
111
+ verifyRecording (chunkFilePrefix + String .format ("%0" + chunks .length () + "d" , i ) + ".jfr" );
112
+ }
100
113
}
101
114
102
115
private static void verifyRecording (String name ) throws IOException {
0 commit comments