Index: modules/portlib/src/test/native/hyerror/unix/makefile =================================================================== --- modules/portlib/src/test/native/hyerror/unix/makefile (revision 548631) +++ modules/portlib/src/test/native/hyerror/unix/makefile (working copy) @@ -19,7 +19,9 @@ include $(HY_HDK)/build/make/defines.mk +INCLUDES += -I../../hycunit BUILDFILES = $(SHAREDSUB)hyerror.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/hyerror/shared/hyerror.c =================================================================== --- modules/portlib/src/test/native/hyerror/shared/hyerror.c (revision 548631) +++ modules/portlib/src/test/native/hyerror/shared/hyerror.c (working copy) @@ -16,18 +16,25 @@ */ #include "hycomp.h" #include "hyport.h" +#include "hycunit.h" #include #include #include #define ERROR_STRING "Argh!" +int test_hyerror_set_last_error(struct HyPortLibrary *hyportLibrary); +int test_hyerror_set_last_error_with_message(struct HyPortLibrary *hyportLibrary); +int test_hyerror_last_error_message(struct HyPortLibrary *hyportLibrary); +int test_hyerror_last_error_number(struct HyPortLibrary *hyportLibrary); +int test_hyerror_startup(struct HyPortLibrary *hyportLibrary); +int test_hyerror_shutdown(struct HyPortLibrary *hyportLibrary); + int main (int argc, char **argv, char **envp) { HyPortLibrary hyportLibrary; HyPortLibraryVersion portLibraryVersion; - I_32 num; - const char *err; + int ret; printf("hyerror:\n"); @@ -40,49 +47,128 @@ } printf(" portlib initialized\n"); - - err = hyportLibrary.error_last_error_message(&hyportLibrary); - printf(" err = %s\n", err); - if (strncmp(err, "", sizeof("")) != 0) { - fprintf(stderr, - "hyerror_last_error_message was not empty but \"%s\"\n", err); + + Hytest_init(&hyportLibrary, "Portlib.Hyerror"); + Hytest_func(&hyportLibrary, test_hyerror_last_error_message, "hyerror_last_error_message"); + Hytest_func(&hyportLibrary, test_hyerror_last_error_number, "hyerror_last_error_number"); + Hytest_func(&hyportLibrary, test_hyerror_set_last_error, "hyerror_set_last_error"); + Hytest_func(&hyportLibrary, test_hyerror_set_last_error_with_message, "hyerror_set_last_error_with_message"); + Hytest_func(&hyportLibrary, test_hyerror_startup, "hyerror_startup"); + Hytest_func(&hyportLibrary, test_hyerror_shutdown, "hyerror_shutdown"); + 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"); + return 0; +} - hyportLibrary.error_set_last_error(&hyportLibrary, +int test_hyerror_set_last_error(struct HyPortLibrary *hyportLibrary) +{ + I_32 num; + const char *err; + hyportLibrary->error_set_last_error(hyportLibrary, 2, HYPORT_ERROR_NOTFOUND); - num = hyportLibrary.error_last_error_number(&hyportLibrary); - err = hyportLibrary.error_last_error_message(&hyportLibrary); + num = hyportLibrary->error_last_error_number(hyportLibrary); + err = hyportLibrary->error_last_error_message(hyportLibrary); printf(" num = %d, err = %s\n", num, err); if (num != HYPORT_ERROR_NOTFOUND) { - fprintf(stderr, "hyerror_last_error_number was %d not %d\n", - num, HYPORT_ERROR_NOTFOUND); - return 1; + Hytest_setErrMsg(hyportLibrary, "hyerror_last_error_number Output should be [%d] not [%d] (%s)\n", + HYPORT_ERROR_NOTFOUND,num,HY_GET_CALLSITE()); + return -1; } if (strncmp(err, "", sizeof("")) == 0) { - fprintf(stderr, "hyerror_last_error_message was empty\n"); - return 1; + Hytest_setErrMsg(hyportLibrary, "hyerror_last_error_message was empty(%s)\n",HY_GET_CALLSITE()); + return -1; } + return 0; +} - hyportLibrary.error_set_last_error_with_message(&hyportLibrary, +int test_hyerror_set_last_error_with_message(struct HyPortLibrary *hyportLibrary) +{ + const char *err; + hyportLibrary->error_set_last_error_with_message(hyportLibrary, HYPORT_ERROR_NOTFOUND, ERROR_STRING); - err = hyportLibrary.error_last_error_message(&hyportLibrary); + err = hyportLibrary->error_last_error_message(hyportLibrary); printf(" err = %s\n", err); if (strncmp(err, ERROR_STRING, sizeof(ERROR_STRING)) != 0) { - fprintf(stderr, "hyerror_last_error_message was %s not %s\n", err, - ERROR_STRING); - return 1; + Hytest_setErrMsg(hyportLibrary, "hyerror_last_error_message Output should be [%s] not [%s] (%s)\n", ERROR_STRING, + err,HY_GET_CALLSITE()); + return -1; } - - if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) { - fprintf(stderr, "portlib shutdown failed\n"); - return 1; + return 0; +} + +int test_hyerror_last_error_message(struct HyPortLibrary *hyportLibrary) +{ + const char *err; + err = hyportLibrary->error_last_error_message(hyportLibrary); + printf(" err = %s\n", err); + if (strncmp(err, "", sizeof("")) != 0) { + Hytest_setErrMsg(hyportLibrary, + "hyerror_last_error_message Output should be empty not [%s] (%s)\n", err,HY_GET_CALLSITE()); + return -1; } - printf(" portlib shutdown\n"); + return 0; +} + +int test_hyerror_last_error_number(struct HyPortLibrary *hyportLibrary) +{ + hyportLibrary->error_last_error_number(hyportLibrary); + return 0; +} +int test_hyerror_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.error_startup (&hyportLibrary2); + if (0 != rc) + { + Hytest_setErrMsg(hyportLibrary, "error startup failed: %s (%s)\n", + hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE()); + return -1; + } + hyportLibrary2.error_shutdown(&hyportLibrary2); + return 0; +} + +int test_hyerror_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; + } + rc = + hyportLibrary2.error_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.error_shutdown(&hyportLibrary2); return 0; } Index: modules/portlib/src/test/native/hyerror/windows/makefile =================================================================== --- modules/portlib/src/test/native/hyerror/windows/makefile (revision 548631) +++ modules/portlib/src/test/native/hyerror/windows/makefile (working copy) @@ -20,9 +20,10 @@ !include <$(HY_HDK)\build\make\defines.mak> EXENAME=..\hyerror.exe -HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) +HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\hycunit BUILDFILES = $(SHAREDSUB)hyerror.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 548631) +++ modules/portlib/build.xml (working copy) @@ -179,29 +179,36 @@ - + - + - + - - + + + + + + + + + - + @{test}: ${@{test}.result}${line.separator} - <?xml version='1.0' encoding='UTF-8' ?> <testsuite tests="1" errors='${@{test}.errorcount}' failures='0' name='${@{test}.name}' time='0'> <testcase classname='${@{test}.name}' name='${@{test}.name}' time='0.0' /> <system-out><![CDATA[${@{test}.output}]]></system-out> -</testsuite>${line.separator} +</testsuite>${line.separator} -->