Bug 1254373: Make TestDemon build on Windows; r?billm draft
authorAaron Klotz <aklotz@mozilla.com>
Thu, 10 Mar 2016 17:32:16 -0700
changeset 339328 c1aa80db925721c9ca9f4a3978f11a4a26ce628e
parent 339110 dd1abe874252e507b825a0a4e1063b0e13578288
child 515966 8853f93946c2d4b12bb475547fb08963ff8befc9
push id12700
push useraklotz@mozilla.com
push dateFri, 11 Mar 2016 00:33:21 +0000
reviewersbillm
bugs1254373
milestone48.0a1
Bug 1254373: Make TestDemon build on Windows; r?billm MozReview-Commit-ID: GtgAVfDYhtk
ipc/ipdl/test/cxx/TestDemon.cpp
--- a/ipc/ipdl/test/cxx/TestDemon.cpp
+++ b/ipc/ipdl/test/cxx/TestDemon.cpp
@@ -1,20 +1,21 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=4 ts=4 et :
  */
 #include "TestDemon.h"
 
 #include <stdlib.h>
-#include <sys/time.h>
 
 #include "IPDLUnitTests.h"      // fail etc.
 #if defined(OS_POSIX)
+#include <sys/time.h>
 #include <unistd.h>
 #else
+#include <time.h>
 #include <windows.h>
 #endif
 
 template<>
 struct RunnableMethodTraits<mozilla::_ipdltest::TestDemonParent>
 {
     static void RetainCallee(mozilla::_ipdltest::TestDemonParent* obj) { }
     static void ReleaseCallee(mozilla::_ipdltest::TestDemonParent* obj) { }
@@ -29,25 +30,29 @@ struct RunnableMethodTraits<mozilla::_ip
 
 namespace mozilla {
 namespace _ipdltest {
 
 const int kMaxStackHeight = 4;
 
 static LazyLogModule sLogModule("demon");
 
-#define DEMON_LOG(args...) MOZ_LOG(sLogModule, LogLevel::Debug, (args))
+#define DEMON_LOG(...) MOZ_LOG(sLogModule, LogLevel::Debug, (__VA_ARGS__))
 
 static int gStackHeight = 0;
 static bool gFlushStack = false;
 
 static int
 Choose(int count)
 {
+#if defined(OS_POSIX)
   return random() % count;
+#else
+  return rand() % count;
+#endif
 }
 
 //-----------------------------------------------------------------------------
 // parent
 
 TestDemonParent::TestDemonParent()
  : mDone(false),
    mIncoming(),
@@ -63,17 +68,21 @@ TestDemonParent::~TestDemonParent()
 
 void
 TestDemonParent::Main()
 {
   if (!getenv("MOZ_TEST_IPC_DEMON")) {
     QuitParent();
     return;
   }
+#if defined(OS_POSIX)
   srandom(time(nullptr));
+#else
+  srand(time(nullptr));
+#endif
 
   DEMON_LOG("Start demon");
 
   if (!SendStart())
 	fail("sending Start");
 
   RunUnlimitedSequence();
 }
@@ -264,17 +273,21 @@ TestDemonChild::TestDemonChild()
 TestDemonChild::~TestDemonChild()
 {
   MOZ_COUNT_DTOR(TestDemonChild);
 }
 
 bool
 TestDemonChild::RecvStart()
 {
+#ifdef OS_POSIX
   srandom(time(nullptr));
+#else
+  srand(time(nullptr));
+#endif
 
   DEMON_LOG("RecvStart");
 
   RunUnlimitedSequence();
   return true;
 }
 
 #ifdef DEBUG