src/server/test/vfs.c

Sun, 19 Mar 2023 16:48:19 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 19 Mar 2023 16:48:19 +0100
changeset 484
c036a8b242a8
parent 415
d938228c382e
child 490
d218607f5a7e
permissions
-rw-r--r--

implement webdav xattr namespace lists

219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2019 Olaf Wintermann. All rights reserved.
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
31 #include <errno.h>
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
33 #include <cx/string.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
34 #include <cx/list.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
35 #include <cx/map.h>
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../daemon/session.h"
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "testutils.h"
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include "vfs.h"
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 typedef struct TestVFS {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
44 CxMap *files;
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
45 int count_unlink;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
46 int count_rmdir;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 } TestVFS;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 typedef struct TestVFSFile {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 VFSFile file;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
51 cxmutstr path;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 int isdir;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
53 CxBuffer content;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 } TestVFSFile;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 typedef struct TestVFSDir {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 VFSDir dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 TestVFSFile *file;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
59 CxIterator i;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
60 cxmutstr name;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 } TestVFSDir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 /* dir io */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
65 static const char* test_resource_name(char *url) {
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
66 cxstring urlstr = cx_str(url);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 if(urlstr.ptr[urlstr.length-1] == '/') {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 urlstr.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
70 cxstring resname = cx_strrchr(urlstr, '/');
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 if(resname.length > 1) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 return resname.ptr+1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 } else {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 return url;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 int testvfs_readdir(VFS_DIR dir, VFS_ENTRY *entry, int getstat) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 TestVFS *vfs = dir->ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 TestVFSDir *vfsdir = (TestVFSDir*)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
82 cxmutstr prefix = cx_strcat(2, vfsdir->file->path, cx_str("/"));
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
84 // not the most efficient file system implementation ever, but it is only
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
85 // for testing
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
86 // check every entry in vfs->files and return, if the parent path
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
87 // matches the open directory
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 TestVFSFile *file = NULL;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
89 cx_foreach(TestVFSFile *, entry, vfsdir->i) {
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
90 if(file) break;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
91 cxmutstr file_path = cx_strcat(
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
92 2,
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
93 prefix,
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
94 cx_str(test_resource_name(entry->path.ptr)));
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
95 file = cxMapGet(vfs->files, cx_hash_key(file_path.ptr, file_path.length));
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
96 free(file_path.ptr);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 free(prefix.ptr);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 if(file) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
101 vfsdir->name = cx_strdup_a(
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
102 pool_allocator(dir->ctx->sn->pool),
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
103 cx_str(test_resource_name(file->path.ptr)));
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
104 ZERO(entry, sizeof(VFS_ENTRY));
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 entry->name = vfsdir->name.ptr;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
106
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
107 if(getstat) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
108 ZERO(&entry->stat, sizeof(struct stat));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
109 if(file->isdir) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
110 entry->stat.st_mode = S_IFDIR;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
111 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
112 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
113
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 return 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 } else {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 void testvfs_dir_close(VFS_DIR dir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 TestVFSDir *testdir = (TestVFSDir*)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 pool_free(testdir->dir.ctx->sn->pool, dir);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
126 ssize_t testvfs_read(SYS_FILE fd, void *buf, size_t nbyte) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
127 TestVFSFile *file = (TestVFSFile*)fd;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
128 return (ssize_t)cxBufferRead(buf, 1, nbyte, &file->content);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
129 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
130
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
131 ssize_t testvfs_write(SYS_FILE fd, const void *buf, size_t nbyte) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
132 TestVFSFile *file = (TestVFSFile*)fd;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
133 return (ssize_t)cxBufferWrite(buf, 1, nbyte, &file->content);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
134 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
135
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
136 ssize_t testvfs_pread(SYS_FILE fd, void *buf, size_t nbyte, off_t offset) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
137 TestVFSFile *file = (TestVFSFile*)fd;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
138 file->content.pos = (size_t)offset;
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
139 return testvfs_read(fd, buf, nbyte);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
140 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
141
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
142 ssize_t testvfs_pwrite(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
143 TestVFSFile *file = (TestVFSFile*)fd;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
144 file->content.pos = (size_t)offset;
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
145 return testvfs_write(fd, buf, nbyte);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
146 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
147
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
148 off_t testvfs_seek(SYS_FILE fd, off_t offset, int whence) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
149 TestVFSFile *file = (TestVFSFile*)fd;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
150 cxBufferSeek(&file->content, offset, whence);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
151 return (off_t)file->content.pos;
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
152 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
153
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
154 void testvfs_close(SYS_FILE fd) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
155 TestVFSFile *file = (TestVFSFile*)fd;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
156 file->content.pos = 0;
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
157 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
158
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
159 VFS_IO test_file_io = {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
160 testvfs_read,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
161 testvfs_write,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
162 testvfs_pread,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
163 testvfs_pwrite,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
164 testvfs_seek,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
165 testvfs_close,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
166 NULL, /* aio_read */
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
167 NULL /* aio_write */
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
168 };
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
169
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 VFS_DIRIO test_dir_io = {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 testvfs_readdir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 testvfs_dir_close
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 };
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 /* vfs funcs */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
178 SYS_FILE testvfs_open(VFSContext *ctx, const char *path, int oflags) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
182 cxstring s_path = cx_str((char*)path);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
183 if(cx_strsuffix(s_path, cx_str("/"))) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 s_path.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
187 file = cxMapGet(vfs->files, cx_hash_key_bytes((const unsigned char*)s_path.ptr, s_path.length));
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 if(!file) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 if((oflags & O_CREAT) == O_CREAT) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 file = pool_malloc(ctx->sn->pool, sizeof(TestVFSFile));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 ZERO(file, sizeof(TestVFSFile));
323
dc5b0fee49df fix TestVFSFile ctx initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
192 file->file.ctx = ctx;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
193 file->path = cx_strdup_a(pool_allocator(ctx->sn->pool), s_path);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
194 file->file.io = &test_file_io;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
195
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
196 cxBufferInit(&file->content, pool_malloc(ctx->sn->pool, 2048), 2048, pool_allocator(ctx->sn->pool), 0);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
198 cxMapPut(vfs->files, cx_hash_key((void*)s_path.ptr, s_path.length), file);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
199 } else {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
200 ctx->vfs_errno = ENOENT;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 }
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
202 }
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 return (SYS_FILE)file;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
207 int testvfs_stat(VFSContext *ctx, const char *path, struct stat *buf) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
211 cxstring s_path = cx_str((char*)path);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
212 if(cx_strsuffix(s_path, cx_str("/"))) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 s_path.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
216 file = cxMapGet(vfs->files, cx_hash_key((void*)s_path.ptr, s_path.length));
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 if(!file) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
218 ctx->vfs_errno = ENOENT;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 return 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 }
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
221
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
222 ZERO(buf, sizeof(struct stat));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
223 if(file->isdir) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
224 buf->st_mode = S_IFDIR;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
225 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
226
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 int testvfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
234 VFS_DIR testvfs_opendir(VFSContext *ctx, const char *path) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
238 cxstring s_path = cx_str((char*)path);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
239 if(cx_strsuffix(s_path, cx_str("/"))) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 s_path.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
243 file = cxMapGet(vfs->files, cx_hash_key((void*)s_path.ptr, s_path.length));
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 if(!file) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
245 ctx->vfs_errno = ENOENT;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 return NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 if(!file->isdir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 return NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 TestVFSDir *dir = pool_malloc(ctx->sn->pool, sizeof(TestVFSDir));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 ZERO(dir, sizeof(TestVFSDir));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 dir->file = file;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
256 dir->i = cxMapIteratorValues(vfs->files);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 dir->dir.ctx = ctx;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 dir->dir.io = &test_dir_io;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 return (VFS_DIR)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 VFS_DIR testvfs_fdopendir(VFSContext *ctx, SYS_FILE fd) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 TestVFSFile *file = (TestVFSFile*)fd;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 if(!file->isdir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 return NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 TestVFSDir *dir = pool_malloc(ctx->sn->pool, sizeof(TestVFSDir));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 ZERO(dir, sizeof(TestVFSDir));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 dir->file = file;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
274 dir->i = cxMapIteratorValues(vfs->files);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 dir->dir.ctx = ctx;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 dir->dir.io = &test_dir_io;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 return (VFS_DIR)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
282 int testvfs_mkdir(VFSContext *ctx, const char *path) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 SYS_FILE fd = testvfs_open(ctx, path, O_CREAT);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 if(!fd) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 return 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 TestVFSFile *file = (TestVFSFile*)fd;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 file->isdir = 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
294 int testvfs_unlink(VFSContext *ctx, const char *path) {
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
295 TestVFS *vfs = ctx->vfs->instance;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
296 CxHashKey path_key = cx_hash_key_str(path);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
297 TestVFSFile *file = cxMapGet(vfs->files, path_key);
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
298 if(!file) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
299 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
300 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
301
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
302 if(file->isdir) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
303 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
304 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
305
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
306 (void)cxMapRemove(vfs->files, path_key);
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
307 vfs->count_unlink++;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
308 return 0;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
309 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
310
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
311 int testvfs_rmdir(VFSContext *ctx, const char *path) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
312 TestVFS *vfs = ctx->vfs->instance;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
313 CxHashKey path_key = cx_hash_key_str(path);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
314 TestVFSFile *dir = cxMapGet(vfs->files, path_key);
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
315 if(!dir) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
316 ctx->vfs_errno = ENOENT;
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
317 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
318 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
319
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
320 if(!dir->isdir) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
321 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
322 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
323
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
324 CxIterator i = cxMapIteratorValues(vfs->files);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
325 cx_foreach(TestVFSFile *, f, i) {
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
326 if(f->path.length > dir->path.length && cx_strprefix(cx_strcast(f->path), cx_strcast(dir->path))){
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
327 return 1; // dir not empty
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
328 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
329 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
330
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
331 (void)cxMapRemove(vfs->files, path_key);
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
332 vfs->count_rmdir++;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 static VFS testVFSClass = {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 testvfs_open,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 testvfs_stat,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 testvfs_fstat,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 testvfs_opendir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 testvfs_fdopendir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 testvfs_mkdir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 testvfs_unlink,
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
344 testvfs_rmdir,
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 0,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 NULL
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 };
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 VFS* testvfs_create(Session *sn) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 TestVFS *vfs = pool_malloc(sn->pool, sizeof(TestVFS));
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
352 vfs->count_unlink = 0;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
353 vfs->count_rmdir = 0;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
354 vfs->files = cxHashMapCreate(pool_allocator(sn->pool), 64);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 testVFSClass.instance = vfs;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 return &testVFSClass;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 /* ------------------------------------------------------------------------- */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 //
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 // VFS Tests
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 //
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 /* ------------------------------------------------------------------------- */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 UCX_TEST(test_vfs_open) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 rq->vfs = testvfs_create(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 UCX_TEST_ASSERT(vfs, "vfs is NULL");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378 SYS_FILE f1 = vfs_open(vfs, "/file1", O_CREAT);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 UCX_TEST_ASSERT(f1, "f1 not opened");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381 SYS_FILE f2 = vfs_open(vfs, "/file1", 0);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 UCX_TEST_ASSERT(f2, "f2 not opened");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 UCX_TEST(test_vfs_mkdir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 rq->vfs = testvfs_create(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 int err = vfs_mkdir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399 UCX_TEST_ASSERT(err == 0, "error not 0");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 SYS_FILE fd = vfs_open(vfs, "/dir", 0);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 UCX_TEST_ASSERT(fd, "no fd");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 UCX_TEST(test_vfs_opendir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 rq->vfs = testvfs_create(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 int err = vfs_mkdir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419 UCX_TEST_ASSERT(err == 0, "error not 0");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 VFSDir *dir = vfs_opendir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 UCX_TEST_ASSERT(dir, "no dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
429 UCX_TEST(test_vfs_readdir) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432 rq->vfs = testvfs_create(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 int err = vfs_mkdir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 UCX_TEST_ASSERT(err == 0, "error not 0");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 // add some test file to /dir
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT), "creation of file1 failed");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT), "creation of file2 failed");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT), "creation of file3 failed");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 VFSDir *dir = vfs_opendir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 UCX_TEST_ASSERT(dir, "dir not opened");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
450 CxMap *files = cxHashMapCreate(cxDefaultAllocator, 8);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 VFSEntry entry;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 while(vfs_readdir(dir, &entry)) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
454 cxMapPut(files, cx_hash_key_str(entry.name), dir);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
457 UCX_TEST_ASSERT(files->size == 4, "wrong files count");
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
458 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file1")), "file1 missing");
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
459 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file2")), "file2 missing");
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
460 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file3")), "file3 missing");
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
461 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file4")), "file4 missing");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 323
diff changeset
463 cxMapDestroy(files);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 }
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
469
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
470 UCX_TEST(test_vfs_unlink) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
471 Session *sn = testutil_session();
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
472 Request *rq = testutil_request(sn->pool, "PUT", "/");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
473 rq->vfs = testvfs_create(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
474
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
475 VFSContext *vfs = vfs_request_context(sn, rq);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
476
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
477 UCX_TEST_BEGIN;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
478 // prepare test
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
479 int err;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
480 err = vfs_mkdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
481 UCX_TEST_ASSERT(err == 0, "mkdir 1: error not 0");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
482 err = vfs_mkdir(vfs, "/dir2");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
483 UCX_TEST_ASSERT(err == 0, "mkdir 1: error not 0");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
484
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
485 SYS_FILE f1 = vfs_open(vfs, "/file1", O_CREAT);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
486 UCX_TEST_ASSERT(f1, "f1 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
487
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
488 SYS_FILE f2 = vfs_open(vfs, "/file2", O_CREAT);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
489 UCX_TEST_ASSERT(f1, "f2 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
490
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
491 SYS_FILE f3 = vfs_open(vfs, "/dir1/file3", O_CREAT);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
492 UCX_TEST_ASSERT(f1, "f3 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
493
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
494 // test unlink
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
495 err = vfs_unlink(vfs, "/file1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
496 UCX_TEST_ASSERT(err == 0, "unlink /file1 failed");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
497 err = vfs_unlink(vfs, "/dir1/file3");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
498 UCX_TEST_ASSERT(err == 0, "unlink /dir1/file3 failed");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
499
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
500 err = vfs_unlink(vfs, "/filex");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
501 UCX_TEST_ASSERT(err != 0, "unlink /filex should fail");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
502
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
503 // check if files were removed
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
504 SYS_FILE o1 = vfs_open(vfs, "/file1", O_RDONLY);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
505 UCX_TEST_ASSERT(o1 == NULL, "/file1 not deleted");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
506 SYS_FILE o3 = vfs_open(vfs, "/dir1/file3", O_RDONLY);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
507 UCX_TEST_ASSERT(o1 == NULL, "/dir1/file3 not deleted");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
508
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
509 // file2 should still be there
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
510 SYS_FILE o2 = vfs_open(vfs, "/file2", O_RDONLY);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
511 UCX_TEST_ASSERT(o2, "/file2 deleted");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
512
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
513 // check if dir unlink fails
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
514 err = vfs_unlink(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
515 UCX_TEST_ASSERT(err != 0, "unlink dir1 should fail");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
516
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
517 UCX_TEST_END;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
518
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
519 testutil_destroy_session(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
520 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
521
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
522 UCX_TEST(test_vfs_rmdir) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
523 Session *sn = testutil_session();
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
524 Request *rq = testutil_request(sn->pool, "PUT", "/");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
525 rq->vfs = testvfs_create(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
526
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
527 VFSContext *vfs = vfs_request_context(sn, rq);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
528
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
529 UCX_TEST_BEGIN;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
530 // prepare test
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
531 int err;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
532 err = vfs_mkdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
533 UCX_TEST_ASSERT(err == 0, "mkdir 1: error not 0");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
534 err = vfs_mkdir(vfs, "/dir2");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
535 UCX_TEST_ASSERT(err == 0, "mkdir 1: error not 0");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
536
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
537 SYS_FILE f1 = vfs_open(vfs, "/dir1/file1", O_CREAT);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
538 UCX_TEST_ASSERT(f1, "f1 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
539
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
540 err = vfs_rmdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
541 UCX_TEST_ASSERT(err != 0, "rmdir /dir1 should fail");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
542 err = vfs_rmdir(vfs, "/dir2");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
543 UCX_TEST_ASSERT(err == 0, "rmdir /dir2 failed");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
544
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
545 err = vfs_unlink(vfs, "/dir1/file1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
546 UCX_TEST_ASSERT(err == 0, "unlink failed");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
547 err = vfs_rmdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
548 UCX_TEST_ASSERT(err == 0, "rmdir /dir1 (2) failed");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
549
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
550 UCX_TEST_END;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
551
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
552 testutil_destroy_session(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
553 }

mercurial