src/server/test/vfs.c

Sun, 01 May 2022 10:48:20 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 01 May 2022 10:48:20 +0200
branch
webdav
changeset 319
a9b9344875aa
parent 251
f727a21497bb
child 323
dc5b0fee49df
permissions
-rw-r--r--

add WebdavNSList <-> string converting functions

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
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include <ucx/string.h>
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include <ucx/list.h>
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include <ucx/map.h>
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 {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 UcxMap *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;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 sstr_t path;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 int isdir;
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
53 UcxBuffer *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;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 UcxMapIterator i;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 sstr_t name;
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
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 static char* test_resource_name(char *url) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 sstr_t urlstr = sstr(url);
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 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 sstr_t resname = sstrrchr(urlstr, '/');
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
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 sstr_t prefix = sstrcat(2, vfsdir->file->path, S("/"));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 UCX_MAP_FOREACH(key, file, vfsdir->i) {
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
86 sstr_t file_path = sstrcat(
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
87 2,
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
88 prefix,
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
89 sstr(test_resource_name(file->path.ptr)));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
90 void *m = ucx_map_get(vfs->files, ucx_key(file_path.ptr, file_path.length));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
91 // don't ask why alfree and not free()
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
92 alfree(ucx_default_allocator(), file_path.ptr);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
93 if(m) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 break;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 } else {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 file = NULL;
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 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 free(prefix.ptr);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 if(file) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 vfsdir->name = sstrdup_a(
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 session_get_allocator(dir->ctx->sn),
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 sstr(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
105 ZERO(entry, sizeof(VFS_ENTRY));
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 entry->name = vfsdir->name.ptr;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
107
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
108 if(getstat) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
109 ZERO(&entry->stat, sizeof(struct stat));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
110 if(file->isdir) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
111 entry->stat.st_mode = S_IFDIR;
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 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
114
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 return 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 } else {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 return 0;
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
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 void testvfs_dir_close(VFS_DIR dir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 TestVFSDir *testdir = (TestVFSDir*)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 pool_free(testdir->dir.ctx->sn->pool, dir);
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 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
127 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
128 TestVFSFile *file = (TestVFSFile*)fd;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
129 return (ssize_t)ucx_buffer_read(buf, 1, nbyte, file->content);
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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
132 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
133 TestVFSFile *file = (TestVFSFile*)fd;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
134 return (ssize_t)ucx_buffer_write(buf, 1, nbyte, file->content);
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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
137 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
138 TestVFSFile *file = (TestVFSFile*)fd;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
139 file->content->pos = (size_t)offset;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
140 return testvfs_read(fd, buf, nbyte);
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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
143 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
144 TestVFSFile *file = (TestVFSFile*)fd;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
145 file->content->pos = (size_t)offset;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
146 return testvfs_write(fd, buf, nbyte);
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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
149 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
150 TestVFSFile *file = (TestVFSFile*)fd;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
151 ucx_buffer_seek(file->content, offset, whence);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
152 return (off_t)file->content->pos;
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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
155 void testvfs_close(SYS_FILE fd) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
156 TestVFSFile *file = (TestVFSFile*)fd;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
157 file->content->pos = 0;
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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
160 VFS_IO test_file_io = {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
161 testvfs_read,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
162 testvfs_write,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
163 testvfs_pread,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
164 testvfs_pwrite,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
165 testvfs_seek,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
166 testvfs_close,
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
167 NULL, /* aio_read */
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
168 NULL /* aio_write */
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
169 };
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
170
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 VFS_DIRIO test_dir_io = {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 testvfs_readdir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 testvfs_dir_close
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
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 /* vfs funcs */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
179 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
180 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
183 sstr_t s_path = sstr((char*)path);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 if(sstrsuffix(s_path, S("/"))) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 s_path.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 file = ucx_map_sstr_get(vfs->files, s_path);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 if(!file) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 if((oflags & O_CREAT) == O_CREAT) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 file = pool_malloc(ctx->sn->pool, sizeof(TestVFSFile));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 ZERO(file, sizeof(TestVFSFile));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 file->path = sstrdup_a(session_get_allocator(ctx->sn), 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
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
196 file->content = pool_calloc(ctx->sn->pool, 1, sizeof(UcxBuffer));
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
197 file->content->capacity = 2048;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
198 file->content->space = pool_malloc(ctx->sn->pool, file->content->capacity);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
199 file->content->flags = 0;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
200 file->content->pos = 0;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
201 file->content->size = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 ucx_map_sstr_put(vfs->files, s_path, file);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
204 } else {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
205 ctx->vfs_errno = ENOENT;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 }
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
207 }
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 return (SYS_FILE)file;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
212 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
213 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
216 sstr_t s_path = sstr((char*)path);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 if(sstrsuffix(s_path, S("/"))) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 s_path.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 file = ucx_map_sstr_get(vfs->files, s_path);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 if(!file) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
223 ctx->vfs_errno = ENOENT;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 return 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 }
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
226
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
227 ZERO(buf, sizeof(struct stat));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
228 if(file->isdir) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
229 buf->st_mode = S_IFDIR;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
230 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 248
diff changeset
231
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 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
236 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
239 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
240 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 TestVFSFile *file = NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
243 sstr_t s_path = sstr((char*)path);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 if(sstrsuffix(s_path, S("/"))) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 s_path.length--;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 }
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 file = ucx_map_sstr_get(vfs->files, s_path);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 if(!file) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
250 ctx->vfs_errno = ENOENT;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 return NULL;
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
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 if(!file->isdir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 return NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 }
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 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
259 ZERO(dir, sizeof(TestVFSDir));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 dir->file = file;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 dir->i = ucx_map_iterator(vfs->files);
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 dir->dir.ctx = ctx;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 dir->dir.io = &test_dir_io;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 return (VFS_DIR)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 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
270 TestVFS *vfs = ctx->vfs->instance;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 TestVFSFile *file = (TestVFSFile*)fd;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 if(!file->isdir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 return NULL;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 }
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 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
277 ZERO(dir, sizeof(TestVFSDir));
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 dir->file = file;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 dir->i = ucx_map_iterator(vfs->files);
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 dir->dir.ctx = ctx;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 dir->dir.io = &test_dir_io;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 return (VFS_DIR)dir;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
287 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
288 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
289 if(!fd) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 return 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 }
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 TestVFSFile *file = (TestVFSFile*)fd;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 file->isdir = 1;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
299 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
300 TestVFS *vfs = ctx->vfs->instance;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
301 TestVFSFile *file = ucx_map_cstr_get(vfs->files, path);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
302 if(!file) {
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
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
306 if(file->isdir) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
307 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
308 }
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 ucx_map_cstr_remove(vfs->files, path);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
311 vfs->count_unlink++;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
312 return 0;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
313 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
314
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
315 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
316 TestVFS *vfs = ctx->vfs->instance;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
317 TestVFSFile *dir = ucx_map_cstr_get(vfs->files, path);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
318 if(!dir) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
319 ctx->vfs_errno = ENOENT;
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
320 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
321 }
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 if(!dir->isdir) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
324 return 1;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
325 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
326
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
327 UcxMapIterator i = ucx_map_iterator(vfs->files);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
328 TestVFSFile *f;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
329 UCX_MAP_FOREACH(key, f, i) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
330 if(f->path.length > dir->path.length && sstrprefix(f->path, dir->path)){
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
331 return 1; // dir not empty
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
332 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
333 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
334
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
335 ucx_map_cstr_remove(vfs->files, path);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
336 vfs->count_rmdir++;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 return 0;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 static VFS testVFSClass = {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 testvfs_open,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 testvfs_stat,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 testvfs_fstat,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344 testvfs_opendir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 testvfs_fdopendir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 testvfs_mkdir,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 testvfs_unlink,
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
348 testvfs_rmdir,
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 0,
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 NULL
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 };
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 VFS* testvfs_create(Session *sn) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 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
356 vfs->count_unlink = 0;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
357 vfs->count_rmdir = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 vfs->files = ucx_map_new_a(session_get_allocator(sn), 64);
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 testVFSClass.instance = vfs;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 return &testVFSClass;
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
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 // VFS Tests
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 //
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 /* ------------------------------------------------------------------------- */
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 UCX_TEST(test_vfs_open) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 rq->vfs = testvfs_create(sn);
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 VFSContext *vfs = vfs_request_context(sn, rq);
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 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 UCX_TEST_ASSERT(vfs, "vfs is NULL");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 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
383 UCX_TEST_ASSERT(f1, "f1 not opened");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 SYS_FILE f2 = vfs_open(vfs, "/file1", 0);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 UCX_TEST_ASSERT(f2, "f2 not opened");
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 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393 UCX_TEST(test_vfs_mkdir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 rq->vfs = testvfs_create(sn);
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 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 int err = vfs_mkdir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 UCX_TEST_ASSERT(err == 0, "error not 0");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 SYS_FILE fd = vfs_open(vfs, "/dir", 0);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 UCX_TEST_ASSERT(fd, "no fd");
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 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 UCX_TEST(test_vfs_opendir) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 rq->vfs = testvfs_create(sn);
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 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 int err = vfs_mkdir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 UCX_TEST_ASSERT(err == 0, "error not 0");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 VFSDir *dir = vfs_opendir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 UCX_TEST_ASSERT(dir, "no dir");
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 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
433 UCX_TEST(test_vfs_readdir) {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 Session *sn = testutil_session();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 Request *rq = testutil_request(sn->pool, "PUT", "/");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 rq->vfs = testvfs_create(sn);
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 VFSContext *vfs = vfs_request_context(sn, rq);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 int err = vfs_mkdir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 UCX_TEST_ASSERT(err == 0, "error not 0");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 // add some test file to /dir
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 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
447 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
448 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
449 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
450
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 VFSDir *dir = vfs_opendir(vfs, "/dir");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 UCX_TEST_ASSERT(dir, "dir not opened");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 UcxMap *files = ucx_map_new(8);
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 VFSEntry entry;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 while(vfs_readdir(dir, &entry)) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 ucx_map_cstr_put(files, entry.name, dir);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 }
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 UCX_TEST_ASSERT(files->count == 4, "wrong files count");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462 UCX_TEST_ASSERT(ucx_map_cstr_get(files, "file1"), "file1 missing");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 UCX_TEST_ASSERT(ucx_map_cstr_get(files, "file2"), "file2 missing");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 UCX_TEST_ASSERT(ucx_map_cstr_get(files, "file3"), "file3 missing");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 UCX_TEST_ASSERT(ucx_map_cstr_get(files, "file4"), "file4 missing");
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 ucx_map_free(files);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 UCX_TEST_END;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 testutil_destroy_session(sn);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 }
248
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
473
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
474 UCX_TEST(test_vfs_unlink) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
475 Session *sn = testutil_session();
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
476 Request *rq = testutil_request(sn->pool, "PUT", "/");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
477 rq->vfs = testvfs_create(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
478
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
479 VFSContext *vfs = vfs_request_context(sn, rq);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
480
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
481 UCX_TEST_BEGIN;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
482 // prepare test
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
483 int err;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
484 err = vfs_mkdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
485 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
486 err = vfs_mkdir(vfs, "/dir2");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
487 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
488
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
489 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
490 UCX_TEST_ASSERT(f1, "f1 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
491
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
492 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
493 UCX_TEST_ASSERT(f1, "f2 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
494
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
495 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
496 UCX_TEST_ASSERT(f1, "f3 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
497
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
498 // test unlink
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
499 err = vfs_unlink(vfs, "/file1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
500 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
501 err = vfs_unlink(vfs, "/dir1/file3");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
502 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
503
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
504 err = vfs_unlink(vfs, "/filex");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
505 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
506
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
507 // check if files were removed
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
508 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
509 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
510 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
511 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
512
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
513 // file2 should still be there
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
514 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
515 UCX_TEST_ASSERT(o2, "/file2 deleted");
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 // check if dir unlink fails
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
518 err = vfs_unlink(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
519 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
520
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
521 UCX_TEST_END;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
522
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
523 testutil_destroy_session(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
524 }
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
525
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
526 UCX_TEST(test_vfs_rmdir) {
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
527 Session *sn = testutil_session();
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
528 Request *rq = testutil_request(sn->pool, "PUT", "/");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
529 rq->vfs = testvfs_create(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
530
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
531 VFSContext *vfs = vfs_request_context(sn, rq);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
532
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
533 UCX_TEST_BEGIN;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
534 // prepare test
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
535 int err;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
536 err = vfs_mkdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
537 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
538 err = vfs_mkdir(vfs, "/dir2");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
539 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
540
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
541 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
542 UCX_TEST_ASSERT(f1, "f1 not opened");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
543
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
544 err = vfs_rmdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
545 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
546 err = vfs_rmdir(vfs, "/dir2");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
547 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
548
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
549 err = vfs_unlink(vfs, "/dir1/file1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
550 UCX_TEST_ASSERT(err == 0, "unlink failed");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
551 err = vfs_rmdir(vfs, "/dir1");
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
552 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
553
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
554 UCX_TEST_END;
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
555
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
556 testutil_destroy_session(sn);
bc8f8ddbad2e add vfs unlink and rmdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
557 }

mercurial