summaryrefslogtreecommitdiff
path: root/test/stdlib/test-canon.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-05-08 13:54:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-05-08 13:54:50 +0000
commit5f3a86ba2fe091fc813969fea5d715623f42f8e3 (patch)
tree4a51a72b308f60320edd70acf468e7a06fd3e7cc /test/stdlib/test-canon.c
parent7347e7337287fd897ecbb13629982e861ab60076 (diff)
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)
Diffstat (limited to 'test/stdlib/test-canon.c')
-rw-r--r--test/stdlib/test-canon.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/test/stdlib/test-canon.c b/test/stdlib/test-canon.c
index dd2f9bce3..f37478d63 100644
--- a/test/stdlib/test-canon.c
+++ b/test/stdlib/test-canon.c
@@ -52,8 +52,12 @@ struct {
};
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 @@ struct {
{"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 @@ do_test (int argc, char ** argv)
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);