static bool test_istream_concat_random(void)
{
- struct istream **streams, *input;
+ struct istream **streams, *concat, **limits = NULL;
const unsigned char *data;
unsigned char *w_data;
size_t size = 0;
- unsigned int i, j, offset, stream_count, data_len;
+ unsigned int i, j, offset, stream_count, data_len, simult;
stream_count = (rand() % TEST_MAX_ISTREAM_COUNT) + 2;
streams = t_new(struct istream *, stream_count + 1);
streams[i] = NULL;
i_assert(offset > 0);
- input = i_stream_create_concat(streams);
- i_stream_set_max_buffer_size(input, TEST_MAX_BUFFER_SIZE);
+ concat = i_stream_create_concat(streams);
+ i_stream_set_max_buffer_size(concat, TEST_MAX_BUFFER_SIZE);
+
+ simult = rand() % TEST_MAX_ISTREAM_COUNT;
+ if (simult > 0) {
+ limits = t_new(struct istream *, simult);
+ for (i = 0; i < simult; i++)
+ limits[i] = i_stream_create_limit(concat, (uoff_t)-1);
+ }
for (i = 0; i < 1000; i++) {
+ struct istream *input = (simult == 0) ? concat : limits[rand() % simult];
if (rand() % 3 == 0) {
i_stream_seek(input, rand() % offset);
} else {
}
for (i = 0; i < stream_count; i++)
i_stream_unref(&streams[i]);
- i_stream_unref(&input);
+ for (i = 0; i < simult; i++)
+ i_stream_unref(&limits[i]);
+ i_stream_unref(&concat);
return !test_has_failed();
}