svn commit: trunk/uClibc/test/stdlib
vda at uclibc.org
vda at uclibc.org
Thu May 8 13:54:50 UTC 2008
Author: vda
Date: 2008-05-08 06:54:50 -0700 (Thu, 08 May 2008)
New Revision: 21951
Log:
test-canon: stop checking realpath buffer in case realpath
returns NULL (the buffer contents is undefined);
also check errno more thoroughly (bugs were seen slipping through)
Modified:
trunk/uClibc/test/stdlib/test-canon.c
Changeset:
Modified: trunk/uClibc/test/stdlib/test-canon.c
===================================================================
--- trunk/uClibc/test/stdlib/test-canon.c 2008-05-08 13:52:22 UTC (rev 21950)
+++ trunk/uClibc/test/stdlib/test-canon.c 2008-05-08 13:54:50 UTC (rev 21951)
@@ -52,8 +52,12 @@
};
struct {
- const char * in, * out, * resolved;
- int error;
+ const char * in;
+ const char * retval; /* what realpath should return */
+ const char * retbuf; /* what realpath should store in buf */
+ /* if both of the above are NULL, we won't check for result,
+ * it's undefined */
+ int error; /* expected errno value */
} tests[] = {
/* 0 */
{"/", "/"},
@@ -72,17 +76,9 @@
{"foobar", 0, "./foobar", ENOENT},
{".", "."},
{"./foobar", 0, "./foobar", ENOENT},
-#ifdef __UCLIBC__
- /* we differ from glibc here, but POSIX allows it as it says that if we did
- * not successfuly complete, the value of resolved_path is undefined */
- {"SYMLINK_LOOP", 0, "", ELOOP},
+ {"SYMLINK_LOOP", 0, 0, ELOOP},
/* 15 */
- {"./SYMLINK_LOOP", 0, "", ELOOP},
-#else
- {"SYMLINK_LOOP", 0, "./SYMLINK_LOOP", ELOOP},
- /* 15 */
- {"./SYMLINK_LOOP", 0, "./SYMLINK_LOOP", ELOOP},
-#endif
+ {"./SYMLINK_LOOP", 0, 0, ELOOP},
{"SYMLINK_1", "."},
{"SYMLINK_1/foobar", 0, "./foobar", ENOENT},
{"SYMLINK_2", "/etc"},
@@ -180,27 +176,29 @@
for (i = 0; i < (int) (sizeof (tests) / sizeof (tests[0])); ++i)
{
buf[0] = '\0';
+ errno = 0;
result = realpath (tests[i].in, buf);
- if (!check_path (result, tests[i].out))
+ if (!check_path (result, tests[i].retval))
{
printf ("%s: flunked test %d (expected `%s', got `%s')\n",
- argv[0], i, tests[i].out ? tests[i].out : "NULL",
+ argv[0], i, tests[i].retval ? tests[i].retval : "NULL",
result ? result : "NULL");
++errors;
continue;
}
- if (!check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
+ if ((tests[i].retval || tests[i].retbuf)
+ && !check_path (buf, tests[i].retval ? tests[i].retval : tests[i].retbuf))
{
printf ("%s: flunked test %d (expected resolved `%s', got `%s')\n",
- argv[0], i, tests[i].out ? tests[i].out : tests[i].resolved,
+ argv[0], i, tests[i].retval ? tests[i].retval : tests[i].retbuf,
buf);
++errors;
continue;
}
- if (!tests[i].out && errno != tests[i].error)
+ if (errno != tests[i].error)
{
printf ("%s: flunked test %d (expected errno %d, got %d)\n",
argv[0], i, tests[i].error, errno);
More information about the uClibc-cvs
mailing list