summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-04-21 17:26:12 +0000
committerNick Mathewson <nickm@torproject.org>2007-04-21 17:26:12 +0000
commit648065fcb4604bcd8abaa86ae1d8c8ef767631df (patch)
treebc0d6a488ee0bb317cdb7bca18a0113b519462b2 /src/or/test.c
parent227b2e0226445d0c4f39572f51f55451f9fa90f3 (diff)
downloadtor-648065fcb4604bcd8abaa86ae1d8c8ef767631df.tar.gz
tor-648065fcb4604bcd8abaa86ae1d8c8ef767631df.zip
r12763@Kushana: nickm | 2007-04-20 18:42:58 -0400
Initial version of code to stop using socket pairs for linked connections. Superficially, it seems to work, but it probably needs a lot more testing and attention. svn:r9995
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/or/test.c b/src/or/test.c
index a03f17134e..21916c8a0e 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -111,9 +111,10 @@ test_buffers(void)
char str[256];
char str2[256];
- buf_t *buf;
+ buf_t *buf, *buf2;
int j;
+ size_t r;
/****
* buf_new
@@ -218,6 +219,37 @@ test_buffers(void)
test_memeq(str2, str, 255);
}
+ /* Move from buf to buf. */
+ buf_free(buf);
+ buf = buf_new_with_capacity(4096);
+ buf2 = buf_new_with_capacity(4096);
+ for (j=0;j<100;++j)
+ write_to_buf(str, 255, buf);
+ test_eq(buf_datalen(buf), 25500);
+ for (j=0;j<100;++j) {
+ r = 10;
+ move_buf_to_buf(buf2, buf, &r);
+ test_eq(r, 0);
+ }
+ test_eq(buf_datalen(buf), 24500);
+ test_eq(buf_datalen(buf2), 1000);
+ for (j=0;j<3;++j) {
+ fetch_from_buf(str2, 255, buf2);
+ test_memeq(str2, str, 255);
+ }
+ r = 8192; /*big move*/
+ move_buf_to_buf(buf2, buf, &r);
+ test_eq(r, 0);
+ r = 30000; /* incomplete move */
+ move_buf_to_buf(buf2, buf, &r);
+ test_eq(r, 13692);
+ for (j=0;j<97;++j) {
+ fetch_from_buf(str2, 255, buf2);
+ test_memeq(str2, str, 255);
+ }
+ buf_free(buf);
+ buf_free(buf2);
+
#if 0
{
int s;
@@ -285,8 +317,6 @@ test_buffers(void)
test_eq(eof, 1);
}
#endif
-
- buf_free(buf);
}
static void