Merge branch 'jk/sort-iter-test-output'
[gitweb.git] / t / helper / test-dir-iterator.c
index a5b96cb0dcfd0e5b493638bc5d6a310ffbf87db3..c7c30664dad2a027c4cf6b0bac7ecb78080cbcf1 100644 (file)
@@ -4,6 +4,15 @@
 #include "iterator.h"
 #include "dir-iterator.h"
 
+static const char *error_name(int error_number)
+{
+       switch (error_number) {
+       case ENOENT: return "ENOENT";
+       case ENOTDIR: return "ENOTDIR";
+       default: return "ESOMETHINGELSE";
+       }
+}
+
 /*
  * usage:
  * tool-test dir-iterator [--follow-symlinks] [--pedantic] directory_path
@@ -31,7 +40,7 @@ int cmd__dir_iterator(int argc, const char **argv)
        diter = dir_iterator_begin(path.buf, flags);
 
        if (!diter) {
-               printf("dir_iterator_begin failure: %d\n", errno);
+               printf("dir_iterator_begin failure: %s\n", error_name(errno));
                exit(EXIT_FAILURE);
        }