harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r499018 - in /harmony/enhanced/classlib/trunk/modules/portlib: ./ src/test/native/hyfile/ src/test/native/hyfile/shared/ src/test/native/hyfile/unix/ src/test/native/hyfile/windows/
Date Tue, 23 Jan 2007 13:41:34 GMT
Author: hindessm
Date: Tue Jan 23 05:41:32 2007
New Revision: 499018

URL: http://svn.apache.org/viewvc?view=rev&rev=499018
Log:
Adding simple hyfile.c tests to portlib.

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

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=499018&r1=499017&r2=499018
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/build.xml Tue Jan 23 05:41:32 2007
@@ -135,6 +135,7 @@
         <make dir="${hy.portlib.src.test.native}/init/${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}" />
     </target>
 
     <target name="-run-native-tests" >
@@ -143,6 +144,7 @@
         <exec-native test="init" />
         <exec-native test="hyerror" />
         <exec-native test="hytime" />
+        <exec-native test="hyfile" />
 
         <antcall target="touch-errors-file" />
     </target>

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c?view=auto&rev=499018
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c
Tue Jan 23 05:41:32 2007
@@ -0,0 +1,165 @@
+/*
+* 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 <stdlib.h>
+#include <stdio.h>
+
+#include "hycomp.h"
+#include "hyport.h"
+#include "hythread.h"
+
+int main (int argc, char **argv, char **envp)
+{
+  HyPortLibrary hyportLibrary;
+  HyPortLibraryVersion portLibraryVersion;
+  IDATA fd;
+  IDATA bytes;
+  IDATA rc;
+  IDATA offset;
+  char buf[20];
+  I_64 length;
+
+  printf("hyfile:\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");
+
+  fd = hyportLibrary.file_open(&hyportLibrary, "hytest.tmp",
+                               HyOpenCreate | HyOpenWrite | HyOpenTruncate,
+                               0600);
+  printf("  fd = %d\n", fd);
+  if (!fd) {
+    fprintf(stderr, "Failed to open hytest.tmp for write\n");
+    exit(1);
+  }
+
+  bytes = hyportLibrary.file_write(&hyportLibrary, fd, (void*)"testing", 7);
+  printf("  hyfile_write wrote %d bytes\n", bytes);
+  if (bytes != 7) {
+    fprintf(stderr, "hyfile_write wrote %d bytes not %d\n", bytes, 7);
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_write_text(&hyportLibrary, fd, "testing", 7);
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_write_text write failed\n");
+    exit(1);
+  }
+
+  hyportLibrary.file_printf(&hyportLibrary, fd, "%d%c%s\n", 1, '2', "3");
+  rc = hyportLibrary.file_sync(&hyportLibrary, fd);
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_sync failed\n");
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_close(&hyportLibrary, fd);
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_close failed\n");
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_move(&hyportLibrary, "hytest.tmp", "hytest.tmp2");
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_move failed\n");
+    exit(1);
+  }
+
+  fd = hyportLibrary.file_open(&hyportLibrary, "hytest.tmp2",
+                               HyOpenRead, 0000);
+  printf("  fd = %d\n", fd);
+  if (!fd) {
+    fprintf(stderr, "Failed to open hytest.tmp2 for read\n");
+    exit(1);
+  }
+
+  offset = hyportLibrary.file_seek(&hyportLibrary, fd, -11, HySeekEnd);
+  printf("  offset = %d\n", offset);
+  if (offset != 7) {
+    fprintf(stderr, "Failed to seek hytest.tmp2\n");
+    exit(1);
+  }
+
+  bytes = hyportLibrary.file_read(&hyportLibrary, fd, buf, 10);
+  printf("  bytes = %d\n", bytes);
+  buf[bytes] = '\0';
+  printf("  buf = %s\n", buf);
+  if (bytes != 10) {
+    fprintf(stderr, "Failed to read hytest.tmp2\n");
+    exit(1);
+  }
+
+  if (strcmp(buf, "testing123") != 0) {
+    fprintf(stderr, "Failed to read correct content from hytest.tmp2\n");
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_close(&hyportLibrary, fd);
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_close failed\n");
+    exit(1);
+  }
+
+  length = hyportLibrary.file_length(&hyportLibrary, "hytest.tmp2");
+  printf("  length = %d\n", length);
+  if (length != 18) {
+    fprintf(stderr, "hytest.tmp2 has incorrect length\n");
+    exit(1);
+  }
+
+  if (hyportLibrary.file_attr(&hyportLibrary, "hytest.tmp2") != HyIsFile) {
+    fprintf(stderr, "hytest.tmp2 has incorrect type\n");
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_unlink(&hyportLibrary, "hytest.tmp2");
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_unlink failed\n");
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_mkdir(&hyportLibrary, "hytest.dir.tmp");
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_mkdir failed\n");
+    exit(1);
+  }
+
+  if (hyportLibrary.file_attr(&hyportLibrary, "hytest.dir.tmp") != HyIsDir) {
+    fprintf(stderr, "hytest.dir.tmp has incorrect type\n");
+    exit(1);
+  }
+
+  rc = hyportLibrary.file_unlinkdir(&hyportLibrary, "hytest.dir.tmp");
+  if (rc != 0) {
+    fprintf(stderr, "hyfile_unlinkdir failed\n");
+    exit(1);
+  }
+
+  if (0 != hyportLibrary.port_shutdown_library (&hyportLibrary)) {
+    fprintf(stderr, "portlib shutdown failed\n");
+    return 1;
+  }
+  printf("  portlib shutdown\n");
+
+  return 0;
+}

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

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/unix/makefile?view=auto&rev=499018
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/unix/makefile (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/unix/makefile Tue
Jan 23 05:41:32 2007
@@ -0,0 +1,27 @@
+#  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 'hyfile'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+BUILDFILES = $(SHAREDSUB)hyfile.o
+MDLLIBFILES = $(LIBPATH)libhycommon.a $(DLLPATH)libhyprt.so \
+	$(DLLPATH)libhythr.so $(DLLPATH)libhysig.so
+EXENAME = ../hyfile
+
+include $(HY_HDK)/build/make/rules.mk

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/windows/makefile?view=auto&rev=499018
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/windows/makefile
(added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/windows/makefile
Tue Jan 23 05:41:32 2007
@@ -0,0 +1,30 @@
+#  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 'hyfile.exe'
+#
+
+!include <$(HY_HDK)\build\make\defines.mak>
+
+EXENAME=../hyfile.exe
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB)
+
+BUILDFILES = $(SHAREDSUB)hyfile.obj
+MDLLIBFILES = $(LIBPATH)hycommon.lib $(LIBPATH)hyprt.lib $(LIBPATH)hythr.lib 
+EXEFLAGS=$(conlflags) -subsystem:console
+EXEDLLFILES=$(conlibsdll)
+
+!include <$(HY_HDK)\build\make\rules.mak>



Mime
View raw message