harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548963 - in /harmony/enhanced/classlib/trunk/modules/portlib: build.xml src/test/native/hytime/shared/hytime.c src/test/native/hytime/unix/makefile src/test/native/hytime/windows/makefile
Date Wed, 20 Jun 2007 07:14:48 GMT
Author: tonywu
Date: Wed Jun 20 00:14:47 2007
New Revision: 548963

URL: http://svn.apache.org/viewvc?view=rev&rev=548963
Log:
Apply patch HARMONY-4244 ([classlib][portlib] Modified the hytime test by using HyCunit)

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/build.xml
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/shared/hytime.c
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/unix/makefile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/windows/makefile

Modified: harmony/enhanced/classlib/trunk/modules/portlib/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/build.xml?view=diff&rev=548963&r1=548962&r2=548963
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/build.xml Wed Jun 20 00:14:47 2007
@@ -195,7 +195,7 @@
         </condition>
         <!-- <exec-native test="init" /> -->
         <exec-native test="hyerror" />
-        <!-- <exec-native test="hytime" /> -->
+        <exec-native test="hytime" />
         <!-- <exec-native test="hyfile" /> -->
         <!-- <exec-native test="hystr" /> -->
 	

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/shared/hytime.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/shared/hytime.c?view=diff&rev=548963&r1=548962&r2=548963
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/shared/hytime.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/shared/hytime.c
Wed Jun 20 00:14:47 2007
@@ -20,17 +20,26 @@
 #include "hycomp.h"
 #include "hyport.h"
 #include "hythread.h"
+#include "hycunit.h"
+
+int test_hytime_current_time_millis(struct HyPortLibrary *hyportLibrary);
+int test_hytime_msec_clock(struct HyPortLibrary *hyportLibrary);
+int test_hytime_hires_clock(struct HyPortLibrary *hyportLibrary);
+int test_hytime_hires_delta(struct HyPortLibrary *hyportLibrary);
+int test_hytime_hires_frequency(struct HyPortLibrary *hyportLibrary);
+int test_hytime_usec_clock(struct HyPortLibrary *hyportLibrary);
+int test_hytime_shutdown(struct HyPortLibrary *hyportLibrary);
+int test_hytime_startup(struct HyPortLibrary *hyportLibrary);
 
 int main (int argc, char **argv, char **envp)
 {
   HyPortLibrary hyportLibrary;
   HyPortLibraryVersion portLibraryVersion;
+  int ret;
+
 #ifdef HY_NO_THR
   HyThreadLibrary *privateThreadLibrary;
 #endif
-  UDATA msec, usec;
-  I_64 millis;
-  U_64 hires, hires2, freq, delta;
 
   printf("hytime:\n");
 
@@ -48,40 +57,138 @@
   privateThreadLibrary = hyportLibrary.port_get_thread_library(&hyportLibrary);
 #endif
 
-  msec = hyportLibrary.time_msec_clock(&hyportLibrary);
-  printf("msec = %u\n", msec);
+  Hytest_init(&hyportLibrary, "Portlib.Hytime");
+  Hytest_func(&hyportLibrary, test_hytime_current_time_millis, "hytime_current_time_millis");
+  Hytest_func(&hyportLibrary, test_hytime_msec_clock, "hytime_msec_clock");
+  Hytest_func(&hyportLibrary, test_hytime_hires_clock, "hytime_hires_clock");
+  Hytest_func(&hyportLibrary, test_hytime_hires_delta, "hytime_hires_delta");
+  Hytest_func(&hyportLibrary, test_hytime_hires_frequency, "hytime_hires_frequency");
+  Hytest_func(&hyportLibrary, test_hytime_usec_clock, "hytime_usec_clock");
+  Hytest_func(&hyportLibrary, test_hytime_shutdown, "hytime_shutdown");
+  Hytest_func(&hyportLibrary, test_hytime_startup, "hytime_startup");
+  ret = Hytest_close_and_output(&hyportLibrary);
+  
+  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
+    fprintf(stderr, "portlib shutdown failed\n");
+    return 1;
+  }
+  printf("  portlib shutdown\n");
 
-  usec = hyportLibrary.time_usec_clock(&hyportLibrary);
-  printf("usec = %u\n", usec);
+  return ret;
+}
 
-  millis = hyportLibrary.time_current_time_millis(&hyportLibrary);
+int test_hytime_current_time_millis(struct HyPortLibrary *hyportLibrary)
+{
+  I_64 millis;
+  millis = hyportLibrary->time_current_time_millis(hyportLibrary);
   printf("millis = %lld\n", millis);
+  return 0;
+}
 
