harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548972 - in /harmony/enhanced/classlib/trunk/modules/portlib: ./ src/test/native/hycpu/ src/test/native/hycpu/shared/ src/test/native/hycpu/unix/ src/test/native/hycpu/windows/ src/test/native/hyerror/shared/ src/test/native/hygp/ src/test...
Date Wed, 20 Jun 2007 08:05:39 GMT
Author: tonywu
Date: Wed Jun 20 01:05:37 2007
New Revision: 548972

URL: http://svn.apache.org/viewvc?view=rev&rev=548972
Log:
Apply patch HARMONY-4246 ([classlib][portlib] Add native tests for hymem, hygp and hycpu)

Added:
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/hycpu.c 
 (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/unix/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/unix/makefile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/windows/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/windows/makefile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/hygp.c   (with
props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/unix/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/unix/makefile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/windows/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/windows/makefile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/hymem.c 
 (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/unix/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/unix/makefile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/windows/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/windows/makefile
Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/build.xml
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyerror/shared/hyerror.c

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=548972&r1=548971&r2=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/build.xml Wed Jun 20 01:05:37 2007
@@ -181,9 +181,12 @@
 
     <target name="-compile-native-tests" >
         <make dir="${hy.portlib.src.test.native}/init/${hy.os.family}" />
+        <make dir="${hy.portlib.src.test.native}/hycpu/${hy.os.family}" />
         <make dir="${hy.portlib.src.test.native}/hyerror/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" />
         <make dir="${hy.portlib.src.test.native}/hyfile/${hy.os.family}" />
+        <make dir="${hy.portlib.src.test.native}/hygp/${hy.os.family}" />
+        <make dir="${hy.portlib.src.test.native}/hymem/${hy.os.family}" />
+        <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" />
     </target>
 
     <target name="-run-native-tests" >
@@ -194,10 +197,12 @@
             <equals arg1="${hy.no.thr}" arg2="true" />
         </condition>
         <!-- <exec-native test="init" /> -->
+        <exec-native test="hycpu" />
         <exec-native test="hyerror" />
-        <exec-native test="hytime" />
         <!-- <exec-native test="hyfile" /> -->
-        <!-- <exec-native test="hystr" /> -->
+        <exec-native test="hygp" />
+        <exec-native test="hymem" />
+        <exec-native test="hytime" />
 	
         <move todir="${hy.tests.reports}">
             <fileset dir="${hy.portlib}">
@@ -211,11 +216,17 @@
     <target name="-clean-native-tests" >
         <make dir="${hy.portlib.src.test.native}/init/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hyerror/${hy.os.family}" 
+        <make dir="${hy.portlib.src.test.native}/hycpu/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" 
+        <make dir="${hy.portlib.src.test.native}/hyerror/${hy.os.family}" 
               target="clean" />
         <make dir="${hy.portlib.src.test.native}/hyfile/${hy.os.family}" 
+              target="clean" />
+        <make dir="${hy.portlib.src.test.native}/hygp/${hy.os.family}" 
+              target="clean" />
+        <make dir="${hy.portlib.src.test.native}/hymem/${hy.os.family}" 
+              target="clean" />
+        <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" 
               target="clean" />
     </target>
 

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/hycpu.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/hycpu.c?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/hycpu.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/hycpu.c Wed
Jun 20 01:05:37 2007
@@ -0,0 +1,112 @@
+/*
+* 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.
+*/
+#include "hyport.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "hycunit.h"
+
+int test_hycpu_flush_icache(struct HyPortLibrary *hyportLibrary);
+int test_hycpu_startup(struct HyPortLibrary *hyportLibrary);
+int test_hycpu_shutdown(struct HyPortLibrary *hyportLibrary);
+
+int main (int argc, char **argv, char **envp)
+{
+  HyPortLibrary hyportLibrary;
+  HyPortLibraryVersion portLibraryVersion;
+  int ret;
+
+  printf("hyerror:\n");
+
+  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
+  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
+                                sizeof (HyPortLibrary)))
+  {
+    fprintf(stderr, "portlib init failed\n");
+    return 1;
+  }
+
+  printf("  portlib initialized\n");
+  
+  Hytest_init(&hyportLibrary, "Portlib.Hycpu");
+  Hytest_func(&hyportLibrary, test_hycpu_flush_icache, "hycpu_flush_icache");
+  Hytest_func(&hyportLibrary, test_hycpu_startup, "hycpu_startup");
+  Hytest_func(&hyportLibrary, test_hycpu_shutdown, "hycpu_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 ret;
+}
+
+int test_hycpu_flush_icache(struct HyPortLibrary *hyportLibrary)
+{
+  hyportLibrary->cpu_flush_icache(hyportLibrary,NULL,512);
+  return 0;
+}
+
+int test_hycpu_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.cpu_startup (&hyportLibrary2);
+  if (0 != rc)
+  {
+    Hytest_setErrMsg(hyportLibrary, "cpu startup failed: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  return 0;
+}
+
+int test_hycpu_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.cpu_startup (&hyportLibrary2);
+  if (0 != rc)
+  {
+    Hytest_setErrMsg(hyportLibrary, "cpu startup failed: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary2.cpu_shutdown(hyportLibrary);
+  return 0;
+}
+

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/shared/hycpu.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/unix/makefile?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/unix/makefile (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/unix/makefile Wed
Jun 20 01:05:37 2007
@@ -0,0 +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 'hycpu'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+INCLUDES += -I../../hycunit
+BUILDFILES = $(SHAREDSUB)hycpu.o
+BUILDFILES += ../../hycunit/hycunit.o
+MDLLIBFILES += $(DLLPATH)libhyprt$(HY_LINKLIB_SUFFIX)
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
+EXENAME = ../hycpu
+
+include $(HY_HDK)/build/make/rules.mk

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/windows/makefile?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/windows/makefile
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hycpu/windows/makefile
Wed Jun 20 01:05:37 2007
@@ -0,0 +1,36 @@
+#  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 module 'hycpu.exe'
+#
+
+!include <$(HY_HDK)\build\make\defines.mak>
+
+EXENAME=..\hycpu.exe
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\hycunit
+
+BUILDFILES = $(SHAREDSUB)hycpu.obj
+BUILDFILES = $(BUILDFILES) ..\..\hycunit\hycunit.obj
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt$(HY_LINKLIB_SUFFIX)
+
+!IF "$(HY_NO_THR)" == "true"
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+EXEFLAGS=$(conlflags) -subsystem:console
+EXEDLLFILES=$(conlibsdll)
+
+!include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyerror/shared/hyerror.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyerror/shared/hyerror.c?view=diff&rev=548972&r1=548971&r2=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyerror/shared/hyerror.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyerror/shared/hyerror.c
Wed Jun 20 01:05:37 2007
@@ -63,7 +63,7 @@
   }
   
   printf("  portlib shutdown\n");
-  return 0;
+  return ret;
 }
 
 int test_hyerror_set_last_error(struct HyPortLibrary *hyportLibrary)

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/hygp.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/hygp.c?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/hygp.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/hygp.c Wed
Jun 20 01:05:37 2007
@@ -0,0 +1,81 @@
+/*
+* 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.
+*/
+#include "hyport.h"
+#include "hycomp.h"
+#include "gp.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "hycunit.h"
+
+int test_hygp_protect(struct HyPortLibrary *hyportLibrary);
+
+UDATA protected_fn_implement(void * arg);
+
+int main (int argc, char **argv, char **envp)
+{
+  HyPortLibrary hyportLibrary;
+  HyPortLibraryVersion portLibraryVersion;
+  int ret;
+
+  printf("hypool:\n");
+
+  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
+  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
+                                sizeof (HyPortLibrary)))
+  {
+    fprintf(stderr, "portlib init failed\n");
+    return 1;
+  }
+
+  printf("  portlib initialized\n");
+  
+  Hytest_init(&hyportLibrary, "Portlib.Hygp");
+  Hytest_func(&hyportLibrary, test_hygp_protect, "hygp_protect");
+  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 ret;
+}
+
+int test_hygp_protect(struct HyPortLibrary *hyportLibrary)
+{
+  protected_fn fn;
+  UDATA ret;
+  fn=protected_fn_implement;
+  ret = hyportLibrary->gp_protect(hyportLibrary, fn, "hello\0");
+  printf("%d",ret);
+  if(ret != 5)
+  {
+    Hytest_setErrMsg(hyportLibrary,
+            "protected_fn_implement Output should be [%d] not [%d] (%s)\n",5 ,ret,HY_GET_CALLSITE());
+    return -1;
+  }
+  return 0;
+}
+
+UDATA protected_fn_implement(void * arg)
+{
+  char* str=arg;
+  return strlen(str);
+}
+

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/shared/hygp.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/unix/makefile?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/unix/makefile (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/unix/makefile Wed
Jun 20 01:05:37 2007
@@ -0,0 +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 'hygp'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+INCLUDES += -I../../hycunit
+BUILDFILES = $(SHAREDSUB)hygp.o
+BUILDFILES += ../../hycunit/hycunit.o
+MDLLIBFILES += $(DLLPATH)libhyprt$(HY_LINKLIB_SUFFIX)
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
+EXENAME = ../hygp
+
+include $(HY_HDK)/build/make/rules.mk

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/windows/makefile?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/windows/makefile
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hygp/windows/makefile
Wed Jun 20 01:05:37 2007
@@ -0,0 +1,36 @@
+#  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 module 'hygp.exe'
+#
+
+!include <$(HY_HDK)\build\make\defines.mak>
+
+EXENAME=..\hygp.exe
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\hycunit
+
+BUILDFILES = $(SHAREDSUB)hygp.obj
+BUILDFILES = $(BUILDFILES) ..\..\hycunit\hycunit.obj
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt$(HY_LINKLIB_SUFFIX)
+
+!IF "$(HY_NO_THR)" == "true"
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+EXEFLAGS=$(conlflags) -subsystem:console
+EXEDLLFILES=$(conlibsdll)
+
+!include <$(HY_HDK)\build\make\rules.mak>

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/hymem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/hymem.c?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/hymem.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/hymem.c Wed
Jun 20 01:05:37 2007
@@ -0,0 +1,172 @@
+/*
+* 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.
+*/
+#include "hyport.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "hycunit.h"
+
+int test_hymem_allocate_memory(struct HyPortLibrary *hyportLibrary);
+int test_hymem_allocate_memory_callSite(struct HyPortLibrary *hyportLibrary);
+int test_hymem_free_memory(struct HyPortLibrary *hyportLibrary);
+int test_hymem_reallocate_memory(struct HyPortLibrary *hyportLibrary);
+int test_hymem_shutdown(struct HyPortLibrary *hyportLibrary);
+int test_hymem_startup(struct HyPortLibrary *hyportLibrary);
+
+int main (int argc, char **argv, char **envp)
+{
+  HyPortLibrary hyportLibrary;
+  HyPortLibraryVersion portLibraryVersion;
+  int ret;
+
+  printf("hymem:\n");
+
+  HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK);
+  if (0 != hyport_init_library (&hyportLibrary, &portLibraryVersion,
+                                sizeof (HyPortLibrary)))
+  {
+    fprintf(stderr, "portlib init failed\n");
+    return 1;
+  }
+
+  printf("  portlib initialized\n");
+  
+  Hytest_init(&hyportLibrary, "Portlib.Hymem");
+  Hytest_func(&hyportLibrary, test_hymem_allocate_memory, "hymem_allocate_memory");
+  Hytest_func(&hyportLibrary, test_hymem_allocate_memory_callSite, "hymem_allocate_memory_callSite");
+  Hytest_func(&hyportLibrary, test_hymem_free_memory, "hymem_free_memory");
+  Hytest_func(&hyportLibrary, test_hymem_reallocate_memory, "hymem_reallocate_memory");
+  Hytest_func(&hyportLibrary, test_hymem_shutdown, "hymem_shutdown");
+  Hytest_func(&hyportLibrary, test_hymem_startup, "hymem_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");
+  return ret;
+}
+
+int test_hymem_allocate_memory(struct HyPortLibrary *hyportLibrary)
+{
+  void* pointer;
+  pointer = hyportLibrary->mem_allocate_memory(hyportLibrary,512);
+  if(!pointer){
+    Hytest_setErrMsg(hyportLibrary, "failed to allocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary->mem_free_memory(hyportLibrary,pointer);
+  return 0;
+}
+
+int test_hymem_allocate_memory_callSite(struct HyPortLibrary *hyportLibrary)
+{
+  void* pointer;
+  pointer = hyportLibrary->mem_allocate_memory_callSite(hyportLibrary,512,"testCallSite");
+  if(!pointer){
+    Hytest_setErrMsg(hyportLibrary, "failed to allocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary->mem_free_memory(hyportLibrary,pointer);
+  return 0;
+}
+
+int test_hymem_free_memory(struct HyPortLibrary *hyportLibrary)
+{
+  void* pointer;
+  pointer = hyportLibrary->mem_allocate_memory(hyportLibrary,512);
+  if(!pointer){
+    Hytest_setErrMsg(hyportLibrary, "failed to allocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary->mem_free_memory(hyportLibrary,pointer);
+  return 0;
+}
+
+int test_hymem_reallocate_memory(struct HyPortLibrary *hyportLibrary)
+{
+  void* pointer;
+  void* pointer2;
+  pointer = hyportLibrary->mem_allocate_memory(hyportLibrary,512);
+  if(!pointer){
+    Hytest_setErrMsg(hyportLibrary, "failed to allocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  } 
+  pointer2 = hyportLibrary->mem_reallocate_memory(hyportLibrary,pointer,1024);
+  if(!pointer2){
+    Hytest_setErrMsg(hyportLibrary, "failed to reallocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary->mem_free_memory(hyportLibrary,pointer2);
+  return 0;
+}
+
+int test_hymem_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.mem_startup (&hyportLibrary2, sizeof (hyportLibrary2.portGlobals));
+  if (0 != rc)
+  {
+    Hytest_setErrMsg(hyportLibrary, "failed to reallocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary2.mem_shutdown (&hyportLibrary2);
+  return 0;
+}
+
+int test_hymem_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.mem_startup (&hyportLibrary2, sizeof (hyportLibrary2.portGlobals));
+  if (0 != rc)
+  {
+    Hytest_setErrMsg(hyportLibrary, "failed to reallocate memory: %s (%s)\n",
+    hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+    return -1;
+  }
+  hyportLibrary2.mem_shutdown (&hyportLibrary2);
+  return 0;
+}
+

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/shared/hymem.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/unix/makefile?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/unix/makefile (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/unix/makefile Wed
Jun 20 01:05:37 2007
@@ -0,0 +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 'hymem'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+INCLUDES += -I../../hycunit
+BUILDFILES = $(SHAREDSUB)hymem.o
+BUILDFILES += ../../hycunit/hycunit.o
+MDLLIBFILES += $(DLLPATH)libhyprt$(HY_LINKLIB_SUFFIX)
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
+EXENAME = ../hymem
+
+include $(HY_HDK)/build/make/rules.mk

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/windows/makefile?view=auto&rev=548972
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/windows/makefile
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymem/windows/makefile
Wed Jun 20 01:05:37 2007
@@ -0,0 +1,36 @@
+#  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 module 'hymem.exe'
+#
+
+!include <$(HY_HDK)\build\make\defines.mak>
+
+EXENAME=..\hymem.exe
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\hycunit
+
+BUILDFILES = $(SHAREDSUB)hymem.obj
+BUILDFILES = $(BUILDFILES) ..\..\hycunit\hycunit.obj
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt$(HY_LINKLIB_SUFFIX)
+
+!IF "$(HY_NO_THR)" == "true"
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+EXEFLAGS=$(conlflags) -subsystem:console
+EXEDLLFILES=$(conlibsdll)
+
+!include <$(HY_HDK)\build\make\rules.mak>



Mime
View raw message