Index: modules/portlib/src/test/native/hytime/unix/makefile
===================================================================
--- modules/portlib/src/test/native/hytime/unix/makefile (revision 548950)
+++ modules/portlib/src/test/native/hytime/unix/makefile (working copy)
@@ -19,7 +19,9 @@
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)
Index: modules/portlib/src/test/native/hytime/shared/hytime.c
===================================================================
--- modules/portlib/src/test/native/hytime/shared/hytime.c (revision 548950)
+++ modules/portlib/src/test/native/hytime/shared/hytime.c (working copy)
@@ -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;
}
+
Index: modules/portlib/src/test/native/hytime/windows/makefile
===================================================================
--- modules/portlib/src/test/native/hytime/windows/makefile (revision 548950)
+++ modules/portlib/src/test/native/hytime/windows/makefile (working copy)
@@ -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"
Index: modules/portlib/build.xml
===================================================================
--- modules/portlib/build.xml (revision 548950)
+++ modules/portlib/build.xml (working copy)
@@ -195,7 +195,7 @@
-
+