62 resdata.data = test_connection; |
62 resdata.data = test_connection; |
63 |
63 |
64 ucx_test_register(suite, test_pg_vfs_open); |
64 ucx_test_register(suite, test_pg_vfs_open); |
65 ucx_test_register(suite, test_pg_vfs_io); |
65 ucx_test_register(suite, test_pg_vfs_io); |
66 ucx_test_register(suite, test_pg_vfs_stat); |
66 ucx_test_register(suite, test_pg_vfs_stat); |
|
67 ucx_test_register(suite, test_pg_vfs_mkdir); |
|
68 ucx_test_register(suite, test_pg_vfs_unlink); |
67 |
69 |
68 PGresult *result = PQexec(test_connection, "BEGIN"); |
70 PGresult *result = PQexec(test_connection, "BEGIN"); |
69 PQclear(result); |
71 PQclear(result); |
70 } |
72 } |
71 } |
73 } |
111 UCX_TEST_ASSERT(file, "cannot create file 1"); |
113 UCX_TEST_ASSERT(file, "cannot create file 1"); |
112 |
114 |
113 vfs_close(file); |
115 vfs_close(file); |
114 |
116 |
115 UCX_TEST_END; |
117 UCX_TEST_END; |
|
118 |
|
119 testutil_destroy_session(sn); |
116 } |
120 } |
117 |
121 |
118 UCX_TEST(test_pg_vfs_io) { |
122 UCX_TEST(test_pg_vfs_io) { |
119 Session *sn = testutil_session(); |
123 Session *sn = testutil_session(); |
120 Request *rq = testutil_request(sn->pool, "PUT", "/"); |
124 Request *rq = testutil_request(sn->pool, "PUT", "/"); |
199 |
204 |
200 int testfail = vfs_stat(vfs, "/test_stat_fail", &st1); |
205 int testfail = vfs_stat(vfs, "/test_stat_fail", &st1); |
201 UCX_TEST_ASSERT(testfail != 0, "stat 3 should fail"); |
206 UCX_TEST_ASSERT(testfail != 0, "stat 3 should fail"); |
202 |
207 |
203 UCX_TEST_END; |
208 UCX_TEST_END; |
|
209 |
|
210 testutil_destroy_session(sn); |
204 } |
211 } |
205 |
212 |
206 UCX_TEST(test_pg_vfs_mkdir) { |
213 UCX_TEST(test_pg_vfs_mkdir) { |
207 |
214 |
208 } |
215 } |
|
216 |
|
217 UCX_TEST(test_pg_vfs_unlink) { |
|
218 Session *sn = testutil_session(); |
|
219 Request *rq = testutil_request(sn->pool, "PUT", "/"); |
|
220 rq->vfs = create_test_pgvfs(sn, rq); |
|
221 VFSContext *vfs = vfs_request_context(sn, rq); |
|
222 |
|
223 UCX_TEST_BEGIN; |
|
224 |
|
225 SYS_FILE f1 = vfs_open(vfs, "/test_unlink1", O_WRONLY|O_CREAT); |
|
226 UCX_TEST_ASSERT(f1, "cannot create test file"); |
|
227 system_fwrite(f1, "test", 4); |
|
228 |
|
229 PgFile *pgfile = f1->data; |
|
230 Oid oid = pgfile->oid; |
|
231 |
|
232 vfs_close(f1); |
|
233 |
|
234 int r = vfs_unlink(vfs, "/test_unlink1"); |
|
235 UCX_TEST_ASSERT(r == 0, "unlink failed"); |
|
236 |
|
237 f1 = vfs_open(vfs, "/test_unlink1", O_RDONLY); |
|
238 UCX_TEST_ASSERT(f1 == NULL, "test file not deleted"); |
|
239 |
|
240 int pgfd = lo_open(test_connection, oid, INV_READ); |
|
241 UCX_TEST_ASSERT(pgfd < 0, "large object not deleted"); |
|
242 |
|
243 r = vfs_unlink(vfs, "/test_unlink1"); |
|
244 UCX_TEST_ASSERT(r, "unlink should fail"); |
|
245 |
|
246 UCX_TEST_END; |
|
247 |
|
248 testutil_destroy_session(sn); |
|
249 } |