dnl See if we are cross-compiling\r
AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)\r
\r
-AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile doc/Makefile python/Makefile])\r
+AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])\r
AC_OUTPUT\r
--- /dev/null
+# FIXME: Actually run a test on a magic file
+check_PROGRAMS = test
+test_LDADD = $(top_builddir)/src/libmagic.la
+
+check-local:
+ MAGIC=$(top_builddir)/magic/magic ./test
+ for i in $(TEST_BASES); do MAGIC=./$$i.magic ./test ./$$i.testfile ./$$i.result; done
+
+TEST_BASES = gedcom
+
+EXTRA_DIST = \
+ gedcom.magic gedcom.testfile gedcom.result
int
main(int argc, char **argv)
{
- struct magic_set *ms;
- const char *m;
- int i;
+ struct magic_set *ms;
+ const char *m;
+ int i;
- ms = magic_open(MAGIC_NONE);
- if (ms == NULL) {
- (void) printf("ERROR opening MAGIC_NONE: out of memory\n");
- return 1;
- }
- if (magic_load(ms, NULL) == -1) {
- (void) printf("ERROR loading with NULL file: %s\n", magic_error(ms));
- return 2;
- }
+ ms = magic_open(MAGIC_NONE);
+ if (ms == NULL) {
+ fprintf(stderr, "ERROR opening MAGIC_NONE: out of memory\n");
+ return 1;
+ }
+ if (magic_load(ms, NULL) == -1) {
+ fprintf(stderr, "ERROR loading with NULL file: %s\n", magic_error(ms));
+ return 2;
+ }
- for (i = 1; i < argc; i++) {
- if ((m = magic_file(ms, argv[i])) == NULL) {
- (void) printf("ERROR loading file %s: %s\n", argv[i], magic_error(ms));
- return 3;
- } else
- (void) printf("%s: %s\n", argv[i], m);
- }
+ if (argc > 1) {
+ if (argc != 3) {
+ fprintf(stderr, "Usage: test TEST-FILE RESULT\n");
+ } else {
+ if ((m = magic_file(ms, argv[1])) == NULL) {
+ fprintf(stderr, "ERROR loading file %s: %s\n", argv[1], magic_error(ms));
+ return 3;
+ } else {
+ printf("%s: %s\n", argv[1], m);
+ /* Compare m with contents of argv[3] */
+ }
+ }
+ }
- magic_close(ms);
- return 0;
+ magic_close(ms);
+ return 0;
}