Author: mturk
Date: Sat Aug 8 20:32:38 2009
New Revision: 802451
URL: http://svn.apache.org/viewvc?rev=802451&view=rev
Log:
Add a simple testcase for win32 dirent port
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c
commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c?rev=802451&r1=802450&r2=802451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c Sat Aug 8
20:32:38 2009
@@ -56,10 +56,9 @@
ACR_SET_OS_ERROR(ACR_ENOTDIR);
return NULL;
}
- if (!(dir = malloc(sizeof(dir))))
+ if (!(dir = malloc(sizeof(DIR))))
return NULL;
-
rc = GetFullPathNameW(wpath, ACR_HBUFF_LEN - 3, dir->d_name, NULL);
if (rc == 0 || rc > ACR_HBUFF_LEN - 3) {
free(dir);
@@ -234,3 +233,47 @@
}
}
+
+
+#if defined(ACR_ENABLE_TEST)
+
+int test_posix_dir(const char *path)
+{
+ DIR *dir;
+ struct dirent *entry;
+
+ dir = opendir(path);
+ if (!dir) {
+ char buf[512];
+ int err = ACR_GET_OS_ERROR();
+
+ fprintf(stderr, "opendir(\"%s\") : %s\n", path,
+ ACR_GetErrorString(err, buf, 512));
+ fflush(stderr);
+ return -1;
+ }
+ fprintf(stdout, "\nOpened : %S\n", dir->d_name);
+ fprintf(stdout, "Current pos : %d\n", telldir(dir));
+
+ while ((entry = readdir(dir))) {
+ fprintf(stdout, " Dir Entry : (%d) %s\n", telldir(dir),
entry->d_name);
+ }
+ fprintf(stdout, "Current pos : %d\n", telldir(dir));
+ fprintf(stdout, "Rewinding ....\n");
+ rewinddir(dir);
+ while ((entry = readdir(dir))) {
+ fprintf(stdout, " Dir Entry : (%d) %s\n", telldir(dir),
entry->d_name);
+ }
+ fprintf(stdout, "Seeking to pos 2 ....\n");
+ seekdir(dir, 2);
+ while ((entry = readdir(dir))) {
+ fprintf(stdout, " Dir Entry : (%d) %s\n", telldir(dir),
entry->d_name);
+ }
+
+ fprintf(stdout, "Finished : %d\n", dir->d_stat);
+ closedir(dir);
+ fflush(stdout);
+ return 0;
+}
+
+#endif
Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=802451&r1=802450&r2=802451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Sat Aug 8
20:32:38 2009
@@ -691,3 +691,19 @@
return ACR_ShmGetSize(s);
}
+#if defined (WIN32)
+extern int test_posix_dir(const char *path);
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test070)(ACR_JNISTDARGS, jint d)
+{
+ test_posix_dir("non existing directory");
+ return test_posix_dir(".");
+}
+
+#else
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test070)(ACR_JNISTDARGS, jint d)
+{
+ return 0;
+}
+
+#endif
Modified:
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=802451&r1=802450&r2=802451&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
(original)
+++
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
Sat Aug 8 20:32:38 2009
@@ -111,6 +111,7 @@
private static native int test064(int l);
private static native int test065(int s);
private static native int test066(int s);
+ private static native int test070(int s);
private static native String test100(String s);
@@ -946,5 +947,14 @@
assertEquals("Destroy Attached memory", 0, rv);
}
+ public void testPosixPort()
+ throws Throwable
+ {
+ int rv;
+ rv = test070(0);
+ assertTrue("opendir", rv == 0);
+
+ }
+
}