test/dump: allow to run manually
authorRan Benita <ran234@gmail.com>
Tue, 5 Jun 2012 14:48:08 +0000 (17:48 +0300)
committerRan Benita <ran234@gmail.com>
Sat, 9 Jun 2012 09:34:57 +0000 (12:34 +0300)
Without the srcdir envvar (and a couple trivial changes).

Signed-off-by: Ran Benita <ran234@gmail.com>
src/keymap-dump.c
test/data/dump.data [moved from test/dump.data with 100% similarity]
test/dump.c

index f80e354..4fafde5 100644 (file)
@@ -98,8 +98,8 @@ do { \
         /* If it was truncated, embiggen the string and roll from the top. */ \
         if (!do_realloc(buf, size, *offset, _printed)) { \
             fprintf(stderr, \
-                    "xkbcommon: failed to allocate %lu bytes for keymap\n", \
-                    (unsigned long) *size); \
+                    "xkbcommon: failed to allocate %zu bytes for keymap\n", \
+                    *size); \
             free(*buf); \
             *buf = NULL; \
             _ret = false; \
similarity index 100%
rename from test/dump.data
rename to test/data/dump.data
index 16d1768..abb9f0a 100644 (file)
@@ -52,8 +52,8 @@ int main(int argc, char *argv[])
     char *path;
     int fd;
 
-    assert(srcdir);
-    assert(asprintf(&path, "%s/test/dump.data", srcdir) != -1);
+    srcdir = srcdir ? srcdir : ".";
+    assert(asprintf(&path, "%s/test/data/dump.data", srcdir) != -1);
     fd = open(path, O_RDONLY);
     assert(fd >= 0);
     assert(stat(path, &stat_buf) == 0);
@@ -72,9 +72,8 @@ int main(int argc, char *argv[])
 
     if (strcmp(as_string, expected) != 0) {
         printf("dumped map differs from expected!\n\n");
-        printf("length: got %lu, expected %lu\n",
-               (unsigned long) strlen(as_string),
-               (unsigned long) strlen(expected));
+        printf("length: got %zu, expected %zu\n",
+               strlen(as_string), strlen(expected));
         printf("result:\n%s\n", as_string);
         assert(0);
     }