Bug 545865: A better way to build NSPR tests for Windows Mobile. Also
authorWan-Teh Chang <wtc@google.com>
Tue, 16 Feb 2010 10:50:04 -0800
changeset 38150 340e7ad3b8efeea1ba3f3738469d5315faadec95
parent 38149 68aa31088a1d2224b4c84b37cf8a5dc86671b939
child 38151 cdccb18bf20531bb838bcf565ceb55eeacb59c57
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs545865, 545031
milestone1.9.3a2pre
Bug 545865: A better way to build NSPR tests for Windows Mobile. Also include the fix for bug 545031.
nsprpub/config/prdepend.h
nsprpub/pr/include/md/_beos.h
nsprpub/pr/include/md/_os2.h
nsprpub/pr/include/md/_unixos.h
nsprpub/pr/include/md/_win95.h
nsprpub/pr/include/md/_winnt.h
nsprpub/pr/include/prinit.h
nsprpub/pr/include/private/primpl.h
nsprpub/pr/src/md/unix/unix.c
nsprpub/pr/src/misc/prinit.c
nsprpub/pr/src/pthreads/ptthread.c
nsprpub/pr/tests/Makefile.in
nsprpub/pr/tests/foreign.c
nsprpub/pr/tests/nst_wince.h
nsprpub/pr/tests/socket.c
nsprpub/pr/tests/thrpool_server.c
nsprpub/pr/tests/tmocon.c
nsprpub/pr/tests/wince_tester.cpp
nsprpub/pr/tests/y2ktmo.c
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -37,9 +37,8 @@
 
 /*
  * A dummy header file that is a dependency for all the object files.
  * Used to force a full recompilation of NSPR in Mozilla's Tinderbox
  * depend builds.  See comments in rules.mk.
  */
 
 #error "Do not include this header file."
