bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainenstatic void test_fs_async_write(const char *test_name, struct fs *fs)
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen unsigned int i;
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_begin(t_strdup_printf("%s: async write", test_name));
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen for (i = 0; i < 3; i++) {
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen file = fs_file_init(fs, "foo", FS_OPEN_MODE_REPLACE |
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_assert(fs_write_stream_finish(file, &output) == 0);
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_assert(fs_write_stream_finish_async(file) == 0);
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_assert(fs_write_stream_finish_async(file) > 0);
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_assert(fs_write_stream_finish_async(file) < 0);
6d035effc27b2556393e6b26fbe1a846741cdb8eAki Tuomi fs_write_stream_abort_error(file, &output, "test");
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainenstatic void test_fs_async_copy(const char *test_name, struct fs *fs)
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_begin(t_strdup_printf("%s: async copy", test_name));
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen src = fs_file_init(fs, "foo", FS_OPEN_MODE_REPLACE);
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen dest = fs_file_init(fs, "bar", FS_OPEN_MODE_REPLACE |
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen test_assert(fs_copy(src, dest) == -1 && errno == EAGAIN);
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainenvoid test_fs_async(const char *test_name, enum fs_properties properties,
b162e16ade1e0d9bfae62e366caf57a3132f5963Timo Sirainen if (fs_init(driver, args, &fs_set, &fs, &error) < 0)