2 Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
17 #endif /* HAVE_CONFIG_H */
24 #include <atalk/util.h>
25 #include <atalk/cnid.h>
26 #include <atalk/logger.h>
27 #include <atalk/volume.h>
28 #include <atalk/directory.h>
29 #include <atalk/queue.h>
30 #include <atalk/bstrlib.h>
31 #include <atalk/globals.h>
35 #include "directory.h"
38 #include "afp_config.h"
43 #include "afpfunc_helpers.h"
45 /* Stuff from main.c which of cource can't be added as source to testbin */
46 unsigned char nologin = 0;
47 struct afp_options default_options;
48 static AFPConfig *configs;
50 /* Static variables */
52 int main(int argc, char **argv)
55 char *args[ARGNUM] = {"test", "-F", "test.conf", "-f", "test.default", "-s" ,"test.system"};
64 printf("Initializing\n============\n");
65 TEST(setuplog("default log_note /dev/tty"));
66 TEST(afp_options_init(&default_options));
67 TEST_int(afp_options_parse( ARGNUM, args, &default_options), 1);
68 TEST_expr(configs = configinit(&default_options), configs != NULL);
70 TEST(load_volumes(&configs->obj));
71 TEST_int(dircache_init(8192), 0);
76 printf("Running tests\n=============\n");
78 TEST_expr(vid = openvol(&configs->obj, "test"), vid != 0);
79 TEST_expr(vol = getvolbyvid(vid), vol != NULL);
81 /* test directory.c stuff */
82 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT_PARENT), retdir != NULL);
83 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL);
84 TEST_expr(path = cname(vol, retdir, cnamewrap("Network Trash Folder")), path != NULL);
86 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL);
87 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT_PARENT, "test"), 0);
88 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, ""), 0);
90 TEST_expr(reti = createdir(&configs->obj, vid, DIRDID_ROOT, "dir1"),
91 reti == 0 || reti == AFPERR_EXIST);
93 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "dir1"), 0);
95 FIXME: this doesn't work although it should. "//" get translated to \000 \000 at means ".."
96 ie this should getfiledirparms for DIRDID_ROOT_PARENT -- at least afair!
97 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "//"), 0);
99 TEST_int(createfile(&configs->obj, vid, DIRDID_ROOT, "dir1/file1"), 0);
100 TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "dir1/file1"), 0);
101 TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "dir1"), 0);
103 TEST_int(createfile(&configs->obj, vid, DIRDID_ROOT, "file1"), 0);
104 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "file1"), 0);
105 TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "file1"), 0);
108 /* test enumerate.c stuff */
109 TEST_int(enumerate(&configs->obj, vid, DIRDID_ROOT), 0);