aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-08-08 12:07:25 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-05 13:57:51 -0400
commitf28e314b0d5a6d4c677b87378cea70dc6524546b (patch)
treea119ec5ccaa8343618cacb3bacc125da69d20c60 /src/test/test_buffers.c
parentcddac959e7fb5729956a5250351e0fa1289d719f (diff)
downloadtor-f28e314b0d5a6d4c677b87378cea70dc6524546b.tar.gz
tor-f28e314b0d5a6d4c677b87378cea70dc6524546b.zip
Make buf_pullup() expose the pulled-up data.
This lets us drop the testing-only function buf_get_first_chunk_data(), and lets us implement proto_http and proto_socks without looking at buf_t internals.
Diffstat (limited to 'src/test/test_buffers.c')
-rw-r--r--src/test/test_buffers.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index 3eb4ac2a35..49a1015d82 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -220,8 +220,7 @@ test_buffer_pullup(void *arg)
/* There are a bunch of cases for pullup. One is the trivial case. Let's
mess around with an empty buffer. */
- buf_pullup(buf, 16);
- buf_get_first_chunk_data(buf, &cp, &sz);
+ buf_pullup(buf, 16, &cp, &sz);
tt_ptr_op(cp, OP_EQ, NULL);
tt_uint_op(sz, OP_EQ, 0);
@@ -234,7 +233,7 @@ test_buffer_pullup(void *arg)
crypto_rand(stuff, 16384);
write_to_buf(stuff, 3000, buf);
write_to_buf(stuff+3000, 3000, buf);
- buf_get_first_chunk_data(buf, &cp, &sz);
+ buf_pullup(buf, 0, &cp, &sz);
tt_ptr_op(cp, OP_NE, NULL);
tt_int_op(sz, OP_LE, 4096);
@@ -242,9 +241,8 @@ test_buffer_pullup(void *arg)
* can get tested. */
tt_int_op(fetch_from_buf(tmp, 3000, buf), OP_EQ, 3000);
tt_mem_op(tmp,OP_EQ, stuff, 3000);
- buf_pullup(buf, 2048);
+ buf_pullup(buf, 2048, &cp, &sz);
assert_buf_ok(buf);
- buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, OP_NE, NULL);
tt_int_op(sz, OP_GE, 2048);
tt_mem_op(cp,OP_EQ, stuff+3000, 2048);
@@ -261,13 +259,12 @@ test_buffer_pullup(void *arg)
write_to_buf(stuff+8000, 4000, buf);
write_to_buf(stuff+12000, 4000, buf);
tt_int_op(buf_datalen(buf), OP_EQ, 16000);
- buf_get_first_chunk_data(buf, &cp, &sz);
+ buf_pullup(buf, 0, &cp, &sz);
tt_ptr_op(cp, OP_NE, NULL);
tt_int_op(sz, OP_LE, 4096);
- buf_pullup(buf, 12500);
+ buf_pullup(buf, 12500, &cp, &sz);
assert_buf_ok(buf);
- buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, OP_NE, NULL);
tt_int_op(sz, OP_GE, 12500);
tt_mem_op(cp,OP_EQ, stuff, 12500);
@@ -288,9 +285,8 @@ test_buffer_pullup(void *arg)
write_to_buf(stuff, 4000, buf);
write_to_buf(stuff+4000, 4000, buf);
fetch_from_buf(tmp, 100, buf); /* dump 100 bytes from first chunk */
- buf_pullup(buf, 16000); /* Way too much. */
+ buf_pullup(buf, 16000, &cp, &sz);
assert_buf_ok(buf);
- buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, OP_NE, NULL);
tt_int_op(sz, OP_EQ, 7900);
tt_mem_op(cp,OP_EQ, stuff+100, 7900);