1 /* |
1 /* |
2 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 6631352 |
26 * @bug 6631352 |
27 * @summary Check that appends are atomic |
27 * @summary Check that appends are atomic |
|
28 * @library /test/lib |
|
29 * @build jdk.test.lib.Platform |
|
30 * @run main AtomicAppend |
28 */ |
31 */ |
29 |
32 |
30 import java.io.File; |
33 import java.io.File; |
31 import java.io.FileOutputStream; |
34 import java.io.FileOutputStream; |
32 import java.util.concurrent.Executors; |
35 import java.util.concurrent.Executors; |
33 import java.util.concurrent.ExecutorService; |
36 import java.util.concurrent.ExecutorService; |
34 import java.util.concurrent.TimeUnit; |
37 import java.util.concurrent.TimeUnit; |
|
38 |
|
39 import jdk.test.lib.Platform; |
35 |
40 |
36 public class AtomicAppend { |
41 public class AtomicAppend { |
37 // Before the fix for |
42 // Before the fix for |
38 // 6631352: Implement atomic append mode using FILE_APPEND_DATA (win) |
43 // 6631352: Implement atomic append mode using FILE_APPEND_DATA (win) |
39 // this would fail intermittently on windows |
44 // this would fail intermittently on windows |
71 void check(boolean cond) {if (cond) pass(); else fail();} |
76 void check(boolean cond) {if (cond) pass(); else fail();} |
72 void equal(Object x, Object y) { |
77 void equal(Object x, Object y) { |
73 if (x == null ? y == null : x.equals(y)) pass(); |
78 if (x == null ? y == null : x.equals(y)) pass(); |
74 else fail(x + " not equal to " + y);} |
79 else fail(x + " not equal to " + y);} |
75 public static void main(String[] args) throws Throwable { |
80 public static void main(String[] args) throws Throwable { |
76 new AtomicAppend().instanceMain(args);} |
81 if (Platform.isOSX()) { |
|
82 final String version = "10.13"; |
|
83 int ineq = Platform.compareOsVersion(version); |
|
84 if (ineq >= 0) { |
|
85 System.out.format("Skipping test for macOS version %s >= %s%n", |
|
86 Platform.getOsVersion(), version); |
|
87 return; |
|
88 } |
|
89 } |
|
90 new AtomicAppend().instanceMain(args); |
|
91 } |
77 void instanceMain(String[] args) throws Throwable { |
92 void instanceMain(String[] args) throws Throwable { |
78 try {test(args);} catch (Throwable t) {unexpected(t);} |
93 try {test(args);} catch (Throwable t) {unexpected(t);} |
79 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
94 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
80 if (failed > 0) throw new AssertionError("Some tests failed");} |
95 if (failed > 0) throw new AssertionError("Some tests failed");} |
81 } |
96 } |