Backed out changeset 67496f44f461 (bug 1125138) for checktest failures
authorWes Kocher <wkocher@mozilla.com>
Mon, 26 Jan 2015 16:14:06 -0800
changeset 225906 7971981a6000a0b92f4d2237745f3a3d052b0a2c
parent 225905 139b3e52f9fe998d6165375096743e1fd339af41
child 225907 f9131ff0a89b6c8f1c1c6c20610db71ee531780a
push id28179
push usercbook@mozilla.com
push dateTue, 27 Jan 2015 14:24:11 +0000
treeherdermozilla-central@232401a6d1cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1125138
milestone38.0a1
backs out67496f44f4617eda8f650d5c801fd9b327e5ac96
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 67496f44f461 (bug 1125138) for checktest failures
xpcom/tests/TestTimeStamp.cpp
xpcom/tests/gtest/TestTimeStamp.cpp
xpcom/tests/gtest/moz.build
xpcom/tests/moz.build
rename from xpcom/tests/gtest/TestTimeStamp.cpp
rename to xpcom/tests/TestTimeStamp.cpp
--- a/xpcom/tests/gtest/TestTimeStamp.cpp
+++ b/xpcom/tests/TestTimeStamp.cpp
@@ -1,69 +1,96 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/TimeStamp.h"
 
+#include "TestHarness.h"
+
 #include "prinrval.h"
 #include "prthread.h"
 
