changeset 20695:56d721e9ee64

dcrypt: Test for stream prefetch
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Thu, 25 Aug 2016 12:27:51 +0300
parents fc3b43738811
children e390f6e14850
files src/lib-dcrypt/test-stream.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dcrypt/test-stream.c	Thu Aug 25 12:26:55 2016 +0300
+++ b/src/lib-dcrypt/test-stream.c	Thu Aug 25 12:27:51 2016 +0300
@@ -121,6 +121,7 @@
 void test_static_v2_input(void)
 {
 	test_begin("test_static_v2_input");
+
 	ssize_t amt;
 	const struct hash_method *hash = hash_method_lookup("sha256");
 	unsigned char hash_ctx[hash->context_size];
@@ -322,10 +323,10 @@
 void test_write_read_v2(void)
 {
 	test_begin("test_write_read_v2");
-	unsigned char payload[IO_BLOCK_SIZE];
+	unsigned char payload[IO_BLOCK_SIZE*10];
 	const unsigned char *ptr;
 	size_t pos = 0, siz;
-	random_fill_weak(payload, IO_BLOCK_SIZE);
+	random_fill_weak(payload, IO_BLOCK_SIZE*10);
 
 	buffer_t *buf = buffer_create_dynamic(default_pool, sizeof(payload));
 	struct ostream *os = o_stream_create_buffer(buf);
@@ -339,6 +340,10 @@
 	o_stream_unref(&os_2);
 
 	struct istream *is = test_istream_create_data(buf->data, buf->used);
+	/* test regression where read fails due to incorrect behaviour
+	   when buffer is full before going to decrypt code */
+	i_stream_set_max_buffer_size(is, 8192);
+	i_stream_read(is);
 	struct istream *is_2 = i_stream_create_decrypt(is, test_v1_kp.priv);
 
 	size_t offset = 0;