Bump to 1.14.1
[platform/upstream/augeas.git] / tests / leak.c
1 #include <config.h>
2 #include "augeas.h"
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 const char *abs_top_srcdir;
8 const char *abs_top_builddir;
9 char *root = NULL, *src_root = NULL, *lensdir = NULL;
10 struct augeas *aug = NULL;
11
12
13 #define die(msg)                                                    \
14     do {                                                            \
15         fprintf(stderr, "%s:%d: Fatal error: %s\n", __FILE__, __LINE__, msg); \
16         exit(EXIT_FAILURE);                                         \
17     } while(0)
18
19
20 int main (void)
21 {
22   abs_top_srcdir = getenv("abs_top_srcdir");
23   if (abs_top_srcdir == NULL)
24     die("env var abs_top_srcdir must be set");
25
26   abs_top_builddir = getenv("abs_top_builddir");
27   if (abs_top_builddir == NULL)
28     die("env var abs_top_builddir must be set");
29
30   if (asprintf(&src_root, "%s/tests/root", abs_top_srcdir) < 0) {
31     die("failed to set src_root");
32   }
33
34   if (asprintf(&lensdir, "%s/lenses", abs_top_srcdir) < 0)
35     die("asprintf lensdir failed");
36
37
38   aug = aug_init (src_root, lensdir, AUG_NO_STDINC);
39   if (!aug) { perror ("aug_init"); exit (1); }
40   aug_close (aug);
41
42   free(root);
43   free(src_root);
44   free(lensdir);
45   return 0;
46 }