23 * questions.
24 */
25
26 package jdk.jfr.api.recording.destination;
27
28 import java.io.IOException;
29 import java.nio.file.Files;
30 import java.nio.file.Path;
31 import java.nio.file.Paths;
32 import java.util.List;
33
34 import jdk.jfr.Recording;
35 import jdk.jfr.consumer.RecordedEvent;
36 import jdk.jfr.consumer.RecordingFile;
37 import jdk.test.lib.Asserts;
38 import jdk.test.lib.jfr.CommonHelper;
39 import jdk.test.lib.jfr.EventNames;
40 import jdk.test.lib.jfr.FileHelper;
41 import jdk.test.lib.jfr.VoidFunction;
42
43 /*
44 * @test
45 * @summary Test setDestination to read-only dir
46 * @key jfr
47 * @library /test/lib
48 * @run main/othervm jdk.jfr.api.recording.destination.TestDestReadOnly
49 */
50 public class TestDestReadOnly {
51
52 public static void main(String[] args) throws Throwable {
53 Path readOnlyDir = FileHelper.createReadOnlyDir(Paths.get(".", "readonly"));
54 if (!FileHelper.isReadOnlyPath(readOnlyDir)) {
55 System.out.println("Failed to create read-only dir. Running as root?. Test ignored");
56 return;
57 }
58
59 Path readOnlyDest = Paths.get(readOnlyDir.toString(), "readonly.jfr");
60 Recording r = new Recording();
61 r.enable(EventNames.OSInformation);
62 r.setToDisk(true);
63 verifyException(()->{r.setDestination(readOnlyDest);}, "No exception for setDestination to read-only dir");
64
65 System.out.println("r.getDestination() = " + r.getDestination());
66
|
23 * questions.
24 */
25
26 package jdk.jfr.api.recording.destination;
27
28 import java.io.IOException;
29 import java.nio.file.Files;
30 import java.nio.file.Path;
31 import java.nio.file.Paths;
32 import java.util.List;
33
34 import jdk.jfr.Recording;
35 import jdk.jfr.consumer.RecordedEvent;
36 import jdk.jfr.consumer.RecordingFile;
37 import jdk.test.lib.Asserts;
38 import jdk.test.lib.jfr.CommonHelper;
39 import jdk.test.lib.jfr.EventNames;
40 import jdk.test.lib.jfr.FileHelper;
41 import jdk.test.lib.jfr.VoidFunction;
42
43 /**
44 * @test
45 * @summary Test setDestination to read-only dir
46 * @key jfr
47 * @requires vm.hasJFR
48 * @library /test/lib
49 * @run main/othervm jdk.jfr.api.recording.destination.TestDestReadOnly
50 */
51 public class TestDestReadOnly {
52
53 public static void main(String[] args) throws Throwable {
54 Path readOnlyDir = FileHelper.createReadOnlyDir(Paths.get(".", "readonly"));
55 if (!FileHelper.isReadOnlyPath(readOnlyDir)) {
56 System.out.println("Failed to create read-only dir. Running as root?. Test ignored");
57 return;
58 }
59
60 Path readOnlyDest = Paths.get(readOnlyDir.toString(), "readonly.jfr");
61 Recording r = new Recording();
62 r.enable(EventNames.OSInformation);
63 r.setToDisk(true);
64 verifyException(()->{r.setDestination(readOnlyDest);}, "No exception for setDestination to read-only dir");
65
66 System.out.println("r.getDestination() = " + r.getDestination());
67
|