1/* 2 Copyright (c) 2010 Frank Lahm <franklahm@gmail.com> 3 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. 8 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. 13*/ 14 15#ifdef HAVE_CONFIG_H 16#include "config.h" 17#endif /* HAVE_CONFIG_H */ 18 19#include <string.h> 20#include <stdio.h> 21#include <stdlib.h> 22#include <errno.h> 23 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> 32#include <atalk/netatalk_conf.h> 33 34#include "file.h" 35#include "filedir.h" 36#include "directory.h" 37#include "dircache.h" 38#include "hash.h" 39#include "afp_config.h" 40#include "volume.h" 41 42#include "test.h" 43#include "subtests.h" 44#include "afpfunc_helpers.h" 45 46/* Stuff from main.c which of cource can't be added as source to testbin */ 47unsigned char nologin = 0; 48static AFPObj obj; 49#define ARGNUM 3 50static char *args[] = {"test", "-F", "test.conf"}; 51/* Static variables */ 52 53int main(int argc, char **argv) 54{ 55 int reti; 56 uint16_t vid; 57 struct vol *vol; 58 struct dir *retdir; 59 struct path *path; 60 61 /* initialize */ 62 printf("Initializing\n============\n"); 63 TEST(setuplog("default:note","/dev/tty")); 64 65 TEST( afp_options_parse_cmdline(&obj, 3, &args[0]) ); 66 67 TEST_int( afp_config_parse(&obj, NULL), 0); 68 TEST_int( configinit(&obj), 0); 69 TEST( cnid_init() ); 70 TEST( load_volumes(&obj) ); 71 TEST_int( dircache_init(8192), 0); 72 obj.afp_version = 32; 73 74 printf("\n"); 75 76 /* now run tests */ 77 printf("Running tests\n=============\n"); 78 79 TEST_expr(vid = openvol(&obj, "test"), vid != 0); 80 TEST_expr(vol = getvolbyvid(vid), vol != NULL); 81 82 /* test directory.c stuff */ 83 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT_PARENT), retdir != NULL); 84 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL); 85 TEST_expr(path = cname(vol, retdir, cnamewrap("Network Trash Folder")), path != NULL); 86 87 TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL); 88 TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT_PARENT, "test"), 0); 89 TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT, ""), 0); 90 91#if 0 92// this doesn't work anymore since cnid sheme = last (which we use in the test) 93// has been changed to force read-only mode for the volume 94 TEST_expr(reti = createdir(&obj, vid, DIRDID_ROOT, "dir1"), 95 reti == 0 || reti == AFPERR_EXIST); 96 97 TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT, "dir1"), 0); 98#endif 99/* 100 FIXME: this doesn't work although it should. "//" get translated to \000 \000 at means ".." 101 ie this should getfiledirparms for DIRDID_ROOT_PARENT -- at least afair! 102 TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "//"), 0); 103*/ 104#if 0 105 TEST_int(createfile(&obj, vid, DIRDID_ROOT, "dir1/file1"), 0); 106 TEST_int(delete(&obj, vid, DIRDID_ROOT, "dir1/file1"), 0); 107 TEST_int(delete(&obj, vid, DIRDID_ROOT, "dir1"), 0); 108 109 TEST_int(createfile(&obj, vid, DIRDID_ROOT, "file1"), 0); 110 TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT, "file1"), 0); 111 TEST_int(delete(&obj, vid, DIRDID_ROOT, "file1"), 0); 112#endif 113 114 /* test enumerate.c stuff */ 115 TEST_int(enumerate(&obj, vid, DIRDID_ROOT), 0); 116} 117