Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278527

java/util/concurrent/tck/JSR166TestCase.java fails nanoTime test

    XMLWordPrintable

Details

    Backports

      Description

        JavaTest Message: JUnit Failure: testNanoTime(SystemTest): null
        junit.framework.AssertionFailedError
        at junit.framework.Assert.fail(Assert.java:55)
        at junit.framework.Assert.assertTrue(Assert.java:22)
        at junit.framework.Assert.assertTrue(Assert.java:31)
        at junit.framework.TestCase.assertTrue(TestCase.java:200)
        at SystemTest.testNanoTime(SystemTest.java:73)


        public void testNanoTime() throws InterruptedException {
                long m0 = System.currentTimeMillis();
                long n0 = System.nanoTime();
                Thread.sleep(1);
                long m1 = System.currentTimeMillis();
                long n1 = System.nanoTime();
                Thread.sleep(50); // avoid possibly scaled SHORT_DELAY_MS
                long m2 = System.currentTimeMillis();
                long n2 = System.nanoTime();
                Thread.sleep(1);
                long m3 = System.currentTimeMillis();
                long n3 = System.nanoTime();
                assertTrue((n2 - n1) / 1_000_000 <= m3 - m0 + MILLIS_ROUND);
                assertTrue(m2 - m1 <= (n3 - n0) / 1_000_000 + MILLIS_ROUND);
            }

        It is the final assertion that is failing.

        Platform: macOS x64

        The test really should print all the values so they can be examined in case of failures like this.

        Attachments

          Issue Links

            Activity

              People

                psandoz Paul Sandoz
                jwilhelm Jesper Wilhelmsson
                Votes:
                0 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: