[or-cvs] further cleanup, test.c still has some bugs
Roger Dingledine
arma at seul.org
Wed Apr 16 23:21:47 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home/arma/work/onion/cvs/src/or
Modified Files:
circuit.c command.c config.c test.c
Log Message:
further cleanup, test.c still has some bugs
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- circuit.c 16 Apr 2003 17:11:56 -0000 1.33
+++ circuit.c 16 Apr 2003 23:21:44 -0000 1.34
@@ -144,7 +144,7 @@
unsigned char digest1[20];
unsigned char digest2[20];
struct timeval start, end;
- int time_passed;
+ long time_passed;
assert(circ && circ->onion);
@@ -518,7 +518,7 @@
void circuit_close(circuit_t *circ) {
connection_t *conn;
- circuit_t *youngest;
+ circuit_t *youngest=NULL;
assert(circ);
if(options.APPort)
Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- command.c 16 Apr 2003 17:04:57 -0000 1.21
+++ command.c 16 Apr 2003 23:21:44 -0000 1.22
@@ -10,7 +10,7 @@
int *num, int *time,
void (*func)(cell_t *, connection_t *)) {
struct timeval start, end;
- int time_passed;
+ long time_passed;
*num += 1;
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- config.c 16 Apr 2003 06:18:30 -0000 1.30
+++ config.c 16 Apr 2003 23:21:44 -0000 1.31
@@ -222,6 +222,7 @@
options->loglevel = LOG_DEBUG;
options->CoinWeight = 0.8;
options->LinkPadding = 0;
+ options->MaxConn = 900;
options->DirFetchPeriod = 600;
options->KeepalivePeriod = 300;
options->MaxOnionsPending = 10;
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- test.c 16 Apr 2003 15:24:09 -0000 1.5
+++ test.c 16 Apr 2003 23:21:44 -0000 1.6
@@ -280,15 +280,15 @@
crypto_cipher_set_iv(env2, "12345678901234567890");
crypto_cipher_encrypt_init_cipher(env1);
crypto_cipher_decrypt_init_cipher(env2);
-
+
/* Try encrypting 512 chars. */
crypto_cipher_encrypt(env1, data1, 512, data2);
crypto_cipher_decrypt(env2, data2, 512, data3);
test_memeq(data1, data3, 512);
- if (str_ciphers[i] != CRYPTO_CIPHER_IDENTITY) {
- test_memneq(data1, data2, 512);
- } else {
+ if (str_ciphers[i] == CRYPTO_CIPHER_IDENTITY) {
test_memeq(data1, data2, 512);
+ } else {
+ test_memneq(data1, data2, 512);
}
/* Now encrypt 1 at a time, and get 1 at a time. */
for (j = 512; j < 560; ++j) {
@@ -399,13 +399,53 @@
}
+void
+test_util() {
+ struct timeval start, end;
+
+ start.tv_sec = 5;
+ start.tv_usec = 5000;
+
+ end.tv_sec = 5;
+ end.tv_usec = 5000;
+
+ test_eq(0L, tv_udiff(&start, &end));
+
+ end.tv_usec = 7000;
+
+ test_eq(2000L, tv_udiff(&start, &end));
+
+ end.tv_sec = 6;
+
+ test_eq(1002000L, tv_udiff(&start, &end));
+
+ end.tv_usec = 0;
+
+ test_eq(995000L, tv_udiff(&start, &end));
+
+ end.tv_sec = 4;
+
+ test_eq(0L, tv_udiff(&start, &end));
+
+}
+
int
main(int c, char**v) {
+#if 0
+ or_options_t options; /* command-line and config-file options */
+
+ if(getconfig(c,v,&options))
+ exit(1);
+#endif
+ log(LOG_ERR,NULL); /* make logging quieter */
+
setup_directory();
- puts("========================= Buffers ==========================");
+ puts("========================== Buffers =========================");
test_buffers();
puts("========================== Crypto ==========================");
- test_crypto();
+ test_crypto(); /* this seg faults :( */
+ puts("========================== Util ============================");
+ test_util();
puts("");
return 0;
}
More information about the tor-commits
mailing list