diff options
author | nobody <nobody@localhost> | 2001-04-16 17:30:54 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2001-04-16 17:30:54 +0800 |
commit | fbb6e7cebf1e3a7fa05346fbf3a64f5fe9cbc2b3 (patch) | |
tree | aaa46c1cf6c9a87e8f291ef7673bd9463803e8c9 /camel/tests/stream/test1.c | |
parent | 75a16468d369f58587f27ab4655fbe1c1091fc95 (diff) | |
download | gsoc2013-evolution-LIBOLE_0_2_2.tar.gz gsoc2013-evolution-LIBOLE_0_2_2.tar.zst gsoc2013-evolution-LIBOLE_0_2_2.zip |
This commit was manufactured by cvs2svn to create tag 'LIBOLE_0_2_2'.LIBOLE_0_2_2
svn path=/tags/LIBOLE_0_2_2/; revision=9357
Diffstat (limited to 'camel/tests/stream/test1.c')
-rw-r--r-- | camel/tests/stream/test1.c | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/camel/tests/stream/test1.c b/camel/tests/stream/test1.c deleted file mode 100644 index 452d45274f..0000000000 --- a/camel/tests/stream/test1.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - test ... camelstreamfs */ - -#include "camel-test.h" -#include "streams.h" - -#include <errno.h> -#include <sys/stat.h> -#include <unistd.h> - -#include "camel/camel-stream-fs.h" - -int main(int argc, char **argv) -{ - CamelSeekableStream *ss = NULL; - int i; - int fd = -1; - struct stat st; - int size; - char buffer[1024]; - - camel_test_init(argc, argv); - - camel_test_start("CamelStream fs, open, seek, read, write, eos"); - for (i=0;i<2;i++) { - - (void)unlink("stream.txt"); - - push("trying to open a nonexistant stream, method %d", i); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0); - break; - case 1: - fd = open("stream.txt", O_RDWR, 0); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss == NULL && errno == ENOENT); - check(stat("stream.txt", &st) == -1 && errno == ENOENT); - pull(); - - push("Creating stream using method %d", i); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_CREAT|O_RDWR|O_TRUNC, 0600); - fd = ((CamelStreamFs *)ss)->fd; - break; - case 1: - fd = open("stream.txt", O_CREAT|O_RDWR|O_TRUNC, 0600); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss != NULL); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0); - pull(); - - test_stream_seekable_writepart(ss); - test_stream_seekable_readpart(ss); - - push("getting filesize"); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode)); - size = st.st_size; - pull(); - - push("checking close closes"); - check_unref(ss, 1); - check(close(fd) == -1); - pull(); - - push("re-opening stream"); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0); - fd = ((CamelStreamFs *)ss)->fd; - break; - case 1: - fd = open("stream.txt", O_RDWR, 0); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss != NULL); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == size); - - test_stream_seekable_readpart(ss); - - check_unref(ss, 1); - check(close(fd) == -1); - pull(); - - push("re-opening stream with truncate"); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_TRUNC, 0); - fd = ((CamelStreamFs *)ss)->fd; - break; - case 1: - fd = open("stream.txt", O_RDWR|O_TRUNC, 0); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss != NULL); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0); - - /* read has to return 0 before eos is set */ - check(camel_stream_read(CAMEL_STREAM(ss), buffer, 1) == 0); - check(camel_stream_eos(CAMEL_STREAM(ss))); - - check_unref(ss, 1); - check(close(fd) == -1); - pull(); - - (void)unlink("stream.txt"); - } - - camel_test_end(); - - return 0; -} |