-#include "gtest/gtest.h"
-
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 
-TEST(TimeStamp, Main)
+static void Assert(bool aCond, const char* aMsg)
 {
+    if (aCond) {
+        passed(aMsg);
+    } else {
+        fail("%s", aMsg);
+    }
+}
+
+int main(int argc, char** argv)
+{
+    ScopedXPCOM xpcom("nsTimeStamp");
+    if (xpcom.failed())
+        return 1;
+
     TimeDuration td;
-    EXPECT_TRUE(td.ToSeconds() == 0.0);
-    EXPECT_TRUE(TimeDuration::FromSeconds(5).ToSeconds() == 5.0);
-    EXPECT_TRUE(TimeDuration::FromMilliseconds(5000).ToSeconds() == 5.0);
-    EXPECT_TRUE(TimeDuration::FromSeconds(1) < TimeDuration::FromSeconds(2));
-    EXPECT_FALSE(TimeDuration::FromSeconds(1) < TimeDuration::FromSeconds(1));
-    EXPECT_TRUE(TimeDuration::FromSeconds(2) > TimeDuration::FromSeconds(1));
-    EXPECT_FALSE(TimeDuration::FromSeconds(1) > TimeDuration::FromSeconds(1));
-    EXPECT_TRUE(TimeDuration::FromSeconds(1) <= TimeDuration::FromSeconds(2));
-    EXPECT_TRUE(TimeDuration::FromSeconds(1) <= TimeDuration::FromSeconds(1));
-    EXPECT_FALSE(TimeDuration::FromSeconds(2) <= TimeDuration::FromSeconds(1));
-    EXPECT_TRUE(TimeDuration::FromSeconds(2) >= TimeDuration::FromSeconds(1));
-    EXPECT_TRUE(TimeDuration::FromSeconds(1) >= TimeDuration::FromSeconds(1));
-    EXPECT_FALSE(TimeDuration::FromSeconds(1) >= TimeDuration::FromSeconds(2));
+    Assert(td.ToSeconds() == 0.0, "TimeDuration default value 0");
+    Assert(TimeDuration::FromSeconds(5).ToSeconds() == 5.0,
+           "TimeDuration FromSeconds/ToSeconds round-trip");
+    Assert(TimeDuration::FromMilliseconds(5000).ToSeconds() == 5.0,
+           "TimeDuration FromMilliseconds/ToSeconds round-trip");
+    Assert(TimeDuration::FromSeconds(1) < TimeDuration::FromSeconds(2),
+           "TimeDuration < operator works");
+    Assert(!(TimeDuration::FromSeconds(1) < TimeDuration::FromSeconds(1)),
+           "TimeDuration < operator works");
+    Assert(TimeDuration::FromSeconds(2) > TimeDuration::FromSeconds(1),
+           "TimeDuration > operator works");
+    Assert(!(TimeDuration::FromSeconds(1) > TimeDuration::FromSeconds(1)),
+           "TimeDuration > operator works");
+    Assert(TimeDuration::FromSeconds(1) <= TimeDuration::FromSeconds(2),
+           "TimeDuration <= operator works");
+    Assert(TimeDuration::FromSeconds(1) <= TimeDuration::FromSeconds(1),
+           "TimeDuration <= operator works");
+    Assert(!(TimeDuration::FromSeconds(2) <= TimeDuration::FromSeconds(1)),
+           "TimeDuration <= operator works");
+    Assert(TimeDuration::FromSeconds(2) >= TimeDuration::FromSeconds(1),
+           "TimeDuration >= operator works");
+    Assert(TimeDuration::FromSeconds(1) >= TimeDuration::FromSeconds(1),
+           "TimeDuration >= operator works");
+    Assert(!(TimeDuration::FromSeconds(1) >= TimeDuration::FromSeconds(2)),
+           "TimeDuration >= operator works");
 
     TimeStamp ts;
-    EXPECT_TRUE(ts.IsNull());
-
+    Assert(ts.IsNull(), "Default TimeStamp value null");
+    
     ts = TimeStamp::Now();
-    EXPECT_TRUE(!ts.IsNull());
-    EXPECT_TRUE((ts - ts).ToSeconds() == 0.0);
+    Assert(!ts.IsNull(), "TimeStamp time value non-null");
+    Assert((ts - ts).ToSeconds() == 0.0, "TimeStamp zero-length duration");
 
     PR_Sleep(PR_SecondsToInterval(2));
 
     TimeStamp ts2(TimeStamp::Now());
-    EXPECT_TRUE(ts2 > ts);
-    EXPECT_FALSE(ts > ts);
-    EXPECT_TRUE(ts < ts2);
-    EXPECT_FALSE(ts < ts);
-    EXPECT_TRUE(ts <= ts2);
-    EXPECT_TRUE(ts <= ts);
-    EXPECT_FALSE(ts2 <= ts);
-    EXPECT_TRUE(ts2 >= ts);
-    EXPECT_TRUE(ts2 >= ts);
-    EXPECT_FALSE(ts >= ts2);
+    Assert(ts2 > ts, "TimeStamp > comparison");
+    Assert(!(ts > ts), "TimeStamp > comparison");
+    Assert(ts < ts2, "TimeStamp < comparison");
+    Assert(!(ts < ts), "TimeStamp < comparison");
+    Assert(ts <= ts2, "TimeStamp <= comparison");
+    Assert(ts <= ts, "TimeStamp <= comparison");
+    Assert(!(ts2 <= ts), "TimeStamp <= comparison");
+    Assert(ts2 >= ts, "TimeStamp >= comparison");
+    Assert(ts2 >= ts, "TimeStamp >= comparison");
+    Assert(!(ts >= ts2), "TimeStamp >= comparison");
 
     // We can't be sure exactly how long PR_Sleep slept for. It should have
     // slept for at least one second. We might have slept a lot longer due
     // to process scheduling, but hopefully not more than 10 seconds.
     td = ts2 - ts;
-    EXPECT_TRUE(td.ToSeconds() > 1.0);
-    EXPECT_TRUE(td.ToSeconds() < 20.0);
+    Assert(td.ToSeconds() > 1.0, "TimeStamp difference lower bound");
+    Assert(td.ToSeconds() < 20.0, "TimeStamp difference upper bound");
     td = ts - ts2;
-    EXPECT_TRUE(td.ToSeconds() < -1.0);
-    EXPECT_TRUE(td.ToSeconds() > -20.0);
+    Assert(td.ToSeconds() < -1.0, "TimeStamp negative difference lower bound");
+    Assert(td.ToSeconds() > -20.0, "TimeStamp negative difference upper bound");
 
     double resolution = TimeDuration::Resolution().ToSecondsSigDigits();
     printf(" (platform timer resolution is ~%g s)\n", resolution);
-    EXPECT_TRUE(0.000000001 < resolution);
+    Assert(0.000000001 < resolution, "Time resolution is sane");
     // Don't upper-bound sanity check ... although NSPR reports 1ms
     // resolution, it might be lying, so we shouldn't compare with it
+
+    return gFailCount > 0;
 }
--- a/xpcom/tests/gtest/moz.build
+++ b/xpcom/tests/gtest/moz.build
@@ -9,14 +9,13 @@ UNIFIED_SOURCES += [
     'TestEncoding.cpp',
     'TestExpirationTracker.cpp',
     'TestPipes.cpp',
     'TestPriorityQueue.cpp',
     'TestSnappyStreams.cpp',
     'TestStorageStream.cpp',
     'TestStrings.cpp',
     'TestSynchronization.cpp',
-    'TestTimeStamp.cpp',
 ]
 
 FINAL_LIBRARY = 'xul-gtest'
 
 FAIL_ON_WARNINGS = True
--- a/xpcom/tests/moz.build
+++ b/xpcom/tests/moz.build
@@ -77,16 +77,17 @@ if CONFIG['MOZ_MEMORY']:
     GeckoCppUnitTests([
         'TestJemalloc',
     ])
 
 # XXX Make these tests work in libxul builds.
 #CPP_UNIT_TESTS += [
 #    'TestThreadPool',
 #    'TestThreads',
+#    'TestTimeStamp',
 #    'TestXPIDLString',
 #    'TestUTF',
 #    'TestAtoms',
 #]
 
 # FIXME: bug 577500 TestStaticAtoms fails when run in dist/bin
 #CPP_UNIT_TESTS += [
 #    'TestStaticAtoms',