1 /***************************************************************************
2 * test_trie.c - Test suite for trie data structure
4 * begin : Thu Oct 24 2007
5 * copyright : (C) 2007 by Patrick Sabin
6 * email : patricksabin@gmx.at
7 ****************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the BSD License (revised). *
14 ***************************************************************************/
30 /*Needs private declarations*/
31 #include <kdbprivate.h>
33 void *mapper(void *s,char *backend)
45 k = keyNew ("user/template/key",0);
46 s=kdbGetBackend(kdb,k);
47 exit_if_fail(s, "Got null pointer from kdbGetBackend");
48 succeed_if(!strcmp("libelektra-template",kdbhGetBackendName(s)), "kdbGetBackend: didn't get the correct value");
53 k = keyNew ("user/key",0);
54 s=kdbGetBackend(kdb,k);
55 exit_if_fail(s, "Got null pointer from kdbGetBackend");
56 succeed_if(!strcmp("libelektra-filesys",kdbhGetBackendName(s)), "kdbGetBackend: didn't get the correct value");
59 k = keyNew ("system/key",0);
60 s=kdbGetBackend(kdb,k);
61 exit_if_fail(s, "Got null pointer from kdbGetBackend");
62 succeed_if(!strcmp("libelektra-filesys",kdbhGetBackendName(s)), "kdbGetBackend: didn't get the correct value");
65 k = keyNew ("system/filesystems/hda/",0);
66 s=kdbGetBackend(kdb,k);
67 exit_if_fail(s, "Got null pointer from kdbGetBackend");
68 succeed_if(!strcmp("libelektra-fstab",kdbhGetBackendName(s)), "kdbGetBackend: didn't get the correct value");
71 printf ("Looking up dynamic mounting\n");
72 printf(BACKEND_DIR "fstab2/config/path\n");
73 ksAppendKey(ks,keyNew(BACKEND_DIR "fstab2/config/path",KEY_VALUE,"/tmp/fstab2",0));
74 kdbMount(kdb, mountpoint=keyNew("system/fstab/",0), "fstab",ks);
76 k = keyNew ("system/fstab/dev/hda",0);
77 s=kdbGetBackend(kdb,k);
78 exit_if_fail(s, "Got null pointer from kdbGetBackend");
79 succeed_if(!strcmp("libelektra-fstab",kdbhGetBackendName(s)), "kdbGetBackend: didn't get the correct value");
82 kdbUnmount(kdb,mountpoint);
85 k = keyNew ("system/fstab/dev/hda",0);
86 s=kdbGetBackend(kdb,k);
87 exit_if_fail(s, "Got null pointer from kdbGetBackend");
88 succeed_if(!strcmp("libelektra-filesys",kdbhGetBackendName(s)), "kdbGetBackend: didn't get the correct value");
99 printf("TRIE TESTS\n");
100 printf("==================\n\n");
106 printf("\ntest_trie RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);