-  hires = hyportLibrary.time_hires_clock(&hyportLibrary);
+int test_hytime_msec_clock(struct HyPortLibrary *hyportLibrary)
+{
+  UDATA msec;
+  msec = hyportLibrary->time_msec_clock(hyportLibrary);
+  printf("msec = %u\n", msec);
+  return 0;
+}
+
+int test_hytime_hires_clock(struct HyPortLibrary *hyportLibrary)
+{
+  U_64 hires,hires2;
+  hires = hyportLibrary->time_hires_clock(hyportLibrary);
   printf("hires = %llu\n", hires);
-  freq = hyportLibrary.time_hires_frequency(&hyportLibrary);
+  hythread_sleep(1000);
+  hires2 = hyportLibrary->time_hires_clock(hyportLibrary);
+  printf("hires2 = %llu\n", hires2);
+  return 0;
+}
+
+int test_hytime_hires_delta(struct HyPortLibrary *hyportLibrary)
+{
+  U_64 delta,hires,hires2,freq;
+  hires = hyportLibrary->time_hires_clock(hyportLibrary);
+  printf("hires = %llu\n", hires);
+  freq = hyportLibrary->time_hires_frequency(hyportLibrary);
   printf("freq = %llu\n", freq);
 
   hythread_sleep(1000);
 
-  hires2 = hyportLibrary.time_hires_clock(&hyportLibrary);
+  hires2 = hyportLibrary->time_hires_clock(hyportLibrary);
   printf("hires2 = %llu\n", hires2);
-
-  delta = hyportLibrary.time_hires_delta(&hyportLibrary,
+  
+  delta = hyportLibrary->time_hires_delta(hyportLibrary,
                                          hires, hires2,
                                          HYPORT_TIME_DELTA_IN_MICROSECONDS);
   printf("delta = %llu\n", delta);
-  
   if (delta <= 0) {
-    fprintf(stderr, "hires_clock did not increment after 1s sleep\n");
-    return 1;
+    Hytest_setErrMsg(hyportLibrary, "hires_clock did not increment after 1s sleep\n");
+    return -1;
   }
+  return 0;
+}
+
+int test_hytime_hires_frequency(struct HyPortLibrary *hyportLibrary)
+{
+  U_64 freq;
+  freq = hyportLibrary->time_hires_frequency(hyportLibrary);
+  printf("freq = %llu\n", freq);
+  return 0;
+}
+
+int test_hytime_usec_clock(struct HyPortLibrary *hyportLibrary)
+{
   
-  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
-    fprintf(stderr, "portlib shutdown failed\n");
-    return 1;
+  UDATA usec;
+  usec = hyportLibrary->time_usec_clock(hyportLibrary);
+  printf("usec = %u\n", usec);
+  return 0;
+}
+
+int test_hytime_shutdown(struct HyPortLibrary *hyportLibrary)
+{
+  HyPortLibrary hyportLibrary2;
+  HyPortLibraryVersion portLibraryVersion;
+  I_32 rc;
+  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
+  if (0 != hyport_init_library (&hyportLibrary2, &portLibraryVersion,
+                                sizeof (HyPortLibrary)))
+  {
+    fprintf(stderr, "portlib init failed\n");
+    return -1;
   }
-  printf("  portlib shutdown\n");
+  rc =
+    hyportLibrary2.time_startup (&hyportLibrary2);
+  if (0 != rc)
+  {
+    Hytest_setErrMsg(hyportLibrary, "time startup failed: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary2.time_shutdown(&hyportLibrary2);
+  return 0;
+}
 
+int test_hytime_startup(struct HyPortLibrary *hyportLibrary)
+{
+  HyPortLibrary hyportLibrary2;
+  HyPortLibraryVersion portLibraryVersion;
+  I_32 rc;
+  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
+  if (0 != hyport_init_library (&hyportLibrary2, &portLibraryVersion,
+                                sizeof (HyPortLibrary)))
+  {
+    fprintf(stderr, "portlib init failed\n");
+    return -1;
+  }
+  rc =
+    hyportLibrary2.time_startup (&hyportLibrary2);
+  if (0 != rc)
+  {
+    Hytest_setErrMsg(hyportLibrary, "time startup failed: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
   return 0;
 }
+

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/unix/makefile?view=diff&rev=548963&r1=548962&r2=548963
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/unix/makefile (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/unix/makefile Wed
Jun 20 00:14:47 2007
@@ -1,29 +1,31 @@
-#  Licensed to the Apache Software Foundation (ASF) under one or more
-#  contributor license agreements.  See the NOTICE file distributed with
-#  this work for additional information regarding copyright ownership.
-#  The ASF licenses this file to You under the Apache License, Version 2.0
-#  (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.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-
-#
-# Makefile for 'hytime'
-#
-
-include $(HY_HDK)/build/make/defines.mk
-
-BUILDFILES = $(SHAREDSUB)hytime.o
-MDLLIBFILES += $(DLLPATH)libhyprt$(HY_LINKLIB_SUFFIX)
-ifeq ($(HY_NO_THR),true)
-MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
-endif
-EXENAME = ../hytime
-
-include $(HY_HDK)/build/make/rules.mk
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (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.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+#
+# Makefile for 'hytime'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+INCLUDES += -I../../hycunit
+BUILDFILES = $(SHAREDSUB)hytime.o
+BUILDFILES += ../../hycunit/hycunit.o
+MDLLIBFILES += $(DLLPATH)libhyprt$(HY_LINKLIB_SUFFIX)
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
+EXENAME = ../hytime
+
+include $(HY_HDK)/build/make/rules.mk

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/windows/makefile?view=diff&rev=548963&r1=548962&r2=548963
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/windows/makefile
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hytime/windows/makefile
Wed Jun 20 00:14:47 2007
@@ -20,9 +20,10 @@
 !include <$(HY_HDK)\build\make\defines.mak>
 
 EXENAME=..\hytime.exe
-HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB)
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\hycunit
 
 BUILDFILES = $(SHAREDSUB)hytime.obj
+BUILDFILES = $(BUILDFILES) ..\..\hycunit\hycunit.obj
 MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt$(HY_LINKLIB_SUFFIX)
 
 !IF "$(HY_NO_THR)" == "true"



Mime
View raw message