diff --git a/js/ctypes/tests/Makefile.in b/js/ctypes/tests/Makefile.in
--- a/js/ctypes/tests/Makefile.in
+++ b/js/ctypes/tests/Makefile.in
@@ -40,16 +40,17 @@ topsrcdir = @top_srcdir@
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = jsctypes-test
 LIBRARY_NAME = jsctypes-test
+SHORT_LIBNAME = jscttest
 FORCE_SHARED_LIB = 1
 NO_DIST_INSTALL = 1
 
 CPPSRCS = jsctypes-test.cpp
 
 EXTRA_DSO_LDOPTS += \
     $(XPCOM_STANDALONE_GLUE_LDOPTS) \
     $(NSPR_LIBS) \
@@ -61,16 +61,16 @@ include $(topsrcdir)/config/rules.mk
 
 xpctestdir = $(testxpcobjdir)/$(MODULE)/unit
 
 # preprocess and install our unit test into the appropriate directory,
 # and install the test library as well. the xpcshell test rules will
 # install the .js.in from the tests srcdir, so remove it when we're done.
 libs:: unit/test_jsctypes.js.in
 	$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
-	  $^ > $(xpctestdir)/test_jsctypes.js
+          -DCTYPES_TEST_LIB=\"$(SHARED_LIBRARY)\" $^ > $(xpctestdir)/test_jsctypes.js
 	$(TEST_INSTALLER) $(SHARED_LIBRARY) $(xpctestdir)
 	$(RM) $(xpctestdir)/test_jsctypes.js.in
 
 GARBAGE += \
     $(xpctestdir)/test_jsctypes.js \
     $(xpctestdir)/$(SHARED_LIBRARY) \
     $(NULL)
diff --git a/js/ctypes/tests/unit/test_jsctypes.js.in b/js/ctypes/tests/unit/test_jsctypes.js.in
--- a/js/ctypes/tests/unit/test_jsctypes.js.in
+++ b/js/ctypes/tests/unit/test_jsctypes.js.in
@@ -38,16 +38,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 Components.utils.import("resource://gre/modules/ctypes.jsm");
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
+#expand const CTYPES_TEST_LIB = __CTYPES_TEST_LIB__;
+
 function do_check_throws(f, type, stack)
 {
   if (!stack)
     stack = Components.stack.caller;
 
   try {
     f();
   } catch (exc) {
@@ -55,26 +57,17 @@ function do_check_throws(f, type, stack)
       return;
     do_throw("expected " + type.name + " exception, caught " + exc, stack);
   }
   do_throw("expected " + type.name + " exception, none thrown", stack);
 }
 
 function run_test()
 {
-#ifdef XP_WIN
-  var libfile = do_get_file("jsctypes-test.dll");
-#elifdef XP_MACOSX
-  var libfile = do_get_file("libjsctypes-test.dylib");
-#elifdef XP_UNIX
-  var libfile = do_get_file("libjsctypes-test.so");
-#else
-  // unsupported OS - don't run the test
-  return;
-#endif
+  var libfile = do_get_file(CTYPES_TEST_LIB);
 
   // open the library with an nsILocalFile
   var library = ctypes.open(libfile);
 
   run_void_tests(library);
   run_int8_tests(library);
   run_int16_tests(library);
   run_int32_tests(library);
@@ -330,14 +330,16 @@ function run_load_system_library()
 function run_load_system_library()
 {
 #ifdef XP_WIN
   var syslib = ctypes.open("user32.dll");
 #elifdef XP_MACOSX
   var syslib = ctypes.open("libm.dylib");
 #elifdef XP_UNIX
   var syslib = ctypes.open("libm.so");
+#elifdef XP_OS2
+  var syslib = ctypes.open("libc063.dll");
 #else
   // nothing run this test
 #endif
   syslib.close();
   return true;
 }