-
--- a/nsprpub/pr/include/md/_beos.h
+++ b/nsprpub/pr/include/md/_beos.h
@@ -224,16 +224,17 @@ struct protoent* getprotobynumber(int nu
 #define _MD_CLEANUP_BEFORE_EXIT _MD_cleanup_before_exit
 #define _MD_EXIT _MD_exit
 
 #define _MD_GET_ENV getenv
 #define _MD_PUT_ENV putenv
 
 #define _MD_EARLY_INIT _MD_early_init
 #define _MD_FINAL_INIT _MD_final_init
+#define _MD_EARLY_CLEANUP()
 
 /* CPU Stuff */
 
 #define _MD_INIT_CPUS _MD_init_cpus
 #define _MD_WAKEUP_CPUS _MD_wakeup_cpus
 #define _MD_START_INTERRUPTS _MD_start_interrupts
 #define _MD_STOP_INTERRUPTS _MD_stop_interrupts
 #define _MD_DISABLE_CLOCK_INTERRUPTS _MD_disable_clock_interrupts
--- a/nsprpub/pr/include/md/_os2.h
+++ b/nsprpub/pr/include/md/_os2.h
@@ -364,16 +364,17 @@ extern PRInt32 _MD_Accept(PRFileDesc *fd
 #define _MD_START_INTERRUPTS()
 #define _MD_STOP_INTERRUPTS()
 #define _MD_DISABLE_CLOCK_INTERRUPTS()
 #define _MD_ENABLE_CLOCK_INTERRUPTS()
 #define _MD_BLOCK_CLOCK_INTERRUPTS()
 #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
 #define _MD_EARLY_INIT                (_PR_MD_EARLY_INIT)
 #define _MD_FINAL_INIT()
+#define _MD_EARLY_CLEANUP()
 #define _MD_INIT_CPUS()
 #define _MD_INIT_RUNNING_CPU(cpu)
 
 struct PRProcess;
 struct PRProcessAttr;
 
 #define _MD_CREATE_PROCESS _PR_CreateOS2Process
 extern struct PRProcess * _PR_CreateOS2Process(
--- a/nsprpub/pr/include/md/_unixos.h
+++ b/nsprpub/pr/include/md/_unixos.h
@@ -230,16 +230,19 @@ extern void _MD_unix_init_running_cpu(st
 #define PR_SET_INTSOFF(newval)
 
 #endif
 
 /************************************************************************/
 
 extern void _PR_UnixInit(void);
 
+extern void _PR_UnixCleanup(void);
+#define _MD_EARLY_CLEANUP _PR_UnixCleanup
+
 /************************************************************************/
 
 struct _MDProcess {
     pid_t pid;
 };
 
 struct PRProcess;
 struct PRProcessAttr;
--- a/nsprpub/pr/include/md/_win95.h
+++ b/nsprpub/pr/include/md/_win95.h
@@ -439,16 +439,17 @@ extern PROsfd _MD_Accept(PRFileDesc *fd,
 #define _MD_START_INTERRUPTS()
 #define _MD_STOP_INTERRUPTS()
 #define _MD_DISABLE_CLOCK_INTERRUPTS()
 #define _MD_ENABLE_CLOCK_INTERRUPTS()
 #define _MD_BLOCK_CLOCK_INTERRUPTS()
 #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
 #define _MD_EARLY_INIT                _PR_MD_EARLY_INIT
 #define _MD_FINAL_INIT()
+#define _MD_EARLY_CLEANUP()
 #define _MD_INIT_CPUS()
 #define _MD_INIT_RUNNING_CPU(cpu)
 
 struct PRProcess;
 struct PRProcessAttr;
 
 #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
 extern struct PRProcess * _PR_CreateWindowsProcess(
--- a/nsprpub/pr/include/md/_winnt.h
+++ b/nsprpub/pr/include/md/_winnt.h
@@ -461,16 +461,17 @@ extern  struct _MDLock              _pr_
 #define _MD_START_INTERRUPTS()
 #define _MD_STOP_INTERRUPTS()
 #define _MD_DISABLE_CLOCK_INTERRUPTS()
 #define _MD_ENABLE_CLOCK_INTERRUPTS()
 #define _MD_BLOCK_CLOCK_INTERRUPTS()
 #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
 #define _MD_EARLY_INIT                _PR_MD_EARLY_INIT
 #define _MD_FINAL_INIT()
+#define _MD_EARLY_CLEANUP()
 #define _MD_INIT_CPUS()
 #define _MD_INIT_RUNNING_CPU(cpu)
 
 struct PRProcess;
 struct PRProcessAttr;
 
 /* --- Create a new process --- */
 #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -58,17 +58,17 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.8.4 Beta"
+#define PR_VERSION  "4.8.4 Beta 2"
 #define PR_VMAJOR   4
 #define PR_VMINOR   8
 #define PR_VPATCH   4
 #define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
--- a/nsprpub/pr/include/private/primpl.h
+++ b/nsprpub/pr/include/private/primpl.h
@@ -1882,16 +1882,19 @@ extern void _PR_MD_EARLY_INIT(void);
 #define    _PR_MD_EARLY_INIT _MD_EARLY_INIT
 
 extern void _PR_MD_INTERVAL_INIT(void);
 #define    _PR_MD_INTERVAL_INIT _MD_INTERVAL_INIT
 
 NSPR_API(void) _PR_MD_FINAL_INIT(void);
 #define    _PR_MD_FINAL_INIT _MD_FINAL_INIT
 
+extern void _PR_MD_EARLY_CLEANUP(void);
+#define    _PR_MD_EARLY_CLEANUP _MD_EARLY_CLEANUP
+
 /* Process control */
 
 extern PRProcess * _PR_MD_CREATE_PROCESS(
     const char *path,
     char *const *argv,
     char *const *envp,
     const PRProcessAttr *attr);
 #define    _PR_MD_CREATE_PROCESS _MD_CREATE_PROCESS
--- a/nsprpub/pr/src/md/unix/unix.c
+++ b/nsprpub/pr/src/md/unix/unix.c
@@ -2888,16 +2888,28 @@ void _PR_UnixInit(void)
     _pr_rename_lock = PR_NewLock();
     PR_ASSERT(NULL != _pr_rename_lock);
     _pr_Xfe_mon = PR_NewMonitor();
     PR_ASSERT(NULL != _pr_Xfe_mon);
 
     _PR_InitIOV();  /* one last hack */
 }
 
+void _PR_UnixCleanup(void)
+{
+    if (_pr_rename_lock) {
+        PR_DestroyLock(_pr_rename_lock);
+        _pr_rename_lock = NULL;
+    }
+    if (_pr_Xfe_mon) {
+        PR_DestroyMonitor(_pr_Xfe_mon);
+        _pr_Xfe_mon = NULL;
+    }
+}
+
 #if !defined(_PR_PTHREADS)
 
 /*
  * Variables used by the GC code, initialized in _MD_InitSegs().
  */
 static PRInt32 _pr_zero_fd = -1;
 static PRLock *_pr_md_lock = NULL;
 
--- a/nsprpub/pr/src/misc/prinit.c
+++ b/nsprpub/pr/src/misc/prinit.c
@@ -404,16 +404,18 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
 #ifdef IRIX
 		_PR_MD_PRE_CLEANUP(me);
 		/*
 		 * The primordial thread must now be running on the primordial cpu
 		 */
     	PR_ASSERT((_PR_IS_NATIVE_THREAD(me)) || (me->cpu->id == 0));
 #endif
 
+        _PR_MD_EARLY_CLEANUP();
+
         _PR_CleanupMW();
         _PR_CleanupTime();
         _PR_CleanupDtoa();
         _PR_CleanupCallOnce();
 		_PR_ShutdownLinker();
         _PR_CleanupNet();
         _PR_CleanupIO();
         /* Release the primordial thread's private data, etc. */
--- a/nsprpub/pr/src/pthreads/ptthread.c
+++ b/nsprpub/pr/src/pthreads/ptthread.c
@@ -1041,16 +1041,18 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup(void)
         while (pt_book.user > pt_book.this_many)
             PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);
         if (me->state & PT_THREAD_SYSTEM)
             pt_book.system -= 1;
         else
             pt_book.user -= 1;
         PR_Unlock(pt_book.ml);
 
+        _PR_MD_EARLY_CLEANUP();
+
         _PR_CleanupMW();
         _PR_CleanupTime();
         _PR_CleanupDtoa();
         _PR_CleanupCallOnce();
         _PR_ShutdownLinker();
         _PR_LogCleanup();
         _PR_CleanupNet();
         /* Close all the fd's before calling _PR_CleanupIO */
--- a/nsprpub/pr/tests/Makefile.in
+++ b/nsprpub/pr/tests/Makefile.in
@@ -202,19 +202,18 @@ CSRCS =             \
 	writev.c        \
 	xnotify.c       \
 	y2k.c           \
 	y2ktmo.c        \
 	zerolen.c       \
 	$(NULL)
 
 ifeq ($(OS_ARCH),WINCE)
-TESTPROGS =          \
-    wince_tester.cpp  \
-    $(NULL)
+CFLAGS += -FImozce_shunt.h -Zi -UDEBUG -DNDEBUG
+LDOPTS += -link $(DIST)/lib/mozce_shunt.lib ws2.lib -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO -PDB:$(@:.exe=.pdb)
 endif
 
 ifeq ($(OS_TARGET),OS2)
 CSRCS +=            \
 	sleep.c			\
 	stat.c		    \
 	yield.c         \
 	$(NULL)
@@ -223,21 +222,17 @@ endif
 ifeq (,$(filter-out WINCE WINNT OS2,$(OS_ARCH)))
 PROG_SUFFIX = .exe
 DLL_SUFFIX = .dll
 else
 PROG_SUFFIX =
 DLL_SUFFIX = 
 endif
 
-ifeq ($(OS_ARCH),WINCE)
-PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(DLL_SUFFIX))) $(addprefix $(OBJDIR)/, $(TESTPROGS:.cpp=$(PROG_SUFFIX)))
-else
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
-endif
 
 TARGETS = $(PROGS)
 
 INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 ifeq ($(OS_ARCH), WINNT)
 ifdef NS_USE_GCC
   EXTRA_LIBS += -lwsock32
@@ -245,34 +240,16 @@ else
   EXTRA_LIBS += wsock32.lib
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifdef PROFILE
     LDOPTS += -PROFILE -MAP
   endif # profile
 endif # NS_USE_GCC
 endif
 
-ifeq ($(OS_ARCH),WINCE)
-ifdef NS_USE_GCC
-  EXTRA_LIBS += -lws2 -lcoredll
-else
-  INCLUDES += -FInst_wince.h
-  EXTRA_LIBS += ws2.lib coredll.lib
-  LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO -PDB:$(@:.dll=.pdb)
-  EXE_EXTRA_LDOPTS = -SUBSYSTEM:CONSOLE
-  ifdef PROFILE
-    LDOPTS += -PROFILE -MAP
-  endif # profile
-endif # NS_USE_GCC
-
-# Use CC to compile all CPP files / also use all CC flags
-CCC = $(CC)
-CXXFLAGS = $(CFLAGS)
-endif
-
 ifeq ($(OS_ARCH),OS2)
 EXTRA_LIBS = $(OS_LIBS)
 LDOPTS = -Zomf -Zlinker /PM:VIO -Zlinker /ST:0x64000
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 # Use an absolute pathname as the runtime library path (for the -R
 # or -rpath linker option or the LD_RUN_PATH environment variable).
@@ -518,46 +495,20 @@ ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
 	link $(LDOPTS) $(EXTRA_LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -out:$@
 ifdef MT
 	@if test -f $@.manifest; then \
 		$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		rm -f $@.manifest; \
 	fi
 endif
 else
-ifeq ($(OS_ARCH),WINCE)
-	$(PURE) $(LD) $(XCFLAGS) $< $(LDOPTS:.exe=.pdb) $(EXE_EXTRA_LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -OUT:$@
-else
 	$(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -o $@
-endif # wince
 endif # WINNT
 endif # AIX_PRE_4_2
 
-
-ifeq ($(OS_ARCH),WINCE)
-$(OBJS): $(OBJDIR)/%.$(OBJ_SUFFIX): nst_wince.h
-
-# WinCE HAS to be different.  Turns out that the OS swallows crashes
-#   and returns a result code of zero -- an indication of success for
-#   the shell script.  AND, WinCE does not really have a good shell 
-#   to use for testing, anyway.
-#
-# To combat both issues, we need to build the tests as stand-alone
-# DLLs, then dynamically load the DLLs one at a time inside a test
-# program.  Each DLL's test will be run inside a TRY/CATCH construct,
-# allowing the testing program to do what the shell script already
-# does naturally. 
-#
-# This section builds DLLs instead of EXEs for each of the tests.
-# - wolfe@lobo.us
-$(OBJDIR)/%$(DLL_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
-	@$(MAKE_OBJDIR)
-	$(PURE) $(LD) $(XCFLAGS) $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -DLL -OUT:$@ $< 
-endif # wince
-
 export:: $(TARGETS)
 clean::
 	rm -f $(TARGETS)
 
 # The following tests call BSD socket functions, so they need to link
 # with -lsocket on some platforms.
 ifeq ($(OS_ARCH),SunOS)
 ifneq ($(OS_RELEASE),4.1.3_U1)
--- a/nsprpub/pr/tests/foreign.c
+++ b/nsprpub/pr/tests/foreign.c
@@ -106,16 +106,19 @@ static void sproc_start(void *arg, PRSiz
     StartFn start = so->start;
     void *data = so->arg;
     PR_Free(so);
     start(data);
 }  /* sproc_start */
 #endif  /* defined(IRIX) && !defined(_PR_PTHREADS) */
 
 #if defined(WIN32)
+#if defined(WINCE)
+#include <windows.h>
+#endif
 #include <process.h>  /* for _beginthreadex() */
 
 static PRUintn __stdcall windows_start(void *arg)
 {
     StartObject *so = (StartObject*)arg;
     StartFn start = so->start;
     void *data = so->arg;
     PR_Free(so);
deleted file mode 100644
--- a/nsprpub/pr/tests/nst_wince.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Netscape Portable Runtime (NSPR) Tests.
- *
- * The Initial Developer of the Original Code is John Wolfe
- * Portions created by the Initial Developer are Copyright (C) 2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nst_wince_h___
-#define nst_wince_h___
-
-#ifndef __WINDOWS__
-#include <windows.h>
-#endif
-
-/***********
- * NOTE: This file is loaded once in each test - and defines two
- * functions for each test's eventual executable: DllMain() and
- * nspr_test_runme() -- both exported functions.
- *
- * DLLs require a DllMain() entry-point.
- *
- * nspr_test_runme() is required so that the WinCE/WinMobile
- * controlling test program can run each DLL's tests in a standard way.
- ***********/
-
-#ifdef WINCE
-
-#ifdef perror
-#undef perror
-#endif
-#define perror(x)
-
-
-/***********
- * Do nothing DllMain -- needed to create a functional DLL
- ***********/
-BOOL WINAPI DllMain( HANDLE hDllHandle,
-                     DWORD  nReason,
-                     LPVOID lpvReserved )
-{
-  BOOLEAN bSuccess = TRUE;
-
-  switch ( nReason )
-  {
-    case DLL_PROCESS_ATTACH:
-      /* Do nothing yet  */
-      break;
-
-    case DLL_THREAD_ATTACH:
-      /* Do nothing yet  */
-      break;
-
-    case DLL_THREAD_DETACH:
-      /* Do nothing yet  */
-      break;
-
-    case DLL_PROCESS_DETACH:
-      /* Do nothing yet  */
-      break;
-
-    default:
-      /* SHOULD NOT GET HERE - Do nothing  */
-      break;
-  }
-
-  return bSuccess;
-}
-/*  end DllMain   */
-
-/* NOW, take care of all the other main() functions out there */
-#define main __declspec(dllexport) WINAPI nspr_test_runme
-
-#undef getcwd
-#define getcwd(x, nc) \
-{ \
-  int i; \
-  unsigned short dir[MAX_PATH]; \
-  GetModuleFileName(GetModuleHandle (NULL), dir, MAX_PATH); \
-  for (i = _tcslen(dir); i && dir[i] != TEXT('\\'); i--) {} \
-  dir[i + 1] = L'\0'; \
-  WideCharToMultiByte(CP_ACP, 0, dir, -1, x, nc, NULL, NULL); \
-}
-
-#endif  /* WINCE */
-
-#endif /* nst_wince_h___ */
--- a/nsprpub/pr/tests/socket.c
+++ b/nsprpub/pr/tests/socket.c
@@ -125,16 +125,20 @@ char *LARGE_FILE_NAME = "/tmp/prsocket_t
 
 #define NUM_TCP_CONNECTIONS_PER_CLIENT    5
 #define NUM_TCP_MESGS_PER_CONNECTION    10
 #define NUM_UDP_DATAGRAMS_PER_CLIENT    5
 #define TCP_SERVER_PORT            10000
 #define UDP_SERVER_PORT            TCP_SERVER_PORT
 #define SERVER_MAX_BIND_COUNT        100
 
+#ifdef WINCE
+#define perror(s)
+#endif
+
 static PRInt32 num_tcp_clients = NUM_TCP_CLIENTS;
 static PRInt32 num_udp_clients = NUM_UDP_CLIENTS;
 static PRInt32 num_transmitfile_clients = NUM_TRANSMITFILE_CLIENTS;
 static PRInt32 num_tcp_connections_per_client = NUM_TCP_CONNECTIONS_PER_CLIENT;
 static PRInt32 tcp_mesg_size = TCP_MESG_SIZE;
 static PRInt32 num_tcp_mesgs_per_connection = NUM_TCP_MESGS_PER_CONNECTION;
 static PRInt32 num_udp_datagrams_per_client = NUM_UDP_DATAGRAMS_PER_CLIENT;
 static PRInt32 udp_datagram_size = UDP_DGRAM_SIZE;
--- a/nsprpub/pr/tests/thrpool_server.c
+++ b/nsprpub/pr/tests/thrpool_server.c
@@ -86,16 +86,27 @@ static void serve_client_write(void *arg
 #define NUM_TCP_CLIENTS  10	/* for a listen queue depth of 5 */
 
 
 #define NUM_TCP_CONNECTIONS_PER_CLIENT  10
 #define NUM_TCP_MESGS_PER_CONNECTION    10
 #define TCP_SERVER_PORT            		10000
 #define SERVER_MAX_BIND_COUNT        	100
 
+#ifdef WINCE
+char *getcwd(char *buf, size_t size)
+{
+    wchar_t wpath[MAX_PATH];
+    _wgetcwd(wpath, MAX_PATH);
+    WideCharToMultiByte(CP_ACP, 0, wpath, -1, buf, size, 0, 0);
+}
+ 
+#define perror(s)
+#endif
+
 static PRInt32 num_tcp_clients = NUM_TCP_CLIENTS;
 static PRInt32 num_tcp_connections_per_client = NUM_TCP_CONNECTIONS_PER_CLIENT;
 static PRInt32 tcp_mesg_size = TCP_MESG_SIZE;
 static PRInt32 num_tcp_mesgs_per_connection = NUM_TCP_MESGS_PER_CONNECTION;
 static void TCP_Server_Accept(void *arg);
 
 
 int failed_already=0;
--- a/nsprpub/pr/tests/tmocon.c
+++ b/nsprpub/pr/tests/tmocon.c
@@ -67,16 +67,25 @@
 
 /* for getcwd */
 #if defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS)
 #include <unistd.h>
 #elif defined(XP_PC)
 #include <direct.h>
 #endif
 
+#ifdef WINCE
+#include <windows.h>
+char *getcwd(char *buf, size_t size)
+{
+    wchar_t wpath[MAX_PATH];
+    _wgetcwd(wpath, MAX_PATH);
+    WideCharToMultiByte(CP_ACP, 0, wpath, -1, buf, size, 0, 0);
+}
+#endif
 
 #define BASE_PORT 9867
 
 #define DEFAULT_DALLY 1
 #define DEFAULT_THREADS 1
 #define DEFAULT_TIMEOUT 10
 #define DEFAULT_MESSAGES 100
 #define DEFAULT_MESSAGESIZE 100
deleted file mode 100644
--- a/nsprpub/pr/tests/wince_tester.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is John Wolfe
- * Portions created by the Initial Developer are Copyright (C) 1998-2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifdef WINCE
-
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-typedef int (*pMainFnc) (int argc, char **argv);
-
-
-#define MAX_ARG_LENGTH		2048
-
-
-/* Set this next global variable to skip down the list of tests */
-/*   A "" string will mean that no modules are skipped */
-WCHAR * skip_until = TEXT(""); /* */
-/* WCHAR * skip_until = TEXT("join"); /* */
-
-
-typedef struct TEST_MODULE_ITEM_NAME {
-    WCHAR *pW;
-    CHAR  *pC;
-} TestModuleItemName, *pTestModuleItemName;
-
-#define TEST_MODULE_ITEM(x)  { TEXT(x), x }
-#define END_POINT_MARKER     { NULL, NULL }
-
-
-TestModuleItemName test_module_list[] =
-{
-    TEST_MODULE_ITEM("accept"),
-    TEST_MODULE_ITEM("acceptread"),
-    TEST_MODULE_ITEM("acceptreademu"),
-    TEST_MODULE_ITEM("affinity"),
-    TEST_MODULE_ITEM("alarm"),
-    TEST_MODULE_ITEM("anonfm"),
-    TEST_MODULE_ITEM("atomic"),
-    TEST_MODULE_ITEM("attach"),
-    TEST_MODULE_ITEM("bigfile"),
-    TEST_MODULE_ITEM("cleanup"),
-    TEST_MODULE_ITEM("cltsrv"),
-    TEST_MODULE_ITEM("concur"),
-    TEST_MODULE_ITEM("cvar"),
-    TEST_MODULE_ITEM("cvar2"),
-    TEST_MODULE_ITEM("dlltest"),
-    TEST_MODULE_ITEM("dtoa"),
-    TEST_MODULE_ITEM("errcodes"),
-    TEST_MODULE_ITEM("exit"),
-    TEST_MODULE_ITEM("fdcach"),
-    TEST_MODULE_ITEM("fileio"),
-    TEST_MODULE_ITEM("foreign"),
-    TEST_MODULE_ITEM("formattm"),
-    TEST_MODULE_ITEM("fsync"),
-    TEST_MODULE_ITEM("gethost"),
-    TEST_MODULE_ITEM("getproto"),
-    TEST_MODULE_ITEM("i2l"),
-    TEST_MODULE_ITEM("initclk"),
-    TEST_MODULE_ITEM("inrval"),
-    TEST_MODULE_ITEM("instrumt"),
-    TEST_MODULE_ITEM("intrio"),
-    TEST_MODULE_ITEM("intrupt"),
-    TEST_MODULE_ITEM("io_timeout"),
-    TEST_MODULE_ITEM("ioconthr"),
-    TEST_MODULE_ITEM("join"),
-    TEST_MODULE_ITEM("joinkk"),
-    TEST_MODULE_ITEM("joinku"),
-    TEST_MODULE_ITEM("joinuk"),
-    TEST_MODULE_ITEM("joinuu"),
-    TEST_MODULE_ITEM("layer"),
-    TEST_MODULE_ITEM("lazyinit"),
-    TEST_MODULE_ITEM("libfilename"),
-    TEST_MODULE_ITEM("lltest"),
-    TEST_MODULE_ITEM("lock"),
-    TEST_MODULE_ITEM("lockfile"),
-    TEST_MODULE_ITEM("logger"),
-    TEST_MODULE_ITEM("many_cv"),
-    TEST_MODULE_ITEM("multiwait"),
-    TEST_MODULE_ITEM("nameshm1"),
-    TEST_MODULE_ITEM("nblayer"),
-    TEST_MODULE_ITEM("nonblock"),
-    TEST_MODULE_ITEM("ntioto"),
-    TEST_MODULE_ITEM("ntoh"),
-    TEST_MODULE_ITEM("op_2long"),
-    TEST_MODULE_ITEM("op_excl"),
-    TEST_MODULE_ITEM("op_filnf"),
-    TEST_MODULE_ITEM("op_filok"),
-    TEST_MODULE_ITEM("op_nofil"),
-    TEST_MODULE_ITEM("parent"),
-    TEST_MODULE_ITEM("peek"),
-    TEST_MODULE_ITEM("perf"),
-    TEST_MODULE_ITEM("pipeping"),
-    TEST_MODULE_ITEM("pipeping2"),
-    TEST_MODULE_ITEM("pipeself"),
-    TEST_MODULE_ITEM("poll_nm"),
-    TEST_MODULE_ITEM("poll_to"),
-    TEST_MODULE_ITEM("pollable"),
-    TEST_MODULE_ITEM("prftest"),
-    TEST_MODULE_ITEM("primblok"),
-    TEST_MODULE_ITEM("provider"),
-    TEST_MODULE_ITEM("prpollml"),
-    TEST_MODULE_ITEM("ranfile"),
-    TEST_MODULE_ITEM("randseed"),
-    TEST_MODULE_ITEM("rwlocktest"),
-    TEST_MODULE_ITEM("sel_spd"),
-    TEST_MODULE_ITEM("selct_er"),
-    TEST_MODULE_ITEM("selct_nm"),
-    TEST_MODULE_ITEM("selct_to"),
-    TEST_MODULE_ITEM("selintr"),
-    TEST_MODULE_ITEM("sema"),
-    TEST_MODULE_ITEM("semaerr"),
-    TEST_MODULE_ITEM("semaping"),
-    TEST_MODULE_ITEM("sendzlf"),
-    TEST_MODULE_ITEM("server_test"),
-    TEST_MODULE_ITEM("servr_kk"),
-    TEST_MODULE_ITEM("servr_uk"),
-    TEST_MODULE_ITEM("servr_ku"),
-    TEST_MODULE_ITEM("servr_uu"),
-    TEST_MODULE_ITEM("short_thread"),
-    TEST_MODULE_ITEM("sigpipe"),
-    TEST_MODULE_ITEM("socket"),
-    TEST_MODULE_ITEM("sockopt"),
-    TEST_MODULE_ITEM("sockping"),
-    TEST_MODULE_ITEM("sprintf"),
-    TEST_MODULE_ITEM("stack"),
-    TEST_MODULE_ITEM("stdio"),
-    TEST_MODULE_ITEM("str2addr"),
-    TEST_MODULE_ITEM("strod"),
-    TEST_MODULE_ITEM("switch"),
-    TEST_MODULE_ITEM("system"),
-    TEST_MODULE_ITEM("testbit"),
-    TEST_MODULE_ITEM("testfile"),
-    TEST_MODULE_ITEM("threads"),
-    TEST_MODULE_ITEM("timemac"),
-    TEST_MODULE_ITEM("timetest"),
-    TEST_MODULE_ITEM("tpd"),
-    TEST_MODULE_ITEM("udpsrv"),
-    TEST_MODULE_ITEM("vercheck"),
-    TEST_MODULE_ITEM("version"),
-    TEST_MODULE_ITEM("writev"),
-    TEST_MODULE_ITEM("xnotify"),
-    TEST_MODULE_ITEM("zerolen"),
-    END_POINT_MARKER
-};
-
-
-int main(int argc, char **argv)
-{
-    int  i,j;
-    char mydir[MAX_ARG_LENGTH];
-
-    char **pp = argv;
-
-    /* Get File Name, strip back to first '\' and what is left is the
-     * path of the executable.
-     */
-
-    SetLastError(0);
-
-    TestModuleItemName *p = test_module_list;
-
-    int skipped = 0;
-
-    printf("\nNSPR Test Results\n");
-
-    WCHAR dateWStr[100];
-    GetDateFormat(NULL, NULL, NULL, TEXT("ddd, MMM dd yyyy"), dateWStr, 100);
-
-    WCHAR timeWStr[100];
-    GetTimeFormat(NULL, TIME_NOSECONDS, NULL, TEXT(" - h:mm tt"), timeWStr, 100);
-
-    wcscat(dateWStr, timeWStr);
-
-    char dateStr[100];
-    int rv = WideCharToMultiByte(CP_ACP, NULL, dateWStr, 100, dateStr, 100, NULL, NULL);
-
-    printf("BEGIN\t%s\n", dateStr);
-    OutputDebugString(L"BEGINNING TEST RUN\n");
-
-    if ( 0 < wcslen(skip_until) )
-    {
-        /* keep going until we find the module at which we want to start */
-        while ( (0 < wcslen(skip_until)) && 
-			    (NULL != p) && (NULL != p->pW) && (0 < wcslen(p->pW)) && 
-				  (0 != wcscmp(p->pW, skip_until)) ) 
-		    {
-            p++, skipped++;
-        }
-
-        if ( (NULL == p) || (NULL == p->pW) || (0 == wcslen(p->pW)) ) {
-            printf("main: EXITING - no tests to run (Skipped %d tests)\n", skipped);
-            return 0;
-        }
-    }
-
-    printf("    Test\tResult\n\n");
-
-    int succeeded = 0;
-    int failed = 0;
-    int total = 0;
-
-    while ( (NULL != p) && (NULL != p->pW) && (0 < wcslen(p->pW)) )
-    {
-        int     rv      = -1;
-        BOOL    bFailed = FALSE;
-        HMODULE hDll    = NULL;
-        WCHAR   wStr[500];
-
-        printf("\nBEGIN TEST %s\n\n", ((NULL != p) ? p->pC : "????"));  /* Should be shunted to LOG FILE */
-        wsprintf(wStr, L"BEGIN TEST - %s\n", p->pW);
-        OutputDebugString(wStr);
-
-        __try
-        {
-            WCHAR dllName[256];
-
-            wsprintf(dllName, TEXT("%s.dll"), ((NULL != p) ? p->pW : TEXT("BOGUS_MODULE_NAME")));
-
-            /* Find and load the DLL */
-            hDll = LoadLibrary(dllName);
-
-            if ( NULL != hDll )
-            {
-                /* Call the entry point for testing */
-                pMainFnc pMF = (pMainFnc) GetProcAddress( hDll, "nspr_test_runme" );
-
-                if ( pMF )
-                    rv = (*pMF)(0, NULL);
-            }
-
-            /* Check the return code (0 == Success) */
-            if (0 != rv) {
-                failed++;
-                bFailed = TRUE;
-            } else
-                succeeded++;
-        }
-        __except ( 1 )  /* Handle ALL exceptions here */
-        {
-            failed++;
-            bFailed = TRUE;
-        }
-
-        if ( NULL != hDll ) {
-            FreeLibrary( hDll );
-            hDll = NULL;
-        }
-
-        total++;
-
-        printf("    %s\t%s\n", ((NULL != p) ? p->pC : "????"), (bFailed ? "FAILED" : "Passed"));
-
-		{
-			WCHAR str[400];
-			if ( bFailed )
-				wsprintf(str, TEXT("----FAILED----: TEST %s: ------FAILED------\n"), p->pW);
-			else
-				wsprintf(str, TEXT("++++PASSED++++: TEST %s: ++++++PASSED++++++\n"), p->pW);
-			OutputDebugString(str);
-		}
-
-        printf("\nEND TEST %s\n\n", ((NULL != p) ? p->pC : "????"));    /* Should be shunted to LOG FILE */
-
-        p++;
-    }
-
-    printf("\n\n**********\nNSPR Test Results:");
-    printf("    Skipped Tests = %d", skipped);
-    printf("    Total Run Tests = %d", total);
-    printf("    Succeeded Tests = %d", succeeded);
-    printf("    Failed Tests = %d\n\n**********\n", failed);
-
-    return 0;
-}
-
-#else /* !WINCE */
-
-int main(int argc, char **argv)
-{
-    printf( "This application is not supported outside of WinCE/WinMobile\n" );
-    return 0;
-}
-
-#endif /* !WINCE */
--- a/nsprpub/pr/tests/y2ktmo.c
+++ b/nsprpub/pr/tests/y2ktmo.c
@@ -66,20 +66,24 @@
 #include "plgetopt.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #if defined(XP_UNIX)
 #include <sys/time.h> /* for gettimeofday */
 #endif
-#if defined(WIN32) && !defined(WINCE)
+#if defined(WIN32)
+#if defined(WINCE)
+#include <windows.h>
+#else
 #include <sys/types.h>
 #include <sys/timeb.h>  /* for _ftime */
 #endif
+#endif
 
 #define DEFAULT_LEAD_TIME_SECS 5
 #define DEFAULT_TOLERANCE_MSECS 500
 
 static PRBool debug_mode = PR_FALSE;
 static PRInt32 lead_time_secs = DEFAULT_LEAD_TIME_SECS;
 static PRInt32 tolerance_msecs = DEFAULT_TOLERANCE_MSECS;
 static PRIntervalTime start_time;