File: libkbdfile-test07.c

package info (click to toggle)
kbd 2.7.1-2%2Bexp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 16,852 kB
  • sloc: ansic: 13,572; javascript: 3,038; sh: 759; pascal: 643; makefile: 578; lex: 525; yacc: 352; perl: 126; python: 96; sed: 6
file content (32 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <kbdfile.h>
#include "libcommon.h"

int
main(int argc KBD_ATTR_UNUSED, char **argv KBD_ATTR_UNUSED)
{
	struct kbdfile *fp = kbdfile_new(NULL);
	if (!fp)
		kbd_error(EXIT_FAILURE, 0, "unable to create kbdfile");

	const char *const dirpath[]  = { "", TESTDIR "/data/findfile/test_0/keymaps/**", 0 };
	const char *const suffixes[] = { ".map", "", ".kmap", 0 };

	const char *expect = TESTDIR "/data/findfile/test_0/keymaps/i386/qwerty/test3.map";

	int rc = kbdfile_find("test3", dirpath, suffixes, fp);

	if (rc != 0)
		kbd_error(EXIT_FAILURE, 0, "unable to find file");

	if (strcmp(expect, kbdfile_get_pathname(fp)) != 0)
		kbd_error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect);

	kbdfile_free(fp);

	return EXIT_SUCCESS;
}