Bump to kbd 2.2.0
[platform/upstream/kbd.git] / tests / libkbdfile-test03.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <errno.h>
5
6 #include <kbdfile.h>
7 #include "libcommon.h"
8
9 int
10 main(int __attribute__((unused)) argc, char **argv)
11 {
12         set_progname(argv[0]);
13         struct kbdfile *fp = kbdfile_new(NULL);
14         if (!fp)
15                 kbd_error(EXIT_FAILURE, 0, "unable to create kbdfile");
16
17         const char *const dirpath[]  = { "", DATADIR "/findfile/test_0/keymaps/**", 0 };
18         const char *const suffixes[] = { "", ".kmap", ".map", 0 };
19
20         const char *expect = DATADIR "/findfile/test_0/keymaps/i386/qwertz/test2";
21
22         int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp);
23
24         if (rc != 0)
25                 kbd_error(EXIT_FAILURE, 0, "unable to find file");
26
27         if (strcmp(expect, kbdfile_get_pathname(fp)) != 0)
28                 kbd_error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect);
29
30         kbdfile_free(fp);
31
32         return EXIT_SUCCESS;
33 }