Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 49774 invoked from network); 2 Jun 2008 13:43:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jun 2008 13:43:03 -0000 Received: (qmail 58305 invoked by uid 500); 2 Jun 2008 13:43:05 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 58289 invoked by uid 500); 2 Jun 2008 13:43:05 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 58280 invoked by uid 99); 2 Jun 2008 13:43:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2008 06:43:05 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2008 13:42:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 90BB52388A09; Mon, 2 Jun 2008 06:42:36 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: odeakin@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080602134236.90BB52388A09@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + @@ -249,6 +250,7 @@ + @@ -286,6 +288,8 @@ target="clean" /> + 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 +#include +#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; }