chiark / gitweb /
wip make it compile; add warnings to Makefile
[inn-innduct.git] / tests / lib / innconf-t.c
1 /* $Id: innconf-t.c 7748 2008-04-06 13:49:56Z iulius $ */
2 /* innconf test suite. */
3
4 #include "config.h"
5 #include "clibrary.h"
6
7 #include "inn/innconf.h"
8 #include "inn/messages.h"
9 #include "libtest.h"
10
11 static const char grep[] =
12 "egrep 'mta|organization|ovmethod|hismethod|path|pgpverify'\
13  ../../samples/inn.conf > config/tmp";
14
15 int
16 main(void)
17 {
18     struct innconf *standard;
19     FILE *config;
20
21     if (access("config/valid", F_OK) < 0)
22         if (access("lib/config/valid", F_OK) == 0)
23             chdir("lib");
24
25     puts("9");
26
27     ok(1, innconf_read("../../samples/inn.conf"));
28     standard = innconf;
29     innconf = NULL;
30     if (system(grep) != 0)
31         die("Unable to create stripped configuration file");
32     ok(2, innconf_read("config/tmp"));
33     unlink("config/tmp");
34     ok(3, innconf_compare(standard, innconf));
35     innconf_free(standard);
36     innconf_free(innconf);
37     innconf = NULL;
38     ok(4, true);
39
40     /* Checking inn.conf. */
41     errors_capture();
42     if (system(grep) != 0)
43         die("Unable to create stripped configuration file");
44     ok(5, innconf_check("config/tmp"));
45     ok(6, errors == NULL);
46     innconf_free(innconf);
47     innconf = NULL;
48     config = fopen("config/tmp", "a");
49     if (config == NULL)
50         sysdie("Unable to open stripped configuration file for append");
51     fputs("foo: bar\n", config);
52     fclose(config);
53     ok(7, !innconf_check("config/tmp"));
54     unlink("config/tmp");
55     ok_string(8, "config/tmp:26: unknown parameter foo\n", errors);
56     errors_uncapture();
57     free(errors);
58     errors = NULL;
59     innconf_free(innconf);
60     innconf = NULL;
61     ok(9, true);
62
63     return 0;
64 }