2 $Id: test.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $
3 Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
18 #endif /* HAVE_CONFIG_H */
25 #include <atalk/util.h>
26 #include <atalk/cnid.h>
27 #include <atalk/logger.h>
28 #include <atalk/volume.h>
29 #include <atalk/directory.h>
30 #include <atalk/queue.h>
31 #include <atalk/bstrlib.h>
35 #include "directory.h"
39 #include "afp_config.h"
44 #include "afpfunc_helpers.h"
46 /* Stuff from main.c which of cource can't be added as source to testbin */
47 unsigned char nologin = 0;
48 struct afp_options default_options;
49 static AFPConfig *configs;
51 /* Static variables */
53 int main(int argc, char **argv)
56 char *args[ARGNUM] = {"test", "-F", "test.conf", "-f", "test.default", "-s" ,"test.system"};
66 printf("Initializing\n============\n");
67 TEST(setuplog("default log_note /dev/tty"));
68 TEST(afp_options_init(&default_options));
69 TEST_int(afp_options_parse( ARGNUM, args, &default_options), 1);
70 TEST_expr(configs = configinit(&default_options), configs != NULL);
72 TEST(load_volumes(&configs->obj));
73 TEST_int(dircache_init(8192), 0);
78 printf("Running tests\n=============\n");
80 TEST_expr(vid = openvol(&configs->obj, "test"), vid != 0);
81 TEST_expr(vol = getvolbyvid(vid), vol != NULL);
83 /* test dircache.c stuff*/
84 TEST_expr(dir = dir_new("dir", "dir", vol, DIRDID_ROOT, htonl(20), bfromcstr(vol->v_path)),
86 TEST_int(dircache_add(dir), 0);
87 TEST_expr(retdir = dircache_search_by_did(vol, dir->d_did ),
88 retdir != NULL && retdir == dir && bstrcmp(retdir->d_u_name, dir->d_u_name) == 0);
89 TEST_expr(retdir = dircache_search_by_name(vol, vol->v_root, "dir", strlen("dir")),
90 retdir != NULL && retdir == dir && bstrcmp(retdir->d_u_name, dir->d_u_name) == 0);
91 TEST_int(dir_remove(vol, dir), 0);
92 TEST_int(test001_add_x_dirs(vol, 100, 100000), 0);
93 TEST_int(test002_rem_x_dirs(vol, 100, 100000), 0);
95 /* test directory.c stuff */
96 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT_PARENT), retdir != NULL);
97 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL);
98 TEST_expr(path = cname(vol, retdir, cnamewrap("Network Trash Folder")), path != NULL);
100 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL);
101 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT_PARENT, "test"), 0);
102 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, ""), 0);
104 TEST_expr(reti = createdir(&configs->obj, vid, DIRDID_ROOT, "dir1"),
105 reti == 0 || reti == AFPERR_EXIST);
107 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "dir1"), 0);
109 FIXME: this doesn't work although it should. "//" get translated to \000 \000 at means ".."
110 ie this should getfiledirparms for DIRDID_ROOT_PARENT -- at least afair!
111 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "//"), 0);
113 TEST_int(createfile(&configs->obj, vid, DIRDID_ROOT, "dir1/file1"), 0);
114 TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "dir1/file1"), 0);
115 TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "dir1"), 0);
117 TEST_int(createfile(&configs->obj, vid, DIRDID_ROOT, "file1"), 0);
118 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "file1"), 0);
119 TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "file1"), 0);
122 /* test enumerate.c stuff */
123 TEST_int(enumerate(&configs->obj, vid, DIRDID_ROOT), 0);