25
26 package jdk.jfr.event.io;
27
28 import java.io.File;
29 import java.io.IOException;
30 import java.io.RandomAccessFile;
31 import java.time.Duration;
32 import java.time.Instant;
33 import java.util.ArrayList;
34 import java.util.Comparator;
35 import java.util.List;
36
37 import jdk.jfr.Recording;
38 import jdk.jfr.consumer.RecordedEvent;
39 import jdk.test.lib.Asserts;
40 import jdk.test.lib.jfr.Events;
41 import jdk.test.lib.thread.TestThread;
42 import jdk.test.lib.thread.XRun;
43
44
45 /*
46 * @test
47 * @summary Verify the event time stamp and thread name
48 * @key jfr
49 * @library /test/lib /test/jdk
50 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.io.TestRandomAccessFileThread
51 */
52
53 // TODO: This test should work without -XX:-UseFastUnorderedTimeStamps
54
55 // The test uses 2 threads to read and write to a file.
56 // The number of bytes in each read/write operation is increased by 1.
57 // By looking at the number of bytes in each event, we know in what order
58 // the events should arrive. This is used to verify the event time stamps.
59 public class TestRandomAccessFileThread {
60 private static final int OP_COUNT = 100; // Total number of read/write operations.
61 private static volatile int writeCount = 0; // Number of writes executed.
62
63 public static void main(String[] args) throws Throwable {
64 File tmp = File.createTempFile("TestRandomAccessFileThread", ".tmp", new File("."));
65 tmp.deleteOnExit();
66
67 Recording recording = new Recording();
68 recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0));
|
25
26 package jdk.jfr.event.io;
27
28 import java.io.File;
29 import java.io.IOException;
30 import java.io.RandomAccessFile;
31 import java.time.Duration;
32 import java.time.Instant;
33 import java.util.ArrayList;
34 import java.util.Comparator;
35 import java.util.List;
36
37 import jdk.jfr.Recording;
38 import jdk.jfr.consumer.RecordedEvent;
39 import jdk.test.lib.Asserts;
40 import jdk.test.lib.jfr.Events;
41 import jdk.test.lib.thread.TestThread;
42 import jdk.test.lib.thread.XRun;
43
44
45 /**
46 * @test
47 * @summary Verify the event time stamp and thread name
48 * @key jfr
49 * @requires vm.hasJFR
50 * @library /test/lib /test/jdk
51 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.io.TestRandomAccessFileThread
52 */
53
54 // TODO: This test should work without -XX:-UseFastUnorderedTimeStamps
55
56 // The test uses 2 threads to read and write to a file.
57 // The number of bytes in each read/write operation is increased by 1.
58 // By looking at the number of bytes in each event, we know in what order
59 // the events should arrive. This is used to verify the event time stamps.
60 public class TestRandomAccessFileThread {
61 private static final int OP_COUNT = 100; // Total number of read/write operations.
62 private static volatile int writeCount = 0; // Number of writes executed.
63
64 public static void main(String[] args) throws Throwable {
65 File tmp = File.createTempFile("TestRandomAccessFileThread", ".tmp", new File("."));
66 tmp.deleteOnExit();
67
68 Recording recording = new Recording();
69 recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0));
|