harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r662430 - in /harmony/enhanced/classlib/trunk/modules/portlib: ./ src/test/native/hyipcmutex/shared/ src/test/native/hymmap/ src/test/native/hymmap/shared/ src/test/native/hymmap/unix/ src/test/native/hymmap/windows/ src/test/native/hysysin...
Date Mon, 02 Jun 2008 13:42:36 GMT
Author: odeakin
Date: Mon Jun  2 06:42:35 2008
New Revision: 662430

URL: http://svn.apache.org/viewvc?rev=662430&view=rev
Log:
Add mmap portlib tests. Fix a couple of minor errors in failure messages.

Added:
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/   (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/emptyFile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/hymmap.c
  (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/testFile
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/makefile 
 (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/makefile
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/build.xml
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyipcmutex/shared/hyipcmutex.c
    harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hysysinfo/shared/hysysinfo.c

Modified: harmony/enhanced/classlib/trunk/modules/portlib/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/build.xml?rev=662430&r1=662429&r2=662430&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/build.xml Mon Jun  2 06:42:35 2008
@@ -228,6 +228,7 @@
         <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" />
         <make dir="${hy.portlib.src.test.native}/hysysinfo/${hy.os.family}" />
         <make dir="${hy.portlib.src.test.native}/hyipcmutex/${hy.os.family}" />
+        <make dir="${hy.portlib.src.test.native}/hymmap/${hy.os.family}" />
     </target>
 
     <target name="-run-native-tests" if="test.portlib">
@@ -249,6 +250,7 @@
         <exec-native test="hytime" />
         <exec-native test="hysysinfo" />
         <exec-native test="hyipcmutex" />
+        <exec-native test="hymmap" />
 	
         <move todir="${hy.tests.reports}">
             <fileset dir="${hy.portlib}">
@@ -286,6 +288,8 @@
               target="clean" />
         <make dir="${hy.portlib.src.test.native}/hyipcmutex/${hy.os.family}" 
               target="clean" />
+        <make dir="${hy.portlib.src.test.native}/hymmap/${hy.os.family}" 
+              target="clean" />
     </target>
 
     <target name="touch-errors-file" if="test.errors">

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyipcmutex/shared/hyipcmutex.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyipcmutex/shared/hyipcmutex.c?rev=662430&r1=662429&r2=662430&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyipcmutex/shared/hyipcmutex.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyipcmutex/shared/hyipcmutex.c
Mon Jun  2 06:42:35 2008
@@ -91,7 +91,7 @@
     rc = hyportLibrary2.ipcmutex_startup(&hyportLibrary2);
     if (0 != rc)
     {
-        Hytest_setErrMsg(hyportLibrary, "ipcmutex startup failed: %s (%s)\n",
+        Hytest_setErrMsg(hyportLibrary, "ipcmutex shutdown failed: %s (%s)\n",
                          hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
         return -1;
     }

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun  2 06:42:35 2008
@@ -0,0 +1 @@
+hymmap

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/emptyFile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/emptyFile?rev=662430&view=auto
==============================================================================
    (empty)

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/hymmap.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/hymmap.c?rev=662430&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/hymmap.c
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/hymmap.c
Mon Jun  2 06:42:35 2008
@@ -0,0 +1,170 @@
+/*
+* 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 <stdio.h>
+#include <string.h>
+#include "hycunit.h"
+
+int test_hymmap_startup(struct HyPortLibrary *hyportLibrary);
+int test_hymmap_shutdown(struct HyPortLibrary *hyportLibrary);
+int test_hymmap_capabilities(struct HyPortLibrary *hyportLibrary);
+int test_hymmap_map_and_unmap_file(struct HyPortLibrary *hyportLibrary);
+
+int main (int argc, char **argv, char **envp)
+{
+    HyPortLibrary hyportLibrary;
+    HyPortLibraryVersion portLibraryVersion;
+    int ret;
+
+    printf("hymmap:\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.Hymmap");
+    Hytest_func(&hyportLibrary, test_hymmap_startup, "hymmap_startup");
+    Hytest_func(&hyportLibrary, test_hymmap_shutdown, "hymmap_shutdown");
+    Hytest_func(&hyportLibrary, test_hymmap_capabilities, "hymmap_capabilities");
+    Hytest_func(&hyportLibrary, test_hymmap_map_and_unmap_file, "hymmap_map_and_unmap_file");
+    
+    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_hymmap_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.mmap_startup(&hyportLibrary2);
+    if (0 != rc)
+    {
+        Hytest_setErrMsg(hyportLibrary, "mmap startup failed: %s (%s)\n",
+                         hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+        return -1;
+    }
+    return 0;
+}
+
+int test_hymmap_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.mmap_startup(&hyportLibrary2);
+    if (0 != rc)
+    {
+        Hytest_setErrMsg(hyportLibrary, "mmap shutdown failed: %s (%s)\n",
+                         hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
+        return -1;
+    }
+    hyportLibrary2.mmap_shutdown(hyportLibrary);
+    return 0;
+}
+
+int test_hymmap_capabilities(struct HyPortLibrary *hyportLibrary) {
+    I_32 capabilities = hyportLibrary->mmap_capabilities(hyportLibrary);
+
+    if (capabilities < 0) {
+        Hytest_setErrMsg(hyportLibrary, "mmap_capabilities returned an unexpected value:
%d (%s)\n",
+                         capabilities, HY_GET_CALLSITE());
+        return -1;
+    }
+    return 0;
+}
+
+int test_hymmap_map_and_unmap_file(struct HyPortLibrary *hyportLibrary) {
+    //I_32 ret;
+    void *handle;
+    char *mappedFile, *execPath, *execName;
+    char *emptyFile, *testFile;
+    char testString[] = "This is a test file!";
+    int pathLen;
+
+    /* Create the path to the test files relative to the location of the test executable
*/
+    hyportLibrary->sysinfo_get_executable_name(hyportLibrary, "unused", &execPath);
+    execName = strrchr(execPath, DIR_SEPARATOR) + 1; /* Find the rightmost slash character
*/
+    pathLen = strlen(execPath) - strlen(execName);
+
+    emptyFile = hyportLibrary->mem_allocate_memory(hyportLibrary, pathLen + strlen("shared")
+ 2 + strlen("emptyFile")); /* +2 for the extra slash and null terminator */
+    testFile = hyportLibrary->mem_allocate_memory(hyportLibrary, pathLen + strlen("shared")
+ 2 + strlen("testFile"));
+
+    strncpy(emptyFile, execPath, pathLen);
+    strcat(emptyFile, "shared");
+    strcat(emptyFile, DIR_SEPARATOR_STR);
+    strcpy(testFile, emptyFile);
+    strcat(emptyFile, "emptyFile");
+    strcat(testFile, "testFile");
+
+    /* Attempt to map an empty file. Should return NULL and create the file */
+    mappedFile = hyportLibrary->mmap_map_file(hyportLibrary, emptyFile, &handle);
+    if (mappedFile != NULL) {
+        Hytest_setErrMsg(hyportLibrary, "mmap_map_file returned an unexpected value: %p (%s)\n",
+                         mappedFile, HY_GET_CALLSITE());
+        return -1;
+    }
+
+    /* Now call again with the newly created file - should be successful this time */
+    mappedFile = hyportLibrary->mmap_map_file(hyportLibrary, testFile, &handle);
+    if (mappedFile == NULL) {
+        Hytest_setErrMsg(hyportLibrary, "mmap_map_file returned NULL unexpectedly (%s)\n",
HY_GET_CALLSITE());
+        return -1;
+    }
+
+    if (strncmp(testString, mappedFile, strlen(testString)) != 0) {
+        Hytest_setErrMsg(hyportLibrary, "Mapped file has incorrect contents: %s (%s)\n",

+                         mappedFile, HY_GET_CALLSITE());
+        return -1;
+    }
+
+    /* Unmap the file */
+    hyportLibrary->mmap_unmap_file(hyportLibrary, handle);
+
+    hyportLibrary->mem_free_memory(hyportLibrary, execPath);
+    hyportLibrary->mem_free_memory(hyportLibrary, emptyFile);
+    hyportLibrary->mem_free_memory(hyportLibrary, testFile);
+
+
+    return 0;
+}
+

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

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/testFile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/testFile?rev=662430&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/testFile
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/shared/testFile
Mon Jun  2 06:42:35 2008
@@ -0,0 +1 @@
+This is a test file!

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/makefile?rev=662430&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/makefile (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/makefile Mon
Jun  2 06:42:35 2008
@@ -0,0 +1,32 @@
+#  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 'hymmap'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+INCLUDES += -I../../hycunit
+BUILDFILES = $(SHAREDSUB)hymmap.o
+BUILDFILES += ../../hycunit/hycunit.o
+MDLLIBFILES += $(DLLPATH)libhyprt$(HY_LINKLIB_SUFFIX)
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
+EXENAME = ../hymmap
+
+CLEANFILES=../TEST-*.xml
+include $(HY_HDK)/build/make/rules.mk

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/unix/makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/makefile?rev=662430&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/makefile
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/makefile
Mon Jun  2 06:42:35 2008
@@ -0,0 +1,37 @@
+#  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 'hymmap.exe'
+#
+
+!include <$(HY_HDK)\build\make\defines.mak>
+
+EXENAME=..\hymmap.exe
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\hycunit
+
+BUILDFILES = $(SHAREDSUB)hymmap.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)
+CLEANFILES=..\TEST-*.xml
+
+!include <$(HY_HDK)\build\make\rules.mak>

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hymmap/windows/makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hysysinfo/shared/hysysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hysysinfo/shared/hysysinfo.c?rev=662430&r1=662429&r2=662430&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hysysinfo/shared/hysysinfo.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hysysinfo/shared/hysysinfo.c
Mon Jun  2 06:42:35 2008
@@ -120,7 +120,7 @@
     rc = hyportLibrary2.sysinfo_startup(&hyportLibrary2);
     if (0 != rc)
     {
-        Hytest_setErrMsg(hyportLibrary, "sysinfo startup failed: %s (%s)\n",
+        Hytest_setErrMsg(hyportLibrary, "sysinfo shutdown failed: %s (%s)\n",
                          hyportLibrary->error_last_error_message(hyportLibrary),HY_GET_CALLSITE());
         return -1;
     }



Mime
View raw message