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