2009-09-22 19:49:09 +02:00
|
|
|
/* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2021-03-12 17:39:23 +01:00
|
|
|
* Copyright (c) 2007-2021, The Tor Project, Inc. */
|
2009-09-22 19:49:09 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
#include "orconfig.h"
|
2012-08-27 23:37:56 +02:00
|
|
|
#include <math.h>
|
|
|
|
|
2018-09-20 14:09:35 +02:00
|
|
|
#define BWAUTH_PRIVATE
|
2016-01-12 18:33:05 +01:00
|
|
|
#define CONFIG_PRIVATE
|
2019-03-25 17:48:52 +01:00
|
|
|
#define CONTROL_GETINFO_PRIVATE
|
2019-12-19 16:42:44 +01:00
|
|
|
#define DIRAUTH_SYS_PRIVATE
|
2018-09-21 16:26:57 +02:00
|
|
|
#define DIRCACHE_PRIVATE
|
|
|
|
#define DIRCLIENT_PRIVATE
|
2009-09-22 19:49:09 +02:00
|
|
|
#define DIRVOTE_PRIVATE
|
2018-09-21 16:26:57 +02:00
|
|
|
#define DLSTATUS_PRIVATE
|
2011-09-07 23:48:21 +02:00
|
|
|
#define HIBERNATE_PRIVATE
|
2014-04-26 19:32:36 +02:00
|
|
|
#define NETWORKSTATUS_PRIVATE
|
2018-10-01 17:44:59 +02:00
|
|
|
#define NS_PARSE_PRIVATE
|
2018-09-19 20:10:15 +02:00
|
|
|
#define NODE_SELECT_PRIVATE
|
2015-09-07 21:04:51 +02:00
|
|
|
#define RELAY_PRIVATE
|
2018-09-20 14:09:35 +02:00
|
|
|
#define ROUTERLIST_PRIVATE
|
|
|
|
#define ROUTER_PRIVATE
|
2018-10-01 01:15:00 +02:00
|
|
|
#define UNPARSEABLE_PRIVATE
|
2018-09-20 14:09:35 +02:00
|
|
|
#define VOTEFLAGS_PRIVATE
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "core/or/or.h"
|
|
|
|
#include "app/config/config.h"
|
2019-10-26 16:09:03 +02:00
|
|
|
#include "lib/confmgt/confmgt.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "core/mainloop/connection.h"
|
|
|
|
#include "core/or/relay.h"
|
2020-10-16 16:03:29 +02:00
|
|
|
#include "core/or/protover.h"
|
2018-10-01 18:22:47 +02:00
|
|
|
#include "core/or/versions.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "feature/client/bridges.h"
|
|
|
|
#include "feature/client/entrynodes.h"
|
2019-03-25 17:48:52 +01:00
|
|
|
#include "feature/control/control_getinfo.h"
|
2018-09-20 14:09:35 +02:00
|
|
|
#include "feature/dirauth/bwauth.h"
|
2019-12-19 16:42:44 +01:00
|
|
|
#include "feature/dirauth/dirauth_sys.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/dirauth/dirvote.h"
|
2018-10-01 07:33:23 +02:00
|
|
|
#include "feature/dirauth/dsigs_parse.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "feature/dirauth/process_descs.h"
|
2018-09-20 14:09:35 +02:00
|
|
|
#include "feature/dirauth/recommend_pkg.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "feature/dirauth/shared_random_state.h"
|
2018-09-20 14:09:35 +02:00
|
|
|
#include "feature/dirauth/voteflags.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "feature/dircache/dircache.h"
|
|
|
|
#include "feature/dircache/dirserv.h"
|
|
|
|
#include "feature/dirclient/dirclient.h"
|
|
|
|
#include "feature/dirclient/dlstatus.h"
|
|
|
|
#include "feature/dircommon/directory.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/dircommon/fp_pair.h"
|
2020-02-24 14:53:54 +01:00
|
|
|
#include "feature/dirauth/voting_schedule.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/hibernate/hibernate.h"
|
2018-09-19 20:10:15 +02:00
|
|
|
#include "feature/nodelist/authcert.h"
|
|
|
|
#include "feature/nodelist/dirlist.h"
|
2019-12-14 19:22:15 +01:00
|
|
|
#include "feature/nodelist/microdesc.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "feature/nodelist/networkstatus.h"
|
|
|
|
#include "feature/nodelist/nickname.h"
|
2018-09-19 20:10:15 +02:00
|
|
|
#include "feature/nodelist/node_select.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/nodelist/routerlist.h"
|
2018-10-01 06:08:25 +02:00
|
|
|
#include "feature/dirparse/authcert_parse.h"
|
2018-10-01 17:44:59 +02:00
|
|
|
#include "feature/dirparse/ns_parse.h"
|
2018-10-01 00:53:58 +02:00
|
|
|
#include "feature/dirparse/routerparse.h"
|
2018-10-01 01:15:00 +02:00
|
|
|
#include "feature/dirparse/unparseable.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/nodelist/routerset.h"
|
|
|
|
#include "feature/nodelist/torcert.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "feature/relay/router.h"
|
|
|
|
#include "feature/relay/routerkeys.h"
|
|
|
|
#include "feature/relay/routermode.h"
|
2018-07-01 17:32:11 +02:00
|
|
|
#include "lib/compress/compress.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "lib/crypt_ops/crypto_ed25519.h"
|
|
|
|
#include "lib/crypt_ops/crypto_format.h"
|
|
|
|
#include "lib/crypt_ops/crypto_rand.h"
|
|
|
|
#include "lib/encoding/confline.h"
|
|
|
|
#include "lib/memarea/memarea.h"
|
|
|
|
#include "lib/osinfo/uname.h"
|
|
|
|
#include "test/log_test_helpers.h"
|
2019-12-19 16:42:44 +01:00
|
|
|
#include "test/opts_test_helpers.h"
|
2018-09-25 23:57:58 +02:00
|
|
|
#include "test/test.h"
|
|
|
|
#include "test/test_dir_common.h"
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "core/or/addr_policy_st.h"
|
2019-12-19 16:42:44 +01:00
|
|
|
#include "feature/dirauth/dirauth_options_st.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/nodelist/authority_cert_st.h"
|
|
|
|
#include "feature/nodelist/document_signature_st.h"
|
|
|
|
#include "feature/nodelist/extrainfo_st.h"
|
2019-12-14 19:22:15 +01:00
|
|
|
#include "feature/nodelist/microdesc_st.h"
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/nodelist/networkstatus_st.h"
|
|
|
|
#include "feature/nodelist/networkstatus_voter_info_st.h"
|
|
|
|
#include "feature/dirauth/ns_detached_signatures_st.h"
|
|
|
|
#include "core/or/port_cfg_st.h"
|
|
|
|
#include "feature/nodelist/routerinfo_st.h"
|
|
|
|
#include "feature/nodelist/routerlist_st.h"
|
|
|
|
#include "core/or/tor_version_st.h"
|
|
|
|
#include "feature/dirauth/vote_microdesc_hash_st.h"
|
|
|
|
#include "feature/nodelist/vote_routerstatus_st.h"
|
2018-06-14 22:41:54 +02:00
|
|
|
|
2018-07-01 21:02:01 +02:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
2018-11-06 15:56:05 +01:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2018-07-01 21:02:01 +02:00
|
|
|
|
2020-10-16 19:57:39 +02:00
|
|
|
static void setup_ei_digests(void);
|
|
|
|
static uint8_t digest_ei_minimal[20];
|
|
|
|
static uint8_t digest_ei_bad_nickname[20];
|
|
|
|
static uint8_t digest_ei_maximal[20];
|
|
|
|
static uint8_t digest_ei_bad_tokens[20];
|
|
|
|
static uint8_t digest_ei_bad_sig2[20];
|
|
|
|
static uint8_t digest_ei_bad_published[20];
|
|
|
|
|
2018-09-11 16:32:17 +02:00
|
|
|
static networkstatus_t *
|
|
|
|
networkstatus_parse_vote_from_string_(const char *s,
|
|
|
|
const char **eos_out,
|
|
|
|
enum networkstatus_type_t ns_type)
|
|
|
|
{
|
|
|
|
size_t len = strlen(s);
|
|
|
|
// memdup so that it won't be nul-terminated.
|
|
|
|
char *tmp = tor_memdup(s, len);
|
|
|
|
networkstatus_t *result =
|
|
|
|
networkstatus_parse_vote_from_string(tmp, len, eos_out, ns_type);
|
|
|
|
if (eos_out && *eos_out) {
|
|
|
|
*eos_out = s + (*eos_out - tmp);
|
|
|
|
}
|
|
|
|
tor_free(tmp);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_nicknames(void *arg)
|
2009-09-22 19:49:09 +02:00
|
|
|
{
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert( is_legal_nickname("a"));
|
|
|
|
tt_assert(!is_legal_nickname(""));
|
|
|
|
tt_assert(!is_legal_nickname("abcdefghijklmnopqrst")); /* 20 chars */
|
|
|
|
tt_assert(!is_legal_nickname("hyphen-")); /* bad char */
|
|
|
|
tt_assert( is_legal_nickname("abcdefghijklmnopqrs")); /* 19 chars */
|
|
|
|
tt_assert(!is_legal_nickname("$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
|
2009-09-22 19:49:09 +02:00
|
|
|
/* valid */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert( is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert( is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA=fred"));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert( is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA~fred"));
|
|
|
|
/* too short */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
|
|
|
|
/* illegal char */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
|
|
|
|
/* hex part too long */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=fred"));
|
|
|
|
/* Bad nickname */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~"));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~hyphen-"));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~"
|
|
|
|
"abcdefghijklmnoppqrst"));
|
|
|
|
/* Bad extra char. */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest(
|
2009-09-22 19:49:09 +02:00
|
|
|
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!"));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(is_legal_nickname_or_hexdigest("xyzzy"));
|
|
|
|
tt_assert(is_legal_nickname_or_hexdigest("abcdefghijklmnopqrs"));
|
|
|
|
tt_assert(!is_legal_nickname_or_hexdigest("abcdefghijklmnopqrst"));
|
2009-09-22 20:02:19 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Allocate and return a new routerinfo, with the fields set from the
|
|
|
|
* arguments to this function.
|
|
|
|
*
|
|
|
|
* Also sets:
|
|
|
|
* - random RSA identity and onion keys,
|
|
|
|
* - the platform field using get_platform_str(), and
|
|
|
|
* - supports_tunnelled_dir_requests to 1.
|
|
|
|
*
|
|
|
|
* If rsa_onion_keypair_out is not NULL, it is set to the onion keypair.
|
|
|
|
* The caller must free this keypair.
|
|
|
|
*/
|
|
|
|
static routerinfo_t *
|
|
|
|
basic_routerinfo_new(const char *nickname, uint32_t ipv4_addr,
|
|
|
|
uint16_t or_port, uint16_t dir_port,
|
|
|
|
uint32_t bandwidthrate, uint32_t bandwidthburst,
|
|
|
|
uint32_t bandwidthcapacity,
|
|
|
|
time_t published_on,
|
|
|
|
crypto_pk_t **rsa_onion_keypair_out)
|
|
|
|
{
|
|
|
|
char platform[256];
|
|
|
|
|
|
|
|
tor_assert(nickname);
|
|
|
|
|
|
|
|
crypto_pk_t *pk1 = NULL, *pk2 = NULL;
|
|
|
|
/* These keys are random: idx is ignored. */
|
|
|
|
pk1 = pk_generate(0);
|
|
|
|
pk2 = pk_generate(1);
|
|
|
|
|
|
|
|
tor_assert(pk1);
|
|
|
|
tor_assert(pk2);
|
|
|
|
|
|
|
|
get_platform_str(platform, sizeof(platform));
|
|
|
|
|
|
|
|
routerinfo_t *r1 = tor_malloc_zero(sizeof(routerinfo_t));
|
|
|
|
|
|
|
|
r1->nickname = tor_strdup(nickname);
|
|
|
|
r1->platform = tor_strdup(platform);
|
|
|
|
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&r1->ipv4_addr, ipv4_addr);
|
|
|
|
r1->ipv4_orport = or_port;
|
|
|
|
r1->ipv4_dirport = dir_port;
|
2019-02-19 02:19:44 +01:00
|
|
|
r1->supports_tunnelled_dir_requests = 1;
|
|
|
|
|
|
|
|
router_set_rsa_onion_pkey(pk1, &r1->onion_pkey, &r1->onion_pkey_len);
|
|
|
|
r1->identity_pkey = pk2;
|
|
|
|
|
|
|
|
r1->bandwidthrate = bandwidthrate;
|
|
|
|
r1->bandwidthburst = bandwidthburst;
|
|
|
|
r1->bandwidthcapacity = bandwidthcapacity;
|
|
|
|
|
|
|
|
r1->cache_info.published_on = published_on;
|
2020-10-16 16:03:29 +02:00
|
|
|
r1->protocol_list = tor_strdup(protover_get_supported_protocols());
|
2019-02-19 02:19:44 +01:00
|
|
|
|
|
|
|
if (rsa_onion_keypair_out) {
|
|
|
|
*rsa_onion_keypair_out = pk1;
|
|
|
|
} else {
|
|
|
|
crypto_pk_free(pk1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return r1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing a "router" line for r1. */
|
|
|
|
static char *
|
|
|
|
get_new_router_line(const routerinfo_t *r1)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
tor_assert(r1);
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
|
|
|
"router %s %s %d 0 %d\n",
|
2020-07-13 20:07:37 +02:00
|
|
|
r1->nickname, fmt_addr(&r1->ipv4_addr),
|
|
|
|
r1->ipv4_orport, r1->ipv4_dirport);
|
2019-02-19 02:19:44 +01:00
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing a "platform" line for the
|
|
|
|
* current Tor version and OS. */
|
|
|
|
static char *
|
|
|
|
get_new_platform_line(void)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
|
|
|
"platform Tor %s on %s\n",
|
|
|
|
VERSION, get_uname());
|
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing a "published" line for r1.
|
|
|
|
* r1->cache_info.published_on must be between 0 and 59 seconds. */
|
|
|
|
static char *
|
|
|
|
get_new_published_line(const routerinfo_t *r1)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
tor_assert(r1);
|
|
|
|
|
|
|
|
tor_assert(r1->cache_info.published_on >= 0);
|
|
|
|
tor_assert(r1->cache_info.published_on <= 59);
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
|
|
|
"published 1970-01-01 00:00:%02u\n",
|
|
|
|
(unsigned)r1->cache_info.published_on);
|
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing a "fingerprint" line for r1. */
|
|
|
|
static char *
|
|
|
|
get_new_fingerprint_line(const routerinfo_t *r1)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
char fingerprint[FINGERPRINT_LEN+1];
|
|
|
|
|
|
|
|
tor_assert(r1);
|
|
|
|
|
|
|
|
tor_assert(!crypto_pk_get_fingerprint(r1->identity_pkey, fingerprint, 1));
|
|
|
|
tor_assert(strlen(fingerprint) > 0);
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
|
|
|
"fingerprint %s\n",
|
|
|
|
fingerprint);
|
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing an "uptime" line with uptime t.
|
|
|
|
*
|
|
|
|
* You should pass a hard-coded value to this function, because even if we made
|
|
|
|
* it reflect uptime, that still wouldn't make it right, because the two
|
|
|
|
* descriptors might be made on different seconds.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_uptime_line(time_t t)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
|
|
|
"uptime %u\n",
|
|
|
|
(unsigned)t);
|
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing an "bandwidth" line for r1.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_bandwidth_line(const routerinfo_t *r1)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
tor_assert(r1);
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
|
|
|
"bandwidth %u %u %u\n",
|
|
|
|
r1->bandwidthrate,
|
|
|
|
r1->bandwidthburst,
|
|
|
|
r1->bandwidthcapacity);
|
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing a key_name block for the
|
|
|
|
* RSA key pk1.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_rsa_key_block(const char *key_name, crypto_pk_t *pk1)
|
|
|
|
{
|
|
|
|
char *block = NULL;
|
|
|
|
char *pk1_str = NULL;
|
|
|
|
size_t pk1_str_len = 0;
|
|
|
|
|
|
|
|
tor_assert(key_name);
|
|
|
|
tor_assert(pk1);
|
|
|
|
|
|
|
|
tor_assert(!crypto_pk_write_public_key_to_string(pk1, &pk1_str,
|
|
|
|
&pk1_str_len));
|
|
|
|
tor_assert(pk1_str);
|
|
|
|
tor_assert(pk1_str_len);
|
|
|
|
|
|
|
|
tor_asprintf(&block,
|
|
|
|
"%s\n%s",
|
|
|
|
key_name,
|
|
|
|
pk1_str);
|
2019-02-19 15:40:18 +01:00
|
|
|
tor_free(pk1_str);
|
2019-02-19 02:19:44 +01:00
|
|
|
|
2019-02-19 15:40:18 +01:00
|
|
|
tor_assert(block);
|
2019-02-19 02:19:44 +01:00
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing an "onion-key" block for the
|
|
|
|
* router r1.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_onion_key_block(const routerinfo_t *r1)
|
|
|
|
{
|
|
|
|
char *block = NULL;
|
|
|
|
tor_assert(r1);
|
|
|
|
crypto_pk_t *pk_tmp = router_get_rsa_onion_pkey(r1->onion_pkey,
|
|
|
|
r1->onion_pkey_len);
|
|
|
|
block = get_new_rsa_key_block("onion-key", pk_tmp);
|
|
|
|
crypto_pk_free(pk_tmp);
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing an "signing-key" block for the
|
|
|
|
* router r1.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_signing_key_block(const routerinfo_t *r1)
|
|
|
|
{
|
|
|
|
tor_assert(r1);
|
|
|
|
return get_new_rsa_key_block("signing-key", r1->identity_pkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and return a new string containing an "ntor-onion-key" line for
|
|
|
|
* the curve25519 public key ntor_onion_pubkey.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_ntor_onion_key_line(const curve25519_public_key_t *ntor_onion_pubkey)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
char cert_buf[256];
|
|
|
|
|
|
|
|
tor_assert(ntor_onion_pubkey);
|
|
|
|
|
2020-06-06 12:34:47 +02:00
|
|
|
curve25519_public_to_base64(cert_buf, ntor_onion_pubkey, false);
|
2019-02-19 02:19:44 +01:00
|
|
|
tor_assert(strlen(cert_buf) > 0);
|
|
|
|
|
|
|
|
tor_asprintf(&line,
|
2020-06-06 12:34:47 +02:00
|
|
|
"ntor-onion-key %s\n",
|
2019-02-19 02:19:44 +01:00
|
|
|
cert_buf);
|
|
|
|
tor_assert(line);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
2019-02-19 06:56:09 +01:00
|
|
|
/* Allocate and return a new string containing a "bridge-distribution-request"
|
|
|
|
* line for options.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
get_new_bridge_distribution_request_line(const or_options_t *options)
|
|
|
|
{
|
|
|
|
if (options->BridgeRelay) {
|
|
|
|
return tor_strdup("bridge-distribution-request any\n");
|
|
|
|
} else {
|
|
|
|
return tor_strdup("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-20 09:30:55 +02:00
|
|
|
static smartlist_t *mocked_configured_ports = NULL;
|
|
|
|
|
|
|
|
/** Returns mocked_configured_ports */
|
|
|
|
static const smartlist_t *
|
|
|
|
mock_get_configured_ports(void)
|
|
|
|
{
|
|
|
|
return mocked_configured_ports;
|
|
|
|
}
|
|
|
|
|
2019-02-18 06:24:26 +01:00
|
|
|
static crypto_pk_t *mocked_server_identitykey = NULL;
|
|
|
|
|
|
|
|
/* Returns mocked_server_identitykey with no checks. */
|
|
|
|
static crypto_pk_t *
|
|
|
|
mock_get_server_identity_key(void)
|
|
|
|
{
|
|
|
|
return mocked_server_identitykey;
|
|
|
|
}
|
|
|
|
|
|
|
|
static crypto_pk_t *mocked_onionkey = NULL;
|
|
|
|
|
|
|
|
/* Returns mocked_onionkey with no checks. */
|
|
|
|
static crypto_pk_t *
|
|
|
|
mock_get_onion_key(void)
|
|
|
|
{
|
|
|
|
return mocked_onionkey;
|
|
|
|
}
|
|
|
|
|
2019-02-18 08:37:47 +01:00
|
|
|
static routerinfo_t *mocked_routerinfo = NULL;
|
|
|
|
|
|
|
|
/* Returns 0 and sets ri_out to mocked_routerinfo.
|
|
|
|
* ri_out must not be NULL. There are no other checks. */
|
|
|
|
static int
|
|
|
|
mock_router_build_fresh_unsigned_routerinfo(routerinfo_t **ri_out)
|
|
|
|
{
|
|
|
|
tor_assert(ri_out);
|
|
|
|
*ri_out = mocked_routerinfo;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ed25519_keypair_t *mocked_master_signing_key = NULL;
|
|
|
|
|
|
|
|
/* Returns mocked_master_signing_key with no checks. */
|
|
|
|
static const ed25519_keypair_t *
|
|
|
|
mock_get_master_signing_keypair(void)
|
|
|
|
{
|
|
|
|
return mocked_master_signing_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct tor_cert_st *mocked_signing_key_cert = NULL;
|
|
|
|
|
|
|
|
/* Returns mocked_signing_key_cert with no checks. */
|
|
|
|
static const struct tor_cert_st *
|
|
|
|
mock_get_master_signing_key_cert(void)
|
|
|
|
{
|
|
|
|
return mocked_signing_key_cert;
|
|
|
|
}
|
|
|
|
|
|
|
|
static curve25519_keypair_t *mocked_curve25519_onion_key = NULL;
|
|
|
|
|
|
|
|
/* Returns mocked_curve25519_onion_key with no checks. */
|
|
|
|
static const curve25519_keypair_t *
|
|
|
|
mock_get_current_curve25519_keypair(void)
|
|
|
|
{
|
|
|
|
return mocked_curve25519_onion_key;
|
|
|
|
}
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Unmock get_configured_ports() and free mocked_configured_ports. */
|
|
|
|
static void
|
|
|
|
cleanup_mock_configured_ports(void)
|
|
|
|
{
|
|
|
|
UNMOCK(get_configured_ports);
|
|
|
|
|
|
|
|
if (mocked_configured_ports) {
|
|
|
|
SMARTLIST_FOREACH(mocked_configured_ports, port_cfg_t *, p, tor_free(p));
|
|
|
|
smartlist_free(mocked_configured_ports);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mock get_configured_ports() with a list containing or_port and dir_port.
|
|
|
|
* If a port is 0, don't set it.
|
|
|
|
* Only sets the minimal data required for the tests to pass. */
|
|
|
|
static void
|
|
|
|
setup_mock_configured_ports(uint16_t or_port, uint16_t dir_port)
|
|
|
|
{
|
|
|
|
cleanup_mock_configured_ports();
|
|
|
|
|
|
|
|
/* Fake just enough of an ORPort and DirPort to get by */
|
|
|
|
MOCK(get_configured_ports, mock_get_configured_ports);
|
|
|
|
mocked_configured_ports = smartlist_new();
|
|
|
|
|
|
|
|
if (or_port) {
|
|
|
|
port_cfg_t *or_port_cfg = tor_malloc_zero(sizeof(*or_port_cfg));
|
|
|
|
or_port_cfg->type = CONN_TYPE_OR_LISTENER;
|
|
|
|
or_port_cfg->addr.family = AF_INET;
|
|
|
|
or_port_cfg->port = or_port;
|
|
|
|
smartlist_add(mocked_configured_ports, or_port_cfg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir_port) {
|
|
|
|
port_cfg_t *dir_port_cfg = tor_malloc_zero(sizeof(*dir_port_cfg));
|
|
|
|
dir_port_cfg->type = CONN_TYPE_DIR_LISTENER;
|
|
|
|
dir_port_cfg->addr.family = AF_INET;
|
|
|
|
dir_port_cfg->port = dir_port;
|
|
|
|
smartlist_add(mocked_configured_ports, dir_port_cfg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up the data structures and unmock the functions needed for generating
|
|
|
|
* a fresh descriptor. */
|
|
|
|
static void
|
|
|
|
cleanup_mocks_for_fresh_descriptor(void)
|
|
|
|
{
|
|
|
|
tor_free(get_options_mutable()->Nickname);
|
|
|
|
|
|
|
|
mocked_server_identitykey = NULL;
|
|
|
|
UNMOCK(get_server_identity_key);
|
|
|
|
|
|
|
|
crypto_pk_free(mocked_onionkey);
|
|
|
|
UNMOCK(get_onion_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mock the data structures and functions needed for generating a fresh
|
|
|
|
* descriptor.
|
|
|
|
*
|
|
|
|
* Sets options->Nickname from r1->nickname.
|
|
|
|
* Mocks get_server_identity_key() with r1->identity_pkey.
|
|
|
|
*
|
|
|
|
* If rsa_onion_keypair is not NULL, it is used to mock get_onion_key().
|
|
|
|
* Otherwise, the public key in r1->onion_pkey is used to mock get_onion_key().
|
|
|
|
*/
|
2009-09-22 20:02:19 +02:00
|
|
|
static void
|
2019-02-19 02:19:44 +01:00
|
|
|
setup_mocks_for_fresh_descriptor(const routerinfo_t *r1,
|
|
|
|
crypto_pk_t *rsa_onion_keypair)
|
|
|
|
{
|
|
|
|
cleanup_mocks_for_fresh_descriptor();
|
|
|
|
|
|
|
|
tor_assert(r1);
|
|
|
|
|
|
|
|
/* router_build_fresh_signed_extrainfo() requires options->Nickname */
|
|
|
|
get_options_mutable()->Nickname = tor_strdup(r1->nickname);
|
|
|
|
|
|
|
|
/* router_build_fresh_signed_extrainfo() requires get_server_identity_key().
|
|
|
|
* Use the same one as the call to router_dump_router_to_string() above.
|
|
|
|
*/
|
|
|
|
mocked_server_identitykey = r1->identity_pkey;
|
|
|
|
MOCK(get_server_identity_key, mock_get_server_identity_key);
|
|
|
|
|
|
|
|
/* router_dump_and_sign_routerinfo_descriptor_body() requires
|
|
|
|
* get_onion_key(). Use the same one as r1.
|
|
|
|
*/
|
|
|
|
if (rsa_onion_keypair) {
|
|
|
|
mocked_onionkey = crypto_pk_dup_key(rsa_onion_keypair);
|
|
|
|
} else {
|
|
|
|
mocked_onionkey = router_get_rsa_onion_pkey(r1->onion_pkey,
|
|
|
|
r1->onion_pkey_len);
|
|
|
|
}
|
|
|
|
MOCK(get_onion_key, mock_get_onion_key);
|
|
|
|
}
|
|
|
|
|
2019-02-19 06:56:09 +01:00
|
|
|
/* Set options based on arg.
|
|
|
|
*
|
|
|
|
* b: BridgeRelay 1
|
|
|
|
* e: ExtraInfoStatistics 1
|
|
|
|
* s: sets all the individual statistics options to 1
|
|
|
|
*
|
|
|
|
* Always sets AssumeReachable to 1.
|
|
|
|
*
|
|
|
|
* Does not set ServerTransportPlugin, because it's parsed before use.
|
|
|
|
*
|
|
|
|
* Does not set BridgeRecordUsageByCountry, because the tests don't have access
|
|
|
|
* to a GeoIPFile or GeoIPv6File. */
|
|
|
|
static void
|
|
|
|
setup_dir_formats_options(const char *arg, or_options_t *options)
|
|
|
|
{
|
|
|
|
/* Skip reachability checks for DirPort, ORPort, and tunnelled-dir-server */
|
|
|
|
options->AssumeReachable = 1;
|
|
|
|
|
|
|
|
if (strchr(arg, 'b')) {
|
|
|
|
options->BridgeRelay = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr(arg, 'e')) {
|
|
|
|
options->ExtraInfoStatistics = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr(arg, 's')) {
|
|
|
|
options->DirReqStatistics = 1;
|
|
|
|
options->HiddenServiceStatistics = 1;
|
|
|
|
options->EntryStatistics = 1;
|
|
|
|
options->CellStatistics = 1;
|
|
|
|
options->ExitPortStatistics = 1;
|
|
|
|
options->ConnDirectionStatistics = 1;
|
|
|
|
options->PaddingStatistics = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Check that routerinfos r1 and rp1 are consistent.
|
|
|
|
* Only performs some basic checks.
|
|
|
|
*/
|
|
|
|
#define CHECK_ROUTERINFO_CONSISTENCY(r1, rp1) \
|
|
|
|
STMT_BEGIN \
|
|
|
|
tt_assert(r1); \
|
|
|
|
tt_assert(rp1); \
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq(&rp1->ipv4_addr, &r1->ipv4_addr)); \
|
|
|
|
tt_int_op(rp1->ipv4_orport,OP_EQ, r1->ipv4_orport); \
|
|
|
|
tt_int_op(rp1->ipv4_dirport,OP_EQ, r1->ipv4_dirport); \
|
2019-02-19 02:19:44 +01:00
|
|
|
tt_int_op(rp1->bandwidthrate,OP_EQ, r1->bandwidthrate); \
|
|
|
|
tt_int_op(rp1->bandwidthburst,OP_EQ, r1->bandwidthburst); \
|
|
|
|
tt_int_op(rp1->bandwidthcapacity,OP_EQ, r1->bandwidthcapacity); \
|
|
|
|
crypto_pk_t *rp1_onion_pkey = router_get_rsa_onion_pkey(rp1->onion_pkey, \
|
|
|
|
rp1->onion_pkey_len); \
|
|
|
|
crypto_pk_t *r1_onion_pkey = router_get_rsa_onion_pkey(r1->onion_pkey, \
|
|
|
|
r1->onion_pkey_len); \
|
|
|
|
tt_int_op(crypto_pk_cmp_keys(rp1_onion_pkey, r1_onion_pkey), OP_EQ, 0); \
|
|
|
|
crypto_pk_free(rp1_onion_pkey); \
|
|
|
|
crypto_pk_free(r1_onion_pkey); \
|
|
|
|
tt_int_op(crypto_pk_cmp_keys(rp1->identity_pkey, r1->identity_pkey), \
|
|
|
|
OP_EQ, 0); \
|
|
|
|
tt_int_op(rp1->supports_tunnelled_dir_requests, OP_EQ, \
|
|
|
|
r1->supports_tunnelled_dir_requests); \
|
|
|
|
STMT_END
|
|
|
|
|
|
|
|
/* Check that routerinfo r1 and extrainfo e1 are consistent.
|
|
|
|
* Only performs some basic checks.
|
|
|
|
*/
|
|
|
|
#define CHECK_EXTRAINFO_CONSISTENCY(r1, e1) \
|
|
|
|
STMT_BEGIN \
|
|
|
|
tt_assert(r1); \
|
|
|
|
tt_assert(e1); \
|
|
|
|
\
|
|
|
|
tt_str_op(e1->nickname, OP_EQ, r1->nickname); \
|
|
|
|
STMT_END
|
|
|
|
|
|
|
|
/* Check that the exit policy in rp2 is as expected. */
|
|
|
|
#define CHECK_PARSED_EXIT_POLICY(rp2) \
|
|
|
|
STMT_BEGIN \
|
|
|
|
tt_int_op(smartlist_len(rp2->exit_policy),OP_EQ, 2); \
|
|
|
|
\
|
|
|
|
p = smartlist_get(rp2->exit_policy, 0); \
|
|
|
|
tt_int_op(p->policy_type,OP_EQ, ADDR_POLICY_ACCEPT); \
|
|
|
|
tt_assert(tor_addr_is_null(&p->addr)); \
|
|
|
|
tt_int_op(p->maskbits,OP_EQ, 0); \
|
|
|
|
tt_int_op(p->prt_min,OP_EQ, 80); \
|
|
|
|
tt_int_op(p->prt_max,OP_EQ, 80); \
|
|
|
|
\
|
|
|
|
p = smartlist_get(rp2->exit_policy, 1); \
|
|
|
|
tt_int_op(p->policy_type,OP_EQ, ADDR_POLICY_REJECT); \
|
|
|
|
tt_assert(tor_addr_eq(&p->addr, &ex2->addr)); \
|
|
|
|
tt_int_op(p->maskbits,OP_EQ, 8); \
|
|
|
|
tt_int_op(p->prt_min,OP_EQ, 24); \
|
|
|
|
tt_int_op(p->prt_max,OP_EQ, 24); \
|
|
|
|
STMT_END
|
|
|
|
|
2019-02-18 08:03:33 +01:00
|
|
|
/** Run unit tests for router descriptor generation logic for a RSA + ed25519
|
|
|
|
* router.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_dir_formats_rsa_ed25519(void *arg)
|
|
|
|
{
|
|
|
|
char *buf = NULL;
|
2019-02-19 02:19:44 +01:00
|
|
|
char *buf2 = NULL;
|
|
|
|
char *cp = NULL;
|
|
|
|
|
|
|
|
crypto_pk_t *r2_onion_pkey = NULL;
|
|
|
|
char cert_buf[256];
|
|
|
|
uint8_t *rsa_cc = NULL;
|
|
|
|
time_t now = time(NULL);
|
|
|
|
|
2019-02-18 08:03:33 +01:00
|
|
|
routerinfo_t *r2 = NULL;
|
|
|
|
extrainfo_t *e2 = NULL;
|
|
|
|
routerinfo_t *r2_out = NULL;
|
|
|
|
routerinfo_t *rp2 = NULL;
|
|
|
|
extrainfo_t *ep2 = NULL;
|
|
|
|
addr_policy_t *ex1, *ex2;
|
|
|
|
const addr_policy_t *p;
|
2019-02-19 02:19:44 +01:00
|
|
|
|
|
|
|
smartlist_t *chunks = NULL;
|
2019-02-18 08:37:47 +01:00
|
|
|
int rv = -1;
|
2019-02-18 08:03:33 +01:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
or_options_t *options = get_options_mutable();
|
2019-02-19 06:56:09 +01:00
|
|
|
setup_dir_formats_options((const char *)arg, options);
|
2019-02-18 08:03:33 +01:00
|
|
|
|
|
|
|
hibernate_set_state_for_testing_(HIBERNATE_STATE_LIVE);
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* r2 is a RSA + ed25519 descriptor, with an exit policy, but no DirPort or
|
|
|
|
* IPv6 */
|
|
|
|
r2 = basic_routerinfo_new("Fred", 0x0a030201u /* 10.3.2.1 */,
|
|
|
|
9005, 0,
|
|
|
|
3000, 3000, 3000,
|
|
|
|
5,
|
|
|
|
&r2_onion_pkey);
|
2019-02-18 08:37:47 +01:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Fake just enough of an ntor key to get by */
|
|
|
|
curve25519_keypair_t r2_onion_keypair;
|
|
|
|
curve25519_keypair_generate(&r2_onion_keypair, 0);
|
|
|
|
r2->onion_curve25519_pkey = tor_memdup(&r2_onion_keypair.pubkey,
|
|
|
|
sizeof(curve25519_public_key_t));
|
2019-02-18 08:37:47 +01:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Now add relay ed25519 keys
|
|
|
|
* We can't use init_mock_ed_keys() here, because the keys are seeded */
|
2014-10-01 05:36:47 +02:00
|
|
|
ed25519_keypair_t kp1, kp2;
|
|
|
|
ed25519_secret_key_from_seed(&kp1.seckey,
|
|
|
|
(const uint8_t*)"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY");
|
|
|
|
ed25519_public_key_generate(&kp1.pubkey, &kp1.seckey);
|
|
|
|
ed25519_secret_key_from_seed(&kp2.seckey,
|
|
|
|
(const uint8_t*)"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
|
|
|
|
ed25519_public_key_generate(&kp2.pubkey, &kp2.seckey);
|
2020-09-17 14:17:36 +02:00
|
|
|
r2->cache_info.signing_key_cert = tor_cert_create_ed25519(&kp1,
|
2014-10-01 05:36:47 +02:00
|
|
|
CERT_TYPE_ID_SIGNING,
|
|
|
|
&kp2.pubkey,
|
|
|
|
now, 86400,
|
|
|
|
CERT_FLAG_INCLUDE_SIGNING_KEY);
|
2019-02-19 02:19:44 +01:00
|
|
|
|
|
|
|
/* Now add an exit policy */
|
|
|
|
ex1 = tor_malloc_zero(sizeof(addr_policy_t));
|
|
|
|
ex2 = tor_malloc_zero(sizeof(addr_policy_t));
|
|
|
|
ex1->policy_type = ADDR_POLICY_ACCEPT;
|
|
|
|
tor_addr_from_ipv4h(&ex1->addr, 0);
|
|
|
|
ex1->maskbits = 0;
|
|
|
|
ex1->prt_min = ex1->prt_max = 80;
|
|
|
|
ex2->policy_type = ADDR_POLICY_REJECT;
|
|
|
|
tor_addr_from_ipv4h(&ex2->addr, 18<<24);
|
|
|
|
ex2->maskbits = 8;
|
|
|
|
ex2->prt_min = ex2->prt_max = 24;
|
|
|
|
|
2012-01-18 21:53:30 +01:00
|
|
|
r2->exit_policy = smartlist_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_add(r2->exit_policy, ex1);
|
2013-04-02 20:45:13 +02:00
|
|
|
smartlist_add(r2->exit_policy, ex2);
|
2014-10-28 23:01:06 +01:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Fake just enough of an ORPort to get by */
|
2020-07-13 20:07:37 +02:00
|
|
|
setup_mock_configured_ports(r2->ipv4_orport, 0);
|
2016-04-20 09:30:55 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
buf = router_dump_router_to_string(r2,
|
|
|
|
r2->identity_pkey, r2_onion_pkey,
|
|
|
|
&r2_onion_keypair, &kp2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(buf);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
cleanup_mock_configured_ports();
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
chunks = smartlist_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Synthesise a router descriptor, without the signatures */
|
|
|
|
smartlist_add(chunks, get_new_router_line(r2));
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_strdup(chunks,
|
|
|
|
"identity-ed25519\n"
|
|
|
|
"-----BEGIN ED25519 CERT-----\n");
|
2016-07-06 09:15:48 +02:00
|
|
|
base64_encode(cert_buf, sizeof(cert_buf),
|
|
|
|
(const char*)r2->cache_info.signing_key_cert->encoded,
|
|
|
|
r2->cache_info.signing_key_cert->encoded_len,
|
|
|
|
BASE64_ENCODE_MULTILINE);
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_strdup(chunks, cert_buf);
|
|
|
|
smartlist_add_strdup(chunks, "-----END ED25519 CERT-----\n");
|
|
|
|
|
|
|
|
smartlist_add_strdup(chunks, "master-key-ed25519 ");
|
2015-06-01 17:24:55 +02:00
|
|
|
{
|
|
|
|
char k[ED25519_BASE64_LEN+1];
|
2019-04-05 07:02:43 +02:00
|
|
|
ed25519_public_to_base64(k, &r2->cache_info.signing_key_cert->signing_key);
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_strdup(chunks, k);
|
|
|
|
smartlist_add_strdup(chunks, "\n");
|
2015-06-01 17:24:55 +02:00
|
|
|
}
|
2019-02-19 02:19:44 +01:00
|
|
|
|
|
|
|
smartlist_add(chunks, get_new_platform_line());
|
2020-10-16 16:03:29 +02:00
|
|
|
smartlist_add_asprintf(chunks,
|
|
|
|
"proto %s\n", protover_get_supported_protocols());
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add(chunks, get_new_published_line(r2));
|
|
|
|
smartlist_add(chunks, get_new_fingerprint_line(r2));
|
|
|
|
|
|
|
|
smartlist_add(chunks, get_new_uptime_line(0));
|
|
|
|
smartlist_add(chunks, get_new_bandwidth_line(r2));
|
|
|
|
|
|
|
|
smartlist_add(chunks, get_new_onion_key_block(r2));
|
|
|
|
smartlist_add(chunks, get_new_signing_key_block(r2));
|
|
|
|
|
2014-10-01 17:54:07 +02:00
|
|
|
int rsa_cc_len;
|
2019-02-19 02:19:44 +01:00
|
|
|
rsa_cc = make_tap_onion_key_crosscert(r2_onion_pkey,
|
2014-10-01 17:54:07 +02:00
|
|
|
&kp1.pubkey,
|
2019-02-19 02:19:44 +01:00
|
|
|
r2->identity_pkey,
|
2014-10-01 17:54:07 +02:00
|
|
|
&rsa_cc_len);
|
|
|
|
tt_assert(rsa_cc);
|
2015-05-28 17:04:33 +02:00
|
|
|
base64_encode(cert_buf, sizeof(cert_buf), (char*)rsa_cc, rsa_cc_len,
|
|
|
|
BASE64_ENCODE_MULTILINE);
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_strdup(chunks, "onion-key-crosscert\n"
|
|
|
|
"-----BEGIN CROSSCERT-----\n");
|
|
|
|
smartlist_add_strdup(chunks, cert_buf);
|
|
|
|
smartlist_add_strdup(chunks, "-----END CROSSCERT-----\n");
|
2014-10-01 17:54:07 +02:00
|
|
|
int ntor_cc_sign;
|
2015-06-01 16:26:11 +02:00
|
|
|
{
|
|
|
|
tor_cert_t *ntor_cc = NULL;
|
|
|
|
ntor_cc = make_ntor_onion_key_crosscert(&r2_onion_keypair,
|
2014-10-01 17:54:07 +02:00
|
|
|
&kp1.pubkey,
|
|
|
|
r2->cache_info.published_on,
|
2017-03-10 12:18:52 +01:00
|
|
|
get_onion_key_lifetime(),
|
2014-10-01 17:54:07 +02:00
|
|
|
&ntor_cc_sign);
|
2015-06-01 16:26:11 +02:00
|
|
|
tt_assert(ntor_cc);
|
|
|
|
base64_encode(cert_buf, sizeof(cert_buf),
|
2015-05-28 17:04:33 +02:00
|
|
|
(char*)ntor_cc->encoded, ntor_cc->encoded_len,
|
|
|
|
BASE64_ENCODE_MULTILINE);
|
2015-06-01 16:26:11 +02:00
|
|
|
tor_cert_free(ntor_cc);
|
|
|
|
}
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_asprintf(chunks,
|
2014-10-01 17:54:07 +02:00
|
|
|
"ntor-onion-key-crosscert %d\n"
|
|
|
|
"-----BEGIN ED25519 CERT-----\n"
|
|
|
|
"%s"
|
|
|
|
"-----END ED25519 CERT-----\n", ntor_cc_sign, cert_buf);
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_strdup(chunks, "hidden-service-dir\n");
|
2013-04-02 20:45:13 +02:00
|
|
|
|
2019-02-19 06:56:09 +01:00
|
|
|
smartlist_add(chunks, get_new_bridge_distribution_request_line(options));
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add(chunks, get_new_ntor_onion_key_line(&r2_onion_keypair.pubkey));
|
|
|
|
smartlist_add_strdup(chunks, "accept *:80\nreject 18.0.0.0/8:24\n");
|
|
|
|
smartlist_add_strdup(chunks, "tunnelled-dir-server\n");
|
2016-04-20 09:30:55 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
smartlist_add_strdup(chunks, "router-sig-ed25519 ");
|
2016-04-20 09:30:55 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
size_t len_out = 0;
|
|
|
|
buf2 = smartlist_join_strings(chunks, "", 0, &len_out);
|
|
|
|
SMARTLIST_FOREACH(chunks, char *, s, tor_free(s));
|
|
|
|
smartlist_free(chunks);
|
2016-04-20 09:30:55 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
tt_assert(len_out > 0);
|
|
|
|
|
|
|
|
buf[strlen(buf2)] = '\0'; /* Don't compare either sig; they're never the same
|
2013-04-02 20:45:13 +02:00
|
|
|
* twice */
|
2014-10-01 17:54:07 +02:00
|
|
|
|
|
|
|
tt_str_op(buf, OP_EQ, buf2);
|
2013-04-02 20:45:13 +02:00
|
|
|
tor_free(buf);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2020-07-13 20:07:37 +02:00
|
|
|
setup_mock_configured_ports(r2->ipv4_orport, 0);
|
2014-10-28 23:01:06 +01:00
|
|
|
|
2020-10-16 16:03:29 +02:00
|
|
|
buf = router_dump_router_to_string(r2, r2->identity_pkey,
|
|
|
|
r2_onion_pkey,
|
|
|
|
&r2_onion_keypair, &kp2);
|
2019-02-19 02:19:44 +01:00
|
|
|
tt_assert(buf);
|
2016-04-20 09:30:55 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
cleanup_mock_configured_ports();
|
|
|
|
|
|
|
|
/* Now, try to parse buf */
|
2009-09-22 19:49:09 +02:00
|
|
|
cp = buf;
|
Treat unparseable (micro)descriptors and extrainfos as undownloadable
One pain point in evolving the Tor design and implementing has been
adding code that makes clients reject directory documents that they
previously would have accepted, if those descriptors actually exist.
When this happened, the clients would get the document, reject it,
and then decide to try downloading it again, ad infinitum. This
problem becomes particularly obnoxious with authorities, since if
some authorities accept a descriptor that others don't, the ones
that don't accept it would go crazy trying to re-fetch it over and
over. (See for example ticket #9286.)
This patch tries to solve this problem by tracking, if a descriptor
isn't parseable, what its digest was, and whether it is invalid
because of some flaw that applies to the portion containing the
digest. (This excludes RSA signature problems: RSA signatures
aren't included in the digest. This means that a directory
authority can still put another directory authority into a loop by
mentioning a descriptor, and then serving that descriptor with an
invalid RSA signatures. But that would also make the misbehaving
directory authority get DoSed by the server it's attacking, so it's
not much of an issue.)
We already have a mechanism to mark something undownloadable with
downloadstatus_mark_impossible(); we use that here for
microdescriptors, extrainfos, and router descriptors.
Unit tests to follow in another patch.
Closes ticket #11243.
2014-10-03 16:55:50 +02:00
|
|
|
rp2 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL,NULL);
|
2019-02-19 02:19:44 +01:00
|
|
|
|
|
|
|
CHECK_ROUTERINFO_CONSISTENCY(r2, rp2);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rp2->onion_curve25519_pkey->public_key,OP_EQ,
|
2013-04-02 20:54:54 +02:00
|
|
|
r2->onion_curve25519_pkey->public_key,
|
|
|
|
CURVE25519_PUBKEY_LEN);
|
2013-04-02 20:45:13 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
CHECK_PARSED_EXIT_POLICY(rp2);
|
|
|
|
|
|
|
|
tor_free(buf);
|
2019-02-18 08:37:47 +01:00
|
|
|
routerinfo_free(rp2);
|
|
|
|
|
|
|
|
/* Test extrainfo creation. */
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* Set up standard mocks and data */
|
|
|
|
setup_mocks_for_fresh_descriptor(r2, r2_onion_pkey);
|
|
|
|
|
2019-02-18 08:37:47 +01:00
|
|
|
/* router_build_fresh_descriptor() requires
|
|
|
|
* router_build_fresh_unsigned_routerinfo(), but the implementation is
|
|
|
|
* too complex. Instead, we re-use r2.
|
|
|
|
*/
|
|
|
|
mocked_routerinfo = r2;
|
|
|
|
MOCK(router_build_fresh_unsigned_routerinfo,
|
|
|
|
mock_router_build_fresh_unsigned_routerinfo);
|
|
|
|
|
|
|
|
/* r2 uses ed25519, so we need to mock the ed key functions */
|
|
|
|
mocked_master_signing_key = &kp2;
|
|
|
|
MOCK(get_master_signing_keypair, mock_get_master_signing_keypair);
|
|
|
|
|
|
|
|
mocked_signing_key_cert = r2->cache_info.signing_key_cert;
|
|
|
|
MOCK(get_master_signing_key_cert, mock_get_master_signing_key_cert);
|
|
|
|
|
|
|
|
mocked_curve25519_onion_key = &r2_onion_keypair;
|
|
|
|
MOCK(get_current_curve25519_keypair, mock_get_current_curve25519_keypair);
|
|
|
|
|
|
|
|
/* Fake just enough of an ORPort to get by */
|
2020-07-13 20:07:37 +02:00
|
|
|
setup_mock_configured_ports(r2->ipv4_orport, 0);
|
2019-02-18 08:37:47 +01:00
|
|
|
|
|
|
|
/* Test the high-level interface. */
|
|
|
|
rv = router_build_fresh_descriptor(&r2_out, &e2);
|
|
|
|
if (rv < 0) {
|
|
|
|
/* router_build_fresh_descriptor() frees r2 on failure. */
|
|
|
|
r2 = NULL;
|
|
|
|
/* Get rid of an alias to rp2 */
|
|
|
|
r2_out = NULL;
|
2009-09-22 19:49:09 +02:00
|
|
|
}
|
2019-02-18 08:37:47 +01:00
|
|
|
tt_assert(rv == 0);
|
|
|
|
tt_assert(r2_out);
|
|
|
|
tt_assert(e2);
|
|
|
|
/* Guaranteed by mock_router_build_fresh_unsigned_routerinfo() */
|
|
|
|
tt_ptr_op(r2_out, OP_EQ, r2);
|
|
|
|
/* Get rid of an alias to r2 */
|
|
|
|
r2_out = NULL;
|
|
|
|
|
|
|
|
/* Now cleanup */
|
2019-02-19 02:19:44 +01:00
|
|
|
cleanup_mocks_for_fresh_descriptor();
|
|
|
|
|
2019-02-18 08:37:47 +01:00
|
|
|
mocked_routerinfo = NULL;
|
|
|
|
UNMOCK(router_build_fresh_unsigned_routerinfo);
|
|
|
|
mocked_master_signing_key = NULL;
|
|
|
|
UNMOCK(get_master_signing_keypair);
|
|
|
|
mocked_signing_key_cert = NULL;
|
|
|
|
UNMOCK(get_master_signing_key_cert);
|
|
|
|
mocked_curve25519_onion_key = NULL;
|
|
|
|
UNMOCK(get_current_curve25519_keypair);
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
cleanup_mock_configured_ports();
|
|
|
|
|
|
|
|
CHECK_EXTRAINFO_CONSISTENCY(r2, e2);
|
2019-02-18 08:37:47 +01:00
|
|
|
|
|
|
|
/* Test that the signed ri is parseable */
|
|
|
|
tt_assert(r2->cache_info.signed_descriptor_body);
|
|
|
|
cp = r2->cache_info.signed_descriptor_body;
|
|
|
|
rp2 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL,NULL);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
CHECK_ROUTERINFO_CONSISTENCY(r2, rp2);
|
|
|
|
|
2019-02-18 08:37:47 +01:00
|
|
|
tt_mem_op(rp2->onion_curve25519_pkey->public_key,OP_EQ,
|
|
|
|
r2->onion_curve25519_pkey->public_key,
|
|
|
|
CURVE25519_PUBKEY_LEN);
|
2019-02-19 02:19:44 +01:00
|
|
|
|
|
|
|
CHECK_PARSED_EXIT_POLICY(rp2);
|
2019-02-18 08:37:47 +01:00
|
|
|
|
|
|
|
routerinfo_free(rp2);
|
|
|
|
|
|
|
|
/* Test that the signed ei is parseable */
|
|
|
|
tt_assert(e2->cache_info.signed_descriptor_body);
|
|
|
|
cp = e2->cache_info.signed_descriptor_body;
|
|
|
|
ep2 = extrainfo_parse_entry_from_string((const char*)cp,NULL,1,NULL,NULL);
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
CHECK_EXTRAINFO_CONSISTENCY(r2, ep2);
|
2019-02-18 08:37:47 +01:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
/* In future tests, we could check the actual extrainfo statistics. */
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
extrainfo_free(ep2);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2009-09-22 20:02:19 +02:00
|
|
|
done:
|
2019-02-18 08:03:33 +01:00
|
|
|
dirserv_free_fingerprint_list();
|
|
|
|
|
2019-02-19 02:19:44 +01:00
|
|
|
tor_free(options->Nickname);
|
|
|
|
|
|
|
|
cleanup_mock_configured_ports();
|
|
|
|
cleanup_mocks_for_fresh_descriptor();
|
|
|
|
|
|
|
|
if (chunks) {
|
|
|
|
SMARTLIST_FOREACH(chunks, char *, s, tor_free(s));
|
|
|
|
smartlist_free(chunks);
|
|
|
|
}
|
|
|
|
|
2019-02-18 06:24:26 +01:00
|
|
|
routerinfo_free(r2);
|
|
|
|
routerinfo_free(r2_out);
|
|
|
|
routerinfo_free(rp2);
|
|
|
|
|
|
|
|
extrainfo_free(e2);
|
|
|
|
extrainfo_free(ep2);
|
2009-09-22 20:02:19 +02:00
|
|
|
|
2014-10-01 17:54:07 +02:00
|
|
|
tor_free(rsa_cc);
|
2019-02-19 02:19:44 +01:00
|
|
|
crypto_pk_free(r2_onion_pkey);
|
|
|
|
|
2013-02-22 18:17:23 +01:00
|
|
|
tor_free(buf);
|
2019-02-19 02:19:44 +01:00
|
|
|
tor_free(buf2);
|
2009-09-22 20:02:19 +02:00
|
|
|
}
|
|
|
|
|
2014-10-06 15:06:04 +02:00
|
|
|
#include "failing_routerdescs.inc"
|
|
|
|
|
|
|
|
static void
|
2014-10-22 20:19:18 +02:00
|
|
|
test_dir_routerinfo_parsing(void *arg)
|
2014-10-06 15:06:04 +02:00
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
int again;
|
|
|
|
routerinfo_t *ri = NULL;
|
|
|
|
|
|
|
|
#define CHECK_OK(s) \
|
|
|
|
do { \
|
|
|
|
routerinfo_free(ri); \
|
|
|
|
ri = router_parse_entry_from_string((s), NULL, 0, 0, NULL, NULL); \
|
|
|
|
tt_assert(ri); \
|
|
|
|
} while (0)
|
|
|
|
#define CHECK_FAIL(s, againval) \
|
|
|
|
do { \
|
|
|
|
routerinfo_free(ri); \
|
|
|
|
again = 999; \
|
|
|
|
ri = router_parse_entry_from_string((s), NULL, 0, 0, NULL, &again); \
|
|
|
|
tt_assert(ri == NULL); \
|
2020-10-16 18:37:16 +02:00
|
|
|
tt_int_op(again, OP_EQ, (againval)); \
|
2014-10-06 15:06:04 +02:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CHECK_OK(EX_RI_MINIMAL);
|
|
|
|
CHECK_OK(EX_RI_MAXIMAL);
|
|
|
|
|
|
|
|
/* good annotations prepended */
|
|
|
|
routerinfo_free(ri);
|
|
|
|
ri = router_parse_entry_from_string(EX_RI_MINIMAL, NULL, 0, 0,
|
|
|
|
"@purpose bridge\n", NULL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ri, OP_NE, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
tt_assert(ri->purpose == ROUTER_PURPOSE_BRIDGE);
|
|
|
|
routerinfo_free(ri);
|
|
|
|
|
|
|
|
/* bad annotations prepended. */
|
|
|
|
ri = router_parse_entry_from_string(EX_RI_MINIMAL,
|
|
|
|
NULL, 0, 0, "@purpose\n", NULL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ri, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
/* bad annotations on router. */
|
|
|
|
ri = router_parse_entry_from_string("@purpose\nrouter x\n", NULL, 0, 1,
|
|
|
|
NULL, NULL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ri, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
/* unwanted annotations on router. */
|
|
|
|
ri = router_parse_entry_from_string("@purpose foo\nrouter x\n", NULL, 0, 0,
|
|
|
|
NULL, NULL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ri, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
/* No signature. */
|
|
|
|
ri = router_parse_entry_from_string("router x\n", NULL, 0, 0,
|
|
|
|
NULL, NULL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ri, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
/* Not a router */
|
|
|
|
routerinfo_free(ri);
|
|
|
|
ri = router_parse_entry_from_string("hello\n", NULL, 0, 0, NULL, NULL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ri, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
CHECK_FAIL(EX_RI_BAD_SIG1, 1);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_TOKENS, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_PUBLISHED, 0);
|
|
|
|
CHECK_FAIL(EX_RI_NEG_BANDWIDTH, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_BANDWIDTH, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_BANDWIDTH2, 0);
|
2020-10-16 18:37:16 +02:00
|
|
|
CHECK_FAIL(EX_RI_BAD_BANDWIDTH3, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_ONIONKEY, 0);
|
2014-10-06 15:06:04 +02:00
|
|
|
CHECK_FAIL(EX_RI_BAD_PORTS, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_IP, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_DIRPORT, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_NAME2, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_UPTIME, 0);
|
|
|
|
|
|
|
|
CHECK_FAIL(EX_RI_BAD_BANDWIDTH3, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_NTOR_KEY, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_FINGERPRINT, 0);
|
|
|
|
CHECK_FAIL(EX_RI_MISMATCHED_FINGERPRINT, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_HAS_ACCEPT6, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_NO_EXIT_POLICY, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_IPV6_EXIT_POLICY, 0);
|
|
|
|
CHECK_FAIL(EX_RI_BAD_FAMILY, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ZERO_ORPORT, 0);
|
|
|
|
|
2015-05-28 16:42:22 +02:00
|
|
|
CHECK_FAIL(EX_RI_ED_MISSING_CROSSCERT, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_MISSING_CROSSCERT2, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_MISSING_CROSSCERT_SIGN, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_BAD_SIG1, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_BAD_SIG2, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_BAD_SIG3, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_BAD_CROSSCERT1, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_MISPLACED1, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_MISPLACED2, 0);
|
|
|
|
CHECK_FAIL(EX_RI_ED_BAD_CERT1, 0);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
#undef CHECK_FAIL
|
|
|
|
#undef CHECK_OK
|
|
|
|
done:
|
|
|
|
routerinfo_free(ri);
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "example_extrainfo.inc"
|
|
|
|
|
2014-12-22 18:27:26 +01:00
|
|
|
static void
|
|
|
|
routerinfo_free_wrapper_(void *arg)
|
|
|
|
{
|
2017-12-04 21:09:18 +01:00
|
|
|
routerinfo_free_(arg);
|
2014-12-22 18:27:26 +01:00
|
|
|
}
|
|
|
|
|
2014-10-06 15:06:04 +02:00
|
|
|
static void
|
|
|
|
test_dir_extrainfo_parsing(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
#define CHECK_OK(s) \
|
|
|
|
do { \
|
|
|
|
extrainfo_free(ei); \
|
|
|
|
ei = extrainfo_parse_entry_from_string((s), NULL, 0, map, NULL); \
|
|
|
|
tt_assert(ei); \
|
|
|
|
} while (0)
|
|
|
|
#define CHECK_FAIL(s, againval) \
|
|
|
|
do { \
|
|
|
|
extrainfo_free(ei); \
|
|
|
|
again = 999; \
|
|
|
|
ei = extrainfo_parse_entry_from_string((s), NULL, 0, map, &again); \
|
|
|
|
tt_assert(ei == NULL); \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(again, OP_EQ, (againval)); \
|
2014-10-06 15:06:04 +02:00
|
|
|
} while (0)
|
|
|
|
#define ADD(name) \
|
|
|
|
do { \
|
|
|
|
ri = tor_malloc_zero(sizeof(routerinfo_t)); \
|
|
|
|
crypto_pk_t *pk = ri->identity_pkey = crypto_pk_new(); \
|
|
|
|
tt_assert(! crypto_pk_read_public_key_from_string(pk, \
|
|
|
|
name##_KEY, strlen(name##_KEY))); \
|
2016-06-17 16:41:45 +02:00
|
|
|
tt_int_op(20,OP_EQ,base16_decode(d, 20, name##_FP, strlen(name##_FP))); \
|
2014-10-06 15:06:04 +02:00
|
|
|
digestmap_set((digestmap_t*)map, d, ri); \
|
|
|
|
ri = NULL; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
routerinfo_t *ri = NULL;
|
|
|
|
char d[20];
|
|
|
|
struct digest_ri_map_t *map = NULL;
|
|
|
|
extrainfo_t *ei = NULL;
|
|
|
|
int again;
|
|
|
|
|
|
|
|
CHECK_OK(EX_EI_MINIMAL);
|
|
|
|
tt_assert(ei->pending_sig);
|
|
|
|
CHECK_OK(EX_EI_MAXIMAL);
|
|
|
|
tt_assert(ei->pending_sig);
|
|
|
|
|
|
|
|
map = (struct digest_ri_map_t *)digestmap_new();
|
|
|
|
ADD(EX_EI_MINIMAL);
|
|
|
|
ADD(EX_EI_MAXIMAL);
|
|
|
|
ADD(EX_EI_BAD_NICKNAME);
|
|
|
|
ADD(EX_EI_BAD_TOKENS);
|
|
|
|
ADD(EX_EI_BAD_START);
|
|
|
|
ADD(EX_EI_BAD_PUBLISHED);
|
|
|
|
|
2015-05-28 16:42:22 +02:00
|
|
|
ADD(EX_EI_ED_MISSING_SIG);
|
|
|
|
ADD(EX_EI_ED_MISSING_CERT);
|
|
|
|
ADD(EX_EI_ED_BAD_CERT1);
|
|
|
|
ADD(EX_EI_ED_BAD_CERT2);
|
|
|
|
ADD(EX_EI_ED_MISPLACED_CERT);
|
|
|
|
ADD(EX_EI_ED_MISPLACED_SIG);
|
|
|
|
|
2014-10-06 15:06:04 +02:00
|
|
|
CHECK_OK(EX_EI_MINIMAL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ei->pending_sig, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
CHECK_OK(EX_EI_MAXIMAL);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ei->pending_sig, OP_EQ, NULL);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
CHECK_FAIL(EX_EI_BAD_SIG1,1);
|
2020-10-16 19:57:39 +02:00
|
|
|
CHECK_FAIL(EX_EI_BAD_SIG2,0);
|
2014-10-06 15:06:04 +02:00
|
|
|
CHECK_FAIL(EX_EI_BAD_NICKNAME,0);
|
|
|
|
CHECK_FAIL(EX_EI_BAD_TOKENS,0);
|
|
|
|
CHECK_FAIL(EX_EI_BAD_START,0);
|
|
|
|
CHECK_FAIL(EX_EI_BAD_PUBLISHED,0);
|
|
|
|
|
2015-05-28 16:42:22 +02:00
|
|
|
CHECK_FAIL(EX_EI_ED_MISSING_SIG,0);
|
|
|
|
CHECK_FAIL(EX_EI_ED_MISSING_CERT,0);
|
|
|
|
CHECK_FAIL(EX_EI_ED_BAD_CERT1,0);
|
|
|
|
CHECK_FAIL(EX_EI_ED_BAD_CERT2,0);
|
|
|
|
CHECK_FAIL(EX_EI_ED_MISPLACED_CERT,0);
|
|
|
|
CHECK_FAIL(EX_EI_ED_MISPLACED_SIG,0);
|
|
|
|
|
2014-10-06 15:06:04 +02:00
|
|
|
#undef CHECK_OK
|
|
|
|
#undef CHECK_FAIL
|
|
|
|
|
|
|
|
done:
|
2016-01-12 18:33:05 +01:00
|
|
|
escaped(NULL);
|
2014-12-22 18:27:26 +01:00
|
|
|
extrainfo_free(ei);
|
2014-10-06 15:06:04 +02:00
|
|
|
routerinfo_free(ri);
|
2017-11-17 17:46:25 +01:00
|
|
|
digestmap_free_((digestmap_t*)map, routerinfo_free_wrapper_);
|
2014-10-06 15:06:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_parse_router_list(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
smartlist_t *invalid = smartlist_new();
|
|
|
|
smartlist_t *dest = smartlist_new();
|
|
|
|
smartlist_t *chunks = smartlist_new();
|
|
|
|
int dest_has_ri = 1;
|
|
|
|
char *list = NULL;
|
|
|
|
const char *cp;
|
|
|
|
digestmap_t *map = NULL;
|
|
|
|
char *mem_op_hex_tmp = NULL;
|
|
|
|
routerinfo_t *ri = NULL;
|
|
|
|
char d[DIGEST_LEN];
|
|
|
|
|
2016-10-27 11:26:06 +02:00
|
|
|
smartlist_add_strdup(chunks, EX_RI_MINIMAL); // ri 0
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_PORTS); // bad ri 0
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_MAXIMAL); // ei 0
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_BAD_SIG2); // bad ei --
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_BAD_NICKNAME);// bad ei 0
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_SIG1); // bad ri --
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_BAD_PUBLISHED); // bad ei 1
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_MAXIMAL); // ri 1
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_FAMILY); // bad ri 1
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_MINIMAL); // ei 1
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
list = smartlist_join_strings(chunks, "", 0, NULL);
|
|
|
|
|
|
|
|
/* First, parse the routers. */
|
|
|
|
cp = list;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-10-06 15:06:04 +02:00
|
|
|
router_parse_list_from_string(&cp, NULL, dest, SAVED_NOWHERE,
|
|
|
|
0, 0, NULL, invalid));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2, OP_EQ, smartlist_len(dest));
|
|
|
|
tt_ptr_op(cp, OP_EQ, list + strlen(list));
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
routerinfo_t *r = smartlist_get(dest, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(r->cache_info.signed_descriptor_body, OP_EQ,
|
2014-10-06 15:06:04 +02:00
|
|
|
EX_RI_MINIMAL, strlen(EX_RI_MINIMAL));
|
|
|
|
r = smartlist_get(dest, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(r->cache_info.signed_descriptor_body, OP_EQ,
|
2014-10-06 15:06:04 +02:00
|
|
|
EX_RI_MAXIMAL, strlen(EX_RI_MAXIMAL));
|
|
|
|
|
2020-10-16 19:57:39 +02:00
|
|
|
setup_ei_digests();
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2, OP_EQ, smartlist_len(invalid));
|
2020-10-16 19:57:39 +02:00
|
|
|
|
2014-10-06 15:06:04 +02:00
|
|
|
test_memeq_hex(smartlist_get(invalid, 0),
|
2020-10-16 18:37:16 +02:00
|
|
|
"10F951AF93AED0D3BC7FA5FFA232EB8C17747ACE");
|
2014-10-06 15:06:04 +02:00
|
|
|
test_memeq_hex(smartlist_get(invalid, 1),
|
2020-10-16 18:37:16 +02:00
|
|
|
"41D8723CDD4B1AADCCE538C28CDE7F69828C73D0");
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
/* Now tidy up */
|
2016-07-05 20:19:31 +02:00
|
|
|
SMARTLIST_FOREACH(dest, routerinfo_t *, rinfo, routerinfo_free(rinfo));
|
|
|
|
SMARTLIST_FOREACH(invalid, uint8_t *, dig, tor_free(dig));
|
2014-10-06 15:06:04 +02:00
|
|
|
smartlist_clear(dest);
|
|
|
|
smartlist_clear(invalid);
|
|
|
|
|
|
|
|
/* And check extrainfos. */
|
|
|
|
dest_has_ri = 0;
|
|
|
|
map = (digestmap_t*)router_get_routerlist()->identity_map;
|
|
|
|
ADD(EX_EI_MINIMAL);
|
|
|
|
ADD(EX_EI_MAXIMAL);
|
|
|
|
ADD(EX_EI_BAD_NICKNAME);
|
|
|
|
ADD(EX_EI_BAD_PUBLISHED);
|
2020-10-16 19:57:39 +02:00
|
|
|
ADD(EX_EI_BAD_SIG2);
|
2014-10-06 15:06:04 +02:00
|
|
|
cp = list;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-10-06 15:06:04 +02:00
|
|
|
router_parse_list_from_string(&cp, NULL, dest, SAVED_NOWHERE,
|
|
|
|
1, 0, NULL, invalid));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2, OP_EQ, smartlist_len(dest));
|
2014-10-06 15:06:04 +02:00
|
|
|
extrainfo_t *e = smartlist_get(dest, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(e->cache_info.signed_descriptor_body, OP_EQ,
|
2014-10-06 15:06:04 +02:00
|
|
|
EX_EI_MAXIMAL, strlen(EX_EI_MAXIMAL));
|
|
|
|
e = smartlist_get(dest, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(e->cache_info.signed_descriptor_body, OP_EQ,
|
2014-10-06 15:06:04 +02:00
|
|
|
EX_EI_MINIMAL, strlen(EX_EI_MINIMAL));
|
|
|
|
|
2020-10-16 19:57:39 +02:00
|
|
|
tt_int_op(3, OP_EQ, smartlist_len(invalid));
|
|
|
|
tt_mem_op(smartlist_get(invalid, 0),
|
|
|
|
OP_EQ,
|
|
|
|
digest_ei_bad_sig2, DIGEST_LEN);
|
|
|
|
tt_mem_op(smartlist_get(invalid, 1),
|
|
|
|
OP_EQ,
|
|
|
|
digest_ei_bad_nickname, DIGEST_LEN);
|
|
|
|
tt_mem_op(smartlist_get(invalid, 2),
|
|
|
|
OP_EQ,
|
|
|
|
digest_ei_bad_published, DIGEST_LEN);
|
2014-10-06 15:06:04 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(list);
|
|
|
|
if (dest_has_ri)
|
|
|
|
SMARTLIST_FOREACH(dest, routerinfo_t *, rt, routerinfo_free(rt));
|
|
|
|
else
|
|
|
|
SMARTLIST_FOREACH(dest, extrainfo_t *, ei, extrainfo_free(ei));
|
|
|
|
smartlist_free(dest);
|
2016-07-05 20:19:31 +02:00
|
|
|
SMARTLIST_FOREACH(invalid, uint8_t *, dig, tor_free(dig));
|
2014-10-06 15:06:04 +02:00
|
|
|
smartlist_free(invalid);
|
2016-07-05 20:19:31 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, chunk, tor_free(chunk));
|
2014-10-06 15:06:04 +02:00
|
|
|
smartlist_free(chunks);
|
|
|
|
routerinfo_free(ri);
|
|
|
|
if (map) {
|
2017-11-17 17:46:25 +01:00
|
|
|
digestmap_free_((digestmap_t*)map, routerinfo_free_wrapper_);
|
2014-10-06 15:06:04 +02:00
|
|
|
router_get_routerlist()->identity_map =
|
|
|
|
(struct digest_ri_map_t*)digestmap_new();
|
|
|
|
}
|
|
|
|
tor_free(mem_op_hex_tmp);
|
|
|
|
|
|
|
|
#undef ADD
|
|
|
|
}
|
|
|
|
|
2014-10-07 15:20:44 +02:00
|
|
|
static download_status_t dls_minimal;
|
|
|
|
static download_status_t dls_maximal;
|
|
|
|
static download_status_t dls_bad_fingerprint;
|
2020-10-16 18:37:16 +02:00
|
|
|
static download_status_t dls_bad_sig1;
|
2014-10-07 15:20:44 +02:00
|
|
|
static download_status_t dls_bad_ports;
|
|
|
|
static download_status_t dls_bad_tokens;
|
|
|
|
|
2020-10-16 18:37:16 +02:00
|
|
|
static uint8_t digest_minimal[20];
|
|
|
|
static uint8_t digest_maximal[20];
|
|
|
|
static uint8_t digest_bad_fingerprint[20];
|
|
|
|
static uint8_t digest_bad_sig1[20];
|
|
|
|
static uint8_t digest_bad_ports[20];
|
|
|
|
static uint8_t digest_bad_tokens[20];
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_dls_digests(void)
|
|
|
|
{
|
|
|
|
#define SETUP(string, name) \
|
|
|
|
do { \
|
|
|
|
router_get_router_hash(string, strlen(string), (char*)digest_##name); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
SETUP(EX_RI_MINIMAL, minimal);
|
|
|
|
SETUP(EX_RI_MAXIMAL, maximal);
|
|
|
|
SETUP(EX_RI_BAD_FINGERPRINT, bad_fingerprint);
|
|
|
|
SETUP(EX_RI_BAD_SIG1, bad_sig1);
|
|
|
|
SETUP(EX_RI_BAD_PORTS, bad_ports);
|
|
|
|
SETUP(EX_RI_BAD_TOKENS, bad_tokens);
|
2020-10-16 19:57:39 +02:00
|
|
|
#undef SETUP
|
2020-10-16 18:37:16 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 15:20:44 +02:00
|
|
|
static int mock_router_get_dl_status_unrecognized = 0;
|
|
|
|
static int mock_router_get_dl_status_calls = 0;
|
|
|
|
|
|
|
|
static download_status_t *
|
|
|
|
mock_router_get_dl_status(const char *d)
|
|
|
|
{
|
|
|
|
++mock_router_get_dl_status_calls;
|
2020-10-16 18:37:16 +02:00
|
|
|
#define CHECK(name) \
|
|
|
|
do { \
|
|
|
|
if (fast_memeq(d, digest_##name, DIGEST_LEN)) \
|
|
|
|
return &dls_##name; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CHECK(minimal);
|
|
|
|
CHECK(maximal);
|
|
|
|
CHECK(bad_fingerprint);
|
|
|
|
CHECK(bad_sig1);
|
|
|
|
CHECK(bad_ports);
|
|
|
|
CHECK(bad_tokens);
|
|
|
|
|
|
|
|
++mock_router_get_dl_status_unrecognized;
|
|
|
|
return NULL;
|
2020-10-16 19:57:39 +02:00
|
|
|
#undef CHECK
|
2014-10-07 15:20:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_load_routers(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
smartlist_t *chunks = smartlist_new();
|
|
|
|
smartlist_t *wanted = smartlist_new();
|
|
|
|
char buf[DIGEST_LEN];
|
|
|
|
char *mem_op_hex_tmp = NULL;
|
2014-12-22 17:13:01 +01:00
|
|
|
char *list = NULL;
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
#define ADD(str) \
|
|
|
|
do { \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,router_get_router_hash(str, strlen(str), buf)); \
|
2016-10-27 12:15:57 +02:00
|
|
|
smartlist_add_strdup(wanted, hex_str(buf, DIGEST_LEN)); \
|
2014-10-07 15:20:44 +02:00
|
|
|
} while (0)
|
|
|
|
|
2020-10-16 18:37:16 +02:00
|
|
|
setup_dls_digests();
|
|
|
|
|
2014-10-07 15:20:44 +02:00
|
|
|
MOCK(router_get_dl_status_by_descriptor_digest, mock_router_get_dl_status);
|
|
|
|
|
2014-10-13 20:11:27 +02:00
|
|
|
update_approx_time(1412510400);
|
|
|
|
|
2016-10-27 11:26:06 +02:00
|
|
|
smartlist_add_strdup(chunks, EX_RI_MINIMAL);
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_FINGERPRINT);
|
2020-10-16 18:37:16 +02:00
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_SIG1);
|
2016-10-27 11:26:06 +02:00
|
|
|
smartlist_add_strdup(chunks, EX_RI_MAXIMAL);
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_PORTS);
|
|
|
|
smartlist_add_strdup(chunks, EX_RI_BAD_TOKENS);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
2020-11-11 12:38:19 +01:00
|
|
|
/* not ADDing MINIMAL */
|
2014-10-07 15:20:44 +02:00
|
|
|
ADD(EX_RI_MAXIMAL);
|
|
|
|
ADD(EX_RI_BAD_FINGERPRINT);
|
2020-10-16 18:37:16 +02:00
|
|
|
ADD(EX_RI_BAD_SIG1);
|
2014-10-07 15:20:44 +02:00
|
|
|
/* Not ADDing BAD_PORTS */
|
|
|
|
ADD(EX_RI_BAD_TOKENS);
|
|
|
|
|
2014-12-22 17:13:01 +01:00
|
|
|
list = smartlist_join_strings(chunks, "", 0, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1, OP_EQ,
|
2014-10-07 15:20:44 +02:00
|
|
|
router_load_routers_from_string(list, NULL, SAVED_IN_JOURNAL,
|
|
|
|
wanted, 1, NULL));
|
|
|
|
|
|
|
|
/* The "maximal" router was added. */
|
|
|
|
/* "minimal" was not. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(router_get_routerlist()->routers),OP_EQ,1);
|
2014-10-07 15:20:44 +02:00
|
|
|
routerinfo_t *r = smartlist_get(router_get_routerlist()->routers, 0);
|
|
|
|
test_memeq_hex(r->cache_info.signed_descriptor_digest,
|
2020-10-16 18:37:16 +02:00
|
|
|
"1F437798ACD1FC9CBD1C3C04DBF80F7E9F819C3F");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dls_minimal.n_download_failures, OP_EQ, 0);
|
|
|
|
tt_int_op(dls_maximal.n_download_failures, OP_EQ, 0);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
/* "Bad fingerprint" and "Bad tokens" should have gotten marked
|
|
|
|
* non-retriable. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(mock_router_get_dl_status_calls, OP_EQ, 2);
|
|
|
|
tt_want_int_op(mock_router_get_dl_status_unrecognized, OP_EQ, 0);
|
|
|
|
tt_int_op(dls_bad_fingerprint.n_download_failures, OP_EQ, 255);
|
|
|
|
tt_int_op(dls_bad_tokens.n_download_failures, OP_EQ, 255);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
/* bad_sig2 and bad ports" are retriable -- one since only the signature
|
|
|
|
* was bad, and one because we didn't ask for it. */
|
2020-10-16 18:37:16 +02:00
|
|
|
tt_int_op(dls_bad_sig1.n_download_failures, OP_EQ, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dls_bad_ports.n_download_failures, OP_EQ, 0);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(wanted), OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(wanted, 0), OP_EQ,
|
2020-10-16 18:37:16 +02:00
|
|
|
"3BB7D03C1C4DBC1DDE840096FF3C330914757B77");
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
#undef ADD
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(mem_op_hex_tmp);
|
|
|
|
UNMOCK(router_get_dl_status_by_descriptor_digest);
|
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(chunks);
|
|
|
|
SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(wanted);
|
2014-12-22 17:13:01 +01:00
|
|
|
tor_free(list);
|
2014-10-07 15:20:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mock_get_by_ei_dd_calls = 0;
|
|
|
|
static int mock_get_by_ei_dd_unrecognized = 0;
|
|
|
|
|
|
|
|
static signed_descriptor_t sd_ei_minimal;
|
|
|
|
static signed_descriptor_t sd_ei_bad_nickname;
|
|
|
|
static signed_descriptor_t sd_ei_maximal;
|
|
|
|
static signed_descriptor_t sd_ei_bad_tokens;
|
|
|
|
static signed_descriptor_t sd_ei_bad_sig2;
|
|
|
|
|
2020-10-16 19:57:39 +02:00
|
|
|
static void
|
|
|
|
setup_ei_digests(void)
|
|
|
|
{
|
|
|
|
#define SETUP(string, name) \
|
|
|
|
do { \
|
|
|
|
router_get_extrainfo_hash(string, strlen(string), \
|
|
|
|
(char*)digest_ei_##name); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
SETUP(EX_EI_MINIMAL, minimal);
|
|
|
|
SETUP(EX_EI_MAXIMAL, maximal);
|
|
|
|
SETUP(EX_EI_BAD_NICKNAME, bad_nickname);
|
|
|
|
SETUP(EX_EI_BAD_TOKENS, bad_tokens);
|
|
|
|
SETUP(EX_EI_BAD_SIG2, bad_sig2);
|
|
|
|
SETUP(EX_EI_BAD_PUBLISHED, bad_published);
|
|
|
|
|
|
|
|
#undef SETUP
|
|
|
|
}
|
|
|
|
|
2014-10-07 15:20:44 +02:00
|
|
|
static signed_descriptor_t *
|
|
|
|
mock_get_by_ei_desc_digest(const char *d)
|
|
|
|
{
|
|
|
|
++mock_get_by_ei_dd_calls;
|
2020-10-16 19:57:39 +02:00
|
|
|
#define CHECK(name) \
|
|
|
|
do { \
|
|
|
|
if (fast_memeq(d, digest_ei_##name, DIGEST_LEN)) \
|
|
|
|
return &sd_ei_##name; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CHECK(minimal);
|
|
|
|
CHECK(maximal);
|
|
|
|
CHECK(bad_nickname);
|
|
|
|
CHECK(bad_sig2);
|
|
|
|
CHECK(bad_tokens);
|
|
|
|
++mock_get_by_ei_dd_unrecognized;
|
|
|
|
return NULL;
|
|
|
|
#undef CHECK
|
2014-10-07 15:20:44 +02:00
|
|
|
}
|
|
|
|
|
2017-04-22 02:17:27 +02:00
|
|
|
static signed_descriptor_t *
|
|
|
|
mock_ei_get_by_ei_digest(const char *d)
|
|
|
|
{
|
|
|
|
signed_descriptor_t *sd = &sd_ei_minimal;
|
|
|
|
|
2020-10-16 19:57:39 +02:00
|
|
|
if (fast_memeq(d, digest_ei_minimal, DIGEST_LEN)) {
|
2017-04-22 02:17:27 +02:00
|
|
|
sd->signed_descriptor_body = (char *)EX_EI_MINIMAL;
|
|
|
|
sd->signed_descriptor_len = sizeof(EX_EI_MINIMAL);
|
|
|
|
sd->annotations_len = 0;
|
|
|
|
sd->saved_location = SAVED_NOWHERE;
|
|
|
|
return sd;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-07 15:20:44 +02:00
|
|
|
static smartlist_t *mock_ei_insert_list = NULL;
|
2014-10-13 20:11:27 +02:00
|
|
|
static was_router_added_t
|
2015-01-07 19:11:06 +01:00
|
|
|
mock_ei_insert(routerlist_t *rl, extrainfo_t *ei, int warn_if_incompatible)
|
2014-10-07 15:20:44 +02:00
|
|
|
{
|
|
|
|
(void) rl;
|
2015-01-07 19:11:06 +01:00
|
|
|
(void) warn_if_incompatible;
|
2014-10-07 15:20:44 +02:00
|
|
|
smartlist_add(mock_ei_insert_list, ei);
|
2014-10-13 20:11:27 +02:00
|
|
|
return ROUTER_ADDED_SUCCESSFULLY;
|
2014-10-07 15:20:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_load_extrainfo(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
smartlist_t *chunks = smartlist_new();
|
|
|
|
smartlist_t *wanted = smartlist_new();
|
|
|
|
char buf[DIGEST_LEN];
|
|
|
|
char *mem_op_hex_tmp = NULL;
|
2014-12-22 17:13:01 +01:00
|
|
|
char *list = NULL;
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
#define ADD(str) \
|
|
|
|
do { \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,router_get_extrainfo_hash(str, strlen(str), buf)); \
|
2016-10-27 12:15:57 +02:00
|
|
|
smartlist_add_strdup(wanted, hex_str(buf, DIGEST_LEN)); \
|
2014-10-07 15:20:44 +02:00
|
|
|
} while (0)
|
|
|
|
|
2020-10-16 19:57:39 +02:00
|
|
|
setup_ei_digests();
|
2014-10-07 15:20:44 +02:00
|
|
|
mock_ei_insert_list = smartlist_new();
|
|
|
|
MOCK(router_get_by_extrainfo_digest, mock_get_by_ei_desc_digest);
|
|
|
|
MOCK(extrainfo_insert, mock_ei_insert);
|
|
|
|
|
2016-10-27 11:26:06 +02:00
|
|
|
smartlist_add_strdup(chunks, EX_EI_MINIMAL);
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_BAD_NICKNAME);
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_MAXIMAL);
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_BAD_PUBLISHED);
|
|
|
|
smartlist_add_strdup(chunks, EX_EI_BAD_TOKENS);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
2020-11-11 12:38:19 +01:00
|
|
|
/* not ADDing MINIMAL */
|
2014-10-07 15:20:44 +02:00
|
|
|
ADD(EX_EI_MAXIMAL);
|
|
|
|
ADD(EX_EI_BAD_NICKNAME);
|
|
|
|
/* Not ADDing BAD_PUBLISHED */
|
|
|
|
ADD(EX_EI_BAD_TOKENS);
|
|
|
|
ADD(EX_EI_BAD_SIG2);
|
|
|
|
|
2014-12-22 17:13:01 +01:00
|
|
|
list = smartlist_join_strings(chunks, "", 0, NULL);
|
2014-10-07 15:20:44 +02:00
|
|
|
router_load_extrainfo_from_string(list, NULL, SAVED_IN_JOURNAL, wanted, 1);
|
|
|
|
|
|
|
|
/* The "maximal" router was added. */
|
|
|
|
/* "minimal" was also added, even though we didn't ask for it, since
|
|
|
|
* that's what we do with extrainfos. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(mock_ei_insert_list),OP_EQ,2);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
extrainfo_t *e = smartlist_get(mock_ei_insert_list, 0);
|
2020-10-16 19:57:39 +02:00
|
|
|
tt_mem_op(e->cache_info.signed_descriptor_digest, OP_EQ,
|
|
|
|
digest_ei_minimal, DIGEST_LEN);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
e = smartlist_get(mock_ei_insert_list, 1);
|
2020-10-16 19:57:39 +02:00
|
|
|
tt_mem_op(e->cache_info.signed_descriptor_digest, OP_EQ,
|
|
|
|
digest_ei_maximal, DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dls_minimal.n_download_failures, OP_EQ, 0);
|
|
|
|
tt_int_op(dls_maximal.n_download_failures, OP_EQ, 0);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
/* "Bad nickname" and "Bad tokens" should have gotten marked
|
|
|
|
* non-retriable. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(mock_get_by_ei_dd_calls, OP_EQ, 2);
|
|
|
|
tt_want_int_op(mock_get_by_ei_dd_unrecognized, OP_EQ, 0);
|
|
|
|
tt_int_op(sd_ei_bad_nickname.ei_dl_status.n_download_failures, OP_EQ, 255);
|
|
|
|
tt_int_op(sd_ei_bad_tokens.ei_dl_status.n_download_failures, OP_EQ, 255);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
/* bad_ports is retriable -- because we didn't ask for it. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dls_bad_ports.n_download_failures, OP_EQ, 0);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
/* Wanted still contains "BAD_SIG2" */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(wanted), OP_EQ, 1);
|
2020-10-16 19:57:39 +02:00
|
|
|
const char *got_wanted =smartlist_get(wanted, 0);
|
|
|
|
tt_int_op(strlen(got_wanted), OP_EQ, HEX_DIGEST_LEN);
|
|
|
|
char d[DIGEST_LEN];
|
|
|
|
base16_decode(d, DIGEST_LEN, got_wanted, strlen(got_wanted));
|
|
|
|
tt_mem_op(d, OP_EQ, digest_ei_bad_sig2, DIGEST_LEN);
|
2014-10-07 15:20:44 +02:00
|
|
|
|
|
|
|
#undef ADD
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(mem_op_hex_tmp);
|
|
|
|
UNMOCK(router_get_by_extrainfo_digest);
|
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(chunks);
|
|
|
|
SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(wanted);
|
2014-12-22 17:13:01 +01:00
|
|
|
tor_free(list);
|
2014-10-07 15:20:44 +02:00
|
|
|
}
|
|
|
|
|
2017-04-22 02:17:27 +02:00
|
|
|
static void
|
|
|
|
test_dir_getinfo_extra(void *arg)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
char *answer = NULL;
|
|
|
|
const char *errmsg = NULL;
|
2020-10-16 19:57:39 +02:00
|
|
|
char buf[128];
|
|
|
|
char hexdigest[HEX_DIGEST_LEN+1];
|
2017-04-22 02:17:27 +02:00
|
|
|
(void)arg;
|
2020-10-16 19:57:39 +02:00
|
|
|
|
|
|
|
setup_ei_digests();
|
|
|
|
base16_encode(hexdigest, sizeof(hexdigest),
|
|
|
|
(const char*)digest_ei_minimal, DIGEST_LEN);
|
|
|
|
tor_snprintf(buf, sizeof(buf), "extra-info/digest/%s", hexdigest);
|
|
|
|
|
2017-04-22 02:17:27 +02:00
|
|
|
MOCK(extrainfo_get_by_descriptor_digest, mock_ei_get_by_ei_digest);
|
2020-10-16 19:57:39 +02:00
|
|
|
r = getinfo_helper_dir(NULL, buf, &answer, &errmsg);
|
2017-04-22 02:17:27 +02:00
|
|
|
tt_int_op(0, OP_EQ, r);
|
|
|
|
tt_ptr_op(NULL, OP_EQ, errmsg);
|
|
|
|
tt_str_op(answer, OP_EQ, EX_EI_MINIMAL);
|
|
|
|
tor_free(answer);
|
|
|
|
|
|
|
|
answer = NULL;
|
|
|
|
r = getinfo_helper_dir(NULL, "extra-info/digest/"
|
|
|
|
"NOTAVALIDHEXSTRINGNOTAVALIDHEXSTRINGNOTA", &answer,
|
|
|
|
&errmsg);
|
|
|
|
tt_int_op(0, OP_EQ, r);
|
|
|
|
/* getinfo_helper_dir() should maybe return an error here but doesn't */
|
|
|
|
tt_ptr_op(NULL, OP_EQ, errmsg);
|
|
|
|
/* In any case, there should be no answer for an invalid hex string. */
|
|
|
|
tt_ptr_op(NULL, OP_EQ, answer);
|
|
|
|
|
|
|
|
done:
|
|
|
|
UNMOCK(extrainfo_get_by_descriptor_digest);
|
|
|
|
}
|
|
|
|
|
2009-09-22 20:02:19 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_versions(void *arg)
|
2009-09-22 20:02:19 +02:00
|
|
|
{
|
|
|
|
tor_version_t ver1;
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Try out version parsing functionality */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.3.4pre2-cvs", &ver1));
|
|
|
|
tt_int_op(0,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(3,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(4,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(VER_PRE,OP_EQ, ver1.status);
|
|
|
|
tt_int_op(2,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.3.4rc1", &ver1));
|
|
|
|
tt_int_op(0,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(3,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(4,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(VER_RC,OP_EQ, ver1.status);
|
|
|
|
tt_int_op(1,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("1.3.4", &ver1));
|
|
|
|
tt_int_op(1,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(3,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(4,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(VER_RELEASE,OP_EQ, ver1.status);
|
|
|
|
tt_int_op(0,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("1.3.4.999", &ver1));
|
|
|
|
tt_int_op(1,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(3,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(4,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(VER_RELEASE,OP_EQ, ver1.status);
|
|
|
|
tt_int_op(999,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.1.2.4-alpha", &ver1));
|
|
|
|
tt_int_op(0,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(1,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(2,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(4,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE,OP_EQ, ver1.status);
|
|
|
|
tt_str_op("alpha",OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.1.2.4", &ver1));
|
|
|
|
tt_int_op(0,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(1,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(2,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(4,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE,OP_EQ, ver1.status);
|
|
|
|
tt_str_op("",OP_EQ, ver1.status_tag);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2015-01-06 21:25:20 +01:00
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("10.1", &ver1));
|
|
|
|
tt_int_op(10, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(1, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("5.99.999", &ver1));
|
|
|
|
tt_int_op(5, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(99, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(999, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("10.1-alpha", &ver1));
|
|
|
|
tt_int_op(10, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(1, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("alpha", OP_EQ, ver1.status_tag);
|
2017-02-19 12:42:44 +01:00
|
|
|
/* Go through the full set of status tags */
|
2015-01-06 21:25:20 +01:00
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("2.1.700-alpha", &ver1));
|
|
|
|
tt_int_op(2, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(1, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(700, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("alpha", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("1.6.8-alpha-dev", &ver1));
|
|
|
|
tt_int_op(1, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(6, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(8, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("alpha-dev", OP_EQ, ver1.status_tag);
|
2017-02-19 12:42:44 +01:00
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("0.2.9.5-rc", &ver1));
|
|
|
|
tt_int_op(0, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(2, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(9, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(5, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("rc", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("0.2.9.6-rc-dev", &ver1));
|
|
|
|
tt_int_op(0, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(2, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(9, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(6, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("rc-dev", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("0.2.9.8", &ver1));
|
|
|
|
tt_int_op(0, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(2, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(9, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(8, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("0.2.9.9-dev", &ver1));
|
|
|
|
tt_int_op(0, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(2, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(9, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(9, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("dev", OP_EQ, ver1.status_tag);
|
2017-02-19 12:45:25 +01:00
|
|
|
/* In #21450, we fixed an inconsistency in parsing versions > INT32_MAX
|
|
|
|
* between i386 and x86_64, as we used tor_parse_long, and then cast to int
|
|
|
|
*/
|
|
|
|
tt_int_op(0, OP_EQ, tor_version_parse("0.2147483647.0", &ver1));
|
|
|
|
tt_int_op(0, OP_EQ, ver1.major);
|
|
|
|
tt_int_op(2147483647, OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(0, OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(VER_RELEASE, OP_EQ, ver1.status);
|
|
|
|
tt_str_op("", OP_EQ, ver1.status_tag);
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.2147483648.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.4294967295.0", &ver1));
|
2017-02-19 12:46:42 +01:00
|
|
|
/* In #21278, we reject negative version components */
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.-1.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.-2147483648.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.-4294967295.0", &ver1));
|
2017-02-19 12:47:47 +01:00
|
|
|
/* In #21507, we reject version components with non-numeric prefixes */
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.-0.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("+1.0.0", &ver1));
|
|
|
|
/* use the list in isspace() */
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.\t0.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.\n0.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.\v0.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.\f0.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0.\r0.0", &ver1));
|
|
|
|
tt_int_op(-1, OP_EQ, tor_version_parse("0. 0.0", &ver1));
|
2014-11-05 19:28:29 +01:00
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
#define tt_versionstatus_op(vs1, op, vs2) \
|
|
|
|
tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \
|
2012-02-13 23:45:15 +01:00
|
|
|
(val1_ op val2_),"%d",TT_EXIT_TEST_FUNCTION)
|
2009-09-22 19:49:09 +02:00
|
|
|
#define test_v_i_o(val, ver, lst) \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_versionstatus_op(val, OP_EQ, tor_version_is_obsolete(ver, lst))
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* make sure tor_version_is_obsolete() works */
|
|
|
|
test_v_i_o(VS_OLD, "0.0.1", "Tor 0.0.2");
|
|
|
|
test_v_i_o(VS_OLD, "0.0.1", "0.0.2, Tor 0.0.3");
|
|
|
|
test_v_i_o(VS_OLD, "0.0.1", "0.0.2,Tor 0.0.3");
|
|
|
|
test_v_i_o(VS_OLD, "0.0.1","0.0.3,BetterTor 0.0.1");
|
|
|
|
test_v_i_o(VS_RECOMMENDED, "0.0.2", "Tor 0.0.2,Tor 0.0.3");
|
|
|
|
test_v_i_o(VS_NEW_IN_SERIES, "0.0.2", "Tor 0.0.2pre1,Tor 0.0.3");
|
|
|
|
test_v_i_o(VS_OLD, "0.0.2", "Tor 0.0.2.1,Tor 0.0.3");
|
|
|
|
test_v_i_o(VS_NEW, "0.1.0", "Tor 0.0.2,Tor 0.0.3");
|
|
|
|
test_v_i_o(VS_RECOMMENDED, "0.0.7rc2", "0.0.7,Tor 0.0.7rc2,Tor 0.0.8");
|
|
|
|
test_v_i_o(VS_OLD, "0.0.5.0", "0.0.5.1-cvs");
|
|
|
|
test_v_i_o(VS_NEW_IN_SERIES, "0.0.5.1-cvs", "0.0.5, 0.0.6");
|
2017-02-19 12:42:44 +01:00
|
|
|
test_v_i_o(VS_NEW, "0.2.9.9-dev", "0.2.9.9");
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Not on list, but newer than any in same series. */
|
|
|
|
test_v_i_o(VS_NEW_IN_SERIES, "0.1.0.3",
|
|
|
|
"Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0");
|
|
|
|
/* Series newer than any on list. */
|
|
|
|
test_v_i_o(VS_NEW, "0.1.2.3", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0");
|
|
|
|
/* Series older than any on list. */
|
|
|
|
test_v_i_o(VS_OLD, "0.0.1.3", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0");
|
|
|
|
/* Not on list, not newer than any on same series. */
|
|
|
|
test_v_i_o(VS_UNRECOMMENDED, "0.1.0.1",
|
|
|
|
"Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0");
|
|
|
|
/* On list, not newer than any on same series. */
|
|
|
|
test_v_i_o(VS_UNRECOMMENDED,
|
|
|
|
"0.1.0.1", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as("Tor 0.0.5", "0.0.9pre1-cvs"));
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.0.8 on Darwin 64-121-192-100.c3-0."
|
|
|
|
"sfpo-ubr1.sfrn-sfpo.ca.cable.rcn.com Power Macintosh",
|
|
|
|
"0.0.8rc2"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.0.8 on Darwin 64-121-192-100.c3-0."
|
|
|
|
"sfpo-ubr1.sfrn-sfpo.ca.cable.rcn.com Power Macintosh", "0.0.8.2"));
|
|
|
|
|
|
|
|
/* Now try svn revisions. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev (r99)"));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.1.0-dev (r100) on Banana Jr",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev (r99) on Hal 9000"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev on Colossus"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r99)",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev (r100)"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r99) on MCP",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev (r100) on AM"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev (r99)"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as("Tor 0.2.1.1",
|
2009-09-22 19:49:09 +02:00
|
|
|
"Tor 0.2.1.0-dev (r99)"));
|
2017-02-19 12:44:07 +01:00
|
|
|
/* And git revisions */
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-56788a2489127072)",
|
|
|
|
"Tor 0.2.9.9 (git-56788a2489127072)"));
|
|
|
|
/* a git revision is newer than no git revision */
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-56788a2489127072)",
|
|
|
|
"Tor 0.2.9.9"));
|
|
|
|
/* a longer git revision is newer than a shorter git revision
|
|
|
|
* this should be true if they prefix-match, but if they don't, they are
|
|
|
|
* incomparable, because hashes aren't ordered (but we compare their bytes
|
|
|
|
* anyway) */
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-56788a2489127072d513cf4baf35a8ff475f3c7b)",
|
|
|
|
"Tor 0.2.9.9 (git-56788a2489127072)"));
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-0102)",
|
|
|
|
"Tor 0.2.9.9 (git-03)"));
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-0102)",
|
|
|
|
"Tor 0.2.9.9 (git-00)"));
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-01)",
|
|
|
|
"Tor 0.2.9.9 (git-00)"));
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2.9.9 (git-00)",
|
|
|
|
"Tor 0.2.9.9 (git-01)"));
|
2018-01-24 09:55:15 +01:00
|
|
|
/* In #21278, we compare without integer overflows.
|
2017-02-19 12:46:42 +01:00
|
|
|
* But since #21450 limits version components to [0, INT32_MAX], it is no
|
|
|
|
* longer possible to cause an integer overflow in tor_version_compare() */
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.0.0.0",
|
|
|
|
"Tor 2147483647.0.0.0"));
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 2147483647.0.0.0",
|
|
|
|
"Tor 0.0.0.0"));
|
|
|
|
/* These versions used to cause an overflow, now they don't parse
|
|
|
|
* (and authorities reject their descriptors), and log a BUG message */
|
|
|
|
setup_full_capture_of_logs(LOG_WARN);
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.0.0.0",
|
|
|
|
"Tor 0.-2147483648.0.0"));
|
|
|
|
expect_single_log_msg_containing("unparseable");
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2147483647.0.0",
|
|
|
|
"Tor 0.-1.0.0"));
|
|
|
|
expect_single_log_msg_containing("unparseable");
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.2147483647.0.0",
|
|
|
|
"Tor 0.-2147483648.0.0"));
|
|
|
|
expect_single_log_msg_containing("unparseable");
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 4294967295.0.0.0",
|
|
|
|
"Tor 0.0.0.0"));
|
|
|
|
expect_no_log_entry();
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_as_new_as(
|
|
|
|
"Tor 0.4294967295.0.0",
|
|
|
|
"Tor 0.-4294967295.0.0"));
|
|
|
|
expect_single_log_msg_containing("unparseable");
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
teardown_capture_of_logs();
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Now try git revisions */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.5.6.7 (git-ff00ff)", &ver1));
|
|
|
|
tt_int_op(0,OP_EQ, ver1.major);
|
|
|
|
tt_int_op(5,OP_EQ, ver1.minor);
|
|
|
|
tt_int_op(6,OP_EQ, ver1.micro);
|
|
|
|
tt_int_op(7,OP_EQ, ver1.patchlevel);
|
|
|
|
tt_int_op(3,OP_EQ, ver1.git_tag_len);
|
|
|
|
tt_mem_op(ver1.git_tag,OP_EQ, "\xff\x00\xff", 3);
|
2017-02-19 12:44:07 +01:00
|
|
|
/* reject bad hex digits */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ, tor_version_parse("0.5.6.7 (git-ff00xx)", &ver1));
|
2017-02-19 12:44:07 +01:00
|
|
|
/* reject odd hex digit count */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ, tor_version_parse("0.5.6.7 (git-ff00fff)", &ver1));
|
2017-02-19 12:44:07 +01:00
|
|
|
/* ignore "git " */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.5.6.7 (git ff00fff)", &ver1));
|
2017-02-19 12:44:07 +01:00
|
|
|
/* standard length is 16 hex digits */
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse("0.5.6.7 (git-0010203040506070)",
|
|
|
|
&ver1));
|
|
|
|
/* length limit is 40 hex digits */
|
|
|
|
tt_int_op(0,OP_EQ, tor_version_parse(
|
|
|
|
"0.5.6.7 (git-000102030405060708090a0b0c0d0e0f10111213)",
|
|
|
|
&ver1));
|
|
|
|
tt_int_op(-1,OP_EQ, tor_version_parse(
|
|
|
|
"0.5.6.7 (git-000102030405060708090a0b0c0d0e0f1011121314)",
|
|
|
|
&ver1));
|
2009-09-22 19:49:09 +02:00
|
|
|
done:
|
2017-02-19 12:46:42 +01:00
|
|
|
teardown_capture_of_logs();
|
2009-09-22 19:49:09 +02:00
|
|
|
}
|
|
|
|
|
2009-10-18 21:45:57 +02:00
|
|
|
/** Run unit tests for directory fp_pair functions. */
|
2009-09-22 19:49:09 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_fp_pairs(void *arg)
|
2009-09-22 19:49:09 +02:00
|
|
|
{
|
2012-01-18 21:53:30 +01:00
|
|
|
smartlist_t *sl = smartlist_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
fp_pair_t *pair;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:49:09 +02:00
|
|
|
dir_split_resource_into_fingerprint_pairs(
|
|
|
|
/* Two pairs, out of order, with one duplicate. */
|
|
|
|
"73656372657420646174612E0000000000FFFFFF-"
|
|
|
|
"557365204145532d32353620696e73746561642e+"
|
|
|
|
"73656372657420646174612E0000000000FFFFFF-"
|
|
|
|
"557365204145532d32353620696e73746561642e+"
|
|
|
|
"48657861646563696d616c2069736e277420736f-"
|
|
|
|
"676f6f6420666f7220686964696e6720796f7572.z", sl);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl),OP_EQ, 2);
|
2009-09-22 19:49:09 +02:00
|
|
|
pair = smartlist_get(sl, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(pair->first,OP_EQ, "Hexadecimal isn't so", DIGEST_LEN);
|
|
|
|
tt_mem_op(pair->second,OP_EQ, "good for hiding your", DIGEST_LEN);
|
2009-09-22 19:49:09 +02:00
|
|
|
pair = smartlist_get(sl, 1);
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_mem_op(pair->first,OP_EQ, "secret data.\0\0\0\0\0\xff\xff\xff",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(pair->second,OP_EQ, "Use AES-256 instead.", DIGEST_LEN);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
done:
|
2016-07-05 20:19:31 +02:00
|
|
|
SMARTLIST_FOREACH(sl, fp_pair_t *, pair_to_free, tor_free(pair_to_free));
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_free(sl);
|
|
|
|
}
|
|
|
|
|
2009-10-18 21:45:57 +02:00
|
|
|
static void
|
|
|
|
test_dir_split_fps(void *testdata)
|
|
|
|
{
|
2012-01-18 21:53:30 +01:00
|
|
|
smartlist_t *sl = smartlist_new();
|
2009-10-18 21:45:57 +02:00
|
|
|
char *mem_op_hex_tmp = NULL;
|
|
|
|
(void)testdata;
|
|
|
|
|
|
|
|
/* Some example hex fingerprints and their base64 equivalents */
|
|
|
|
#define HEX1 "Fe0daff89127389bc67558691231234551193EEE"
|
|
|
|
#define HEX2 "Deadbeef99999991111119999911111111f00ba4"
|
|
|
|
#define HEX3 "b33ff00db33ff00db33ff00db33ff00db33ff00d"
|
|
|
|
#define HEX256_1 \
|
|
|
|
"f3f3f3f3fbbbbf3f3f3f3fbbbf3f3f3f3fbbbbf3f3f3f3fbbbf3f3f3f3fbbbbf"
|
|
|
|
#define HEX256_2 \
|
|
|
|
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccCCc"
|
|
|
|
#define HEX256_3 \
|
|
|
|
"0123456789ABCdef0123456789ABCdef0123456789ABCdef0123456789ABCdef"
|
|
|
|
#define B64_1 "/g2v+JEnOJvGdVhpEjEjRVEZPu4"
|
|
|
|
#define B64_2 "3q2+75mZmZERERmZmRERERHwC6Q"
|
|
|
|
#define B64_256_1 "8/Pz8/u7vz8/Pz+7vz8/Pz+7u/Pz8/P7u/Pz8/P7u78"
|
|
|
|
#define B64_256_2 "zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMw"
|
|
|
|
|
|
|
|
/* no flags set */
|
|
|
|
dir_split_resource_into_fingerprints("A+C+B", sl, NULL, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 3);
|
|
|
|
tt_str_op(smartlist_get(sl, 0), OP_EQ, "A");
|
|
|
|
tt_str_op(smartlist_get(sl, 1), OP_EQ, "C");
|
|
|
|
tt_str_op(smartlist_get(sl, 2), OP_EQ, "B");
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* uniq strings. */
|
|
|
|
dir_split_resource_into_fingerprints("A+C+B+A+B+B", sl, NULL, DSR_SORT_UNIQ);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 3);
|
|
|
|
tt_str_op(smartlist_get(sl, 0), OP_EQ, "A");
|
|
|
|
tt_str_op(smartlist_get(sl, 1), OP_EQ, "B");
|
|
|
|
tt_str_op(smartlist_get(sl, 2), OP_EQ, "C");
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* Decode hex. */
|
|
|
|
dir_split_resource_into_fingerprints(HEX1"+"HEX2, sl, NULL, DSR_HEX);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX1);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX2);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* decode hex and drop weirdness. */
|
|
|
|
dir_split_resource_into_fingerprints(HEX1"+bogus+"HEX2"+"HEX256_1,
|
|
|
|
sl, NULL, DSR_HEX);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX1);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX2);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* Decode long hex */
|
|
|
|
dir_split_resource_into_fingerprints(HEX256_1"+"HEX256_2"+"HEX2"+"HEX256_3,
|
|
|
|
sl, NULL, DSR_HEX|DSR_DIGEST256);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 3);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX256_1);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX256_2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 2), OP_EQ, HEX256_3);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* Decode hex and sort. */
|
|
|
|
dir_split_resource_into_fingerprints(HEX1"+"HEX2"+"HEX3"+"HEX2,
|
|
|
|
sl, NULL, DSR_HEX|DSR_SORT_UNIQ);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 3);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX3);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 2), OP_EQ, HEX1);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* Decode long hex and sort */
|
|
|
|
dir_split_resource_into_fingerprints(HEX256_1"+"HEX256_2"+"HEX256_3
|
|
|
|
"+"HEX256_1,
|
|
|
|
sl, NULL,
|
|
|
|
DSR_HEX|DSR_DIGEST256|DSR_SORT_UNIQ);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 3);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX256_3);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX256_2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 2), OP_EQ, HEX256_1);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* Decode base64 */
|
|
|
|
dir_split_resource_into_fingerprints(B64_1"-"B64_2, sl, NULL, DSR_BASE64);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX1);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX2);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
/* Decode long base64 */
|
|
|
|
dir_split_resource_into_fingerprints(B64_256_1"-"B64_256_2,
|
|
|
|
sl, NULL, DSR_BASE64|DSR_DIGEST256);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 2);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX256_1);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 1), OP_EQ, HEX256_2);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
dir_split_resource_into_fingerprints(B64_256_1,
|
|
|
|
sl, NULL, DSR_BASE64|DSR_DIGEST256);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(sl), OP_EQ, 1);
|
|
|
|
test_mem_op_hex(smartlist_get(sl, 0), OP_EQ, HEX256_1);
|
2009-10-18 21:45:57 +02:00
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_clear(sl);
|
|
|
|
|
|
|
|
done:
|
|
|
|
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(sl);
|
|
|
|
tor_free(mem_op_hex_tmp);
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_measured_bw_kb(void *arg)
|
2009-09-22 19:49:09 +02:00
|
|
|
{
|
|
|
|
measured_bw_line_t mbwl;
|
|
|
|
int i;
|
|
|
|
const char *lines_pass[] = {
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e\t bw=1024 \n",
|
|
|
|
" node_id=$557365204145532d32353620696e73746561642e bw=1024\n",
|
|
|
|
"\tnoise\tnode_id=$557365204145532d32353620696e73746561642e "
|
|
|
|
"bw=1024 junk=007\n",
|
|
|
|
"misc=junk node_id=$557365204145532d32353620696e73746561642e "
|
|
|
|
"bw=1024 junk=007\n",
|
2018-05-03 10:29:57 +02:00
|
|
|
/* check whether node_id can be at the end */
|
|
|
|
"bw=1024 node_id=$557365204145532d32353620696e73746561642e\n",
|
|
|
|
/* check whether node_id can be at the end and bw has something in front*/
|
|
|
|
"foo=bar bw=1024 node_id=$557365204145532d32353620696e73746561642e\n",
|
|
|
|
/* check whether node_id can be at the end and something in the
|
|
|
|
* in the middle of bw and node_id */
|
|
|
|
"bw=1024 foo=bar node_id=$557365204145532d32353620696e73746561642e\n",
|
2019-03-19 12:48:42 +01:00
|
|
|
|
|
|
|
/* Test that a line with vote=1 will pass. */
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 vote=1\n",
|
|
|
|
/* Test that a line with unmeasured=1 will pass. */
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 unmeasured=1\n",
|
|
|
|
/* Test that a line with vote=1 and unmeasured=1 will pass. */
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 vote=1"
|
|
|
|
"unmeasured=1\n",
|
|
|
|
/* Test that a line with unmeasured=0 will pass. */
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 unmeasured=0\n",
|
|
|
|
/* Test that a line with vote=1 and unmeasured=0 will pass. */
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 vote=1"
|
|
|
|
"unmeasured=0\n",
|
2009-09-22 19:49:09 +02:00
|
|
|
"end"
|
|
|
|
};
|
|
|
|
const char *lines_fail[] = {
|
|
|
|
/* Test possible python stupidity on input */
|
|
|
|
"node_id=None bw=1024\n",
|
|
|
|
"node_id=$None bw=1024\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=None\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024.0\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=.1024\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1.024\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 bw=0\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 bw=None\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=-1024\n",
|
|
|
|
/* Test incomplete writes due to race conditions, partial copies, etc */
|
|
|
|
"node_i",
|
|
|
|
"node_i\n",
|
|
|
|
"node_id=",
|
|
|
|
"node_id=\n",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024",
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=\n",
|
|
|
|
"node_id=$557365204145532d32353620696e7374",
|
|
|
|
"node_id=$557365204145532d32353620696e7374\n",
|
|
|
|
"",
|
|
|
|
"\n",
|
|
|
|
" \n ",
|
|
|
|
" \n\n",
|
|
|
|
/* Test assorted noise */
|
|
|
|
" node_id= ",
|
|
|
|
"node_id==$557365204145532d32353620696e73746561642e bw==1024\n",
|
|
|
|
"node_id=$55736520414552d32353620696e73746561642e bw=1024\n",
|
|
|
|
"node_id=557365204145532d32353620696e73746561642e bw=1024\n",
|
|
|
|
"node_id= $557365204145532d32353620696e73746561642e bw=0.23\n",
|
2019-03-19 12:48:42 +01:00
|
|
|
|
|
|
|
/* Test that a line with vote=0 will fail too, so that it is ignored. */
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 vote=0\n",
|
|
|
|
/* Test that a line with vote=0 will fail even if unmeasured=0. */
|
2021-07-01 19:03:19 +02:00
|
|
|
("node_id=$557365204145532d32353620696e73746561642e bw=1024 vote=0 "
|
|
|
|
"unmeasured=0\n"),
|
2009-09-22 19:49:09 +02:00
|
|
|
"end"
|
|
|
|
};
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:49:09 +02:00
|
|
|
for (i = 0; strcmp(lines_fail[i], "end"); i++) {
|
|
|
|
//fprintf(stderr, "Testing: %s\n", lines_fail[i]);
|
2018-06-20 14:29:38 +02:00
|
|
|
/* Testing only with line_is_after_headers = 1. Tests with
|
|
|
|
* line_is_after_headers = 0 in
|
|
|
|
* test_dir_measured_bw_kb_line_is_after_headers */
|
|
|
|
tt_assert(measured_bw_line_parse(&mbwl, lines_fail[i], 1) == -1);
|
2009-09-22 19:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; strcmp(lines_pass[i], "end"); i++) {
|
|
|
|
//fprintf(stderr, "Testing: %s %d\n", lines_pass[i], TOR_ISSPACE('\n'));
|
2018-06-20 14:29:38 +02:00
|
|
|
/* Testing only with line_is_after_headers = 1. Tests with
|
|
|
|
* line_is_after_headers = 0 in
|
|
|
|
* test_dir_measured_bw_kb_line_is_after_headers */
|
|
|
|
tt_assert(measured_bw_line_parse(&mbwl, lines_pass[i], 1) == 0);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(mbwl.bw_kb == 1024);
|
|
|
|
tt_assert(strcmp(mbwl.node_hex,
|
2009-09-22 19:49:09 +02:00
|
|
|
"557365204145532d32353620696e73746561642e") == 0);
|
|
|
|
}
|
|
|
|
|
2010-08-16 00:29:27 +02:00
|
|
|
done:
|
2009-09-22 19:49:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-20 14:29:38 +02:00
|
|
|
/* Unit tests for measured_bw_line_parse using line_is_after_headers flag.
|
|
|
|
* When the end of the header is detected (a first complete bw line is parsed),
|
|
|
|
* incomplete lines fail and give warnings, but do not give warnings if
|
|
|
|
* the header is not ended, allowing to ignore additional header lines. */
|
|
|
|
static void
|
|
|
|
test_dir_measured_bw_kb_line_is_after_headers(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
measured_bw_line_t mbwl;
|
|
|
|
const char *line_pass = \
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024\n";
|
|
|
|
int i;
|
|
|
|
const char *lines_fail[] = {
|
|
|
|
"node_id=$557365204145532d32353620696e73746561642e \n",
|
|
|
|
"bw=1024\n",
|
|
|
|
"rtt=300\n",
|
|
|
|
"end"
|
|
|
|
};
|
|
|
|
|
|
|
|
setup_capture_of_logs(LOG_DEBUG);
|
|
|
|
|
|
|
|
/* Test bw lines when header has ended */
|
|
|
|
for (i = 0; strcmp(lines_fail[i], "end"); i++) {
|
|
|
|
tt_assert(measured_bw_line_parse(&mbwl, lines_fail[i], 1) == -1);
|
|
|
|
expect_log_msg_containing("Incomplete line in bandwidth file:");
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
}
|
|
|
|
|
|
|
|
tt_assert(measured_bw_line_parse(&mbwl, line_pass, 1) == 0);
|
|
|
|
|
|
|
|
/* Test bw lines when header has not ended */
|
|
|
|
for (i = 0; strcmp(lines_fail[i], "end"); i++) {
|
|
|
|
tt_assert(measured_bw_line_parse(&mbwl, lines_fail[i], 0) == -1);
|
|
|
|
expect_log_msg_containing("Missing bw or node_id in bandwidth file line:");
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
}
|
|
|
|
|
|
|
|
tt_assert(measured_bw_line_parse(&mbwl, line_pass, 0) == 0);
|
|
|
|
|
|
|
|
done:
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
}
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
/* Test dirserv_read_measured_bandwidths with headers and complete files. */
|
2018-06-20 14:29:38 +02:00
|
|
|
static void
|
|
|
|
test_dir_dirserv_read_measured_bandwidths(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
char *content = NULL;
|
|
|
|
time_t timestamp = time(NULL);
|
|
|
|
char *fname = tor_strdup(get_fname("V3BandwidthsFile"));
|
2018-06-30 08:29:11 +02:00
|
|
|
smartlist_t *bw_file_headers = smartlist_new();
|
|
|
|
/* bw file strings in vote */
|
|
|
|
char *bw_file_headers_str = NULL;
|
|
|
|
char *bw_file_headers_str_v100 = NULL;
|
|
|
|
char *bw_file_headers_str_v110 = NULL;
|
|
|
|
char *bw_file_headers_str_bad = NULL;
|
|
|
|
char *bw_file_headers_str_extra = NULL;
|
2018-06-30 15:57:41 +02:00
|
|
|
char bw_file_headers_str_long[MAX_BW_FILE_HEADER_COUNT_IN_VOTE * 8 + 1] = "";
|
2018-06-30 08:29:11 +02:00
|
|
|
/* string header lines in bw file */
|
|
|
|
char *header_lines_v100 = NULL;
|
|
|
|
char *header_lines_v110_no_terminator = NULL;
|
|
|
|
char *header_lines_v110 = NULL;
|
2018-06-30 15:57:41 +02:00
|
|
|
char header_lines_long[MAX_BW_FILE_HEADER_COUNT_IN_VOTE * 8 + 1] = "";
|
2018-06-30 08:29:11 +02:00
|
|
|
int i;
|
|
|
|
const char *header_lines_v110_no_terminator_no_timestamp =
|
|
|
|
"version=1.1.0\n"
|
|
|
|
"software=sbws\n"
|
|
|
|
"software_version=0.1.0\n"
|
|
|
|
"earliest_bandwidth=2018-05-08T16:13:26\n"
|
|
|
|
"file_created=2018-04-16T21:49:18\n"
|
|
|
|
"generator_started=2018-05-08T16:13:25\n"
|
|
|
|
"latest_bandwidth=2018-04-16T20:49:18\n";
|
|
|
|
const char *bw_file_headers_str_v110_no_timestamp =
|
|
|
|
"version=1.1.0 software=sbws "
|
|
|
|
"software_version=0.1.0 "
|
|
|
|
"earliest_bandwidth=2018-05-08T16:13:26 "
|
|
|
|
"file_created=2018-04-16T21:49:18 "
|
|
|
|
"generator_started=2018-05-08T16:13:25 "
|
|
|
|
"latest_bandwidth=2018-04-16T20:49:18";
|
|
|
|
const char *relay_lines_v100 =
|
2018-06-20 14:29:38 +02:00
|
|
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024 "
|
|
|
|
"nick=Test measured_at=1523911725 updated_at=1523911725 "
|
|
|
|
"pid_error=4.11374090719 pid_error_sum=4.11374090719 "
|
|
|
|
"pid_bw=57136645 pid_delta=2.12168374577 circ_fail=0.2 "
|
|
|
|
"scanner=/filepath\n";
|
2018-06-30 08:29:11 +02:00
|
|
|
const char *relay_lines_v110 =
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 "
|
|
|
|
"master_key_ed25519=YaqV4vbvPYKucElk297eVdNArDz9HtIwUoIeo0+cVIpQ "
|
|
|
|
"bw=760 nick=Test rtt=380 time=2018-05-08T16:13:26\n";
|
|
|
|
const char *relay_lines_bad =
|
2018-06-30 15:57:41 +02:00
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A\n";
|
2018-06-30 08:29:11 +02:00
|
|
|
|
|
|
|
tor_asprintf(&header_lines_v100, "%ld\n", (long)timestamp);
|
|
|
|
tor_asprintf(&header_lines_v110_no_terminator, "%ld\n%s", (long)timestamp,
|
|
|
|
header_lines_v110_no_terminator_no_timestamp);
|
|
|
|
tor_asprintf(&header_lines_v110, "%s%s",
|
|
|
|
header_lines_v110_no_terminator, BW_FILE_HEADERS_TERMINATOR);
|
|
|
|
|
|
|
|
tor_asprintf(&bw_file_headers_str_v100, "timestamp=%ld",(long)timestamp);
|
|
|
|
tor_asprintf(&bw_file_headers_str_v110, "timestamp=%ld %s",
|
|
|
|
(long)timestamp, bw_file_headers_str_v110_no_timestamp);
|
|
|
|
tor_asprintf(&bw_file_headers_str_bad, "%s "
|
2018-06-30 15:57:41 +02:00
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A",
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str_v110);
|
|
|
|
|
2018-06-30 15:57:41 +02:00
|
|
|
for (i=0; i<MAX_BW_FILE_HEADER_COUNT_IN_VOTE; i++) {
|
2018-06-30 08:29:11 +02:00
|
|
|
strlcat(header_lines_long, "foo=bar\n",
|
|
|
|
sizeof(header_lines_long));
|
|
|
|
}
|
|
|
|
/* 8 is the number of v110 lines in header_lines_v110 */
|
2018-06-30 15:57:41 +02:00
|
|
|
for (i=0; i<MAX_BW_FILE_HEADER_COUNT_IN_VOTE - 8 - 1; i++) {
|
2018-06-30 08:29:11 +02:00
|
|
|
strlcat(bw_file_headers_str_long, "foo=bar ",
|
|
|
|
sizeof(bw_file_headers_str_long));
|
|
|
|
}
|
|
|
|
strlcat(bw_file_headers_str_long, "foo=bar",
|
|
|
|
sizeof(bw_file_headers_str_long));
|
|
|
|
tor_asprintf(&bw_file_headers_str_extra,
|
|
|
|
"%s %s",
|
|
|
|
bw_file_headers_str_v110,
|
|
|
|
bw_file_headers_str_long);
|
|
|
|
|
|
|
|
/* Test an empty bandwidth file. bw_file_headers will be empty string */
|
|
|
|
write_str_to_file(fname, "", 0);
|
|
|
|
setup_capture_of_logs(LOG_WARN);
|
|
|
|
tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
2018-06-30 08:29:11 +02:00
|
|
|
expect_log_msg("Empty bandwidth file\n");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op("", OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test bandwidth file with only timestamp.
|
|
|
|
* bw_file_headers will be empty string */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%ld", (long)timestamp);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-06-30 08:29:11 +02:00
|
|
|
tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op("", OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.0.0 bandwidth file headers */
|
|
|
|
write_str_to_file(fname, header_lines_v100, 0);
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v100, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.0.0 complete bandwidth file */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s", header_lines_v100, relay_lines_v100);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-06-30 08:29:11 +02:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v100, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
2018-06-30 15:52:54 +02:00
|
|
|
/* Test v1.0.0 complete bandwidth file with NULL bw_file_headers. */
|
|
|
|
tor_asprintf(&content, "%s%s", header_lines_v100, relay_lines_v100);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-11-06 15:49:20 +01:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL, NULL,
|
|
|
|
NULL));
|
2018-06-20 14:29:38 +02:00
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
/* Test bandwidth file including v1.1.0 bandwidth headers and
|
|
|
|
* v1.0.0 relay lines. bw_file_headers will contain the v1.1.0 headers. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s", header_lines_v100, header_lines_v110,
|
|
|
|
relay_lines_v100);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-06-30 08:29:11 +02:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v110, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.0.0 complete bandwidth file with v1.1.0 headers at the end.
|
|
|
|
* bw_file_headers will contain only v1.0.0 headers and the additional
|
|
|
|
* headers will be interpreted as malformed relay lines. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s", header_lines_v100, relay_lines_v100,
|
|
|
|
header_lines_v110);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-06-30 08:29:11 +02:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v100, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.0.0 complete bandwidth file, the v1.1.0 headers and more relay
|
|
|
|
* lines. bw_file_headers will contain only v1.0.0 headers, the additional
|
|
|
|
* headers will be interpreted as malformed relay lines and the last relay
|
|
|
|
* lines will be correctly interpreted as relay lines. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s%s", header_lines_v100, relay_lines_v100,
|
|
|
|
header_lines_v110, relay_lines_v100);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v100, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth headers without terminator */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
write_str_to_file(fname, header_lines_v110_no_terminator, 0);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v110, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth headers with terminator */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
write_str_to_file(fname, header_lines_v110, 0);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v110, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth file without terminator, then relay lines.
|
|
|
|
* bw_file_headers will contain the v1.1.0 headers. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s",
|
|
|
|
header_lines_v110_no_terminator, relay_lines_v110);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v110, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth headers with terminator, then relay lines
|
|
|
|
* bw_file_headers will contain the v1.1.0 headers. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s",
|
|
|
|
header_lines_v110, relay_lines_v110);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-06-30 08:29:11 +02:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v110, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth headers with terminator, then bad relay lines,
|
|
|
|
* then terminator, then relay_lines_bad.
|
|
|
|
* bw_file_headers will contain the v1.1.0 headers. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s%s", header_lines_v110, relay_lines_bad,
|
|
|
|
BW_FILE_HEADERS_TERMINATOR, relay_lines_bad);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 08:29:11 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_v110, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
2018-06-20 14:29:38 +02:00
|
|
|
|
2018-06-30 15:57:41 +02:00
|
|
|
/* Test v1.1.0 bandwidth headers without terminator, then bad relay lines,
|
|
|
|
* then relay lines. bw_file_headers will contain the v1.1.0 headers and
|
|
|
|
* the bad relay lines. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s",
|
|
|
|
header_lines_v110_no_terminator, relay_lines_bad,
|
|
|
|
relay_lines_v110);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 15:57:41 +02:00
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_bad, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth headers without terminator,
|
|
|
|
* then many bad relay lines, then relay lines.
|
|
|
|
* bw_file_headers will contain the v1.1.0 headers and the bad relay lines
|
|
|
|
* to a maximum of MAX_BW_FILE_HEADER_COUNT_IN_VOTE header lines. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s",
|
|
|
|
header_lines_v110_no_terminator, header_lines_long,
|
|
|
|
relay_lines_v110);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 15:57:41 +02:00
|
|
|
tt_int_op(MAX_BW_FILE_HEADER_COUNT_IN_VOTE, OP_EQ,
|
|
|
|
smartlist_len(bw_file_headers));
|
|
|
|
bw_file_headers_str = smartlist_join_strings(bw_file_headers, " ", 0, NULL);
|
|
|
|
tt_str_op(bw_file_headers_str_extra, OP_EQ, bw_file_headers_str);
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
|
|
|
|
|
|
|
/* Test v1.1.0 bandwidth headers without terminator,
|
|
|
|
* then many bad relay lines, then relay lines.
|
|
|
|
* bw_file_headers will contain the v1.1.0 headers and the bad relay lines.
|
|
|
|
* Force bw_file_headers to have more than MAX_BW_FILE_HEADER_COUNT_IN_VOTE
|
|
|
|
* This test is needed while there is not dirvote test. */
|
|
|
|
bw_file_headers = smartlist_new();
|
|
|
|
tor_asprintf(&content, "%s%s%s",
|
|
|
|
header_lines_v110_no_terminator, header_lines_long,
|
|
|
|
relay_lines_v110);
|
2018-06-20 14:29:38 +02:00
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
2018-06-30 15:57:41 +02:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL,
|
2018-11-06 15:49:20 +01:00
|
|
|
bw_file_headers,
|
|
|
|
NULL));
|
|
|
|
|
2018-06-30 15:57:41 +02:00
|
|
|
tt_int_op(MAX_BW_FILE_HEADER_COUNT_IN_VOTE, OP_EQ,
|
|
|
|
smartlist_len(bw_file_headers));
|
|
|
|
/* force bw_file_headers to be bigger than
|
|
|
|
* MAX_BW_FILE_HEADER_COUNT_IN_VOTE */
|
|
|
|
char line[8] = "foo=bar\0";
|
|
|
|
smartlist_add_strdup(bw_file_headers, line);
|
|
|
|
tt_int_op(MAX_BW_FILE_HEADER_COUNT_IN_VOTE, OP_LT,
|
|
|
|
smartlist_len(bw_file_headers));
|
|
|
|
SMARTLIST_FOREACH(bw_file_headers, char *, c, tor_free(c));
|
|
|
|
smartlist_free(bw_file_headers);
|
|
|
|
tor_free(bw_file_headers_str);
|
2018-06-20 14:29:38 +02:00
|
|
|
|
2019-03-19 12:48:42 +01:00
|
|
|
/* Test v1.x.x bandwidth line with vote=0.
|
|
|
|
* It will be ignored it and logged it at debug level. */
|
|
|
|
const char *relay_lines_ignore =
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=0\n"
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=0"
|
|
|
|
"unmeasured=1\n"
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=0"
|
|
|
|
"unmeasured=0\n";
|
|
|
|
|
|
|
|
/* Create the bandwidth file */
|
|
|
|
tor_asprintf(&content, "%ld\n%s", (long)timestamp, relay_lines_ignore);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
|
|
|
|
/* Read the bandwidth file */
|
|
|
|
setup_full_capture_of_logs(LOG_DEBUG);
|
2019-03-21 14:35:56 +01:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL, NULL,
|
|
|
|
NULL));
|
2019-03-19 12:48:42 +01:00
|
|
|
expect_log_msg_containing("Ignoring bandwidth file line");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
/* Test v1.x.x bandwidth line with "vote=1" or "unmeasured=1" or
|
|
|
|
* "unmeasured=0".
|
|
|
|
* They will not be ignored. */
|
|
|
|
/* Create the bandwidth file */
|
|
|
|
const char *relay_lines_vote =
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 vote=1\n"
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 unmeasured=0\n"
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 bw=1024 unmeasured=1\n";
|
|
|
|
tor_asprintf(&content, "%ld\n%s", (long)timestamp, relay_lines_vote);
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tor_free(content);
|
|
|
|
|
|
|
|
/* Read the bandwidth file */
|
|
|
|
setup_full_capture_of_logs(LOG_DEBUG);
|
2019-03-21 14:35:56 +01:00
|
|
|
tt_int_op(0, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL, NULL,
|
|
|
|
NULL));
|
2019-03-19 12:48:42 +01:00
|
|
|
expect_log_msg_not_containing("Ignoring bandwidth file line");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
2018-06-20 14:29:38 +02:00
|
|
|
done:
|
2018-11-06 15:56:05 +01:00
|
|
|
unlink(fname);
|
2018-06-20 14:29:38 +02:00
|
|
|
tor_free(fname);
|
2018-06-30 08:29:11 +02:00
|
|
|
tor_free(header_lines_v100);
|
|
|
|
tor_free(header_lines_v110_no_terminator);
|
|
|
|
tor_free(header_lines_v110);
|
|
|
|
tor_free(bw_file_headers_str_v100);
|
|
|
|
tor_free(bw_file_headers_str_v110);
|
|
|
|
tor_free(bw_file_headers_str_bad);
|
|
|
|
tor_free(bw_file_headers_str_extra);
|
2018-06-20 14:29:38 +02:00
|
|
|
}
|
|
|
|
|
2013-03-08 00:41:22 +01:00
|
|
|
#define MBWC_INIT_TIME 1000
|
|
|
|
|
|
|
|
/** Do the measured bandwidth cache unit test */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_measured_bw_kb_cache(void *arg)
|
2013-03-08 00:41:22 +01:00
|
|
|
{
|
|
|
|
/* Initial fake time_t for testing */
|
|
|
|
time_t curr = MBWC_INIT_TIME;
|
|
|
|
/* Some measured_bw_line_ts */
|
|
|
|
measured_bw_line_t mbwl[3];
|
|
|
|
/* For receiving output on cache queries */
|
|
|
|
long bw;
|
|
|
|
time_t as_of;
|
|
|
|
|
|
|
|
/* First, clear the cache and assert that it's empty */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2013-03-08 00:41:22 +01:00
|
|
|
dirserv_clear_measured_bw_cache();
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 0);
|
2013-03-08 00:41:22 +01:00
|
|
|
/*
|
|
|
|
* Set up test mbwls; none of the dirserv_cache_*() functions care about
|
|
|
|
* the node_hex field.
|
|
|
|
*/
|
|
|
|
memset(mbwl[0].node_id, 0x01, DIGEST_LEN);
|
2013-04-11 17:43:40 +02:00
|
|
|
mbwl[0].bw_kb = 20;
|
2013-03-08 00:41:22 +01:00
|
|
|
memset(mbwl[1].node_id, 0x02, DIGEST_LEN);
|
2013-04-11 17:43:40 +02:00
|
|
|
mbwl[1].bw_kb = 40;
|
2013-03-08 00:41:22 +01:00
|
|
|
memset(mbwl[2].node_id, 0x03, DIGEST_LEN);
|
2013-04-11 17:43:40 +02:00
|
|
|
mbwl[2].bw_kb = 80;
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Try caching something */
|
|
|
|
dirserv_cache_measured_bw(&(mbwl[0]), curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 1);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Okay, let's see if we can retrieve it */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,&bw, &as_of));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(bw,OP_EQ, 20);
|
|
|
|
tt_int_op(as_of,OP_EQ, MBWC_INIT_TIME);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Try retrieving it without some outputs */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,NULL, NULL));
|
|
|
|
tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,&bw, NULL));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(bw,OP_EQ, 20);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,NULL,&as_of));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(as_of,OP_EQ, MBWC_INIT_TIME);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Now expire it */
|
|
|
|
curr += MAX_MEASUREMENT_AGE + 1;
|
|
|
|
dirserv_expire_measured_bw_cache(curr);
|
|
|
|
/* Check that the cache is empty */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 0);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Check that we can't retrieve it */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!dirserv_query_measured_bw_cache_kb(mbwl[0].node_id, NULL,NULL));
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Try caching a few things now */
|
|
|
|
dirserv_cache_measured_bw(&(mbwl[0]), curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 1);
|
2013-03-08 00:41:22 +01:00
|
|
|
curr += MAX_MEASUREMENT_AGE / 4;
|
|
|
|
dirserv_cache_measured_bw(&(mbwl[1]), curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 2);
|
2013-03-08 00:41:22 +01:00
|
|
|
curr += MAX_MEASUREMENT_AGE / 4;
|
|
|
|
dirserv_cache_measured_bw(&(mbwl[2]), curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 3);
|
2013-03-08 00:41:22 +01:00
|
|
|
curr += MAX_MEASUREMENT_AGE / 4 + 1;
|
|
|
|
/* Do an expire that's too soon to get any of them */
|
|
|
|
dirserv_expire_measured_bw_cache(curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 3);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* Push the oldest one off the cliff */
|
|
|
|
curr += MAX_MEASUREMENT_AGE / 4;
|
|
|
|
dirserv_expire_measured_bw_cache(curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 2);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* And another... */
|
|
|
|
curr += MAX_MEASUREMENT_AGE / 4;
|
|
|
|
dirserv_expire_measured_bw_cache(curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 1);
|
2013-03-08 00:41:22 +01:00
|
|
|
/* This should empty it out again */
|
|
|
|
curr += MAX_MEASUREMENT_AGE / 4;
|
|
|
|
dirserv_expire_measured_bw_cache(curr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dirserv_get_measured_bw_cache_size(),OP_EQ, 0);
|
2013-03-08 00:41:22 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-10 02:10:43 +02:00
|
|
|
static char *
|
2016-07-01 23:52:32 +02:00
|
|
|
my_dirvote_compute_params(smartlist_t *votes, int method,
|
|
|
|
int total_authorities)
|
2016-05-10 02:10:43 +02:00
|
|
|
{
|
|
|
|
smartlist_t *s = dirvote_compute_params(votes, method, total_authorities);
|
|
|
|
tor_assert(s);
|
|
|
|
char *res = smartlist_join_strings(s, " ", 0, NULL);
|
|
|
|
SMARTLIST_FOREACH(s, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(s);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define dirvote_compute_params my_dirvote_compute_params
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_param_voting(void *arg)
|
2009-09-22 19:49:09 +02:00
|
|
|
{
|
|
|
|
networkstatus_t vote1, vote2, vote3, vote4;
|
2012-01-18 21:53:30 +01:00
|
|
|
smartlist_t *votes = smartlist_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
char *res = NULL;
|
|
|
|
|
|
|
|
/* dirvote_compute_params only looks at the net_params field of the votes,
|
|
|
|
so that's all we need to set.
|
|
|
|
*/
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:49:09 +02:00
|
|
|
memset(&vote1, 0, sizeof(vote1));
|
|
|
|
memset(&vote2, 0, sizeof(vote2));
|
|
|
|
memset(&vote3, 0, sizeof(vote3));
|
|
|
|
memset(&vote4, 0, sizeof(vote4));
|
2012-01-18 21:53:30 +01:00
|
|
|
vote1.net_params = smartlist_new();
|
|
|
|
vote2.net_params = smartlist_new();
|
|
|
|
vote3.net_params = smartlist_new();
|
|
|
|
vote4.net_params = smartlist_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_split_string(vote1.net_params,
|
|
|
|
"ab=90 abcd=20 cw=50 x-yz=-99", NULL, 0, 0);
|
|
|
|
smartlist_split_string(vote2.net_params,
|
|
|
|
"ab=27 cw=5 x-yz=88", NULL, 0, 0);
|
|
|
|
smartlist_split_string(vote3.net_params,
|
|
|
|
"abcd=20 c=60 cw=500 x-yz=-9 zzzzz=101", NULL, 0, 0);
|
|
|
|
smartlist_split_string(vote4.net_params,
|
|
|
|
"ab=900 abcd=200 c=1 cw=51 x-yz=100", NULL, 0, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(100,OP_EQ, networkstatus_get_param(&vote4, "x-yz", 50, 0, 300));
|
|
|
|
tt_int_op(222,OP_EQ, networkstatus_get_param(&vote4, "foobar", 222, 0, 300));
|
|
|
|
tt_int_op(80,OP_EQ, networkstatus_get_param(&vote4, "ab", 12, 0, 80));
|
|
|
|
tt_int_op(-8,OP_EQ, networkstatus_get_param(&vote4, "ab", -12, -100, -8));
|
|
|
|
tt_int_op(0,OP_EQ, networkstatus_get_param(&vote4, "foobar", 0, -100, 8));
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2016-11-26 15:22:04 +01:00
|
|
|
tt_int_op(100,OP_EQ, networkstatus_get_overridable_param(
|
|
|
|
&vote4, -1, "x-yz", 50, 0, 300));
|
|
|
|
tt_int_op(30,OP_EQ, networkstatus_get_overridable_param(
|
|
|
|
&vote4, 30, "x-yz", 50, 0, 300));
|
|
|
|
tt_int_op(0,OP_EQ, networkstatus_get_overridable_param(
|
|
|
|
&vote4, -101, "foobar", 0, -100, 8));
|
|
|
|
tt_int_op(-99,OP_EQ, networkstatus_get_overridable_param(
|
|
|
|
&vote4, -99, "foobar", 0, -100, 8));
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_add(votes, &vote1);
|
2011-02-21 03:05:17 +01:00
|
|
|
|
|
|
|
/* Do the first tests without adding all the other votes, for
|
|
|
|
* networks without many dirauths. */
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=90 abcd=20 cw=50 x-yz=-99");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_add(votes, &vote2);
|
2011-02-21 03:05:17 +01:00
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=27 cw=5 x-yz=-99");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 3);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=27 cw=5 x-yz=-99");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 6);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_add(votes, &vote3);
|
2011-02-21 03:05:17 +01:00
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 3);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=27 abcd=20 cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 5);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 9);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_add(votes, &vote4);
|
|
|
|
|
2011-02-21 03:05:17 +01:00
|
|
|
res = dirvote_compute_params(votes, 12, 4);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=90 abcd=20 cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 5);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=90 abcd=20 cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
/* Test that the special-cased "at least three dirauths voted for
|
|
|
|
* this param" logic works as expected. */
|
|
|
|
res = dirvote_compute_params(votes, 12, 6);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=90 abcd=20 cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
res = dirvote_compute_params(votes, 12, 10);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(res,OP_EQ, "ab=90 abcd=20 cw=50 x-yz=-9");
|
2011-02-21 03:05:17 +01:00
|
|
|
tor_free(res);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(res);
|
|
|
|
SMARTLIST_FOREACH(vote1.net_params, char *, cp, tor_free(cp));
|
|
|
|
SMARTLIST_FOREACH(vote2.net_params, char *, cp, tor_free(cp));
|
|
|
|
SMARTLIST_FOREACH(vote3.net_params, char *, cp, tor_free(cp));
|
|
|
|
SMARTLIST_FOREACH(vote4.net_params, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(vote1.net_params);
|
|
|
|
smartlist_free(vote2.net_params);
|
|
|
|
smartlist_free(vote3.net_params);
|
|
|
|
smartlist_free(vote4.net_params);
|
2009-09-26 15:58:54 +02:00
|
|
|
smartlist_free(votes);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-03 17:42:50 +02:00
|
|
|
static void
|
|
|
|
test_dir_param_voting_lookup(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
smartlist_t *lst = smartlist_new();
|
|
|
|
|
|
|
|
smartlist_split_string(lst,
|
|
|
|
"moomin=9 moomin=10 moomintroll=5 fred "
|
|
|
|
"jack= electricity=sdk opa=6z abc=9 abcd=99",
|
|
|
|
NULL, 0, 0);
|
|
|
|
|
|
|
|
tt_int_op(1000,
|
|
|
|
OP_EQ, dirvote_get_intermediate_param_value(lst, "ab", 1000));
|
|
|
|
tt_int_op(9, OP_EQ, dirvote_get_intermediate_param_value(lst, "abc", 1000));
|
2016-07-01 23:52:32 +02:00
|
|
|
tt_int_op(99, OP_EQ,
|
|
|
|
dirvote_get_intermediate_param_value(lst, "abcd", 1000));
|
2016-05-03 17:42:50 +02:00
|
|
|
|
2020-03-14 17:51:01 +01:00
|
|
|
#ifndef ALL_BUGS_ARE_FATAL
|
2016-09-07 19:49:18 +02:00
|
|
|
/* moomin appears twice. That's a bug. */
|
|
|
|
tor_capture_bugs_(1);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_int_op(-100, OP_EQ,
|
|
|
|
dirvote_get_intermediate_param_value(lst, "moomin", -100));
|
2016-09-07 19:49:18 +02:00
|
|
|
tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ,
|
2017-07-07 19:06:02 +02:00
|
|
|
"n_found == 0");
|
2016-09-07 19:49:18 +02:00
|
|
|
tor_end_capture_bugs_();
|
|
|
|
/* There is no 'fred=', so that is treated as not existing. */
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_int_op(-100, OP_EQ,
|
|
|
|
dirvote_get_intermediate_param_value(lst, "fred", -100));
|
2016-09-07 19:49:18 +02:00
|
|
|
/* jack is truncated */
|
|
|
|
tor_capture_bugs_(1);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_int_op(-100, OP_EQ,
|
|
|
|
dirvote_get_intermediate_param_value(lst, "jack", -100));
|
2016-09-07 19:49:18 +02:00
|
|
|
tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ,
|
2020-01-10 16:20:39 +01:00
|
|
|
"!(!ok)");
|
2016-09-07 19:49:18 +02:00
|
|
|
tor_end_capture_bugs_();
|
2016-05-03 17:42:50 +02:00
|
|
|
/* electricity and opa aren't integers. */
|
2016-09-07 19:49:18 +02:00
|
|
|
tor_capture_bugs_(1);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_int_op(-100, OP_EQ,
|
|
|
|
dirvote_get_intermediate_param_value(lst, "electricity", -100));
|
2016-09-07 19:49:18 +02:00
|
|
|
tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ,
|
2020-01-10 16:20:39 +01:00
|
|
|
"!(!ok)");
|
2016-09-07 19:49:18 +02:00
|
|
|
tor_end_capture_bugs_();
|
|
|
|
|
|
|
|
tor_capture_bugs_(1);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_int_op(-100, OP_EQ,
|
|
|
|
dirvote_get_intermediate_param_value(lst, "opa", -100));
|
2016-09-07 19:49:18 +02:00
|
|
|
tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(tor_get_captured_bug_log_(), 0), OP_EQ,
|
2020-01-10 16:20:39 +01:00
|
|
|
"!(!ok)");
|
2016-09-07 19:49:18 +02:00
|
|
|
tor_end_capture_bugs_();
|
2020-04-29 14:07:35 +02:00
|
|
|
#endif /* !defined(ALL_BUGS_ARE_FATAL) */
|
2016-05-03 17:42:50 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
SMARTLIST_FOREACH(lst, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(lst);
|
2016-09-07 19:49:18 +02:00
|
|
|
tor_end_capture_bugs_();
|
2016-05-03 17:42:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef dirvote_compute_params
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
/** Helper: Test that two networkstatus_voter_info_t do in fact represent the
|
|
|
|
* same voting authority, and that they do in fact have all the same
|
|
|
|
* information. */
|
|
|
|
static void
|
|
|
|
test_same_voter(networkstatus_voter_info_t *v1,
|
|
|
|
networkstatus_voter_info_t *v2)
|
|
|
|
{
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(v1->nickname,OP_EQ, v2->nickname);
|
|
|
|
tt_mem_op(v1->identity_digest,OP_EQ, v2->identity_digest, DIGEST_LEN);
|
|
|
|
tt_str_op(v1->address,OP_EQ, v2->address);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq(&v1->ipv4_addr, &v2->ipv4_addr));
|
|
|
|
tt_int_op(v1->ipv4_dirport,OP_EQ, v2->ipv4_dirport);
|
|
|
|
tt_int_op(v1->ipv4_orport,OP_EQ, v2->ipv4_orport);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(v1->contact,OP_EQ, v2->contact);
|
|
|
|
tt_mem_op(v1->vote_digest,OP_EQ, v2->vote_digest, DIGEST_LEN);
|
2009-09-22 19:49:09 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-09-23 21:23:04 +02:00
|
|
|
/** Helper: get a detached signatures document for one or two
|
|
|
|
* consensuses. */
|
2009-09-23 09:02:32 +02:00
|
|
|
static char *
|
2009-09-23 21:23:04 +02:00
|
|
|
get_detached_sigs(networkstatus_t *ns, networkstatus_t *ns2)
|
2009-09-23 09:02:32 +02:00
|
|
|
{
|
|
|
|
char *r;
|
|
|
|
smartlist_t *sl;
|
|
|
|
tor_assert(ns && ns->flavor == FLAV_NS);
|
2012-01-18 21:53:30 +01:00
|
|
|
sl = smartlist_new();
|
2009-09-23 09:02:32 +02:00
|
|
|
smartlist_add(sl,ns);
|
2009-09-23 21:23:04 +02:00
|
|
|
if (ns2)
|
|
|
|
smartlist_add(sl,ns2);
|
2009-09-23 09:02:32 +02:00
|
|
|
r = networkstatus_get_detached_signatures(sl);
|
|
|
|
smartlist_free(sl);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-02-15 09:28:04 +01:00
|
|
|
/** Apply tweaks to the vote list for each voter */
|
2013-02-19 17:58:09 +01:00
|
|
|
static int
|
2013-02-15 09:28:04 +01:00
|
|
|
vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
|
|
|
|
{
|
|
|
|
vote_routerstatus_t *vrs;
|
|
|
|
const char *msg = NULL;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v);
|
2013-02-15 09:28:04 +01:00
|
|
|
(void)now;
|
|
|
|
|
|
|
|
if (voter == 1) {
|
|
|
|
measured_bw_line_t mbw;
|
|
|
|
memset(mbw.node_id, 33, sizeof(mbw.node_id));
|
2013-04-11 17:43:40 +02:00
|
|
|
mbw.bw_kb = 1024;
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(measured_bw_line_apply(&mbw, v->routerstatus_list), OP_EQ, 1);
|
2013-02-15 09:28:04 +01:00
|
|
|
} else if (voter == 2 || voter == 3) {
|
|
|
|
/* Monkey around with the list a bit */
|
|
|
|
vrs = smartlist_get(v->routerstatus_list, 2);
|
|
|
|
smartlist_del_keeporder(v->routerstatus_list, 2);
|
2014-04-26 19:32:36 +02:00
|
|
|
vote_routerstatus_free(vrs);
|
2013-02-15 09:28:04 +01:00
|
|
|
vrs = smartlist_get(v->routerstatus_list, 0);
|
|
|
|
vrs->status.is_fast = 1;
|
|
|
|
|
|
|
|
if (voter == 3) {
|
|
|
|
vrs = smartlist_get(v->routerstatus_list, 0);
|
|
|
|
smartlist_del_keeporder(v->routerstatus_list, 0);
|
2014-04-26 19:32:36 +02:00
|
|
|
vote_routerstatus_free(vrs);
|
2013-02-15 09:28:04 +01:00
|
|
|
vrs = smartlist_get(v->routerstatus_list, 0);
|
|
|
|
memset(vrs->status.descriptor_digest, (int)'Z', DIGEST_LEN);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(router_add_to_routerlist(
|
2015-01-26 20:49:48 +01:00
|
|
|
dir_common_generate_ri_from_rs(vrs), &msg,0,0) >= 0);
|
2013-02-15 09:28:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2013-02-19 17:58:09 +01:00
|
|
|
return 0;
|
2013-02-15 09:28:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test a parsed vote_routerstatus_t for v3_networkstatus test
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
|
|
|
|
{
|
|
|
|
routerstatus_t *rs;
|
|
|
|
tor_addr_t addr_ipv6;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(vrs);
|
2013-02-15 09:28:04 +01:00
|
|
|
rs = &(vrs->status);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
|
|
|
/* Split out by digests to test */
|
|
|
|
if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN) &&
|
|
|
|
(voter == 1)) {
|
|
|
|
/* Check the first routerstatus. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(vrs->version,OP_EQ, "0.1.2.14");
|
2021-11-09 19:29:36 +01:00
|
|
|
tt_int_op(vrs->published_on,OP_EQ, now-1500);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(rs->nickname,OP_EQ, "router2");
|
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-15 09:28:04 +01:00
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&rs->ipv4_addr, 0x99008801));
|
|
|
|
tt_int_op(rs->ipv4_orport,OP_EQ, 443);
|
|
|
|
tt_int_op(rs->ipv4_dirport,OP_EQ, 8000);
|
2016-09-07 19:40:38 +02:00
|
|
|
/* no flags except "running" (16) and "v2dir" (64) and "valid" (128) */
|
2018-07-03 16:33:50 +02:00
|
|
|
tt_u64_op(vrs->flags, OP_EQ, UINT64_C(0xd0));
|
2013-02-15 09:28:04 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN) &&
|
|
|
|
(voter == 1 || voter == 2)) {
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-15 09:28:04 +01:00
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN);
|
|
|
|
|
|
|
|
if (voter == 1) {
|
|
|
|
/* Check the second routerstatus. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(vrs->version,OP_EQ, "0.2.0.5");
|
2021-11-09 19:29:36 +01:00
|
|
|
tt_int_op(vrs->published_on,OP_EQ, now-1000);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(rs->nickname,OP_EQ, "router1");
|
2013-02-15 09:28:04 +01:00
|
|
|
}
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&rs->ipv4_addr, 0x99009901));
|
|
|
|
tt_int_op(rs->ipv4_orport,OP_EQ, 443);
|
|
|
|
tt_int_op(rs->ipv4_dirport,OP_EQ, 0);
|
2013-02-15 09:28:04 +01:00
|
|
|
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->ipv6_orport,OP_EQ, 4711);
|
2013-02-15 09:28:04 +01:00
|
|
|
if (voter == 1) {
|
2014-10-28 18:12:52 +01:00
|
|
|
/* all except "authority" (1) */
|
2018-07-03 16:33:50 +02:00
|
|
|
tt_u64_op(vrs->flags, OP_EQ, UINT64_C(254));
|
2013-02-15 09:28:04 +01:00
|
|
|
} else {
|
2014-10-28 18:12:52 +01:00
|
|
|
/* 1023 - authority(1) - madeofcheese(16) - madeoftin(32) */
|
2018-07-03 16:33:50 +02:00
|
|
|
tt_u64_op(vrs->flags, OP_EQ, UINT64_C(974));
|
2013-02-15 09:28:04 +01:00
|
|
|
}
|
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
|
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33",
|
|
|
|
DIGEST_LEN) &&
|
|
|
|
(voter == 1 || voter == 2)) {
|
|
|
|
/* Check the measured bandwidth bits */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(vrs->has_measured_bw &&
|
2013-04-11 17:43:40 +02:00
|
|
|
vrs->measured_bw_kb == 1024);
|
2013-02-15 09:28:04 +01:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Didn't expect this, but the old unit test only checked some of them,
|
|
|
|
* so don't assert.
|
|
|
|
*/
|
2014-09-16 03:29:48 +02:00
|
|
|
/* tt_assert(0); */
|
2013-02-15 09:28:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test a consensus for v3_networkstatus_test
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_consensus_for_v3ns(networkstatus_t *con, time_t now)
|
|
|
|
{
|
|
|
|
(void)now;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(con);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(con->cert, OP_EQ, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2,OP_EQ, smartlist_len(con->routerstatus_list));
|
2013-02-15 09:28:04 +01:00
|
|
|
/* There should be two listed routers: one with identity 3, one with
|
|
|
|
* identity 5. */
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test a router list entry for v3_networkstatus test
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_routerstatus_for_v3ns(routerstatus_t *rs, time_t now)
|
|
|
|
{
|
2021-11-09 19:29:36 +01:00
|
|
|
(void)now;
|
2013-02-15 09:28:04 +01:00
|
|
|
tor_addr_t addr_ipv6;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
|
|
|
/* There should be two listed routers: one with identity 3, one with
|
|
|
|
* identity 5. */
|
|
|
|
/* This one showed up in 2 digests. */
|
|
|
|
if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3",
|
|
|
|
DIGEST_LEN)) {
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-15 09:28:04 +01:00
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_authority);
|
|
|
|
tt_assert(!rs->is_exit);
|
|
|
|
tt_assert(!rs->is_fast);
|
|
|
|
tt_assert(!rs->is_possible_guard);
|
|
|
|
tt_assert(!rs->is_stable);
|
2013-02-15 09:28:04 +01:00
|
|
|
/* (If it wasn't running it wouldn't be here) */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->is_flagged_running);
|
2016-09-07 19:40:38 +02:00
|
|
|
tt_assert(rs->is_valid);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_named);
|
2014-10-28 23:01:06 +01:00
|
|
|
tt_assert(rs->is_v2_dir);
|
2013-02-15 09:28:04 +01:00
|
|
|
/* XXXX check version */
|
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/* This one showed up in 3 digests. Twice with ID 'M', once with 'Z'. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-15 09:28:04 +01:00
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(rs->nickname,OP_EQ, "router1");
|
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&rs->ipv4_addr, 0x99009901));
|
|
|
|
tt_int_op(rs->ipv4_orport,OP_EQ, 443);
|
|
|
|
tt_int_op(rs->ipv4_dirport,OP_EQ, 0);
|
2013-02-15 09:28:04 +01:00
|
|
|
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->ipv6_orport,OP_EQ, 4711);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_authority);
|
|
|
|
tt_assert(rs->is_exit);
|
|
|
|
tt_assert(rs->is_fast);
|
|
|
|
tt_assert(rs->is_possible_guard);
|
|
|
|
tt_assert(rs->is_stable);
|
|
|
|
tt_assert(rs->is_flagged_running);
|
|
|
|
tt_assert(rs->is_valid);
|
2014-10-28 18:12:52 +01:00
|
|
|
tt_assert(rs->is_v2_dir);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_named);
|
2013-02-15 09:28:04 +01:00
|
|
|
/* XXXX check version */
|
|
|
|
} else {
|
|
|
|
/* Weren't expecting this... */
|
2017-08-24 21:34:34 +02:00
|
|
|
tt_abort();
|
2013-02-15 09:28:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-04 03:09:25 +02:00
|
|
|
static void
|
|
|
|
test_dir_networkstatus_compute_bw_weights_v10(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
smartlist_t *chunks = smartlist_new();
|
|
|
|
int64_t G, M, E, D, T, weight_scale;
|
|
|
|
int ret;
|
|
|
|
weight_scale = 10000;
|
|
|
|
|
|
|
|
/* no case. one or more of the values is 0 */
|
|
|
|
G = M = E = D = 0;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
tt_int_op(smartlist_len(chunks), OP_EQ, 0);
|
|
|
|
|
|
|
|
/* case 1 */
|
|
|
|
/* XXX dir-spec not followed? See #20272. If it isn't closed, then this is
|
|
|
|
* testing current behavior, not spec. */
|
|
|
|
G = E = 10;
|
|
|
|
M = D = 1;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
|
|
|
tt_int_op(smartlist_len(chunks), OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=3333 "
|
|
|
|
"Wbe=3000 Wbg=3000 Wbm=10000 Wdb=10000 Web=10000 Wed=3333 Wee=7000 "
|
2016-10-09 21:41:08 +02:00
|
|
|
"Weg=3333 Wem=7000 Wgb=10000 Wgd=3333 Wgg=7000 Wgm=7000 Wmb=10000 "
|
|
|
|
"Wmd=3333 Wme=3000 Wmg=3000 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 2a E scarce */
|
|
|
|
M = 100;
|
|
|
|
G = 20;
|
|
|
|
E = D = 5;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 Wbe=0 "
|
|
|
|
"Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=10000 Wee=10000 Weg=10000 "
|
2016-10-09 21:41:08 +02:00
|
|
|
"Wem=10000 Wgb=10000 Wgd=0 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=0 Wme=0 "
|
|
|
|
"Wmg=0 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 2a G scarce */
|
|
|
|
M = 100;
|
|
|
|
E = 20;
|
|
|
|
G = D = 5;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 Wbe=0 "
|
|
|
|
"Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=0 Wee=10000 Weg=0 Wem=10000 "
|
|
|
|
"Wgb=10000 Wgd=10000 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=0 Wme=0 Wmg=0 "
|
|
|
|
"Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 2b1 (Wgg=1, Wmd=Wgd) */
|
|
|
|
M = 10;
|
|
|
|
E = 30;
|
|
|
|
G = 10;
|
|
|
|
D = 100;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
2016-10-09 21:41:08 +02:00
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=4000 "
|
|
|
|
"Wbe=0 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=2000 Wee=10000 Weg=2000 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=4000 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=4000 "
|
|
|
|
"Wme=0 Wmg=0 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 2b2 */
|
|
|
|
M = 60;
|
|
|
|
E = 30;
|
|
|
|
G = 10;
|
|
|
|
D = 100;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=666 Wbe=0 "
|
2016-10-09 21:41:08 +02:00
|
|
|
"Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=3666 Wee=10000 Weg=3666 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=5668 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=666 "
|
|
|
|
"Wme=0 Wmg=0 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 2b3 */
|
2016-10-09 21:41:08 +02:00
|
|
|
/* XXX I can't get a combination of values that hits this case without error,
|
|
|
|
* so this just tests that it fails. See #20285. Also see #20284 as 2b3 does
|
|
|
|
* not follow dir-spec. */
|
2016-10-04 03:09:25 +02:00
|
|
|
/* (E < T/3 && G < T/3) && (E+D>=G || G+D>=E) && (M > T/3) */
|
|
|
|
M = 80;
|
|
|
|
E = 30;
|
|
|
|
G = 30;
|
|
|
|
D = 30;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 3a G scarce */
|
|
|
|
M = 10;
|
|
|
|
E = 30;
|
|
|
|
G = 10;
|
|
|
|
D = 5;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
2016-10-09 21:41:08 +02:00
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 "
|
|
|
|
"Wbe=3333 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=0 Wee=6667 Weg=0 "
|
|
|
|
"Wem=6667 Wgb=10000 Wgd=10000 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=0 "
|
|
|
|
"Wme=3333 Wmg=0 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 3a E scarce */
|
|
|
|
M = 10;
|
|
|
|
E = 10;
|
|
|
|
G = 30;
|
|
|
|
D = 5;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 Wbe=0 "
|
|
|
|
"Wbg=3333 Wbm=10000 Wdb=10000 Web=10000 Wed=10000 Wee=10000 Weg=10000 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=0 Wgg=6667 Wgm=6667 Wmb=10000 Wmd=0 Wme=0 "
|
|
|
|
"Wmg=3333 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 3bg */
|
|
|
|
M = 10;
|
|
|
|
E = 30;
|
|
|
|
G = 10;
|
|
|
|
D = 10;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
2016-10-09 21:41:08 +02:00
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 "
|
|
|
|
"Wbe=3334 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=0 Wee=6666 Weg=0 "
|
|
|
|
"Wem=6666 Wgb=10000 Wgd=10000 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=0 "
|
|
|
|
"Wme=3334 Wmg=0 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case 3be */
|
|
|
|
M = 10;
|
|
|
|
E = 10;
|
|
|
|
G = 30;
|
|
|
|
D = 10;
|
|
|
|
T = G + M + E + D;
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2016-10-04 03:09:25 +02:00
|
|
|
tt_int_op(ret, OP_EQ, 1);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 Wbe=0 "
|
|
|
|
"Wbg=3334 Wbm=10000 Wdb=10000 Web=10000 Wed=10000 Wee=10000 Weg=10000 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=0 Wgg=6666 Wgm=6666 Wmb=10000 Wmd=0 Wme=0 "
|
|
|
|
"Wmg=3334 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-04 03:09:25 +02:00
|
|
|
smartlist_clear(chunks);
|
2016-10-09 21:41:08 +02:00
|
|
|
|
|
|
|
/* case from 21 Jul 2013 (3be) */
|
|
|
|
G = 5483409;
|
|
|
|
M = 1455379;
|
|
|
|
E = 980834;
|
|
|
|
D = 3385803;
|
|
|
|
T = 11305425;
|
2016-10-28 17:37:28 +02:00
|
|
|
tt_i64_op(G+M+E+D, OP_EQ, T);
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2017-09-12 23:46:09 +02:00
|
|
|
tt_assert(ret);
|
2016-10-09 21:41:08 +02:00
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=883 Wbe=0 "
|
|
|
|
"Wbg=3673 Wbm=10000 Wdb=10000 Web=10000 Wed=8233 Wee=10000 Weg=8233 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=883 Wgg=6327 Wgm=6327 Wmb=10000 Wmd=883 Wme=0 "
|
|
|
|
"Wmg=3673 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-09 21:41:08 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case from 04 Oct 2016 (3a E scarce) */
|
|
|
|
G=29322240;
|
|
|
|
M=4721546;
|
|
|
|
E=1522058;
|
|
|
|
D=9273571;
|
|
|
|
T=44839415;
|
2016-10-28 17:37:28 +02:00
|
|
|
tt_i64_op(G+M+E+D, OP_EQ, T);
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2017-09-12 23:46:09 +02:00
|
|
|
tt_assert(ret);
|
2016-10-09 21:41:08 +02:00
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=0 Wbe=0 "
|
|
|
|
"Wbg=4194 Wbm=10000 Wdb=10000 Web=10000 Wed=10000 Wee=10000 Weg=10000 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=0 Wgg=5806 Wgm=5806 Wmb=10000 Wmd=0 Wme=0 "
|
|
|
|
"Wmg=4194 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-09 21:41:08 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* case from 04 Sep 2013 (2b1) */
|
|
|
|
G=3091352;
|
|
|
|
M=1838837;
|
|
|
|
E=2109300;
|
|
|
|
D=2469369;
|
|
|
|
T=9508858;
|
2016-10-28 17:37:28 +02:00
|
|
|
tt_i64_op(G+M+E+D, OP_EQ, T);
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
2017-09-12 23:46:09 +02:00
|
|
|
tt_assert(ret);
|
2016-10-09 21:41:08 +02:00
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=317 "
|
|
|
|
"Wbe=5938 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=9366 Wee=4061 "
|
|
|
|
"Weg=9366 Wem=4061 Wgb=10000 Wgd=317 Wgg=10000 Wgm=10000 Wmb=10000 "
|
|
|
|
"Wmd=317 Wme=5938 Wmg=0 Wmm=10000\n");
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
2016-10-09 21:41:08 +02:00
|
|
|
smartlist_clear(chunks);
|
|
|
|
|
|
|
|
/* explicitly test initializing weights to 1*/
|
|
|
|
G=1;
|
|
|
|
M=1;
|
|
|
|
E=1;
|
|
|
|
D=1;
|
|
|
|
T=4;
|
2016-10-28 17:37:28 +02:00
|
|
|
tt_i64_op(G+M+E+D, OP_EQ, T);
|
2016-10-09 21:41:08 +02:00
|
|
|
ret = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D, T,
|
|
|
|
weight_scale);
|
|
|
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "bandwidth-weights Wbd=3333 "
|
|
|
|
"Wbe=0 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=3333 Wee=10000 Weg=3333 "
|
|
|
|
"Wem=10000 Wgb=10000 Wgd=3333 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=3333 "
|
|
|
|
"Wme=0 Wmg=0 Wmm=10000\n");
|
2017-09-12 23:46:09 +02:00
|
|
|
tt_assert(ret);
|
2016-10-27 15:41:19 +02:00
|
|
|
|
2016-10-04 03:09:25 +02:00
|
|
|
done:
|
2016-10-27 15:41:19 +02:00
|
|
|
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(chunks);
|
2016-10-04 03:09:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-03 17:42:50 +02:00
|
|
|
static authority_cert_t *mock_cert;
|
|
|
|
|
|
|
|
static authority_cert_t *
|
|
|
|
get_my_v3_authority_cert_m(void)
|
|
|
|
{
|
|
|
|
tor_assert(mock_cert);
|
|
|
|
return mock_cert;
|
|
|
|
}
|
|
|
|
|
2013-02-15 09:28:04 +01:00
|
|
|
/** Run a unit tests for generating and parsing networkstatuses, with
|
|
|
|
* the supply test fns. */
|
|
|
|
static void
|
|
|
|
test_a_networkstatus(
|
|
|
|
vote_routerstatus_t * (*vrs_gen)(int idx, time_t now),
|
2013-02-19 17:58:09 +01:00
|
|
|
int (*vote_tweaks)(networkstatus_t *v, int voter, time_t now),
|
2013-02-15 09:28:04 +01:00
|
|
|
void (*vrs_test)(vote_routerstatus_t *vrs, int voter, time_t now),
|
|
|
|
void (*consensus_test)(networkstatus_t *con, time_t now),
|
|
|
|
void (*rs_test)(routerstatus_t *rs, time_t now))
|
2009-09-22 19:49:09 +02:00
|
|
|
{
|
|
|
|
authority_cert_t *cert1=NULL, *cert2=NULL, *cert3=NULL;
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *sign_skey_1=NULL, *sign_skey_2=NULL, *sign_skey_3=NULL;
|
|
|
|
crypto_pk_t *sign_skey_leg1=NULL;
|
2013-02-19 17:58:09 +01:00
|
|
|
/*
|
|
|
|
* Sum the non-zero returns from vote_tweaks() we've seen; if vote_tweaks()
|
|
|
|
* returns non-zero, it changed net_params and we should skip the tests for
|
|
|
|
* that later as they will fail.
|
|
|
|
*/
|
|
|
|
int params_tweaked = 0;
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
time_t now = time(NULL);
|
|
|
|
networkstatus_voter_info_t *voter;
|
2009-09-16 23:01:01 +02:00
|
|
|
document_signature_t *sig;
|
2009-09-23 21:23:04 +02:00
|
|
|
networkstatus_t *vote=NULL, *v1=NULL, *v2=NULL, *v3=NULL, *con=NULL,
|
|
|
|
*con_md=NULL;
|
2009-09-22 19:49:09 +02:00
|
|
|
vote_routerstatus_t *vrs;
|
|
|
|
routerstatus_t *rs;
|
2013-02-15 09:28:04 +01:00
|
|
|
int idx, n_rs, n_vrs;
|
2015-01-26 20:49:48 +01:00
|
|
|
char *consensus_text=NULL, *cp=NULL;
|
2012-01-18 21:53:30 +01:00
|
|
|
smartlist_t *votes = smartlist_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* For generating the two other consensuses. */
|
|
|
|
char *detached_text1=NULL, *detached_text2=NULL;
|
|
|
|
char *consensus_text2=NULL, *consensus_text3=NULL;
|
2009-09-23 21:23:04 +02:00
|
|
|
char *consensus_text_md2=NULL, *consensus_text_md3=NULL;
|
|
|
|
char *consensus_text_md=NULL;
|
|
|
|
networkstatus_t *con2=NULL, *con_md2=NULL, *con3=NULL, *con_md3=NULL;
|
2009-09-22 19:49:09 +02:00
|
|
|
ns_detached_signatures_t *dsig1=NULL, *dsig2=NULL;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(vrs_gen);
|
|
|
|
tt_assert(rs_test);
|
|
|
|
tt_assert(vrs_test);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
2016-05-03 17:42:50 +02:00
|
|
|
MOCK(get_my_v3_authority_cert, get_my_v3_authority_cert_m);
|
|
|
|
|
|
|
|
/* Parse certificates and keys. */
|
2018-09-11 17:37:55 +02:00
|
|
|
cert1 = mock_cert = authority_cert_parse_from_string(AUTHORITY_CERT_1,
|
|
|
|
strlen(AUTHORITY_CERT_1),
|
|
|
|
NULL);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_assert(cert1);
|
2018-09-11 17:37:55 +02:00
|
|
|
cert2 = authority_cert_parse_from_string(AUTHORITY_CERT_2,
|
|
|
|
strlen(AUTHORITY_CERT_2),
|
|
|
|
NULL);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_assert(cert2);
|
2018-09-11 17:37:55 +02:00
|
|
|
cert3 = authority_cert_parse_from_string(AUTHORITY_CERT_3,
|
|
|
|
strlen(AUTHORITY_CERT_3),
|
|
|
|
NULL);
|
2016-05-03 17:42:50 +02:00
|
|
|
tt_assert(cert3);
|
|
|
|
sign_skey_1 = crypto_pk_new();
|
|
|
|
sign_skey_2 = crypto_pk_new();
|
|
|
|
sign_skey_3 = crypto_pk_new();
|
2009-09-22 19:49:09 +02:00
|
|
|
sign_skey_leg1 = pk_generate(4);
|
2020-02-24 16:06:55 +01:00
|
|
|
dirauth_sched_recalculate_timing(get_options(), now);
|
2016-05-03 17:42:50 +02:00
|
|
|
sr_state_init(0, 0);
|
|
|
|
|
|
|
|
tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_1,
|
|
|
|
AUTHORITY_SIGNKEY_1, -1));
|
|
|
|
tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_2,
|
|
|
|
AUTHORITY_SIGNKEY_2, -1));
|
|
|
|
tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_3,
|
|
|
|
AUTHORITY_SIGNKEY_3, -1));
|
|
|
|
|
|
|
|
tt_assert(!crypto_pk_cmp_keys(sign_skey_1, cert1->signing_key));
|
|
|
|
tt_assert(!crypto_pk_cmp_keys(sign_skey_2, cert2->signing_key));
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2015-01-26 20:49:48 +01:00
|
|
|
tt_assert(!dir_common_construct_vote_1(&vote, cert1, sign_skey_1, vrs_gen,
|
|
|
|
&v1, &n_vrs, now, 1));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v1);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Make sure the parsed thing was right. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(v1->type,OP_EQ, NS_TYPE_VOTE);
|
|
|
|
tt_int_op(v1->published,OP_EQ, vote->published);
|
|
|
|
tt_int_op(v1->valid_after,OP_EQ, vote->valid_after);
|
|
|
|
tt_int_op(v1->fresh_until,OP_EQ, vote->fresh_until);
|
|
|
|
tt_int_op(v1->valid_until,OP_EQ, vote->valid_until);
|
|
|
|
tt_int_op(v1->vote_seconds,OP_EQ, vote->vote_seconds);
|
|
|
|
tt_int_op(v1->dist_seconds,OP_EQ, vote->dist_seconds);
|
|
|
|
tt_str_op(v1->client_versions,OP_EQ, vote->client_versions);
|
|
|
|
tt_str_op(v1->server_versions,OP_EQ, vote->server_versions);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v1->voters && smartlist_len(v1->voters));
|
2009-09-22 19:49:09 +02:00
|
|
|
voter = smartlist_get(v1->voters, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(voter->nickname,OP_EQ, "Voter1");
|
|
|
|
tt_str_op(voter->address,OP_EQ, "1.2.3.4");
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&voter->ipv4_addr, 0x01020304));
|
|
|
|
tt_int_op(voter->ipv4_dirport,OP_EQ, 80);
|
|
|
|
tt_int_op(voter->ipv4_orport,OP_EQ, 9000);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(voter->contact,OP_EQ, "voter@example.com");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v1->cert);
|
|
|
|
tt_assert(!crypto_pk_cmp_keys(sign_skey_1, v1->cert->signing_key));
|
2009-09-22 19:49:09 +02:00
|
|
|
cp = smartlist_join_strings(v1->known_flags, ":", 0, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp,OP_EQ, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
|
2009-09-22 19:49:09 +02:00
|
|
|
tor_free(cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(v1->routerstatus_list),OP_EQ, n_vrs);
|
2016-01-15 17:45:19 +01:00
|
|
|
networkstatus_vote_free(vote);
|
|
|
|
vote = NULL;
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2013-02-19 17:58:09 +01:00
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v1, 1, now);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
|
|
|
/* Check the routerstatuses. */
|
|
|
|
for (idx = 0; idx < n_vrs; ++idx) {
|
|
|
|
vrs = smartlist_get(v1->routerstatus_list, idx);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(vrs);
|
2013-02-15 09:28:04 +01:00
|
|
|
vrs_test(vrs, 1, now);
|
2009-09-22 19:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate second vote. It disagrees on some of the times,
|
2015-01-26 20:49:48 +01:00
|
|
|
* and doesn't list versions, and knows some crazy flags.
|
|
|
|
* Generate and parse v2. */
|
|
|
|
tt_assert(!dir_common_construct_vote_2(&vote, cert2, sign_skey_2, vrs_gen,
|
|
|
|
&v2, &n_vrs, now, 1));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v2);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
2013-02-19 17:58:09 +01:00
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v2, 2, now);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Check that flags come out right.*/
|
|
|
|
cp = smartlist_join_strings(v2->known_flags, ":", 0, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp,OP_EQ, "Authority:Exit:Fast:Guard:MadeOfCheese:MadeOfTin:"
|
2009-09-22 19:49:09 +02:00
|
|
|
"Running:Stable:V2Dir:Valid");
|
|
|
|
tor_free(cp);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
|
|
|
/* Check the routerstatuses. */
|
|
|
|
n_vrs = smartlist_len(v2->routerstatus_list);
|
|
|
|
for (idx = 0; idx < n_vrs; ++idx) {
|
|
|
|
vrs = smartlist_get(v2->routerstatus_list, idx);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(vrs);
|
2013-02-15 09:28:04 +01:00
|
|
|
vrs_test(vrs, 2, now);
|
|
|
|
}
|
2016-01-15 17:45:19 +01:00
|
|
|
networkstatus_vote_free(vote);
|
|
|
|
vote = NULL;
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2015-01-26 20:49:48 +01:00
|
|
|
/* Generate the third vote with a legacy id. */
|
|
|
|
tt_assert(!dir_common_construct_vote_3(&vote, cert3, sign_skey_3, vrs_gen,
|
|
|
|
&v3, &n_vrs, now, 1));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v3);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2013-02-19 17:58:09 +01:00
|
|
|
if (vote_tweaks) params_tweaked += vote_tweaks(v3, 3, now);
|
2013-02-15 09:28:04 +01:00
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Compute a consensus as voter 3. */
|
|
|
|
smartlist_add(votes, v3);
|
|
|
|
smartlist_add(votes, v1);
|
|
|
|
smartlist_add(votes, v2);
|
|
|
|
consensus_text = networkstatus_compute_consensus(votes, 3,
|
|
|
|
cert3->identity_key,
|
|
|
|
sign_skey_3,
|
|
|
|
"AAAAAAAAAAAAAAAAAAAA",
|
2009-08-24 18:51:33 +02:00
|
|
|
sign_skey_leg1,
|
|
|
|
FLAV_NS);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(consensus_text);
|
2018-09-11 16:32:17 +02:00
|
|
|
con = networkstatus_parse_vote_from_string_(consensus_text, NULL,
|
2009-09-22 19:49:09 +02:00
|
|
|
NS_TYPE_CONSENSUS);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(con);
|
2009-09-22 19:49:09 +02:00
|
|
|
//log_notice(LD_GENERAL, "<<%s>>\n<<%s>>\n<<%s>>\n",
|
|
|
|
// v1_text, v2_text, v3_text);
|
2009-09-23 21:23:04 +02:00
|
|
|
consensus_text_md = networkstatus_compute_consensus(votes, 3,
|
|
|
|
cert3->identity_key,
|
|
|
|
sign_skey_3,
|
|
|
|
"AAAAAAAAAAAAAAAAAAAA",
|
|
|
|
sign_skey_leg1,
|
|
|
|
FLAV_MICRODESC);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(consensus_text_md);
|
2018-09-11 16:32:17 +02:00
|
|
|
con_md = networkstatus_parse_vote_from_string_(consensus_text_md, NULL,
|
2009-09-23 21:23:04 +02:00
|
|
|
NS_TYPE_CONSENSUS);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(con_md);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(con_md->flavor,OP_EQ, FLAV_MICRODESC);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Check consensus contents. */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(con->type == NS_TYPE_CONSENSUS);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(con->published,OP_EQ, 0); /* this field only appears in votes. */
|
|
|
|
tt_int_op(con->valid_after,OP_EQ, now+1000);
|
|
|
|
tt_int_op(con->fresh_until,OP_EQ, now+2003); /* median */
|
|
|
|
tt_int_op(con->valid_until,OP_EQ, now+3000);
|
|
|
|
tt_int_op(con->vote_seconds,OP_EQ, 100);
|
|
|
|
tt_int_op(con->dist_seconds,OP_EQ, 250); /* median */
|
|
|
|
tt_str_op(con->client_versions,OP_EQ, "0.1.2.14");
|
|
|
|
tt_str_op(con->server_versions,OP_EQ, "0.1.2.15,0.1.2.16");
|
2009-09-22 19:49:09 +02:00
|
|
|
cp = smartlist_join_strings(v2->known_flags, ":", 0, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp,OP_EQ, "Authority:Exit:Fast:Guard:MadeOfCheese:MadeOfTin:"
|
2009-09-22 19:49:09 +02:00
|
|
|
"Running:Stable:V2Dir:Valid");
|
|
|
|
tor_free(cp);
|
2013-02-19 17:58:09 +01:00
|
|
|
if (!params_tweaked) {
|
|
|
|
/* Skip this one if vote_tweaks() messed with the param lists */
|
|
|
|
cp = smartlist_join_strings(con->net_params, ":", 0, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp,OP_EQ, "circuitwindow=80:foo=660");
|
2013-02-19 17:58:09 +01:00
|
|
|
tor_free(cp);
|
|
|
|
}
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(4,OP_EQ, smartlist_len(con->voters)); /*3 voters, 1 legacy key.*/
|
2009-09-22 19:49:09 +02:00
|
|
|
/* The voter id digests should be in this order. */
|
checkSpace.pl now forbids more identifiers.
The functions it warns about are:
assert, memcmp, strcat, strcpy, sprintf, malloc, free, realloc,
strdup, strndup, calloc.
Also, fix a few lingering instances of these in the code. Use other
conventions to indicate _intended_ use of assert and
malloc/realloc/etc.
2016-09-06 18:35:37 +02:00
|
|
|
tt_assert(fast_memcmp(cert2->cache_info.identity_digest,
|
2009-09-22 19:49:09 +02:00
|
|
|
cert1->cache_info.identity_digest,DIGEST_LEN)<0);
|
checkSpace.pl now forbids more identifiers.
The functions it warns about are:
assert, memcmp, strcat, strcpy, sprintf, malloc, free, realloc,
strdup, strndup, calloc.
Also, fix a few lingering instances of these in the code. Use other
conventions to indicate _intended_ use of assert and
malloc/realloc/etc.
2016-09-06 18:35:37 +02:00
|
|
|
tt_assert(fast_memcmp(cert1->cache_info.identity_digest,
|
2009-09-22 19:49:09 +02:00
|
|
|
cert3->cache_info.identity_digest,DIGEST_LEN)<0);
|
|
|
|
test_same_voter(smartlist_get(con->voters, 1),
|
|
|
|
smartlist_get(v2->voters, 0));
|
|
|
|
test_same_voter(smartlist_get(con->voters, 2),
|
|
|
|
smartlist_get(v1->voters, 0));
|
|
|
|
test_same_voter(smartlist_get(con->voters, 3),
|
|
|
|
smartlist_get(v3->voters, 0));
|
|
|
|
|
2013-02-15 09:28:04 +01:00
|
|
|
consensus_test(con, now);
|
|
|
|
|
|
|
|
/* Check the routerstatuses. */
|
|
|
|
n_rs = smartlist_len(con->routerstatus_list);
|
2015-05-27 18:37:10 +02:00
|
|
|
tt_assert(n_rs);
|
2013-02-15 09:28:04 +01:00
|
|
|
for (idx = 0; idx < n_rs; ++idx) {
|
|
|
|
rs = smartlist_get(con->routerstatus_list, idx);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs);
|
2013-02-15 09:28:04 +01:00
|
|
|
rs_test(rs, now);
|
|
|
|
}
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2015-05-27 18:37:10 +02:00
|
|
|
n_rs = smartlist_len(con_md->routerstatus_list);
|
|
|
|
tt_assert(n_rs);
|
|
|
|
for (idx = 0; idx < n_rs; ++idx) {
|
|
|
|
rs = smartlist_get(con_md->routerstatus_list, idx);
|
|
|
|
tt_assert(rs);
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Check signatures. the first voter is a pseudo-entry with a legacy key.
|
|
|
|
* The second one hasn't signed. The fourth one has signed: validate it. */
|
|
|
|
voter = smartlist_get(con->voters, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(voter->sigs),OP_EQ, 0);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
voter = smartlist_get(con->voters, 3);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(smartlist_len(voter->sigs),OP_EQ, 1);
|
2009-09-16 23:01:01 +02:00
|
|
|
sig = smartlist_get(voter->sigs, 0);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(sig->signature);
|
|
|
|
tt_assert(!sig->good_signature);
|
|
|
|
tt_assert(!sig->bad_signature);
|
2009-09-16 23:01:01 +02:00
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!networkstatus_check_document_signature(con, sig, cert3));
|
|
|
|
tt_assert(sig->signature);
|
|
|
|
tt_assert(sig->good_signature);
|
|
|
|
tt_assert(!sig->bad_signature);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
const char *msg=NULL;
|
|
|
|
/* Compute the other two signed consensuses. */
|
|
|
|
smartlist_shuffle(votes);
|
|
|
|
consensus_text2 = networkstatus_compute_consensus(votes, 3,
|
|
|
|
cert2->identity_key,
|
2009-08-24 18:51:33 +02:00
|
|
|
sign_skey_2, NULL,NULL,
|
|
|
|
FLAV_NS);
|
2009-09-23 21:23:04 +02:00
|
|
|
consensus_text_md2 = networkstatus_compute_consensus(votes, 3,
|
|
|
|
cert2->identity_key,
|
|
|
|
sign_skey_2, NULL,NULL,
|
|
|
|
FLAV_MICRODESC);
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_shuffle(votes);
|
|
|
|
consensus_text3 = networkstatus_compute_consensus(votes, 3,
|
|
|
|
cert1->identity_key,
|
2009-08-24 18:51:33 +02:00
|
|
|
sign_skey_1, NULL,NULL,
|
|
|
|
FLAV_NS);
|
2009-09-23 21:23:04 +02:00
|
|
|
consensus_text_md3 = networkstatus_compute_consensus(votes, 3,
|
|
|
|
cert1->identity_key,
|
|
|
|
sign_skey_1, NULL,NULL,
|
|
|
|
FLAV_MICRODESC);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(consensus_text2);
|
|
|
|
tt_assert(consensus_text3);
|
|
|
|
tt_assert(consensus_text_md2);
|
|
|
|
tt_assert(consensus_text_md3);
|
2018-09-11 16:32:17 +02:00
|
|
|
con2 = networkstatus_parse_vote_from_string_(consensus_text2, NULL,
|
2009-09-22 19:49:09 +02:00
|
|
|
NS_TYPE_CONSENSUS);
|
2018-09-11 16:32:17 +02:00
|
|
|
con3 = networkstatus_parse_vote_from_string_(consensus_text3, NULL,
|
2009-09-22 19:49:09 +02:00
|
|
|
NS_TYPE_CONSENSUS);
|
2018-09-11 16:32:17 +02:00
|
|
|
con_md2 = networkstatus_parse_vote_from_string_(consensus_text_md2, NULL,
|
2009-09-23 21:23:04 +02:00
|
|
|
NS_TYPE_CONSENSUS);
|
2018-09-11 16:32:17 +02:00
|
|
|
con_md3 = networkstatus_parse_vote_from_string_(consensus_text_md3, NULL,
|
2009-09-23 21:23:04 +02:00
|
|
|
NS_TYPE_CONSENSUS);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(con2);
|
|
|
|
tt_assert(con3);
|
|
|
|
tt_assert(con_md2);
|
|
|
|
tt_assert(con_md3);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* All three should have the same digest. */
|
2016-02-10 21:28:19 +01:00
|
|
|
tt_mem_op(&con->digests,OP_EQ, &con2->digests, sizeof(common_digests_t));
|
|
|
|
tt_mem_op(&con->digests,OP_EQ, &con3->digests, sizeof(common_digests_t));
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2016-02-10 21:35:46 +01:00
|
|
|
tt_mem_op(&con_md->digests,OP_EQ, &con_md2->digests,
|
|
|
|
sizeof(common_digests_t));
|
|
|
|
tt_mem_op(&con_md->digests,OP_EQ, &con_md3->digests,
|
|
|
|
sizeof(common_digests_t));
|
2009-09-23 21:23:04 +02:00
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Extract a detached signature from con3. */
|
2009-09-23 21:23:04 +02:00
|
|
|
detached_text1 = get_detached_sigs(con3, con_md3);
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(detached_text1);
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Try to parse it. */
|
|
|
|
dsig1 = networkstatus_parse_detached_signatures(detached_text1, NULL);
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(dsig1);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Are parsed values as expected? */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(dsig1->valid_after,OP_EQ, con3->valid_after);
|
|
|
|
tt_int_op(dsig1->fresh_until,OP_EQ, con3->fresh_until);
|
|
|
|
tt_int_op(dsig1->valid_until,OP_EQ, con3->valid_until);
|
2009-09-16 23:01:01 +02:00
|
|
|
{
|
2016-02-10 21:28:19 +01:00
|
|
|
common_digests_t *dsig_digests = strmap_get(dsig1->digests, "ns");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dsig_digests);
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_mem_op(dsig_digests->d[DIGEST_SHA1], OP_EQ,
|
|
|
|
con3->digests.d[DIGEST_SHA1], DIGEST_LEN);
|
2009-09-23 21:23:04 +02:00
|
|
|
dsig_digests = strmap_get(dsig1->digests, "microdesc");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dsig_digests);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(dsig_digests->d[DIGEST_SHA256],OP_EQ,
|
2009-09-23 21:23:04 +02:00
|
|
|
con_md3->digests.d[DIGEST_SHA256],
|
|
|
|
DIGEST256_LEN);
|
2009-09-16 23:01:01 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
smartlist_t *dsig_signatures = strmap_get(dsig1->signatures, "ns");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dsig_signatures);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, smartlist_len(dsig_signatures));
|
2009-09-16 23:01:01 +02:00
|
|
|
sig = smartlist_get(dsig_signatures, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(sig->identity_digest,OP_EQ, cert1->cache_info.identity_digest,
|
2009-09-16 23:01:01 +02:00
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(sig->alg,OP_EQ, DIGEST_SHA1);
|
2009-09-23 21:23:04 +02:00
|
|
|
|
|
|
|
dsig_signatures = strmap_get(dsig1->signatures, "microdesc");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dsig_signatures);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, smartlist_len(dsig_signatures));
|
2009-09-23 21:23:04 +02:00
|
|
|
sig = smartlist_get(dsig_signatures, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(sig->identity_digest,OP_EQ, cert1->cache_info.identity_digest,
|
2009-09-23 21:23:04 +02:00
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(sig->alg,OP_EQ, DIGEST_SHA256);
|
2009-09-16 23:01:01 +02:00
|
|
|
}
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Try adding it to con2. */
|
2009-09-23 21:23:04 +02:00
|
|
|
detached_text2 = get_detached_sigs(con2,con_md2);
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(1,OP_EQ, networkstatus_add_detached_signatures(con2, dsig1,
|
|
|
|
"test", LOG_INFO, &msg));
|
2009-09-22 19:49:09 +02:00
|
|
|
tor_free(detached_text2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
networkstatus_add_detached_signatures(con_md2, dsig1, "test",
|
2012-01-08 16:03:46 +01:00
|
|
|
LOG_INFO, &msg));
|
2009-09-23 21:23:04 +02:00
|
|
|
tor_free(detached_text2);
|
|
|
|
detached_text2 = get_detached_sigs(con2,con_md2);
|
2009-09-22 19:49:09 +02:00
|
|
|
//printf("\n<%s>\n", detached_text2);
|
|
|
|
dsig2 = networkstatus_parse_detached_signatures(detached_text2, NULL);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dsig2);
|
2009-09-22 19:49:09 +02:00
|
|
|
/*
|
|
|
|
printf("\n");
|
|
|
|
SMARTLIST_FOREACH(dsig2->signatures, networkstatus_voter_info_t *, vi, {
|
|
|
|
char hd[64];
|
|
|
|
base16_encode(hd, sizeof(hd), vi->identity_digest, DIGEST_LEN);
|
|
|
|
printf("%s\n", hd);
|
|
|
|
});
|
|
|
|
*/
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2,OP_EQ,
|
2009-09-16 23:01:01 +02:00
|
|
|
smartlist_len((smartlist_t*)strmap_get(dsig2->signatures, "ns")));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2,OP_EQ,
|
2009-09-23 21:23:04 +02:00
|
|
|
smartlist_len((smartlist_t*)strmap_get(dsig2->signatures,
|
|
|
|
"microdesc")));
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Try adding to con2 twice; verify that nothing changes. */
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0,OP_EQ, networkstatus_add_detached_signatures(con2, dsig1,
|
|
|
|
"test", LOG_INFO, &msg));
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
/* Add to con. */
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(2,OP_EQ, networkstatus_add_detached_signatures(con, dsig2,
|
|
|
|
"test", LOG_INFO, &msg));
|
2009-09-22 19:49:09 +02:00
|
|
|
/* Check signatures */
|
2009-09-16 23:01:01 +02:00
|
|
|
voter = smartlist_get(con->voters, 1);
|
|
|
|
sig = smartlist_get(voter->sigs, 0);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(sig);
|
|
|
|
tt_assert(!networkstatus_check_document_signature(con, sig, cert2));
|
2009-09-16 23:01:01 +02:00
|
|
|
voter = smartlist_get(con->voters, 2);
|
|
|
|
sig = smartlist_get(voter->sigs, 0);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(sig);
|
|
|
|
tt_assert(!networkstatus_check_document_signature(con, sig, cert1));
|
2009-09-22 19:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2014-02-12 00:10:33 +01:00
|
|
|
tor_free(cp);
|
2009-09-22 19:49:09 +02:00
|
|
|
smartlist_free(votes);
|
|
|
|
tor_free(consensus_text);
|
2009-09-23 21:23:04 +02:00
|
|
|
tor_free(consensus_text_md);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2016-01-15 17:45:19 +01:00
|
|
|
networkstatus_vote_free(vote);
|
|
|
|
networkstatus_vote_free(v1);
|
|
|
|
networkstatus_vote_free(v2);
|
|
|
|
networkstatus_vote_free(v3);
|
|
|
|
networkstatus_vote_free(con);
|
|
|
|
networkstatus_vote_free(con_md);
|
|
|
|
crypto_pk_free(sign_skey_1);
|
|
|
|
crypto_pk_free(sign_skey_2);
|
|
|
|
crypto_pk_free(sign_skey_3);
|
|
|
|
crypto_pk_free(sign_skey_leg1);
|
|
|
|
authority_cert_free(cert1);
|
|
|
|
authority_cert_free(cert2);
|
|
|
|
authority_cert_free(cert3);
|
2009-09-22 19:49:09 +02:00
|
|
|
|
|
|
|
tor_free(consensus_text2);
|
|
|
|
tor_free(consensus_text3);
|
2009-09-23 21:23:04 +02:00
|
|
|
tor_free(consensus_text_md2);
|
|
|
|
tor_free(consensus_text_md3);
|
2009-09-22 19:49:09 +02:00
|
|
|
tor_free(detached_text1);
|
|
|
|
tor_free(detached_text2);
|
2016-01-15 17:45:19 +01:00
|
|
|
|
|
|
|
networkstatus_vote_free(con2);
|
|
|
|
networkstatus_vote_free(con3);
|
|
|
|
networkstatus_vote_free(con_md2);
|
|
|
|
networkstatus_vote_free(con_md3);
|
|
|
|
ns_detached_signatures_free(dsig1);
|
|
|
|
ns_detached_signatures_free(dsig2);
|
2009-09-22 19:49:09 +02:00
|
|
|
}
|
|
|
|
|
2013-02-15 09:28:04 +01:00
|
|
|
/** Run unit tests for generating and parsing V3 consensus networkstatus
|
|
|
|
* documents. */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_v3_networkstatus(void *arg)
|
2013-02-15 09:28:04 +01:00
|
|
|
{
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2015-01-26 20:49:48 +01:00
|
|
|
test_a_networkstatus(dir_common_gen_routerstatus_for_v3ns,
|
2013-02-15 09:28:04 +01:00
|
|
|
vote_tweaks_for_v3ns,
|
|
|
|
test_vrs_for_v3ns,
|
|
|
|
test_consensus_for_v3ns,
|
|
|
|
test_routerstatus_for_v3ns);
|
|
|
|
}
|
|
|
|
|
2012-08-27 23:37:56 +02:00
|
|
|
static void
|
|
|
|
test_dir_scale_bw(void *testdata)
|
|
|
|
{
|
|
|
|
double v[8] = { 2.0/3,
|
|
|
|
7.0,
|
|
|
|
1.0,
|
|
|
|
3.0,
|
|
|
|
1.0/5,
|
|
|
|
1.0/7,
|
|
|
|
12.0,
|
|
|
|
24.0 };
|
2016-04-27 16:16:43 +02:00
|
|
|
double vals_dbl[8];
|
|
|
|
uint64_t vals_u64[8];
|
2012-08-27 23:37:56 +02:00
|
|
|
uint64_t total;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
(void) testdata;
|
|
|
|
|
|
|
|
for (i=0; i<8; ++i)
|
2016-04-27 16:16:43 +02:00
|
|
|
vals_dbl[i] = v[i];
|
2012-08-27 23:37:56 +02:00
|
|
|
|
2016-04-27 16:16:43 +02:00
|
|
|
scale_array_elements_to_u64(vals_u64, vals_dbl, 8, &total);
|
2012-08-27 23:37:56 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((int)total, OP_EQ, 48);
|
2012-08-27 23:37:56 +02:00
|
|
|
total = 0;
|
|
|
|
for (i=0; i<8; ++i) {
|
2016-04-27 16:16:43 +02:00
|
|
|
total += vals_u64[i];
|
2012-08-27 23:37:56 +02:00
|
|
|
}
|
2018-07-03 16:33:50 +02:00
|
|
|
tt_assert(total >= (UINT64_C(1)<<60));
|
|
|
|
tt_assert(total <= (UINT64_C(1)<<62));
|
2012-08-27 23:37:56 +02:00
|
|
|
|
|
|
|
for (i=0; i<8; ++i) {
|
2014-09-11 05:59:21 +02:00
|
|
|
/* vals[2].u64 is the scaled value of 1.0 */
|
2016-04-27 16:16:43 +02:00
|
|
|
double ratio = ((double)vals_u64[i]) / vals_u64[2];
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_double_op(fabs(ratio - v[i]), OP_LT, .00001);
|
2012-08-27 23:37:56 +02:00
|
|
|
}
|
|
|
|
|
2014-09-11 05:59:21 +02:00
|
|
|
/* test handling of no entries */
|
|
|
|
total = 1;
|
2016-04-27 16:16:43 +02:00
|
|
|
scale_array_elements_to_u64(vals_u64, vals_dbl, 0, &total);
|
2014-09-11 05:59:21 +02:00
|
|
|
tt_assert(total == 0);
|
|
|
|
|
|
|
|
/* make sure we don't read the array when we have no entries
|
|
|
|
* may require compiler flags to catch NULL dereferences */
|
|
|
|
total = 1;
|
2016-04-27 16:16:43 +02:00
|
|
|
scale_array_elements_to_u64(NULL, NULL, 0, &total);
|
2014-09-11 05:59:21 +02:00
|
|
|
tt_assert(total == 0);
|
|
|
|
|
2016-04-27 16:16:43 +02:00
|
|
|
scale_array_elements_to_u64(NULL, NULL, 0, NULL);
|
2014-09-11 05:59:21 +02:00
|
|
|
|
|
|
|
/* test handling of zero totals */
|
|
|
|
total = 1;
|
2016-04-27 16:16:43 +02:00
|
|
|
vals_dbl[0] = 0.0;
|
|
|
|
scale_array_elements_to_u64(vals_u64, vals_dbl, 1, &total);
|
2014-09-11 05:59:21 +02:00
|
|
|
tt_assert(total == 0);
|
2016-04-27 16:16:43 +02:00
|
|
|
tt_assert(vals_u64[0] == 0);
|
2014-09-11 05:59:21 +02:00
|
|
|
|
2016-04-27 16:16:43 +02:00
|
|
|
vals_dbl[0] = 0.0;
|
|
|
|
vals_dbl[1] = 0.0;
|
|
|
|
scale_array_elements_to_u64(vals_u64, vals_dbl, 2, NULL);
|
|
|
|
tt_assert(vals_u64[0] == 0);
|
|
|
|
tt_assert(vals_u64[1] == 0);
|
2014-09-11 05:59:21 +02:00
|
|
|
|
2012-08-27 23:37:56 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2012-08-09 19:47:42 +02:00
|
|
|
static void
|
|
|
|
test_dir_random_weighted(void *testdata)
|
|
|
|
{
|
|
|
|
int histogram[10];
|
|
|
|
uint64_t vals[10] = {3,1,2,4,6,0,7,5,8,9}, total=0;
|
2016-04-27 16:16:43 +02:00
|
|
|
uint64_t inp_u64[10];
|
2012-08-09 19:47:42 +02:00
|
|
|
int i, choice;
|
|
|
|
const int n = 50000;
|
|
|
|
double max_sq_error;
|
|
|
|
(void) testdata;
|
|
|
|
|
|
|
|
/* Try a ten-element array with values from 0 through 10. The values are
|
|
|
|
* in a scrambled order to make sure we don't depend on order. */
|
|
|
|
memset(histogram,0,sizeof(histogram));
|
2012-08-27 23:37:56 +02:00
|
|
|
for (i=0; i<10; ++i) {
|
2016-04-27 16:16:43 +02:00
|
|
|
inp_u64[i] = vals[i];
|
2012-08-09 19:47:42 +02:00
|
|
|
total += vals[i];
|
2012-08-27 23:37:56 +02:00
|
|
|
}
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_u64_op(total, OP_EQ, 45);
|
2012-08-09 19:47:42 +02:00
|
|
|
for (i=0; i<n; ++i) {
|
2016-04-27 16:16:43 +02:00
|
|
|
choice = choose_array_element_by_weight(inp_u64, 10);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(choice, OP_GE, 0);
|
|
|
|
tt_int_op(choice, OP_LT, 10);
|
2012-08-09 19:47:42 +02:00
|
|
|
histogram[choice]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now see if we chose things about frequently enough. */
|
|
|
|
max_sq_error = 0;
|
|
|
|
for (i=0; i<10; ++i) {
|
|
|
|
int expected = (int)(n*vals[i]/total);
|
|
|
|
double frac_diff = 0, sq;
|
|
|
|
TT_BLATHER((" %d : %5d vs %5d\n", (int)vals[i], histogram[i], expected));
|
|
|
|
if (expected)
|
|
|
|
frac_diff = (histogram[i] - expected) / ((double)expected);
|
|
|
|
else
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(histogram[i], OP_EQ, 0);
|
2012-08-09 19:47:42 +02:00
|
|
|
|
|
|
|
sq = frac_diff * frac_diff;
|
|
|
|
if (sq > max_sq_error)
|
|
|
|
max_sq_error = sq;
|
|
|
|
}
|
|
|
|
/* It should almost always be much much less than this. If you want to
|
|
|
|
* figure out the odds, please feel free. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_double_op(max_sq_error, OP_LT, .05);
|
2012-08-09 19:47:42 +02:00
|
|
|
|
|
|
|
/* Now try a singleton; do we choose it? */
|
|
|
|
for (i = 0; i < 100; ++i) {
|
2016-04-27 16:16:43 +02:00
|
|
|
choice = choose_array_element_by_weight(inp_u64, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(choice, OP_EQ, 0);
|
2012-08-09 19:47:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now try an array of zeros. We should choose randomly. */
|
|
|
|
memset(histogram,0,sizeof(histogram));
|
2012-08-27 23:37:56 +02:00
|
|
|
for (i = 0; i < 5; ++i)
|
2016-04-27 16:16:43 +02:00
|
|
|
inp_u64[i] = 0;
|
2012-08-09 19:47:42 +02:00
|
|
|
for (i = 0; i < n; ++i) {
|
2016-04-27 16:16:43 +02:00
|
|
|
choice = choose_array_element_by_weight(inp_u64, 5);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(choice, OP_GE, 0);
|
|
|
|
tt_int_op(choice, OP_LT, 5);
|
2012-08-09 19:47:42 +02:00
|
|
|
histogram[choice]++;
|
|
|
|
}
|
|
|
|
/* Now see if we chose things about frequently enough. */
|
|
|
|
max_sq_error = 0;
|
|
|
|
for (i=0; i<5; ++i) {
|
|
|
|
int expected = n/5;
|
|
|
|
double frac_diff = 0, sq;
|
|
|
|
TT_BLATHER((" %d : %5d vs %5d\n", (int)vals[i], histogram[i], expected));
|
|
|
|
frac_diff = (histogram[i] - expected) / ((double)expected);
|
|
|
|
sq = frac_diff * frac_diff;
|
|
|
|
if (sq > max_sq_error)
|
|
|
|
max_sq_error = sq;
|
|
|
|
}
|
|
|
|
/* It should almost always be much much less than this. If you want to
|
|
|
|
* figure out the odds, please feel free. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_double_op(max_sq_error, OP_LT, .05);
|
2012-08-09 19:47:42 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2013-04-11 17:43:40 +02:00
|
|
|
/* Function pointers for test_dir_clip_unmeasured_bw_kb() */
|
2013-02-19 15:20:29 +01:00
|
|
|
|
2013-02-19 17:58:09 +01:00
|
|
|
static uint32_t alternate_clip_bw = 0;
|
|
|
|
|
2013-02-19 15:20:29 +01:00
|
|
|
/**
|
2013-04-11 17:43:40 +02:00
|
|
|
* Generate a routerstatus for clip_unmeasured_bw_kb test; based on the
|
2013-02-19 15:20:29 +01:00
|
|
|
* v3_networkstatus ones.
|
|
|
|
*/
|
|
|
|
static vote_routerstatus_t *
|
|
|
|
gen_routerstatus_for_umbw(int idx, time_t now)
|
|
|
|
{
|
2013-02-19 21:00:08 +01:00
|
|
|
vote_routerstatus_t *vrs = NULL;
|
2013-02-19 15:20:29 +01:00
|
|
|
routerstatus_t *rs;
|
|
|
|
tor_addr_t addr_ipv6;
|
2013-04-11 17:43:40 +02:00
|
|
|
uint32_t max_unmeasured_bw_kb = (alternate_clip_bw > 0) ?
|
|
|
|
alternate_clip_bw : DEFAULT_MAX_UNMEASURED_BW_KB;
|
2013-02-19 15:20:29 +01:00
|
|
|
|
|
|
|
switch (idx) {
|
|
|
|
case 0:
|
|
|
|
/* Generate the first routerstatus. */
|
|
|
|
vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
|
rs = &vrs->status;
|
|
|
|
vrs->version = tor_strdup("0.1.2.14");
|
2021-11-09 19:29:36 +01:00
|
|
|
vrs->published_on = now-1500;
|
2013-02-19 15:20:29 +01:00
|
|
|
strlcpy(rs->nickname, "router2", sizeof(rs->nickname));
|
|
|
|
memset(rs->identity_digest, 3, DIGEST_LEN);
|
|
|
|
memset(rs->descriptor_digest, 78, DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs->ipv4_addr, 0x99008801);
|
|
|
|
rs->ipv4_orport = 443;
|
|
|
|
rs->ipv4_dirport = 8000;
|
2018-04-09 20:31:51 +02:00
|
|
|
/* all flags but running and valid cleared */
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->is_flagged_running = 1;
|
2018-04-09 20:31:51 +02:00
|
|
|
rs->is_valid = 1;
|
2013-02-19 15:20:29 +01:00
|
|
|
/*
|
|
|
|
* This one has measured bandwidth below the clip cutoff, and
|
|
|
|
* so shouldn't be clipped; we'll have to test that it isn't
|
|
|
|
* later.
|
|
|
|
*/
|
2013-02-19 16:57:49 +01:00
|
|
|
vrs->has_measured_bw = 1;
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->has_bandwidth = 1;
|
2013-04-11 17:43:40 +02:00
|
|
|
vrs->measured_bw_kb = rs->bandwidth_kb = max_unmeasured_bw_kb / 2;
|
2020-10-16 15:51:20 +02:00
|
|
|
vrs->protocols = tor_strdup("Link=2 Wombat=40");
|
2013-02-19 15:20:29 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* Generate the second routerstatus. */
|
|
|
|
vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
|
rs = &vrs->status;
|
|
|
|
vrs->version = tor_strdup("0.2.0.5");
|
2021-11-09 19:29:36 +01:00
|
|
|
vrs->published_on = now-1000;
|
2013-02-19 15:20:29 +01:00
|
|
|
strlcpy(rs->nickname, "router1", sizeof(rs->nickname));
|
|
|
|
memset(rs->identity_digest, 5, DIGEST_LEN);
|
|
|
|
memset(rs->descriptor_digest, 77, DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs->ipv4_addr, 0x99009901);
|
|
|
|
rs->ipv4_orport = 443;
|
|
|
|
rs->ipv4_dirport = 0;
|
2013-02-19 15:20:29 +01:00
|
|
|
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
|
|
|
|
tor_addr_copy(&rs->ipv6_addr, &addr_ipv6);
|
|
|
|
rs->ipv6_orport = 4711;
|
|
|
|
rs->is_exit = rs->is_stable = rs->is_fast = rs->is_flagged_running =
|
2014-01-29 21:17:05 +01:00
|
|
|
rs->is_valid = rs->is_possible_guard = 1;
|
2013-02-19 15:20:29 +01:00
|
|
|
/*
|
|
|
|
* This one has measured bandwidth above the clip cutoff, and
|
|
|
|
* so shouldn't be clipped; we'll have to test that it isn't
|
|
|
|
* later.
|
|
|
|
*/
|
2013-02-19 16:57:49 +01:00
|
|
|
vrs->has_measured_bw = 1;
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->has_bandwidth = 1;
|
2013-04-11 17:43:40 +02:00
|
|
|
vrs->measured_bw_kb = rs->bandwidth_kb = 2 * max_unmeasured_bw_kb;
|
2020-10-16 15:51:20 +02:00
|
|
|
vrs->protocols = tor_strdup("Link=2 Wombat=40");
|
2013-02-19 15:20:29 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* Generate the third routerstatus. */
|
|
|
|
vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
|
rs = &vrs->status;
|
|
|
|
vrs->version = tor_strdup("0.1.0.3");
|
2021-11-09 19:29:36 +01:00
|
|
|
vrs->published_on = now-1000;
|
2013-02-19 15:20:29 +01:00
|
|
|
strlcpy(rs->nickname, "router3", sizeof(rs->nickname));
|
|
|
|
memset(rs->identity_digest, 0x33, DIGEST_LEN);
|
|
|
|
memset(rs->descriptor_digest, 79, DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs->ipv4_addr, 0xAA009901);
|
|
|
|
rs->ipv4_orport = 400;
|
|
|
|
rs->ipv4_dirport = 9999;
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
|
2014-01-29 21:17:05 +01:00
|
|
|
rs->is_flagged_running = rs->is_valid =
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->is_possible_guard = 1;
|
|
|
|
/*
|
|
|
|
* This one has unmeasured bandwidth above the clip cutoff, and
|
|
|
|
* so should be clipped; we'll have to test that it isn't
|
|
|
|
* later.
|
|
|
|
*/
|
2013-02-19 16:57:49 +01:00
|
|
|
vrs->has_measured_bw = 0;
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->has_bandwidth = 1;
|
2013-04-11 17:43:40 +02:00
|
|
|
vrs->measured_bw_kb = 0;
|
|
|
|
rs->bandwidth_kb = 2 * max_unmeasured_bw_kb;
|
2020-10-16 15:51:20 +02:00
|
|
|
vrs->protocols = tor_strdup("Link=2 Wombat=40");
|
2013-02-19 15:20:29 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
/* Generate a fourth routerstatus that is not running. */
|
|
|
|
vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
|
|
|
|
rs = &vrs->status;
|
|
|
|
vrs->version = tor_strdup("0.1.6.3");
|
2021-11-09 19:29:36 +01:00
|
|
|
vrs->published_on = now-1000;
|
2013-02-19 15:20:29 +01:00
|
|
|
strlcpy(rs->nickname, "router4", sizeof(rs->nickname));
|
|
|
|
memset(rs->identity_digest, 0x34, DIGEST_LEN);
|
|
|
|
memset(rs->descriptor_digest, 47, DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs->ipv4_addr, 0xC0000203);
|
|
|
|
rs->ipv4_orport = 500;
|
|
|
|
rs->ipv4_dirport = 1999;
|
2018-04-09 20:31:51 +02:00
|
|
|
/* all flags but running and valid cleared */
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->is_flagged_running = 1;
|
2018-04-09 20:31:51 +02:00
|
|
|
rs->is_valid = 1;
|
2013-02-19 15:20:29 +01:00
|
|
|
/*
|
|
|
|
* This one has unmeasured bandwidth below the clip cutoff, and
|
|
|
|
* so shouldn't be clipped; we'll have to test that it isn't
|
|
|
|
* later.
|
|
|
|
*/
|
2013-02-19 16:57:49 +01:00
|
|
|
vrs->has_measured_bw = 0;
|
2013-02-19 15:20:29 +01:00
|
|
|
rs->has_bandwidth = 1;
|
2013-04-11 17:43:40 +02:00
|
|
|
vrs->measured_bw_kb = 0;
|
|
|
|
rs->bandwidth_kb = max_unmeasured_bw_kb / 2;
|
2020-10-16 15:51:20 +02:00
|
|
|
vrs->protocols = tor_strdup("Link=2 Wombat=40");
|
2013-02-19 15:20:29 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
/* No more for this test; return NULL */
|
|
|
|
vrs = NULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Shouldn't happen */
|
2017-08-24 21:34:34 +02:00
|
|
|
tt_abort();
|
2013-02-19 15:20:29 +01:00
|
|
|
}
|
2013-04-02 17:49:30 +02:00
|
|
|
if (vrs) {
|
|
|
|
vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
|
|
|
|
tor_asprintf(&vrs->microdesc->microdesc_hash_line,
|
2018-04-09 20:31:51 +02:00
|
|
|
"m 25,26,27,28 "
|
2013-04-02 17:49:30 +02:00
|
|
|
"sha256=xyzajkldsdsajdadlsdjaslsdksdjlsdjsdaskdaaa%d\n",
|
|
|
|
idx);
|
|
|
|
}
|
2013-02-19 15:20:29 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
return vrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Apply tweaks to the vote list for each voter; for the umbw test this is
|
|
|
|
* just adding the right consensus methods to let clipping happen */
|
2013-02-19 17:58:09 +01:00
|
|
|
static int
|
2013-02-19 15:20:29 +01:00
|
|
|
vote_tweaks_for_umbw(networkstatus_t *v, int voter, time_t now)
|
|
|
|
{
|
2013-02-19 17:58:09 +01:00
|
|
|
char *maxbw_param = NULL;
|
|
|
|
int rv = 0;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v);
|
2013-02-19 15:20:29 +01:00
|
|
|
(void)voter;
|
|
|
|
(void)now;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(v->supported_methods);
|
2014-04-26 19:32:36 +02:00
|
|
|
SMARTLIST_FOREACH(v->supported_methods, char *, c, tor_free(c));
|
2013-02-19 15:20:29 +01:00
|
|
|
smartlist_clear(v->supported_methods);
|
2013-04-11 17:43:40 +02:00
|
|
|
/* Method 17 is MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB */
|
2013-02-19 15:20:29 +01:00
|
|
|
smartlist_split_string(v->supported_methods,
|
2018-04-09 20:31:51 +02:00
|
|
|
"25 26 27 28",
|
2013-02-19 15:20:29 +01:00
|
|
|
NULL, 0, -1);
|
2013-02-19 17:58:09 +01:00
|
|
|
/* If we're using a non-default clip bandwidth, add it to net_params */
|
|
|
|
if (alternate_clip_bw > 0) {
|
|
|
|
tor_asprintf(&maxbw_param, "maxunmeasuredbw=%u", alternate_clip_bw);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(maxbw_param);
|
2013-02-19 17:58:09 +01:00
|
|
|
if (maxbw_param) {
|
|
|
|
smartlist_add(v->net_params, maxbw_param);
|
|
|
|
rv = 1;
|
|
|
|
}
|
|
|
|
}
|
2013-02-19 15:20:29 +01:00
|
|
|
|
|
|
|
done:
|
2013-02-19 17:58:09 +01:00
|
|
|
return rv;
|
2013-02-19 15:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test a parsed vote_routerstatus_t for umbw test.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_vrs_for_umbw(vote_routerstatus_t *vrs, int voter, time_t now)
|
|
|
|
{
|
|
|
|
routerstatus_t *rs;
|
|
|
|
tor_addr_t addr_ipv6;
|
2013-04-11 17:43:40 +02:00
|
|
|
uint32_t max_unmeasured_bw_kb = (alternate_clip_bw > 0) ?
|
|
|
|
alternate_clip_bw : DEFAULT_MAX_UNMEASURED_BW_KB;
|
2013-02-19 15:20:29 +01:00
|
|
|
|
|
|
|
(void)voter;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(vrs);
|
2013-02-19 15:20:29 +01:00
|
|
|
rs = &(vrs->status);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs);
|
2013-02-19 15:20:29 +01:00
|
|
|
|
|
|
|
/* Split out by digests to test */
|
|
|
|
if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/*
|
|
|
|
* Check the first routerstatus - measured bandwidth below the clip
|
|
|
|
* cutoff.
|
|
|
|
*/
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(vrs->version,OP_EQ, "0.1.2.14");
|
2021-11-09 19:29:36 +01:00
|
|
|
tt_int_op(vrs->published_on,OP_EQ, now-1500);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(rs->nickname,OP_EQ, "router2");
|
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-19 15:20:29 +01:00
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&rs->ipv4_addr, 0x99008801));
|
|
|
|
tt_int_op(rs->ipv4_orport,OP_EQ, 443);
|
|
|
|
tt_int_op(rs->ipv4_dirport,OP_EQ, 8000);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
|
|
|
tt_assert(vrs->has_measured_bw);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb / 2);
|
|
|
|
tt_int_op(vrs->measured_bw_kb,OP_EQ, max_unmeasured_bw_kb / 2);
|
2013-02-19 15:20:29 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the second routerstatus - measured bandwidth above the clip
|
|
|
|
* cutoff.
|
|
|
|
*/
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(vrs->version,OP_EQ, "0.2.0.5");
|
2021-11-09 19:29:36 +01:00
|
|
|
tt_int_op(vrs->published_on,OP_EQ, now-1000);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(rs->nickname,OP_EQ, "router1");
|
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-19 15:20:29 +01:00
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&rs->ipv4_addr, 0x99009901));
|
|
|
|
tt_int_op(rs->ipv4_orport,OP_EQ, 443);
|
|
|
|
tt_int_op(rs->ipv4_dirport,OP_EQ, 0);
|
2013-02-19 15:20:29 +01:00
|
|
|
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->ipv6_orport,OP_EQ, 4711);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
|
|
|
tt_assert(vrs->has_measured_bw);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb * 2);
|
|
|
|
tt_int_op(vrs->measured_bw_kb,OP_EQ, max_unmeasured_bw_kb * 2);
|
2013-02-19 15:20:29 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
|
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/*
|
|
|
|
* Check the third routerstatus - unmeasured bandwidth above the clip
|
|
|
|
* cutoff; this one should be clipped later on in the consensus, but
|
|
|
|
* appears unclipped in the vote.
|
|
|
|
*/
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
|
|
|
tt_assert(!(vrs->has_measured_bw));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb * 2);
|
|
|
|
tt_int_op(vrs->measured_bw_kb,OP_EQ, 0);
|
2013-02-19 15:20:29 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34"
|
|
|
|
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/*
|
|
|
|
* Check the fourth routerstatus - unmeasured bandwidth below the clip
|
|
|
|
* cutoff; this one should not be clipped.
|
|
|
|
*/
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
|
|
|
tt_assert(!(vrs->has_measured_bw));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb / 2);
|
|
|
|
tt_int_op(vrs->measured_bw_kb,OP_EQ, 0);
|
2013-02-19 15:20:29 +01:00
|
|
|
} else {
|
2017-08-24 21:34:34 +02:00
|
|
|
tt_abort();
|
2013-02-19 15:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test a consensus for v3_networkstatus_test
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_consensus_for_umbw(networkstatus_t *con, time_t now)
|
|
|
|
{
|
|
|
|
(void)now;
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(con);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(con->cert, OP_EQ, NULL);
|
2014-09-16 03:29:48 +02:00
|
|
|
// tt_assert(con->consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB);
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(con->consensus_method, OP_GE, 16);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(4,OP_EQ, smartlist_len(con->routerstatus_list));
|
2013-02-19 15:20:29 +01:00
|
|
|
/* There should be four listed routers; all voters saw the same in this */
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test a router list entry for umbw test
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_routerstatus_for_umbw(routerstatus_t *rs, time_t now)
|
|
|
|
{
|
2021-11-09 19:29:36 +01:00
|
|
|
(void)now;
|
2013-02-19 15:20:29 +01:00
|
|
|
tor_addr_t addr_ipv6;
|
2013-04-11 17:43:40 +02:00
|
|
|
uint32_t max_unmeasured_bw_kb = (alternate_clip_bw > 0) ?
|
|
|
|
alternate_clip_bw : DEFAULT_MAX_UNMEASURED_BW_KB;
|
2013-02-19 15:20:29 +01:00
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs);
|
2013-02-19 15:20:29 +01:00
|
|
|
|
|
|
|
/* There should be four listed routers, as constructed above */
|
|
|
|
if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN)) {
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-19 15:20:29 +01:00
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
|
|
|
|
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_authority);
|
|
|
|
tt_assert(!rs->is_exit);
|
|
|
|
tt_assert(!rs->is_fast);
|
|
|
|
tt_assert(!rs->is_possible_guard);
|
|
|
|
tt_assert(!rs->is_stable);
|
2018-04-09 20:31:51 +02:00
|
|
|
/* (If it wasn't running and valid it wouldn't be here) */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->is_flagged_running);
|
2018-04-09 20:31:51 +02:00
|
|
|
tt_assert(rs->is_valid);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_named);
|
2013-02-19 15:20:29 +01:00
|
|
|
/* This one should have measured bandwidth below the clip cutoff */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb / 2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!(rs->bw_is_unmeasured));
|
2013-02-19 15:20:29 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/* This one showed up in 3 digests. Twice with ID 'M', once with 'Z'. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(rs->identity_digest,OP_EQ,
|
2013-02-19 15:20:29 +01:00
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
|
|
|
|
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
|
|
|
|
DIGEST_LEN);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(rs->nickname,OP_EQ, "router1");
|
|
|
|
tt_mem_op(rs->descriptor_digest,OP_EQ, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tt_assert(tor_addr_eq_ipv4h(&rs->ipv4_addr, 0x99009901));
|
|
|
|
tt_int_op(rs->ipv4_orport,OP_EQ, 443);
|
|
|
|
tt_int_op(rs->ipv4_dirport,OP_EQ, 0);
|
2013-02-19 15:20:29 +01:00
|
|
|
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->ipv6_orport,OP_EQ, 4711);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!rs->is_authority);
|
|
|
|
tt_assert(rs->is_exit);
|
|
|
|
tt_assert(rs->is_fast);
|
|
|
|
tt_assert(rs->is_possible_guard);
|
|
|
|
tt_assert(rs->is_stable);
|
|
|
|
tt_assert(rs->is_flagged_running);
|
|
|
|
tt_assert(rs->is_valid);
|
|
|
|
tt_assert(!rs->is_named);
|
2013-02-19 15:20:29 +01:00
|
|
|
/* This one should have measured bandwidth above the clip cutoff */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb * 2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!(rs->bw_is_unmeasured));
|
2013-02-19 15:20:29 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
|
|
|
|
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/*
|
|
|
|
* This one should have unmeasured bandwidth above the clip cutoff,
|
|
|
|
* and so should be clipped
|
|
|
|
*/
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->bw_is_unmeasured);
|
2013-02-19 15:20:29 +01:00
|
|
|
} else if (tor_memeq(rs->identity_digest,
|
|
|
|
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34"
|
|
|
|
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34",
|
|
|
|
DIGEST_LEN)) {
|
|
|
|
/*
|
|
|
|
* This one should have unmeasured bandwidth below the clip cutoff,
|
|
|
|
* and so should not be clipped
|
|
|
|
*/
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->has_bandwidth);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(rs->bandwidth_kb,OP_EQ, max_unmeasured_bw_kb / 2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(rs->bw_is_unmeasured);
|
2013-02-19 15:20:29 +01:00
|
|
|
} else {
|
|
|
|
/* Weren't expecting this... */
|
2017-08-24 21:34:34 +02:00
|
|
|
tt_abort();
|
2013-02-19 15:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute a consensus involving clipping unmeasured bandwidth with consensus
|
|
|
|
* method 17; this uses the same test_a_networkstatus() function that the
|
|
|
|
* v3_networkstatus test uses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_clip_unmeasured_bw_kb(void *arg)
|
2013-02-19 15:20:29 +01:00
|
|
|
{
|
2013-02-19 17:58:09 +01:00
|
|
|
/* Run the test with the default clip bandwidth */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2013-02-19 17:58:09 +01:00
|
|
|
alternate_clip_bw = 0;
|
|
|
|
test_a_networkstatus(gen_routerstatus_for_umbw,
|
|
|
|
vote_tweaks_for_umbw,
|
|
|
|
test_vrs_for_umbw,
|
|
|
|
test_consensus_for_umbw,
|
|
|
|
test_routerstatus_for_umbw);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-04-18 16:30:14 +02:00
|
|
|
* This version of test_dir_clip_unmeasured_bw_kb() uses a non-default choice
|
|
|
|
* of clip bandwidth.
|
2013-02-19 17:58:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_dir_clip_unmeasured_bw_kb_alt(void *arg)
|
2013-02-19 17:58:09 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Try a different one; this value is chosen so that the below-the-cutoff
|
|
|
|
* unmeasured nodes the test uses, at alternate_clip_bw / 2, will be above
|
2013-04-11 17:43:40 +02:00
|
|
|
* DEFAULT_MAX_UNMEASURED_BW_KB and if the consensus incorrectly uses that
|
2013-02-19 17:58:09 +01:00
|
|
|
* cutoff it will fail the test.
|
|
|
|
*/
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2013-04-11 17:43:40 +02:00
|
|
|
alternate_clip_bw = 3 * DEFAULT_MAX_UNMEASURED_BW_KB;
|
2013-02-19 15:20:29 +01:00
|
|
|
test_a_networkstatus(gen_routerstatus_for_umbw,
|
|
|
|
vote_tweaks_for_umbw,
|
|
|
|
test_vrs_for_umbw,
|
|
|
|
test_consensus_for_umbw,
|
|
|
|
test_routerstatus_for_umbw);
|
|
|
|
}
|
|
|
|
|
2013-04-02 19:59:53 +02:00
|
|
|
static void
|
|
|
|
test_dir_fmt_control_ns(void *arg)
|
|
|
|
{
|
|
|
|
char *s = NULL;
|
|
|
|
routerstatus_t rs;
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
memset(&rs, 0, sizeof(rs));
|
|
|
|
strlcpy(rs.nickname, "TetsuoMilk", sizeof(rs.nickname));
|
|
|
|
memcpy(rs.identity_digest, "Stately, plump Buck ", DIGEST_LEN);
|
|
|
|
memcpy(rs.descriptor_digest, "Mulligan came up fro", DIGEST_LEN);
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs.ipv4_addr, 0x20304050);
|
|
|
|
rs.ipv4_orport = 9001;
|
|
|
|
rs.ipv4_dirport = 9002;
|
2013-04-02 19:59:53 +02:00
|
|
|
rs.is_exit = 1;
|
|
|
|
rs.is_fast = 1;
|
|
|
|
rs.is_flagged_running = 1;
|
|
|
|
rs.has_bandwidth = 1;
|
2014-10-28 18:12:52 +01:00
|
|
|
rs.is_v2_dir = 1;
|
2013-04-18 17:13:36 +02:00
|
|
|
rs.bandwidth_kb = 1000;
|
2013-04-02 19:59:53 +02:00
|
|
|
|
|
|
|
s = networkstatus_getinfo_helper_single(&rs);
|
|
|
|
tt_assert(s);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(s, OP_EQ,
|
2013-04-02 19:59:53 +02:00
|
|
|
"r TetsuoMilk U3RhdGVseSwgcGx1bXAgQnVjayA "
|
2021-11-09 19:29:36 +01:00
|
|
|
"TXVsbGlnYW4gY2FtZSB1cCBmcm8 2038-01-01 00:00:00 "
|
2013-04-02 19:59:53 +02:00
|
|
|
"32.48.64.80 9001 9002\n"
|
2014-01-29 21:17:05 +01:00
|
|
|
"s Exit Fast Running V2Dir\n"
|
2013-04-02 19:59:53 +02:00
|
|
|
"w Bandwidth=1000\n");
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(s);
|
|
|
|
}
|
2013-04-02 18:45:12 +02:00
|
|
|
|
2015-08-18 13:50:15 +02:00
|
|
|
static int mock_get_options_calls = 0;
|
|
|
|
static or_options_t *mock_options = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
reset_options(or_options_t *options, int *get_options_calls)
|
|
|
|
{
|
|
|
|
memset(options, 0, sizeof(or_options_t));
|
|
|
|
options->TestingTorNetwork = 1;
|
|
|
|
|
|
|
|
*get_options_calls = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const or_options_t *
|
|
|
|
mock_get_options(void)
|
|
|
|
{
|
|
|
|
++mock_get_options_calls;
|
|
|
|
tor_assert(mock_options);
|
|
|
|
return mock_options;
|
|
|
|
}
|
|
|
|
|
2018-11-06 15:56:05 +01:00
|
|
|
/**
|
|
|
|
* Test dirauth_get_b64_digest_bw_file.
|
|
|
|
* This function should be near the other bwauth functions, but it needs
|
|
|
|
* mock_get_options, that is only defined here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_bwauth_bw_file_digest256(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
const char *content =
|
|
|
|
"1541171221\n"
|
|
|
|
"node_id=$68A483E05A2ABDCA6DA5A3EF8DB5177638A27F80 "
|
|
|
|
"master_key_ed25519=YaqV4vbvPYKucElk297eVdNArDz9HtIwUoIeo0+cVIpQ "
|
|
|
|
"bw=760 nick=Test time=2018-05-08T16:13:26\n";
|
|
|
|
|
|
|
|
char *fname = tor_strdup(get_fname("V3BandwidthsFile"));
|
|
|
|
/* Initialize to a wrong digest. */
|
|
|
|
uint8_t digest[DIGEST256_LEN] = "01234567890123456789abcdefghijkl";
|
|
|
|
|
|
|
|
/* Digest of an empty string. Initialize to a wrong digest. */
|
|
|
|
char digest_empty_str[DIGEST256_LEN] = "01234567890123456789abcdefghijkl";
|
|
|
|
crypto_digest256(digest_empty_str, "", 0, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Digest of the content. Initialize to a wrong digest. */
|
|
|
|
char digest_expected[DIGEST256_LEN] = "01234567890123456789abcdefghijkl";
|
|
|
|
crypto_digest256(digest_expected, content, strlen(content), DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* When the bandwidth file can not be found. */
|
|
|
|
tt_int_op(-1, OP_EQ,
|
|
|
|
dirserv_read_measured_bandwidths(fname,
|
|
|
|
NULL, NULL, digest));
|
|
|
|
tt_mem_op(digest, OP_EQ, digest_empty_str, DIGEST256_LEN);
|
|
|
|
|
|
|
|
/* When there is a timestamp but it is too old. */
|
|
|
|
write_str_to_file(fname, content, 0);
|
|
|
|
tt_int_op(-1, OP_EQ,
|
|
|
|
dirserv_read_measured_bandwidths(fname,
|
|
|
|
NULL, NULL, digest));
|
|
|
|
/* The digest will be correct. */
|
|
|
|
tt_mem_op(digest, OP_EQ, digest_expected, DIGEST256_LEN);
|
|
|
|
|
|
|
|
update_approx_time(1541171221);
|
|
|
|
|
|
|
|
/* When there is a bandwidth file and it can be read. */
|
|
|
|
tt_int_op(0, OP_EQ,
|
|
|
|
dirserv_read_measured_bandwidths(fname,
|
|
|
|
NULL, NULL, digest));
|
|
|
|
tt_mem_op(digest, OP_EQ, digest_expected, DIGEST256_LEN);
|
|
|
|
|
|
|
|
done:
|
|
|
|
unlink(fname);
|
|
|
|
tor_free(fname);
|
|
|
|
update_approx_time(time(NULL));
|
|
|
|
}
|
|
|
|
|
2015-08-18 13:50:15 +02:00
|
|
|
static void
|
|
|
|
reset_routerstatus(routerstatus_t *rs,
|
|
|
|
const char *hex_identity_digest,
|
2017-09-13 03:09:18 +02:00
|
|
|
uint32_t ipv4_addr)
|
2015-08-18 13:50:15 +02:00
|
|
|
{
|
|
|
|
memset(rs, 0, sizeof(routerstatus_t));
|
|
|
|
base16_decode(rs->identity_digest, sizeof(rs->identity_digest),
|
|
|
|
hex_identity_digest, HEX_DIGEST_LEN);
|
|
|
|
/* A zero address matches everything, so the address needs to be set.
|
|
|
|
* But the specific value is irrelevant. */
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs->ipv4_addr, ipv4_addr);
|
2015-08-18 13:50:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ROUTER_A_ID_STR "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
|
|
|
#define ROUTER_A_IPV4 0xAA008801
|
|
|
|
#define ROUTER_B_ID_STR "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
|
|
|
#define ROUTER_B_IPV4 0xBB008801
|
|
|
|
|
|
|
|
#define ROUTERSET_ALL_STR "*"
|
|
|
|
#define ROUTERSET_A_STR ROUTER_A_ID_STR
|
|
|
|
#define ROUTERSET_NONE_STR ""
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test that dirserv_set_routerstatus_testing sets router flags correctly
|
|
|
|
* Using "*" sets flags on A and B
|
|
|
|
* Using "A" sets flags on A
|
|
|
|
* Using "" sets flags on Neither
|
|
|
|
* If the router is not included:
|
|
|
|
* - if *Strict is set, the flag is set to 0,
|
|
|
|
* - otherwise, the flag is not modified. */
|
|
|
|
static void
|
|
|
|
test_dir_dirserv_set_routerstatus_testing(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
/* Init options */
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options_t *dirauth_options =
|
|
|
|
tor_malloc_zero(sizeof(dirauth_options_t));
|
|
|
|
|
2016-06-30 20:36:31 +02:00
|
|
|
mock_options = tor_malloc(sizeof(or_options_t));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
|
|
|
MOCK(get_options, mock_get_options);
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_set_options(dirauth_options);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Init routersets */
|
|
|
|
routerset_t *routerset_all = routerset_new();
|
|
|
|
routerset_parse(routerset_all, ROUTERSET_ALL_STR, "All routers");
|
|
|
|
|
|
|
|
routerset_t *routerset_a = routerset_new();
|
|
|
|
routerset_parse(routerset_a, ROUTERSET_A_STR, "Router A only");
|
|
|
|
|
|
|
|
routerset_t *routerset_none = routerset_new();
|
|
|
|
/* Routersets are empty when provided by routerset_new(),
|
|
|
|
* so this is not strictly necessary */
|
|
|
|
routerset_parse(routerset_none, ROUTERSET_NONE_STR, "No routers");
|
|
|
|
|
|
|
|
/* Init routerstatuses */
|
2016-06-30 20:36:31 +02:00
|
|
|
routerstatus_t *rs_a = tor_malloc(sizeof(routerstatus_t));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_a, ROUTER_A_ID_STR, ROUTER_A_IPV4);
|
|
|
|
|
2016-06-30 20:36:31 +02:00
|
|
|
routerstatus_t *rs_b = tor_malloc(sizeof(routerstatus_t));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
|
|
|
/* Sanity check that routersets correspond to routerstatuses.
|
|
|
|
* Return values are {2, 3, 4} */
|
|
|
|
|
|
|
|
/* We want 3 ("*" means match all addresses) */
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(routerset_contains_routerstatus(routerset_all, rs_a, 0), OP_EQ, 3);
|
|
|
|
tt_int_op(routerset_contains_routerstatus(routerset_all, rs_b, 0), OP_EQ, 3);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* We want 4 (match id_digest [or nickname]) */
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(routerset_contains_routerstatus(routerset_a, rs_a, 0), OP_EQ, 4);
|
|
|
|
tt_int_op(routerset_contains_routerstatus(routerset_a, rs_b, 0), OP_EQ, 0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(routerset_contains_routerstatus(routerset_none, rs_a, 0), OP_EQ,
|
|
|
|
0);
|
|
|
|
tt_int_op(routerset_contains_routerstatus(routerset_none, rs_b, 0), OP_EQ,
|
|
|
|
0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check that "*" sets flags on all routers: Exit
|
|
|
|
* Check the flags aren't being confused with each other */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_a, ROUTER_A_ID_STR, ROUTER_A_IPV4);
|
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteExit = routerset_all;
|
|
|
|
dirauth_options->TestingDirAuthVoteExitIsStrict = 0;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_a);
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_a->is_exit, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 1);
|
2015-08-18 13:50:15 +02:00
|
|
|
/* Be paranoid - check no other flags are set */
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_a->is_possible_guard, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_a->is_hs_dir, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check that "*" sets flags on all routers: Guard & HSDir
|
|
|
|
* Cover the remaining flags in one test */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_a, ROUTER_A_ID_STR, ROUTER_A_IPV4);
|
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteGuard = routerset_all;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuardIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDir = routerset_all;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDirIsStrict = 0;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_a);
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_a->is_possible_guard, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_a->is_hs_dir, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 1);
|
2015-08-18 13:50:15 +02:00
|
|
|
/* Be paranoid - check exit isn't set */
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_a->is_exit, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check routerset A sets all flags on router A,
|
|
|
|
* but leaves router B unmodified */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_a, ROUTER_A_ID_STR, ROUTER_A_IPV4);
|
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteExit = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteExitIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuard = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuardIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDir = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDirIsStrict = 0;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_a);
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_a->is_exit, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_a->is_possible_guard, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_a->is_hs_dir, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check routerset A unsets all flags on router B when Strict is set */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteExit = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteExitIsStrict = 1;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuard = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuardIsStrict = 1;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDir = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDirIsStrict = 1;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
rs_b->is_exit = 1;
|
|
|
|
rs_b->is_possible_guard = 1;
|
|
|
|
rs_b->is_hs_dir = 1;
|
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check routerset A doesn't modify flags on router B without Strict set */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteExit = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteExitIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuard = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuardIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDir = routerset_a;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDirIsStrict = 0;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
rs_b->is_exit = 1;
|
|
|
|
rs_b->is_possible_guard = 1;
|
|
|
|
rs_b->is_hs_dir = 1;
|
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 1);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check the empty routerset zeroes all flags
|
|
|
|
* on routers A & B with Strict set */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteExit = routerset_none;
|
|
|
|
dirauth_options->TestingDirAuthVoteExitIsStrict = 1;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuard = routerset_none;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuardIsStrict = 1;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDir = routerset_none;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDirIsStrict = 1;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
rs_b->is_exit = 1;
|
|
|
|
rs_b->is_possible_guard = 1;
|
|
|
|
rs_b->is_hs_dir = 1;
|
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 0);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
/* Check the empty routerset doesn't modify any flags
|
|
|
|
* on A or B without Strict set */
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2019-12-19 16:42:44 +01:00
|
|
|
memset(dirauth_options, 0, sizeof(*dirauth_options));
|
2015-08-18 13:50:15 +02:00
|
|
|
reset_routerstatus(rs_a, ROUTER_A_ID_STR, ROUTER_A_IPV4);
|
|
|
|
reset_routerstatus(rs_b, ROUTER_B_ID_STR, ROUTER_B_IPV4);
|
|
|
|
|
2019-12-19 16:42:44 +01:00
|
|
|
dirauth_options->TestingDirAuthVoteExit = routerset_none;
|
|
|
|
dirauth_options->TestingDirAuthVoteExitIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuard = routerset_none;
|
|
|
|
dirauth_options->TestingDirAuthVoteGuardIsStrict = 0;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDir = routerset_none;
|
|
|
|
dirauth_options->TestingDirAuthVoteHSDirIsStrict = 0;
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
rs_b->is_exit = 1;
|
|
|
|
rs_b->is_possible_guard = 1;
|
|
|
|
rs_b->is_hs_dir = 1;
|
|
|
|
|
|
|
|
dirserv_set_routerstatus_testing(rs_a);
|
|
|
|
dirserv_set_routerstatus_testing(rs_b);
|
|
|
|
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_uint_op(rs_a->is_exit, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_a->is_possible_guard, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_a->is_hs_dir, OP_EQ, 0);
|
|
|
|
tt_uint_op(rs_b->is_exit, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_possible_guard, OP_EQ, 1);
|
|
|
|
tt_uint_op(rs_b->is_hs_dir, OP_EQ, 1);
|
2015-08-18 13:50:15 +02:00
|
|
|
|
|
|
|
done:
|
2016-06-30 20:36:31 +02:00
|
|
|
tor_free(mock_options);
|
2019-12-19 16:42:44 +01:00
|
|
|
tor_free(dirauth_options);
|
2015-08-18 13:50:15 +02:00
|
|
|
mock_options = NULL;
|
|
|
|
|
|
|
|
UNMOCK(get_options);
|
|
|
|
|
|
|
|
routerset_free(routerset_all);
|
|
|
|
routerset_free(routerset_a);
|
|
|
|
routerset_free(routerset_none);
|
|
|
|
|
2016-06-30 20:36:31 +02:00
|
|
|
tor_free(rs_a);
|
|
|
|
tor_free(rs_b);
|
2015-08-18 13:50:15 +02:00
|
|
|
}
|
|
|
|
|
2013-09-03 02:14:43 +02:00
|
|
|
static void
|
|
|
|
test_dir_http_handling(void *args)
|
|
|
|
{
|
|
|
|
char *url = NULL;
|
2013-09-03 19:39:31 +02:00
|
|
|
(void)args;
|
2013-09-03 02:14:43 +02:00
|
|
|
|
|
|
|
/* Parse http url tests: */
|
|
|
|
/* Good headers */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1\r\n"
|
2013-09-03 02:14:43 +02:00
|
|
|
"Host: example.com\r\n"
|
|
|
|
"User-Agent: Mozilla/5.0 (Windows;"
|
|
|
|
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
|
2014-11-12 19:28:07 +01:00
|
|
|
&url),OP_EQ, 0);
|
|
|
|
tt_str_op(url,OP_EQ, "/tor/a/b/c.txt");
|
2013-09-03 02:14:43 +02:00
|
|
|
tor_free(url);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.0\r\n", &url),OP_EQ, 0);
|
|
|
|
tt_str_op(url,OP_EQ, "/tor/a/b/c.txt");
|
2013-09-03 17:37:04 +02:00
|
|
|
tor_free(url);
|
|
|
|
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.600\r\n", &url),
|
|
|
|
OP_EQ, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(url,OP_EQ, "/tor/a/b/c.txt");
|
2013-09-03 17:37:04 +02:00
|
|
|
tor_free(url);
|
|
|
|
|
|
|
|
/* Should prepend '/tor/' to url if required */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_int_op(parse_http_url("GET /a/b/c.txt HTTP/1.1\r\n"
|
2013-09-03 02:14:43 +02:00
|
|
|
"Host: example.com\r\n"
|
|
|
|
"User-Agent: Mozilla/5.0 (Windows;"
|
|
|
|
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
|
2014-11-12 19:28:07 +01:00
|
|
|
&url),OP_EQ, 0);
|
|
|
|
tt_str_op(url,OP_EQ, "/tor/a/b/c.txt");
|
2013-09-03 02:14:43 +02:00
|
|
|
tor_free(url);
|
|
|
|
|
2013-09-03 17:37:04 +02:00
|
|
|
/* Bad headers -- no HTTP/1.x*/
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_int_op(parse_http_url("GET /a/b/c.txt\r\n"
|
2013-09-03 17:37:04 +02:00
|
|
|
"Host: example.com\r\n"
|
|
|
|
"User-Agent: Mozilla/5.0 (Windows;"
|
|
|
|
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
|
2014-11-12 19:28:07 +01:00
|
|
|
&url),OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 17:37:04 +02:00
|
|
|
|
2013-09-03 02:14:43 +02:00
|
|
|
/* Bad headers */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_int_op(parse_http_url("GET /a/b/c.txt\r\n"
|
2013-09-03 02:14:43 +02:00
|
|
|
"Host: example.com\r\n"
|
|
|
|
"User-Agent: Mozilla/5.0 (Windows;"
|
|
|
|
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
|
2014-11-12 19:28:07 +01:00
|
|
|
&url),OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 02:14:43 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt", &url),OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 17:37:04 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1", &url),OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 17:37:04 +02:00
|
|
|
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1x\r\n", &url),
|
|
|
|
OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 17:37:04 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.", &url),OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 17:37:04 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.\r", &url),OP_EQ, -1);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(url, OP_EQ, NULL);
|
2013-09-03 02:14:43 +02:00
|
|
|
|
2013-09-03 17:37:04 +02:00
|
|
|
done:
|
|
|
|
tor_free(url);
|
2013-09-03 02:14:43 +02:00
|
|
|
}
|
|
|
|
|
2016-10-19 02:04:22 +02:00
|
|
|
static void
|
|
|
|
test_dir_purpose_needs_anonymity_returns_true_by_default(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
2020-03-06 17:51:23 +01:00
|
|
|
#ifdef ALL_BUGS_ARE_FATAL
|
2020-03-19 08:11:13 +01:00
|
|
|
/* Coverity (and maybe clang analyser) complain that the code following
|
|
|
|
* tt_skip() is unconditionally unreachable. */
|
|
|
|
#if !defined(__COVERITY__) && !defined(__clang_analyzer__)
|
2020-03-06 17:51:23 +01:00
|
|
|
tt_skip();
|
2020-03-19 08:11:13 +01:00
|
|
|
#endif
|
2020-04-29 14:07:35 +02:00
|
|
|
#endif /* defined(ALL_BUGS_ARE_FATAL) */
|
2020-03-06 17:51:23 +01:00
|
|
|
|
2016-10-19 23:23:11 +02:00
|
|
|
tor_capture_bugs_(1);
|
2016-12-07 17:19:49 +01:00
|
|
|
setup_full_capture_of_logs(LOG_WARN);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(0, 0, NULL));
|
|
|
|
tt_int_op(1, OP_EQ, smartlist_len(tor_get_captured_bug_log_()));
|
2016-12-07 17:19:49 +01:00
|
|
|
expect_single_log_msg_containing("Called with dir_purpose=0");
|
|
|
|
|
|
|
|
tor_end_capture_bugs_();
|
|
|
|
done:
|
2016-10-19 23:23:11 +02:00
|
|
|
tor_end_capture_bugs_();
|
2016-12-07 17:19:49 +01:00
|
|
|
teardown_capture_of_logs();
|
2016-10-19 02:04:22 +02:00
|
|
|
}
|
|
|
|
|
2014-09-23 18:22:36 +02:00
|
|
|
static void
|
2016-10-09 02:28:38 +02:00
|
|
|
test_dir_purpose_needs_anonymity_returns_true_for_bridges(void *arg)
|
2014-09-23 18:22:36 +02:00
|
|
|
{
|
|
|
|
(void)arg;
|
2016-10-09 02:28:38 +02:00
|
|
|
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE, NULL));
|
|
|
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE,
|
2016-10-26 01:30:50 +02:00
|
|
|
"foobar"));
|
|
|
|
done: ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_purpose_needs_anonymity_returns_false_for_own_bridge_desc(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC,
|
2016-10-26 01:30:50 +02:00
|
|
|
ROUTER_PURPOSE_BRIDGE,
|
|
|
|
"authority.z"));
|
2016-10-09 02:28:38 +02:00
|
|
|
done: ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_purpose_needs_anonymity_ret_false_for_non_sensitive_conn(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_DIR,
|
2016-10-26 01:30:50 +02:00
|
|
|
ROUTER_PURPOSE_GENERAL, NULL));
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_VOTE, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_SIGNATURES, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(
|
2016-10-26 01:30:50 +02:00
|
|
|
DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_CONSENSUS, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_EXTRAINFO, 0, NULL));
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ,
|
2016-10-26 01:30:50 +02:00
|
|
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC, 0, NULL));
|
2016-10-09 02:28:38 +02:00
|
|
|
done: ;
|
|
|
|
}
|
|
|
|
|
2014-09-23 18:22:36 +02:00
|
|
|
static void
|
|
|
|
test_dir_fetch_type(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
2016-09-08 20:39:20 +02:00
|
|
|
|
2015-09-07 21:04:51 +02:00
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_EXTRAINFO, ROUTER_PURPOSE_BRIDGE,
|
|
|
|
NULL), OP_EQ, EXTRAINFO_DIRINFO | BRIDGE_DIRINFO);
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_EXTRAINFO, ROUTER_PURPOSE_GENERAL,
|
|
|
|
NULL), OP_EQ, EXTRAINFO_DIRINFO | V3_DIRINFO);
|
|
|
|
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_SERVERDESC, ROUTER_PURPOSE_BRIDGE,
|
|
|
|
NULL), OP_EQ, BRIDGE_DIRINFO);
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_SERVERDESC,
|
|
|
|
ROUTER_PURPOSE_GENERAL, NULL), OP_EQ, V3_DIRINFO);
|
|
|
|
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_STATUS_VOTE,
|
|
|
|
ROUTER_PURPOSE_GENERAL, NULL), OP_EQ, V3_DIRINFO);
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_DETACHED_SIGNATURES,
|
|
|
|
ROUTER_PURPOSE_GENERAL, NULL), OP_EQ, V3_DIRINFO);
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_CERTIFICATE,
|
|
|
|
ROUTER_PURPOSE_GENERAL, NULL), OP_EQ, V3_DIRINFO);
|
|
|
|
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_CONSENSUS, ROUTER_PURPOSE_GENERAL,
|
|
|
|
"microdesc"), OP_EQ, V3_DIRINFO|MICRODESC_DIRINFO);
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_CONSENSUS, ROUTER_PURPOSE_GENERAL,
|
|
|
|
NULL), OP_EQ, V3_DIRINFO);
|
|
|
|
|
|
|
|
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_MICRODESC, ROUTER_PURPOSE_GENERAL,
|
|
|
|
NULL), OP_EQ, MICRODESC_DIRINFO);
|
|
|
|
|
2016-09-08 20:39:20 +02:00
|
|
|
done:
|
2016-09-08 21:01:32 +02:00
|
|
|
teardown_capture_of_logs();
|
2014-09-23 18:22:36 +02:00
|
|
|
}
|
|
|
|
|
2015-01-09 17:36:47 +01:00
|
|
|
static void
|
|
|
|
test_dir_packages(void *arg)
|
|
|
|
{
|
|
|
|
smartlist_t *votes = smartlist_new();
|
|
|
|
char *res = NULL;
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
#define BAD(s) \
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(0, OP_EQ, validate_recommended_package_line(s));
|
2015-01-09 17:36:47 +01:00
|
|
|
#define GOOD(s) \
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(1, OP_EQ, validate_recommended_package_line(s));
|
2015-01-09 17:36:47 +01:00
|
|
|
GOOD("tor 0.2.6.3-alpha "
|
|
|
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
|
|
|
|
"sha256=sssdlkfjdsklfjdskfljasdklfj");
|
|
|
|
GOOD("tor 0.2.6.3-alpha "
|
|
|
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
|
|
|
|
"sha256=sssdlkfjdsklfjdskfljasdklfj blake2b=fred");
|
|
|
|
BAD("tor 0.2.6.3-alpha "
|
|
|
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
|
|
|
|
"sha256=sssdlkfjdsklfjdskfljasdklfj=");
|
|
|
|
BAD("tor 0.2.6.3-alpha "
|
|
|
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
|
|
|
|
"sha256=sssdlkfjdsklfjdskfljasdklfj blake2b");
|
|
|
|
BAD("tor 0.2.6.3-alpha "
|
|
|
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz ");
|
|
|
|
BAD("tor 0.2.6.3-alpha "
|
|
|
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz");
|
|
|
|
BAD("tor 0.2.6.3-alpha ");
|
|
|
|
BAD("tor 0.2.6.3-alpha");
|
|
|
|
BAD("tor ");
|
|
|
|
BAD("tor");
|
|
|
|
BAD("");
|
2015-01-29 20:04:57 +01:00
|
|
|
BAD("=foobar sha256="
|
|
|
|
"3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7");
|
|
|
|
BAD("= = sha256="
|
|
|
|
"3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7");
|
|
|
|
|
|
|
|
BAD("sha512= sha256="
|
|
|
|
"3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7");
|
2015-01-09 17:36:47 +01:00
|
|
|
|
|
|
|
smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
|
|
|
|
smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
|
|
|
|
smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
|
|
|
|
smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
|
|
|
|
smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
|
|
|
|
smartlist_add(votes, tor_malloc_zero(sizeof(networkstatus_t)));
|
|
|
|
SMARTLIST_FOREACH(votes, networkstatus_t *, ns,
|
|
|
|
ns->package_lines = smartlist_new());
|
|
|
|
|
|
|
|
#define ADD(i, s) \
|
|
|
|
smartlist_add(((networkstatus_t*)smartlist_get(votes, (i)))->package_lines, \
|
|
|
|
(void*)(s));
|
|
|
|
|
|
|
|
/* Only one vote for this one. */
|
|
|
|
ADD(4, "cisco 99z http://foobar.example.com/ sha256=blahblah");
|
|
|
|
|
|
|
|
/* Only two matching entries for this one, but 3 voters */
|
|
|
|
ADD(1, "mystic 99y http://barfoo.example.com/ sha256=blahblah");
|
|
|
|
ADD(3, "mystic 99y http://foobar.example.com/ sha256=blahblah");
|
|
|
|
ADD(4, "mystic 99y http://foobar.example.com/ sha256=blahblah");
|
|
|
|
|
|
|
|
/* Only two matching entries for this one, but at least 4 voters */
|
|
|
|
ADD(1, "mystic 99p http://barfoo.example.com/ sha256=ggggggg");
|
|
|
|
ADD(3, "mystic 99p http://foobar.example.com/ sha256=blahblah");
|
|
|
|
ADD(4, "mystic 99p http://foobar.example.com/ sha256=blahblah");
|
|
|
|
ADD(5, "mystic 99p http://foobar.example.com/ sha256=ggggggg");
|
|
|
|
|
|
|
|
/* This one has only invalid votes. */
|
|
|
|
ADD(0, "haffenreffer 1.2 http://foobar.example.com/ sha256");
|
|
|
|
ADD(1, "haffenreffer 1.2 http://foobar.example.com/ ");
|
|
|
|
ADD(2, "haffenreffer 1.2 ");
|
|
|
|
ADD(3, "haffenreffer ");
|
|
|
|
ADD(4, "haffenreffer");
|
|
|
|
|
|
|
|
/* Three matching votes for this; it should actually go in! */
|
|
|
|
ADD(2, "element 0.66.1 http://quux.example.com/ sha256=abcdef");
|
|
|
|
ADD(3, "element 0.66.1 http://quux.example.com/ sha256=abcdef");
|
|
|
|
ADD(4, "element 0.66.1 http://quux.example.com/ sha256=abcdef");
|
|
|
|
ADD(1, "element 0.66.1 http://quum.example.com/ sha256=abcdef");
|
|
|
|
ADD(0, "element 0.66.1 http://quux.example.com/ sha256=abcde");
|
|
|
|
|
|
|
|
/* Three votes for A, three votes for B */
|
|
|
|
ADD(0, "clownshoes 22alpha1 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(1, "clownshoes 22alpha1 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(2, "clownshoes 22alpha1 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(3, "clownshoes 22alpha1 http://quumble.example.com/ blake2=fooz");
|
|
|
|
ADD(4, "clownshoes 22alpha1 http://quumble.example.com/ blake2=fooz");
|
|
|
|
ADD(5, "clownshoes 22alpha1 http://quumble.example.com/ blake2=fooz");
|
|
|
|
|
|
|
|
/* Three votes for A, two votes for B */
|
|
|
|
ADD(1, "clownshoes 22alpha3 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(2, "clownshoes 22alpha3 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(3, "clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz");
|
|
|
|
ADD(4, "clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz");
|
|
|
|
ADD(5, "clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz");
|
|
|
|
|
|
|
|
/* Four votes for A, two for B. */
|
|
|
|
ADD(0, "clownshoes 22alpha4 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(1, "clownshoes 22alpha4 http://quumble.example.com/ blake2=foob");
|
|
|
|
ADD(2, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
|
|
|
|
ADD(3, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
|
|
|
|
ADD(4, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
|
|
|
|
ADD(5, "clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa");
|
|
|
|
|
2016-01-27 14:51:28 +01:00
|
|
|
/* Five votes for A ... all from the same authority. Three for B. */
|
2015-01-09 17:36:47 +01:00
|
|
|
ADD(0, "cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m");
|
|
|
|
ADD(1, "cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m");
|
|
|
|
ADD(3, "cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m");
|
|
|
|
ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.1 http://example.com/ cubehash=ahooy");
|
|
|
|
|
|
|
|
/* As above but new replaces old: no two match. */
|
|
|
|
ADD(0, "cbc 99.1.11.1.2 http://example.com/cbc/ cubehash=ahooy sha512=m");
|
|
|
|
ADD(1, "cbc 99.1.11.1.2 http://example.com/cbc/ cubehash=ahooy sha512=m");
|
|
|
|
ADD(1, "cbc 99.1.11.1.2 http://example.com/cbc/x cubehash=ahooy sha512=m");
|
|
|
|
ADD(2, "cbc 99.1.11.1.2 http://example.com/cbc/ cubehash=ahooy sha512=m");
|
|
|
|
ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
|
|
|
|
ADD(2, "cbc 99.1.11.1.2 http://example.com/ cubehash=ahooy");
|
|
|
|
|
|
|
|
res = compute_consensus_package_lines(votes);
|
|
|
|
tt_assert(res);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_str_op(res, OP_EQ,
|
2015-01-09 17:36:47 +01:00
|
|
|
"package cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m\n"
|
|
|
|
"package clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz\n"
|
|
|
|
"package clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa\n"
|
|
|
|
"package element 0.66.1 http://quux.example.com/ sha256=abcdef\n"
|
|
|
|
"package mystic 99y http://foobar.example.com/ sha256=blahblah\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
#undef ADD
|
|
|
|
#undef BAD
|
|
|
|
#undef GOOD
|
|
|
|
done:
|
|
|
|
SMARTLIST_FOREACH(votes, networkstatus_t *, ns,
|
|
|
|
{ smartlist_free(ns->package_lines); tor_free(ns); });
|
2015-02-03 21:58:48 +01:00
|
|
|
smartlist_free(votes);
|
2015-01-09 17:36:47 +01:00
|
|
|
tor_free(res);
|
|
|
|
}
|
|
|
|
|
2015-12-07 07:55:38 +01:00
|
|
|
static void
|
2018-01-25 22:05:20 +01:00
|
|
|
download_status_random_backoff_helper(int min_delay)
|
2016-06-12 21:07:38 +02:00
|
|
|
{
|
|
|
|
download_status_t dls_random =
|
|
|
|
{ 0, 0, 0, DL_SCHED_GENERIC, DL_WANT_AUTHORITY,
|
2018-01-25 21:51:13 +01:00
|
|
|
DL_SCHED_INCREMENT_FAILURE, 0, 0 };
|
2016-06-12 21:07:38 +02:00
|
|
|
int increment = -1;
|
2017-07-04 17:31:23 +02:00
|
|
|
int old_increment = -1;
|
2016-06-12 21:07:38 +02:00
|
|
|
time_t current_time = time(NULL);
|
|
|
|
|
|
|
|
/* Check the random backoff cases */
|
2017-10-17 19:24:40 +02:00
|
|
|
int n_attempts = 0;
|
2016-06-12 21:07:38 +02:00
|
|
|
do {
|
|
|
|
increment = download_status_schedule_get_delay(&dls_random,
|
2018-01-25 22:05:20 +01:00
|
|
|
min_delay,
|
2016-06-12 21:07:38 +02:00
|
|
|
current_time);
|
2017-07-04 17:31:23 +02:00
|
|
|
|
2018-01-25 22:05:20 +01:00
|
|
|
log_debug(LD_DIR, "Min: %d, Inc: %d, Old Inc: %d",
|
|
|
|
min_delay, increment, old_increment);
|
2017-07-04 17:31:23 +02:00
|
|
|
|
|
|
|
/* Regression test for 20534 and friends
|
|
|
|
* increment must always increase after the first */
|
2018-01-25 22:05:20 +01:00
|
|
|
if (dls_random.last_backoff_position > 0) {
|
2017-07-04 17:31:23 +02:00
|
|
|
/* Always increment the exponential backoff */
|
|
|
|
tt_int_op(increment, OP_GE, 1);
|
|
|
|
}
|
|
|
|
|
2016-06-12 21:07:38 +02:00
|
|
|
/* Test */
|
|
|
|
tt_int_op(increment, OP_GE, min_delay);
|
|
|
|
|
|
|
|
/* Advance */
|
2017-11-08 14:11:22 +01:00
|
|
|
if (dls_random.n_download_attempts < IMPOSSIBLE_TO_DOWNLOAD - 1) {
|
|
|
|
++(dls_random.n_download_attempts);
|
|
|
|
++(dls_random.n_download_failures);
|
|
|
|
}
|
2016-06-12 21:07:38 +02:00
|
|
|
|
|
|
|
/* Try another maybe */
|
|
|
|
old_increment = increment;
|
2018-01-25 22:05:20 +01:00
|
|
|
} while (++n_attempts < 1000);
|
2016-06-12 21:07:38 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-04 17:31:23 +02:00
|
|
|
static void
|
|
|
|
test_dir_download_status_random_backoff(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
/* Do a standard test */
|
2018-01-25 22:05:20 +01:00
|
|
|
download_status_random_backoff_helper(0);
|
2017-07-04 17:31:23 +02:00
|
|
|
/* regression tests for 17750: initial delay */
|
2018-01-25 22:05:20 +01:00
|
|
|
download_status_random_backoff_helper(10);
|
|
|
|
download_status_random_backoff_helper(20);
|
2017-07-04 17:31:23 +02:00
|
|
|
|
|
|
|
/* Pathological cases */
|
2018-01-25 22:05:20 +01:00
|
|
|
download_status_random_backoff_helper(INT_MAX/2);
|
2017-07-04 17:31:23 +02:00
|
|
|
}
|
|
|
|
|
2017-10-17 19:24:40 +02:00
|
|
|
static void
|
|
|
|
test_dir_download_status_random_backoff_ranges(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
int lo, hi;
|
|
|
|
next_random_exponential_delay_range(&lo, &hi, 0, 10);
|
|
|
|
tt_int_op(lo, OP_EQ, 10);
|
|
|
|
tt_int_op(hi, OP_EQ, 11);
|
|
|
|
|
|
|
|
next_random_exponential_delay_range(&lo, &hi, 6, 10);
|
|
|
|
tt_int_op(lo, OP_EQ, 10);
|
|
|
|
tt_int_op(hi, OP_EQ, 6*3);
|
|
|
|
|
|
|
|
next_random_exponential_delay_range(&lo, &hi, 13, 10);
|
|
|
|
tt_int_op(lo, OP_EQ, 10);
|
|
|
|
tt_int_op(hi, OP_EQ, 13 * 3);
|
|
|
|
|
|
|
|
next_random_exponential_delay_range(&lo, &hi, 37, 10);
|
|
|
|
tt_int_op(lo, OP_EQ, 10);
|
|
|
|
tt_int_op(hi, OP_EQ, 111);
|
|
|
|
|
|
|
|
next_random_exponential_delay_range(&lo, &hi, 123, 10);
|
|
|
|
tt_int_op(lo, OP_EQ, 10);
|
|
|
|
tt_int_op(hi, OP_EQ, 369);
|
|
|
|
|
|
|
|
next_random_exponential_delay_range(&lo, &hi, INT_MAX-5, 10);
|
|
|
|
tt_int_op(lo, OP_EQ, 10);
|
|
|
|
tt_int_op(hi, OP_EQ, INT_MAX);
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2015-12-07 07:55:38 +01:00
|
|
|
static void
|
|
|
|
test_dir_download_status_increment(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
2017-07-04 17:31:23 +02:00
|
|
|
download_status_t dls_exp = { 0, 0, 0, DL_SCHED_GENERIC,
|
|
|
|
DL_WANT_ANY_DIRSERVER,
|
|
|
|
DL_SCHED_INCREMENT_ATTEMPT,
|
2018-01-25 21:51:13 +01:00
|
|
|
0, 0 };
|
2015-12-07 07:55:38 +01:00
|
|
|
or_options_t test_options;
|
|
|
|
time_t current_time = time(NULL);
|
|
|
|
|
2018-04-18 17:19:14 +02:00
|
|
|
const int delay0 = 10;
|
|
|
|
const int no_delay = 0;
|
|
|
|
const int schedule = 10;
|
|
|
|
const int schedule_no_initial_delay = 0;
|
2017-07-04 17:31:23 +02:00
|
|
|
|
2015-12-07 07:55:38 +01:00
|
|
|
/* Put it in the options */
|
|
|
|
mock_options = &test_options;
|
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
2018-04-18 17:19:14 +02:00
|
|
|
mock_options->TestingBridgeBootstrapDownloadInitialDelay = schedule;
|
|
|
|
mock_options->TestingClientDownloadInitialDelay = schedule;
|
2015-12-07 07:55:38 +01:00
|
|
|
|
|
|
|
MOCK(get_options, mock_get_options);
|
|
|
|
|
2017-07-04 17:31:23 +02:00
|
|
|
/* Check that the initial value of the schedule is the first value used,
|
|
|
|
* whether or not it was reset before being used */
|
|
|
|
|
|
|
|
/* regression test for 17750: no initial delay */
|
2018-04-18 17:19:14 +02:00
|
|
|
mock_options->TestingClientDownloadInitialDelay = schedule_no_initial_delay;
|
2017-07-04 17:31:23 +02:00
|
|
|
mock_get_options_calls = 0;
|
|
|
|
/* we really want to test that it's equal to time(NULL) + delay0, but that's
|
|
|
|
* an unrealiable test, because time(NULL) might change. */
|
|
|
|
|
|
|
|
/* regression test for 17750: exponential, no initial delay */
|
2018-04-18 17:19:14 +02:00
|
|
|
mock_options->TestingClientDownloadInitialDelay = schedule_no_initial_delay;
|
2017-07-04 17:31:23 +02:00
|
|
|
mock_get_options_calls = 0;
|
|
|
|
/* we really want to test that it's equal to time(NULL) + delay0, but that's
|
|
|
|
* an unrealiable test, because time(NULL) might change. */
|
|
|
|
tt_assert(download_status_get_next_attempt_at(&dls_exp)
|
|
|
|
>= current_time + no_delay);
|
|
|
|
tt_assert(download_status_get_next_attempt_at(&dls_exp)
|
|
|
|
!= TIME_MAX);
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(download_status_get_n_failures(&dls_exp), OP_EQ, 0);
|
|
|
|
tt_int_op(download_status_get_n_attempts(&dls_exp), OP_EQ, 0);
|
|
|
|
tt_int_op(mock_get_options_calls, OP_GE, 1);
|
2017-07-04 17:31:23 +02:00
|
|
|
|
|
|
|
/* regression test for 17750: exponential, initial delay */
|
2018-04-18 17:19:14 +02:00
|
|
|
mock_options->TestingClientDownloadInitialDelay = schedule;
|
2017-07-04 17:31:23 +02:00
|
|
|
mock_get_options_calls = 0;
|
|
|
|
/* we really want to test that it's equal to time(NULL) + delay0, but that's
|
|
|
|
* an unrealiable test, because time(NULL) might change. */
|
|
|
|
tt_assert(download_status_get_next_attempt_at(&dls_exp)
|
|
|
|
>= current_time + delay0);
|
|
|
|
tt_assert(download_status_get_next_attempt_at(&dls_exp)
|
|
|
|
!= TIME_MAX);
|
2017-08-24 21:49:59 +02:00
|
|
|
tt_int_op(download_status_get_n_failures(&dls_exp), OP_EQ, 0);
|
|
|
|
tt_int_op(download_status_get_n_attempts(&dls_exp), OP_EQ, 0);
|
|
|
|
tt_int_op(mock_get_options_calls, OP_GE, 1);
|
2017-07-04 17:31:23 +02:00
|
|
|
|
2015-12-07 07:55:38 +01:00
|
|
|
done:
|
|
|
|
UNMOCK(get_options);
|
|
|
|
mock_options = NULL;
|
|
|
|
mock_get_options_calls = 0;
|
2016-11-07 22:10:42 +01:00
|
|
|
teardown_capture_of_logs();
|
2015-12-07 07:55:38 +01:00
|
|
|
}
|
|
|
|
|
2015-09-07 21:04:51 +02:00
|
|
|
static void
|
|
|
|
test_dir_authdir_type_to_string(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
2016-01-12 18:33:05 +01:00
|
|
|
char *res;
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2016-01-12 18:33:05 +01:00
|
|
|
tt_str_op(res = authdir_type_to_string(NO_DIRINFO), OP_EQ,
|
2015-09-07 21:04:51 +02:00
|
|
|
"[Not an authority]");
|
2016-01-12 18:33:05 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
tt_str_op(res = authdir_type_to_string(EXTRAINFO_DIRINFO), OP_EQ,
|
2015-09-07 21:04:51 +02:00
|
|
|
"[Not an authority]");
|
2016-01-12 18:33:05 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
tt_str_op(res = authdir_type_to_string(MICRODESC_DIRINFO), OP_EQ,
|
2015-09-07 21:04:51 +02:00
|
|
|
"[Not an authority]");
|
2016-01-12 18:33:05 +01:00
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
tt_str_op(res = authdir_type_to_string(V3_DIRINFO), OP_EQ, "V3");
|
|
|
|
tor_free(res);
|
|
|
|
|
|
|
|
tt_str_op(res = authdir_type_to_string(BRIDGE_DIRINFO), OP_EQ, "Bridge");
|
|
|
|
tor_free(res);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2016-01-12 18:33:05 +01:00
|
|
|
tt_str_op(res = authdir_type_to_string(
|
2015-09-07 21:04:51 +02:00
|
|
|
V3_DIRINFO | BRIDGE_DIRINFO | EXTRAINFO_DIRINFO), OP_EQ,
|
|
|
|
"V3, Bridge");
|
2016-01-12 18:33:05 +01:00
|
|
|
done:
|
|
|
|
tor_free(res);
|
2015-09-07 21:04:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_conn_purpose_to_string(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
|
|
|
|
#define EXPECT_CONN_PURPOSE(purpose, expected) \
|
|
|
|
tt_str_op(dir_conn_purpose_to_string(purpose), OP_EQ, expected);
|
|
|
|
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_UPLOAD_DIR, "server descriptor upload");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_UPLOAD_VOTE, "server vote upload");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_UPLOAD_SIGNATURES,
|
|
|
|
"consensus signature upload");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_SERVERDESC, "server descriptor fetch");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_EXTRAINFO, "extra-info fetch");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_CONSENSUS,
|
|
|
|
"consensus network-status fetch");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_CERTIFICATE, "authority cert fetch");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_STATUS_VOTE, "status vote fetch");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_DETACHED_SIGNATURES,
|
|
|
|
"consensus signature fetch");
|
|
|
|
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_MICRODESC, "microdescriptor fetch");
|
2016-09-08 20:39:20 +02:00
|
|
|
|
|
|
|
/* This will give a warning, because there is no purpose 1024. */
|
2016-09-08 21:01:32 +02:00
|
|
|
setup_full_capture_of_logs(LOG_WARN);
|
2015-09-07 21:04:51 +02:00
|
|
|
EXPECT_CONN_PURPOSE(1024, "(unknown)");
|
2016-09-08 20:39:20 +02:00
|
|
|
expect_single_log_msg_containing("Called with unknown purpose 1024");
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2016-09-08 20:39:20 +02:00
|
|
|
done:
|
2016-09-08 21:01:32 +02:00
|
|
|
teardown_capture_of_logs();
|
2015-09-07 21:04:51 +02:00
|
|
|
}
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
static int dir_tests_public_server_mode(const or_options_t *options);
|
|
|
|
ATTR_UNUSED static int dir_tests_public_server_mode_called = 0;
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
static int
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
dir_tests_public_server_mode(const or_options_t *options)
|
2015-09-07 21:04:51 +02:00
|
|
|
{
|
|
|
|
(void)options;
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
if (dir_tests_public_server_mode_called++ == 0) {
|
2015-09-07 21:04:51 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_should_use_directory_guards(void *data)
|
|
|
|
{
|
|
|
|
or_options_t *options;
|
|
|
|
char *errmsg = NULL;
|
|
|
|
(void)data;
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
MOCK(public_server_mode,
|
|
|
|
dir_tests_public_server_mode);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
options = options_new();
|
|
|
|
options_init(options);
|
|
|
|
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 0);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 1);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
options->UseEntryGuards = 1;
|
|
|
|
options->DownloadExtraInfo = 0;
|
|
|
|
options->FetchDirInfoEarly = 0;
|
|
|
|
options->FetchDirInfoExtraEarly = 0;
|
|
|
|
options->FetchUselessDescriptors = 0;
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 1);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 2);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
options->UseEntryGuards = 0;
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 0);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 3);
|
2015-09-07 21:04:51 +02:00
|
|
|
options->UseEntryGuards = 1;
|
|
|
|
|
|
|
|
options->DownloadExtraInfo = 1;
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 0);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 4);
|
2015-09-07 21:04:51 +02:00
|
|
|
options->DownloadExtraInfo = 0;
|
|
|
|
|
|
|
|
options->FetchDirInfoEarly = 1;
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 0);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 5);
|
2015-09-07 21:04:51 +02:00
|
|
|
options->FetchDirInfoEarly = 0;
|
|
|
|
|
|
|
|
options->FetchDirInfoExtraEarly = 1;
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 0);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 6);
|
2015-09-07 21:04:51 +02:00
|
|
|
options->FetchDirInfoExtraEarly = 0;
|
|
|
|
|
|
|
|
options->FetchUselessDescriptors = 1;
|
|
|
|
tt_int_op(should_use_directory_guards(options), OP_EQ, 0);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_public_server_mode_called, OP_EQ, 7);
|
2015-09-07 21:04:51 +02:00
|
|
|
options->FetchUselessDescriptors = 0;
|
|
|
|
|
|
|
|
done:
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
UNMOCK(public_server_mode);
|
2016-01-12 18:33:05 +01:00
|
|
|
or_options_free(options);
|
2015-09-07 21:04:51 +02:00
|
|
|
tor_free(errmsg);
|
|
|
|
}
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
static void dir_tests_directory_initiate_request(directory_request_t *req);
|
|
|
|
ATTR_UNUSED static int dir_tests_directory_initiate_request_called = 0;
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_should_not_init_request_to_ourselves(void *data)
|
|
|
|
{
|
|
|
|
char digest[DIGEST_LEN];
|
|
|
|
dir_server_t *ourself = NULL;
|
|
|
|
crypto_pk_t *key = pk_generate(2);
|
|
|
|
(void) data;
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
MOCK(directory_initiate_request,
|
|
|
|
dir_tests_directory_initiate_request);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
clear_dir_servers();
|
|
|
|
routerlist_free_all();
|
|
|
|
|
|
|
|
set_server_identity_key(key);
|
|
|
|
crypto_pk_get_digest(key, (char*) &digest);
|
2016-01-15 17:20:14 +01:00
|
|
|
ourself = trusted_dir_server_new("ourself", "127.0.0.1", 9059, 9060,
|
|
|
|
NULL, digest,
|
2015-09-07 21:04:51 +02:00
|
|
|
NULL, V3_DIRINFO, 1.0);
|
|
|
|
|
|
|
|
tt_assert(ourself);
|
|
|
|
dir_server_add(ourself);
|
|
|
|
|
|
|
|
directory_get_from_all_authorities(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_directory_initiate_request_called, OP_EQ, 0);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
directory_get_from_all_authorities(DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0,
|
|
|
|
NULL);
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_directory_initiate_request_called, OP_EQ, 0);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
done:
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
UNMOCK(directory_initiate_request);
|
2015-09-07 21:04:51 +02:00
|
|
|
clear_dir_servers();
|
|
|
|
routerlist_free_all();
|
|
|
|
crypto_pk_free(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_should_not_init_request_to_dir_auths_without_v3_info(void *data)
|
|
|
|
{
|
|
|
|
dir_server_t *ds = NULL;
|
|
|
|
dirinfo_type_t dirinfo_type = BRIDGE_DIRINFO | EXTRAINFO_DIRINFO \
|
|
|
|
| MICRODESC_DIRINFO;
|
|
|
|
(void) data;
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
MOCK(directory_initiate_request,
|
|
|
|
dir_tests_directory_initiate_request);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
clear_dir_servers();
|
|
|
|
routerlist_free_all();
|
|
|
|
|
2016-01-15 17:20:14 +01:00
|
|
|
ds = trusted_dir_server_new("ds", "10.0.0.1", 9059, 9060, NULL,
|
2015-09-07 21:04:51 +02:00
|
|
|
"12345678901234567890", NULL, dirinfo_type, 1.0);
|
|
|
|
tt_assert(ds);
|
|
|
|
dir_server_add(ds);
|
|
|
|
|
|
|
|
directory_get_from_all_authorities(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_directory_initiate_request_called, OP_EQ, 0);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
directory_get_from_all_authorities(DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0,
|
|
|
|
NULL);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_directory_initiate_request_called, OP_EQ, 0);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
done:
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
UNMOCK(directory_initiate_request);
|
2015-09-07 21:04:51 +02:00
|
|
|
clear_dir_servers();
|
|
|
|
routerlist_free_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_should_init_request_to_dir_auths(void *data)
|
|
|
|
{
|
|
|
|
dir_server_t *ds = NULL;
|
|
|
|
(void) data;
|
|
|
|
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
MOCK(directory_initiate_request,
|
|
|
|
dir_tests_directory_initiate_request);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
clear_dir_servers();
|
|
|
|
routerlist_free_all();
|
|
|
|
|
2016-01-15 17:20:14 +01:00
|
|
|
ds = trusted_dir_server_new("ds", "10.0.0.1", 9059, 9060, NULL,
|
2015-09-07 21:04:51 +02:00
|
|
|
"12345678901234567890", NULL, V3_DIRINFO, 1.0);
|
|
|
|
tt_assert(ds);
|
|
|
|
dir_server_add(ds);
|
|
|
|
|
|
|
|
directory_get_from_all_authorities(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_directory_initiate_request_called, OP_EQ, 1);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
directory_get_from_all_authorities(DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0,
|
|
|
|
NULL);
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
tt_int_op(dir_tests_directory_initiate_request_called, OP_EQ, 2);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
done:
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
UNMOCK(directory_initiate_request);
|
2015-09-07 21:04:51 +02:00
|
|
|
clear_dir_servers();
|
|
|
|
routerlist_free_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
dir_tests_directory_initiate_request(directory_request_t *req)
|
2015-09-07 21:04:51 +02:00
|
|
|
{
|
2017-04-21 20:31:35 +02:00
|
|
|
(void)req;
|
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.
#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
while (<>) {
s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;
if (/# *define +NS_MODULE +(\w+)/) {
$mod = $1;
next;
} elsif (/# *define +NS_SUBMODULE +(\w+)/) {
$submod = $1;
next;
}
next if (/#undef NS_(SUB)?MODULE/);
s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/;
s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;
if (/^$/) {
print if (! $last_was_empty);
$last_was_empty = 1;
} else {
$last_was_empty = 0;
print;
}
if (eof) {
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;
}
}
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date: Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
# modified: src/test/test_accounting.c
# modified: src/test/test_compat_libevent.c
# modified: src/test/test_dir.c
# modified: src/test/test_dir_handle_get.c
# modified: src/test/test_dns.c
# modified: src/test/test_options.c
# modified: src/test/test_procmon.c
# modified: src/test/test_rendcache.c
# modified: src/test/test_router.c
# modified: src/test/test_routerset.c
# modified: src/test/test_status.c
# modified: src/test/test_tortls.c
# modified: src/test/test_tortls_openssl.c
# modified: src/test/test_util_format.c
# modified: src/test/test_util_process.c
#
# Untracked files:
# experiments/
# locate_options.sh
# un_ns.pl
#
2020-01-09 16:26:10 +01:00
|
|
|
dir_tests_directory_initiate_request_called++;
|
2015-09-07 21:04:51 +02:00
|
|
|
}
|
|
|
|
|
2016-06-30 02:39:29 +02:00
|
|
|
/*
|
|
|
|
* Mock check_private_dir(), and always succeed - no need to actually
|
|
|
|
* look at or create anything on the filesystem.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
mock_check_private_dir(const char *dirname, cpd_check_t check,
|
|
|
|
const char *effective_user)
|
|
|
|
{
|
|
|
|
(void)dirname;
|
|
|
|
(void)check;
|
|
|
|
(void)effective_user;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-25 10:32:16 +02:00
|
|
|
/*
|
|
|
|
* This really mocks options_get_datadir_fname2_suffix(), but for testing
|
|
|
|
* dump_desc(), we only care about get_datadir_fname(sub1), which is defined
|
|
|
|
* in config.h as:
|
|
|
|
*
|
|
|
|
* options_get_datadir_fname2_suffix(get_options(), sub1, NULL, NULL)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char *
|
|
|
|
mock_get_datadir_fname(const or_options_t *options,
|
2017-11-15 00:14:08 +01:00
|
|
|
directory_root_t roottype,
|
2016-06-25 10:32:16 +02:00
|
|
|
const char *sub1, const char *sub2,
|
|
|
|
const char *suffix)
|
|
|
|
{
|
2017-11-15 00:14:08 +01:00
|
|
|
(void) roottype;
|
2016-06-25 10:32:16 +02:00
|
|
|
char *rv = NULL;
|
|
|
|
|
|
|
|
/*
|
2016-06-30 02:39:29 +02:00
|
|
|
* Assert we were called like get_datadir_fname2() or get_datadir_fname(),
|
|
|
|
* since that's all we implement here.
|
2016-06-25 10:32:16 +02:00
|
|
|
*/
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(options, OP_NE, NULL);
|
|
|
|
tt_ptr_op(sub1, OP_NE, NULL);
|
2016-06-30 02:39:29 +02:00
|
|
|
/*
|
|
|
|
* No particular assertions about sub2, since we could be in the
|
|
|
|
* get_datadir_fname() or get_datadir_fname2() case.
|
|
|
|
*/
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(suffix, OP_EQ, NULL);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/* Just duplicate the basename and return it for this mock */
|
2016-06-30 02:39:29 +02:00
|
|
|
if (sub2) {
|
|
|
|
/* If we have sub2, it's the basename, otherwise sub1 */
|
2016-06-30 20:30:28 +02:00
|
|
|
rv = tor_strdup(sub2);
|
2016-06-30 02:39:29 +02:00
|
|
|
} else {
|
2016-06-30 20:30:28 +02:00
|
|
|
rv = tor_strdup(sub1);
|
2016-06-30 02:39:29 +02:00
|
|
|
}
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *last_unlinked_path = NULL;
|
|
|
|
static int unlinked_count = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
mock_unlink_reset(void)
|
|
|
|
{
|
|
|
|
tor_free(last_unlinked_path);
|
|
|
|
unlinked_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mock_unlink(const char *path)
|
|
|
|
{
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(path, OP_NE, NULL);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
tor_free(last_unlinked_path);
|
|
|
|
last_unlinked_path = tor_strdup(path);
|
|
|
|
++unlinked_count;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *last_write_str_path = NULL;
|
|
|
|
static uint8_t last_write_str_hash[DIGEST256_LEN];
|
|
|
|
static int write_str_count = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
mock_write_str_to_file_reset(void)
|
|
|
|
{
|
|
|
|
tor_free(last_write_str_path);
|
|
|
|
write_str_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mock_write_str_to_file(const char *path, const char *str, int bin)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
uint8_t hash[DIGEST256_LEN];
|
|
|
|
|
|
|
|
(void)bin;
|
|
|
|
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(path, OP_NE, NULL);
|
|
|
|
tt_ptr_op(str, OP_NE, NULL);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
len = strlen(str);
|
|
|
|
crypto_digest256((char *)hash, str, len, DIGEST_SHA256);
|
|
|
|
|
|
|
|
tor_free(last_write_str_path);
|
|
|
|
last_write_str_path = tor_strdup(path);
|
|
|
|
memcpy(last_write_str_hash, hash, sizeof(last_write_str_hash));
|
|
|
|
++write_str_count;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_dump_unparseable_descriptors(void *data)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* These bogus descriptors look nothing at all like real bogus descriptors
|
|
|
|
* we might see, but we're only testing dump_desc() here, not the parser.
|
|
|
|
*/
|
|
|
|
const char *test_desc_type = "squamous";
|
|
|
|
/* strlen(test_desc_1) = 583 bytes */
|
|
|
|
const char *test_desc_1 =
|
|
|
|
"The most merciful thing in the world, I think, is the inability of the "
|
|
|
|
"human mind to correlate all its contents. We live on a placid island of"
|
|
|
|
" ignorance in the midst of black seas of infinity, and it was not meant"
|
|
|
|
" that we should voyage far. The sciences, each straining in its own dir"
|
|
|
|
"ection, have hitherto harmed us little; but some day the piecing togeth"
|
|
|
|
"er of dissociated knowledge will open up such terrifying vistas of real"
|
|
|
|
"ity, and of our frightful position therein, that we shall either go mad"
|
|
|
|
"from the revelation or flee from the light into the peace and safety of"
|
|
|
|
"a new dark age.";
|
|
|
|
uint8_t test_desc_1_hash[DIGEST256_LEN];
|
|
|
|
char test_desc_1_hash_str[HEX_DIGEST256_LEN+1];
|
|
|
|
/* strlen(test_desc_2) = 650 bytes */
|
|
|
|
const char *test_desc_2 =
|
|
|
|
"I think their predominant colour was a greyish-green, though they had w"
|
|
|
|
"hite bellies. They were mostly shiny and slippery, but the ridges of th"
|
|
|
|
"eir backs were scaly. Their forms vaguely suggested the anthropoid, whi"
|
|
|
|
"le their heads were the heads of fish, with prodigious bulging eyes tha"
|
|
|
|
"t never closed. At the sides of their necks were palpitating gills, and"
|
|
|
|
"their long paws were webbed. They hopped irregularly, sometimes on two "
|
|
|
|
"legs and sometimes on four. I was somehow glad that they had no more th"
|
|
|
|
"an four limbs. Their croaking, baying voices, clearly wed tar articulat"
|
|
|
|
"e speech, held all the dark shades of expression which their staring fa"
|
|
|
|
"ces lacked.";
|
|
|
|
uint8_t test_desc_2_hash[DIGEST256_LEN];
|
|
|
|
char test_desc_2_hash_str[HEX_DIGEST256_LEN+1];
|
|
|
|
/* strlen(test_desc_3) = 700 bytes */
|
|
|
|
const char *test_desc_3 =
|
|
|
|
"Without knowing what futurism is like, Johansen achieved something very"
|
|
|
|
"close to it when he spoke of the city; for instead of describing any de"
|
|
|
|
"finite structure or building, he dwells only on broad impressions of va"
|
|
|
|
"st angles and stone surfaces - surfaces too great to belong to anything"
|
|
|
|
"right or proper for this earth, and impious with horrible images and hi"
|
|
|
|
"eroglyphs. I mention his talk about angles because it suggests somethin"
|
|
|
|
"g Wilcox had told me of his awful dreams. He said that the geometry of "
|
|
|
|
"the dream-place he saw was abnormal, non-Euclidean, and loathsomely red"
|
|
|
|
"olent of spheres and dimensions apart from ours. Now an unlettered seam"
|
|
|
|
"an felt the same thing whilst gazing at the terrible reality.";
|
|
|
|
uint8_t test_desc_3_hash[DIGEST256_LEN];
|
|
|
|
char test_desc_3_hash_str[HEX_DIGEST256_LEN+1];
|
|
|
|
/* strlen(test_desc_3) = 604 bytes */
|
|
|
|
const char *test_desc_4 =
|
|
|
|
"So we glanced back simultaneously, it would appear; though no doubt the"
|
|
|
|
"incipient motion of one prompted the imitation of the other. As we did "
|
|
|
|
"so we flashed both torches full strength at the momentarily thinned mis"
|
|
|
|
"t; either from sheer primitive anxiety to see all we could, or in a les"
|
|
|
|
"s primitive but equally unconscious effort to dazzle the entity before "
|
|
|
|
"we dimmed our light and dodged among the penguins of the labyrinth cent"
|
|
|
|
"er ahead. Unhappy act! Not Orpheus himself, or Lot's wife, paid much mo"
|
|
|
|
"re dearly for a backward glance. And again came that shocking, wide-ran"
|
|
|
|
"ged piping - \"Tekeli-li! Tekeli-li!\"";
|
|
|
|
uint8_t test_desc_4_hash[DIGEST256_LEN];
|
|
|
|
char test_desc_4_hash_str[HEX_DIGEST256_LEN+1];
|
|
|
|
(void)data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up options mock so we can force a tiny FIFO size and generate
|
|
|
|
* cleanups.
|
|
|
|
*/
|
2016-06-30 20:36:31 +02:00
|
|
|
mock_options = tor_malloc(sizeof(or_options_t));
|
2016-06-25 10:32:16 +02:00
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
|
|
|
mock_options->MaxUnparseableDescSizeToLog = 1536;
|
|
|
|
MOCK(get_options, mock_get_options);
|
2016-06-30 02:39:29 +02:00
|
|
|
MOCK(check_private_dir, mock_check_private_dir);
|
2017-11-15 00:14:08 +01:00
|
|
|
MOCK(options_get_dir_fname2_suffix,
|
2016-06-25 10:32:16 +02:00
|
|
|
mock_get_datadir_fname);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up unlink and write mocks
|
|
|
|
*/
|
|
|
|
MOCK(tor_unlink, mock_unlink);
|
|
|
|
mock_unlink_reset();
|
|
|
|
MOCK(write_str_to_file, mock_write_str_to_file);
|
|
|
|
mock_write_str_to_file_reset();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute hashes we'll need to recognize which descriptor is which
|
|
|
|
*/
|
|
|
|
crypto_digest256((char *)test_desc_1_hash, test_desc_1,
|
|
|
|
strlen(test_desc_1), DIGEST_SHA256);
|
|
|
|
base16_encode(test_desc_1_hash_str, sizeof(test_desc_1_hash_str),
|
|
|
|
(const char *)test_desc_1_hash,
|
|
|
|
sizeof(test_desc_1_hash));
|
|
|
|
crypto_digest256((char *)test_desc_2_hash, test_desc_2,
|
|
|
|
strlen(test_desc_2), DIGEST_SHA256);
|
|
|
|
base16_encode(test_desc_2_hash_str, sizeof(test_desc_2_hash_str),
|
|
|
|
(const char *)test_desc_2_hash,
|
|
|
|
sizeof(test_desc_2_hash));
|
|
|
|
crypto_digest256((char *)test_desc_3_hash, test_desc_3,
|
|
|
|
strlen(test_desc_3), DIGEST_SHA256);
|
|
|
|
base16_encode(test_desc_3_hash_str, sizeof(test_desc_3_hash_str),
|
|
|
|
(const char *)test_desc_3_hash,
|
|
|
|
sizeof(test_desc_3_hash));
|
|
|
|
crypto_digest256((char *)test_desc_4_hash, test_desc_4,
|
|
|
|
strlen(test_desc_4), DIGEST_SHA256);
|
|
|
|
base16_encode(test_desc_4_hash_str, sizeof(test_desc_4_hash_str),
|
|
|
|
(const char *)test_desc_4_hash,
|
|
|
|
sizeof(test_desc_4_hash));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (1) Fire off dump_desc() once; these descriptors should all be safely
|
|
|
|
* smaller than configured FIFO size.
|
|
|
|
*/
|
|
|
|
|
|
|
|
dump_desc(test_desc_1, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (2) Fire off dump_desc() twice; this still should trigger no cleanup.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First time */
|
|
|
|
dump_desc(test_desc_2, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Second time */
|
|
|
|
dump_desc(test_desc_3, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_2) + strlen(test_desc_3));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (3) Three calls to dump_desc cause a FIFO cleanup
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First time */
|
|
|
|
dump_desc(test_desc_4, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_4));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Second time */
|
|
|
|
dump_desc(test_desc_1, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_4) + strlen(test_desc_1));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Third time - we should unlink the dump of test_desc_4 here */
|
|
|
|
dump_desc(test_desc_2, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_1) + strlen(test_desc_2));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 3);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (4) But repeating one (A B B) doesn't overflow and cleanup
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First time */
|
|
|
|
dump_desc(test_desc_3, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Second time */
|
|
|
|
dump_desc(test_desc_4, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_3) + strlen(test_desc_4));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Third time */
|
|
|
|
dump_desc(test_desc_4, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_3) + strlen(test_desc_4));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (5) Same for the (A B A) repetition
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First time */
|
|
|
|
dump_desc(test_desc_1, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Second time */
|
|
|
|
dump_desc(test_desc_2, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_1) + strlen(test_desc_2));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Third time */
|
|
|
|
dump_desc(test_desc_1, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_1) + strlen(test_desc_2));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (6) (A B B C) triggering overflow on C causes A, not B to be unlinked
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First time */
|
|
|
|
dump_desc(test_desc_3, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Second time */
|
|
|
|
dump_desc(test_desc_4, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_3) + strlen(test_desc_4));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Third time */
|
|
|
|
dump_desc(test_desc_4, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_3) + strlen(test_desc_4));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Fourth time - we should unlink the dump of test_desc_3 here */
|
|
|
|
dump_desc(test_desc_1, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_4) + strlen(test_desc_1));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 3);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (7) (A B A C) triggering overflow on C causes B, not A to be unlinked
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First time */
|
|
|
|
dump_desc(test_desc_2, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 1);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Second time */
|
|
|
|
dump_desc(test_desc_3, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_2) + strlen(test_desc_3));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Third time */
|
|
|
|
dump_desc(test_desc_2, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_2) + strlen(test_desc_3));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 2);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/* Fourth time - we should unlink the dump of test_desc_3 here */
|
|
|
|
dump_desc(test_desc_4, test_desc_type);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the FIFO state
|
|
|
|
*/
|
2017-06-05 16:38:20 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ,
|
|
|
|
strlen(test_desc_2) + strlen(test_desc_4));
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assert things about the mocks
|
|
|
|
*/
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 3);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the FIFO and check its state
|
|
|
|
*/
|
|
|
|
dump_desc_fifo_cleanup();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
|
|
|
mock_write_str_to_file_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
|
|
|
tt_int_op(write_str_count, OP_EQ, 0);
|
2016-06-25 10:32:16 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
/* Clean up the fifo */
|
|
|
|
dump_desc_fifo_cleanup();
|
|
|
|
|
|
|
|
/* Remove mocks */
|
|
|
|
UNMOCK(tor_unlink);
|
|
|
|
mock_unlink_reset();
|
|
|
|
UNMOCK(write_str_to_file);
|
|
|
|
mock_write_str_to_file_reset();
|
2017-11-15 00:14:08 +01:00
|
|
|
UNMOCK(options_get_dir_fname2_suffix);
|
2016-06-30 02:39:29 +02:00
|
|
|
UNMOCK(check_private_dir);
|
2016-06-25 10:32:16 +02:00
|
|
|
UNMOCK(get_options);
|
2016-06-30 20:36:31 +02:00
|
|
|
tor_free(mock_options);
|
2016-06-25 10:32:16 +02:00
|
|
|
mock_options = NULL;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:13:44 +02:00
|
|
|
/* Variables for reset_read_file_to_str_mock() */
|
|
|
|
|
2016-07-01 16:10:55 +02:00
|
|
|
static int enforce_expected_filename = 0;
|
2016-06-30 08:13:44 +02:00
|
|
|
static char *expected_filename = NULL;
|
|
|
|
static char *file_content = NULL;
|
|
|
|
static size_t file_content_len = 0;
|
|
|
|
static struct stat file_stat;
|
|
|
|
static int read_count = 0, read_call_count = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
reset_read_file_to_str_mock(void)
|
|
|
|
{
|
|
|
|
tor_free(expected_filename);
|
|
|
|
tor_free(file_content);
|
|
|
|
file_content_len = 0;
|
|
|
|
memset(&file_stat, 0, sizeof(file_stat));
|
|
|
|
read_count = 0;
|
|
|
|
read_call_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
read_file_to_str_mock(const char *filename, int flags,
|
|
|
|
struct stat *stat_out) {
|
|
|
|
char *result = NULL;
|
|
|
|
|
|
|
|
/* Insist we got a filename */
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(filename, OP_NE, NULL);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
/* We ignore flags */
|
|
|
|
(void)flags;
|
|
|
|
|
|
|
|
/* Bump the call count */
|
|
|
|
++read_call_count;
|
|
|
|
|
2016-07-01 16:10:55 +02:00
|
|
|
if (enforce_expected_filename) {
|
|
|
|
tt_assert(expected_filename);
|
|
|
|
tt_str_op(filename, OP_EQ, expected_filename);
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:13:44 +02:00
|
|
|
if (expected_filename != NULL &&
|
|
|
|
file_content != NULL &&
|
|
|
|
strcmp(filename, expected_filename) == 0) {
|
|
|
|
/* You asked for it, you got it */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the same behavior as the real read_file_to_str();
|
|
|
|
* if there's a NUL, the real size ends up in stat_out.
|
|
|
|
*/
|
|
|
|
result = tor_malloc(file_content_len + 1);
|
|
|
|
if (file_content_len > 0) {
|
|
|
|
memcpy(result, file_content, file_content_len);
|
|
|
|
}
|
|
|
|
result[file_content_len] = '\0';
|
|
|
|
|
|
|
|
/* Do we need to set up stat_out? */
|
|
|
|
if (stat_out != NULL) {
|
|
|
|
memcpy(stat_out, &file_stat, sizeof(file_stat));
|
|
|
|
/* We always return the correct length here */
|
|
|
|
stat_out->st_size = file_content_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wooo, we have a return value - bump the counter */
|
|
|
|
++read_count;
|
|
|
|
}
|
|
|
|
/* else no match, return NULL */
|
|
|
|
|
|
|
|
done:
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:59:29 +02:00
|
|
|
/* This one tests dump_desc_populate_one_file() */
|
2016-06-30 08:13:44 +02:00
|
|
|
static void
|
|
|
|
test_dir_populate_dump_desc_fifo(void *data)
|
|
|
|
{
|
|
|
|
const char *dirname = "foo";
|
|
|
|
const char *fname = NULL;
|
|
|
|
dumped_desc_t *ent;
|
|
|
|
|
|
|
|
(void)data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up unlink and read_file_to_str mocks
|
|
|
|
*/
|
|
|
|
MOCK(tor_unlink, mock_unlink);
|
|
|
|
mock_unlink_reset();
|
|
|
|
MOCK(read_file_to_str, read_file_to_str_mock);
|
|
|
|
reset_read_file_to_str_mock();
|
|
|
|
|
|
|
|
/* Check state of unlink mock */
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
/* Some cases that should fail before trying to read the file */
|
|
|
|
ent = dump_desc_populate_one_file(dirname, "bar");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
ent = dump_desc_populate_one_file(dirname, "unparseable-desc");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 2);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
ent = dump_desc_populate_one_file(dirname, "unparseable-desc.baz");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 3);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
ent = dump_desc_populate_one_file(
|
|
|
|
dirname,
|
|
|
|
"unparseable-desc.08AE85E90461F59E");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 4);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
ent = dump_desc_populate_one_file(
|
|
|
|
dirname,
|
|
|
|
"unparseable-desc.08AE85E90461F59EDF0981323F3A70D02B55AB54B44B04F"
|
|
|
|
"287D72F7B72F242E85C8CB0EDA8854A99");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 5);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
/* This is a correct-length digest but base16_decode() will fail */
|
|
|
|
ent = dump_desc_populate_one_file(
|
|
|
|
dirname,
|
|
|
|
"unparseable-desc.68219B8BGE64B705A6FFC728C069DC596216D60A7D7520C"
|
|
|
|
"D5ECE250D912E686B");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 6);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
/* This one has a correctly formed filename and should try reading */
|
|
|
|
|
|
|
|
/* Read fails */
|
|
|
|
ent = dump_desc_populate_one_file(
|
|
|
|
dirname,
|
|
|
|
"unparseable-desc.DF0981323F3A70D02B55AB54B44B04F287D72F7B72F242E"
|
|
|
|
"85C8CB0EDA8854A99");
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 7);
|
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 1);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
/* This read will succeed but the digest won't match the file content */
|
|
|
|
fname =
|
|
|
|
"unparseable-desc."
|
|
|
|
"DF0981323F3A70D02B55AB54B44B04F287D72F7B72F242E85C8CB0EDA8854A99";
|
2016-07-01 16:10:55 +02:00
|
|
|
enforce_expected_filename = 1;
|
2016-07-01 00:26:44 +02:00
|
|
|
tor_asprintf(&expected_filename, "%s%s%s", dirname, PATH_SEPARATOR, fname);
|
2016-06-30 08:13:44 +02:00
|
|
|
file_content = tor_strdup("hanc culpam maiorem an illam dicam?");
|
|
|
|
file_content_len = strlen(file_content);
|
|
|
|
file_stat.st_mtime = 123456;
|
|
|
|
ent = dump_desc_populate_one_file(dirname, fname);
|
2016-07-01 16:10:55 +02:00
|
|
|
enforce_expected_filename = 0;
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_EQ, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 8);
|
|
|
|
tt_int_op(read_count, OP_EQ, 1);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 2);
|
2016-06-30 08:13:44 +02:00
|
|
|
tor_free(expected_filename);
|
2016-06-30 20:30:26 +02:00
|
|
|
tor_free(file_content);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
/* This one will match */
|
|
|
|
fname =
|
|
|
|
"unparseable-desc."
|
|
|
|
"0786C7173447B7FB033FFCA2FC47C3CF71C30DD47CA8236D3FC7FF35853271C6";
|
2016-07-01 00:26:44 +02:00
|
|
|
tor_asprintf(&expected_filename, "%s%s%s", dirname, PATH_SEPARATOR, fname);
|
2016-06-30 08:13:44 +02:00
|
|
|
file_content = tor_strdup("hanc culpam maiorem an illam dicam?");
|
|
|
|
file_content_len = strlen(file_content);
|
|
|
|
file_stat.st_mtime = 789012;
|
|
|
|
ent = dump_desc_populate_one_file(dirname, fname);
|
2017-08-24 21:55:27 +02:00
|
|
|
tt_ptr_op(ent, OP_NE, NULL);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 8);
|
|
|
|
tt_int_op(read_count, OP_EQ, 2);
|
|
|
|
tt_int_op(read_call_count, OP_EQ, 3);
|
2016-06-30 08:13:44 +02:00
|
|
|
tt_str_op(ent->filename, OP_EQ, expected_filename);
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(ent->len, OP_EQ, file_content_len);
|
|
|
|
tt_int_op(ent->when, OP_EQ, file_stat.st_mtime);
|
2016-06-30 08:13:44 +02:00
|
|
|
tor_free(ent->filename);
|
|
|
|
tor_free(ent);
|
|
|
|
tor_free(expected_filename);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the mocks and check their state
|
|
|
|
*/
|
|
|
|
mock_unlink_reset();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
reset_read_file_to_str_mock();
|
2017-06-05 16:23:02 +02:00
|
|
|
tt_int_op(read_count, OP_EQ, 0);
|
2016-06-30 08:13:44 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
UNMOCK(tor_unlink);
|
|
|
|
mock_unlink_reset();
|
|
|
|
UNMOCK(read_file_to_str);
|
|
|
|
reset_read_file_to_str_mock();
|
|
|
|
|
2016-06-30 20:30:26 +02:00
|
|
|
tor_free(file_content);
|
|
|
|
|
2016-06-30 08:13:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:59:29 +02:00
|
|
|
static smartlist_t *
|
|
|
|
listdir_mock(const char *dname)
|
|
|
|
{
|
|
|
|
smartlist_t *l;
|
|
|
|
|
|
|
|
/* Ignore the name, always return this list */
|
|
|
|
(void)dname;
|
|
|
|
|
|
|
|
l = smartlist_new();
|
2016-10-27 11:26:06 +02:00
|
|
|
smartlist_add_strdup(l, "foo");
|
|
|
|
smartlist_add_strdup(l, "bar");
|
|
|
|
smartlist_add_strdup(l, "baz");
|
2016-06-30 08:59:29 +02:00
|
|
|
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
static dumped_desc_t *
|
|
|
|
pop_one_mock(const char *dirname, const char *f)
|
|
|
|
{
|
|
|
|
dumped_desc_t *ent = NULL;
|
|
|
|
|
|
|
|
if (dirname != NULL && strcmp(dirname, "d") == 0) {
|
|
|
|
if (f != NULL && strcmp(f, "foo") == 0) {
|
|
|
|
ent = tor_malloc_zero(sizeof(*ent));
|
2016-06-30 20:30:28 +02:00
|
|
|
ent->filename = tor_strdup("d/foo");
|
2016-06-30 08:59:29 +02:00
|
|
|
ent->len = 123;
|
|
|
|
ent->digest_sha256[0] = 1;
|
|
|
|
ent->when = 1024;
|
|
|
|
} else if (f != NULL && strcmp(f, "bar") == 0) {
|
|
|
|
ent = tor_malloc_zero(sizeof(*ent));
|
2016-06-30 20:30:28 +02:00
|
|
|
ent->filename = tor_strdup("d/bar");
|
2016-06-30 08:59:29 +02:00
|
|
|
ent->len = 456;
|
|
|
|
ent->digest_sha256[0] = 2;
|
|
|
|
/*
|
|
|
|
* Note that the timestamps are in a different order than
|
|
|
|
* listdir_mock() returns; we're testing the sort order.
|
|
|
|
*/
|
|
|
|
ent->when = 512;
|
|
|
|
} else if (f != NULL && strcmp(f, "baz") == 0) {
|
|
|
|
ent = tor_malloc_zero(sizeof(*ent));
|
2016-06-30 20:30:28 +02:00
|
|
|
ent->filename = tor_strdup("d/baz");
|
2016-06-30 08:59:29 +02:00
|
|
|
ent->len = 789;
|
|
|
|
ent->digest_sha256[0] = 3;
|
|
|
|
ent->when = 768;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This one tests dump_desc_populate_fifo_from_directory() */
|
|
|
|
static void
|
|
|
|
test_dir_populate_dump_desc_fifo_2(void *data)
|
|
|
|
{
|
|
|
|
dumped_desc_t *ent = NULL;
|
|
|
|
|
|
|
|
(void)data;
|
|
|
|
|
|
|
|
/* Set up the mocks */
|
|
|
|
MOCK(tor_listdir, listdir_mock);
|
|
|
|
MOCK(dump_desc_populate_one_file, pop_one_mock);
|
|
|
|
|
|
|
|
/* Run dump_desc_populate_fifo_from_directory() */
|
|
|
|
descs_dumped = NULL;
|
|
|
|
len_descs_dumped = 0;
|
|
|
|
dump_desc_populate_fifo_from_directory("d");
|
|
|
|
tt_assert(descs_dumped != NULL);
|
|
|
|
tt_int_op(smartlist_len(descs_dumped), OP_EQ, 3);
|
2016-06-30 21:34:36 +02:00
|
|
|
tt_u64_op(len_descs_dumped, OP_EQ, 1368);
|
2016-06-30 08:59:29 +02:00
|
|
|
ent = smartlist_get(descs_dumped, 0);
|
|
|
|
tt_str_op(ent->filename, OP_EQ, "d/bar");
|
|
|
|
tt_int_op(ent->len, OP_EQ, 456);
|
|
|
|
tt_int_op(ent->when, OP_EQ, 512);
|
|
|
|
ent = smartlist_get(descs_dumped, 1);
|
|
|
|
tt_str_op(ent->filename, OP_EQ, "d/baz");
|
|
|
|
tt_int_op(ent->len, OP_EQ, 789);
|
|
|
|
tt_int_op(ent->when, OP_EQ, 768);
|
|
|
|
ent = smartlist_get(descs_dumped, 2);
|
|
|
|
tt_str_op(ent->filename, OP_EQ, "d/foo");
|
|
|
|
tt_int_op(ent->len, OP_EQ, 123);
|
|
|
|
tt_int_op(ent->when, OP_EQ, 1024);
|
|
|
|
|
|
|
|
done:
|
|
|
|
dump_desc_fifo_cleanup();
|
|
|
|
|
|
|
|
UNMOCK(dump_desc_populate_one_file);
|
|
|
|
UNMOCK(tor_listdir);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-19 03:31:03 +02:00
|
|
|
static int mock_networkstatus_consensus_is_bootstrapping_value = 0;
|
|
|
|
static int
|
|
|
|
mock_networkstatus_consensus_is_bootstrapping(time_t now)
|
|
|
|
{
|
|
|
|
(void)now;
|
|
|
|
return mock_networkstatus_consensus_is_bootstrapping_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mock_networkstatus_consensus_can_use_extra_fallbacks_value = 0;
|
|
|
|
static int
|
|
|
|
mock_networkstatus_consensus_can_use_extra_fallbacks(
|
|
|
|
const or_options_t *options)
|
|
|
|
{
|
|
|
|
(void)options;
|
|
|
|
return mock_networkstatus_consensus_can_use_extra_fallbacks_value;
|
|
|
|
}
|
|
|
|
|
2017-11-21 15:50:46 +01:00
|
|
|
static int mock_num_bridges_usable_value = 0;
|
2017-09-11 05:56:35 +02:00
|
|
|
static int
|
2017-12-10 16:29:05 +01:00
|
|
|
mock_num_bridges_usable(int use_maybe_reachable)
|
2017-09-11 05:56:35 +02:00
|
|
|
{
|
2017-12-10 16:29:05 +01:00
|
|
|
(void)use_maybe_reachable;
|
2017-11-21 15:50:46 +01:00
|
|
|
return mock_num_bridges_usable_value;
|
2017-09-11 05:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* data is a 3 character nul-terminated string.
|
2016-05-19 03:31:03 +02:00
|
|
|
* If data[0] is 'b', set bootstrapping, anything else means not bootstrapping
|
|
|
|
* If data[1] is 'f', set extra fallbacks, anything else means no extra
|
2017-09-11 05:56:35 +02:00
|
|
|
* If data[2] is 'f', set running bridges, anything else means no extra
|
2016-05-19 03:31:03 +02:00
|
|
|
* fallbacks.
|
|
|
|
*/
|
2015-09-07 21:04:51 +02:00
|
|
|
static void
|
2018-04-18 17:26:40 +02:00
|
|
|
test_dir_find_dl_min_delay(void* data)
|
2015-09-07 21:04:51 +02:00
|
|
|
{
|
2016-05-19 03:31:03 +02:00
|
|
|
const char *str = (const char *)data;
|
|
|
|
|
2017-09-11 05:56:35 +02:00
|
|
|
tt_assert(strlen(data) == 3);
|
2016-05-19 03:31:03 +02:00
|
|
|
|
|
|
|
if (str[0] == 'b') {
|
|
|
|
mock_networkstatus_consensus_is_bootstrapping_value = 1;
|
|
|
|
} else {
|
|
|
|
mock_networkstatus_consensus_is_bootstrapping_value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str[1] == 'f') {
|
|
|
|
mock_networkstatus_consensus_can_use_extra_fallbacks_value = 1;
|
|
|
|
} else {
|
|
|
|
mock_networkstatus_consensus_can_use_extra_fallbacks_value = 0;
|
|
|
|
}
|
|
|
|
|
2017-09-11 05:56:35 +02:00
|
|
|
if (str[2] == 'r') {
|
2017-11-21 15:50:46 +01:00
|
|
|
/* Any positive, non-zero value should work */
|
|
|
|
mock_num_bridges_usable_value = 2;
|
2017-09-11 05:56:35 +02:00
|
|
|
} else {
|
2017-11-21 15:50:46 +01:00
|
|
|
mock_num_bridges_usable_value = 0;
|
2017-09-11 05:56:35 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 03:31:03 +02:00
|
|
|
MOCK(networkstatus_consensus_is_bootstrapping,
|
|
|
|
mock_networkstatus_consensus_is_bootstrapping);
|
|
|
|
MOCK(networkstatus_consensus_can_use_extra_fallbacks,
|
|
|
|
mock_networkstatus_consensus_can_use_extra_fallbacks);
|
2017-11-21 15:50:46 +01:00
|
|
|
MOCK(num_bridges_usable,
|
|
|
|
mock_num_bridges_usable);
|
2016-05-19 03:31:03 +02:00
|
|
|
|
2015-09-07 21:04:51 +02:00
|
|
|
download_status_t dls;
|
2018-04-18 17:19:14 +02:00
|
|
|
|
|
|
|
const int server=10, client=20, server_cons=30, client_cons=40;
|
|
|
|
const int client_boot_auth_only_cons=50, client_boot_auth_cons=60;
|
|
|
|
const int client_boot_fallback_cons=70, bridge=80, bridge_bootstrap=90;
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2016-06-30 20:36:31 +02:00
|
|
|
mock_options = tor_malloc(sizeof(or_options_t));
|
2015-09-07 21:04:51 +02:00
|
|
|
reset_options(mock_options, &mock_get_options_calls);
|
|
|
|
MOCK(get_options, mock_get_options);
|
|
|
|
|
2018-04-18 17:19:14 +02:00
|
|
|
mock_options->TestingServerDownloadInitialDelay = server;
|
|
|
|
mock_options->TestingClientDownloadInitialDelay = client;
|
|
|
|
mock_options->TestingServerConsensusDownloadInitialDelay = server_cons;
|
|
|
|
mock_options->TestingClientConsensusDownloadInitialDelay = client_cons;
|
|
|
|
mock_options->ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay =
|
|
|
|
client_boot_auth_only_cons;
|
|
|
|
mock_options->ClientBootstrapConsensusAuthorityDownloadInitialDelay =
|
|
|
|
client_boot_auth_cons;
|
|
|
|
mock_options->ClientBootstrapConsensusFallbackDownloadInitialDelay =
|
|
|
|
client_boot_fallback_cons;
|
|
|
|
mock_options->TestingBridgeDownloadInitialDelay = bridge;
|
|
|
|
mock_options->TestingBridgeBootstrapDownloadInitialDelay = bridge_bootstrap;
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
dls.schedule = DL_SCHED_GENERIC;
|
2016-05-19 03:31:03 +02:00
|
|
|
/* client */
|
2016-01-15 17:20:14 +01:00
|
|
|
mock_options->ClientOnly = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, client);
|
2016-01-15 17:20:14 +01:00
|
|
|
mock_options->ClientOnly = 0;
|
2016-05-19 03:31:03 +02:00
|
|
|
|
|
|
|
/* dir mode */
|
2016-01-15 17:20:14 +01:00
|
|
|
mock_options->DirPort_set = 1;
|
|
|
|
mock_options->DirCache = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, server);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->DirPort_set = 0;
|
|
|
|
mock_options->DirCache = 0;
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
dls.schedule = DL_SCHED_CONSENSUS;
|
2016-05-19 03:31:03 +02:00
|
|
|
/* public server mode */
|
|
|
|
mock_options->ORPort_set = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, server_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ORPort_set = 0;
|
|
|
|
|
|
|
|
/* client and bridge modes */
|
|
|
|
if (networkstatus_consensus_is_bootstrapping(time(NULL))) {
|
|
|
|
if (networkstatus_consensus_can_use_extra_fallbacks(mock_options)) {
|
|
|
|
dls.want_authority = 1;
|
|
|
|
/* client */
|
|
|
|
mock_options->ClientOnly = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_boot_auth_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ClientOnly = 0;
|
|
|
|
|
|
|
|
/* bridge relay */
|
|
|
|
mock_options->ORPort_set = 1;
|
|
|
|
mock_options->BridgeRelay = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_boot_auth_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ORPort_set = 0;
|
|
|
|
mock_options->BridgeRelay = 0;
|
|
|
|
|
|
|
|
dls.want_authority = 0;
|
|
|
|
/* client */
|
|
|
|
mock_options->ClientOnly = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_boot_fallback_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ClientOnly = 0;
|
|
|
|
|
|
|
|
/* bridge relay */
|
|
|
|
mock_options->ORPort_set = 1;
|
|
|
|
mock_options->BridgeRelay = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_boot_fallback_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ORPort_set = 0;
|
|
|
|
mock_options->BridgeRelay = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* dls.want_authority is ignored */
|
|
|
|
/* client */
|
|
|
|
mock_options->ClientOnly = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_boot_auth_only_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ClientOnly = 0;
|
|
|
|
|
|
|
|
/* bridge relay */
|
|
|
|
mock_options->ORPort_set = 1;
|
|
|
|
mock_options->BridgeRelay = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_boot_auth_only_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ORPort_set = 0;
|
|
|
|
mock_options->BridgeRelay = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* client */
|
|
|
|
mock_options->ClientOnly = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ClientOnly = 0;
|
|
|
|
|
|
|
|
/* bridge relay */
|
|
|
|
mock_options->ORPort_set = 1;
|
|
|
|
mock_options->BridgeRelay = 1;
|
2018-04-18 17:26:40 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ,
|
2018-04-18 17:19:14 +02:00
|
|
|
client_cons);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options->ORPort_set = 0;
|
|
|
|
mock_options->BridgeRelay = 0;
|
|
|
|
}
|
2015-09-07 21:04:51 +02:00
|
|
|
|
|
|
|
dls.schedule = DL_SCHED_BRIDGE;
|
2016-05-19 03:31:03 +02:00
|
|
|
/* client */
|
fetch missing bridge descriptors without delay
Without this change, if we have a working bridge, and we add a new bridge,
we will schedule the fetch attempt for that new bridge descriptor for
three hours(!) in the future.
This change is especially needed because of bug #40396, where if you have
one working bridge and one bridge whose descriptor you haven't fetched
yet, your Tor will stall until you have successfully fetched that new
descriptor -- in this case for hours.
In the old design, we would put off all further bridge descriptor fetches
once we had any working bridge descriptor. In this new design, we make the
decision per bridge based on whether we successfully got *its* descriptor.
To make this work, we need to also call learned_bridge_descriptor() every
time we get a bridge descriptor, not just when it's a novel descriptor.
Fixes bug 40396.
Also happens to fix bug 40495 (redundant descriptor fetches for every
bridge) since now we delay fetches once we succeed.
A side effect of this change is that if we have any configured bridges
that *aren't* working, we will keep trying to fetch their descriptors
on the modern directory retry schedule -- every couple of seconds for
the first half minute, then backing off after that -- which is a lot
faster than before.
2021-10-23 10:18:00 +02:00
|
|
|
tt_int_op(find_dl_min_delay(&dls, mock_options), OP_EQ, bridge_bootstrap);
|
2015-09-07 21:04:51 +02:00
|
|
|
|
2016-01-15 17:20:14 +01:00
|
|
|
done:
|
2016-05-19 03:31:03 +02:00
|
|
|
UNMOCK(networkstatus_consensus_is_bootstrapping);
|
|
|
|
UNMOCK(networkstatus_consensus_can_use_extra_fallbacks);
|
2017-11-21 15:50:46 +01:00
|
|
|
UNMOCK(num_bridges_usable);
|
2016-01-15 17:20:14 +01:00
|
|
|
UNMOCK(get_options);
|
2016-06-30 20:36:31 +02:00
|
|
|
tor_free(mock_options);
|
2016-05-19 03:31:03 +02:00
|
|
|
mock_options = NULL;
|
2015-09-07 21:04:51 +02:00
|
|
|
}
|
|
|
|
|
2018-12-03 19:40:08 +01:00
|
|
|
static void
|
|
|
|
test_dir_matching_flags(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
routerstatus_t *rs_noflags = NULL;
|
|
|
|
routerstatus_t *rs = NULL;
|
|
|
|
char *s = NULL;
|
|
|
|
|
|
|
|
smartlist_t *tokens = smartlist_new();
|
|
|
|
memarea_t *area = memarea_new();
|
|
|
|
|
|
|
|
int expected_val_when_unused = 0;
|
|
|
|
|
|
|
|
const char *ex_noflags =
|
|
|
|
"r example hereiswhereyouridentitygoes 2015-08-30 12:00:00 "
|
|
|
|
"192.168.0.1 9001 0\n"
|
|
|
|
"m thisoneislongerbecauseitisa256bitmddigest33\n"
|
2020-10-16 15:48:56 +02:00
|
|
|
"s\n"
|
|
|
|
"pr Link=4\n";
|
2018-12-03 19:40:08 +01:00
|
|
|
const char *cp = ex_noflags;
|
|
|
|
rs_noflags = routerstatus_parse_entry_from_string(
|
|
|
|
area, &cp,
|
|
|
|
cp + strlen(cp),
|
|
|
|
tokens, NULL, NULL,
|
|
|
|
MAX_SUPPORTED_CONSENSUS_METHOD, FLAV_MICRODESC);
|
|
|
|
tt_assert(rs_noflags);
|
|
|
|
|
|
|
|
#define FLAG(string, field) STMT_BEGIN { \
|
|
|
|
tor_asprintf(&s,\
|
|
|
|
"r example hereiswhereyouridentitygoes 2015-08-30 12:00:00 " \
|
|
|
|
"192.168.0.1 9001 0\n" \
|
|
|
|
"m thisoneislongerbecauseitisa256bitmddigest33\n" \
|
2020-10-16 15:48:56 +02:00
|
|
|
"pr Link=4\n" \
|
2018-12-03 19:40:08 +01:00
|
|
|
"s %s\n", string); \
|
|
|
|
cp = s; \
|
|
|
|
rs = routerstatus_parse_entry_from_string( \
|
|
|
|
area, &cp, \
|
|
|
|
cp + strlen(cp), \
|
|
|
|
tokens, NULL, NULL, \
|
|
|
|
MAX_SUPPORTED_CONSENSUS_METHOD, FLAV_MICRODESC); \
|
|
|
|
/* the field should usually be 0 when no flags are listed */ \
|
|
|
|
tt_int_op(rs_noflags->field, OP_EQ, expected_val_when_unused); \
|
|
|
|
/* the field should be 1 when this flags islisted */ \
|
|
|
|
tt_int_op(rs->field, OP_EQ, 1); \
|
|
|
|
tor_free(s); \
|
|
|
|
routerstatus_free(rs); \
|
|
|
|
} STMT_END
|
|
|
|
|
|
|
|
FLAG("Authority", is_authority);
|
|
|
|
FLAG("BadExit", is_bad_exit);
|
|
|
|
FLAG("Exit", is_exit);
|
|
|
|
FLAG("Fast", is_fast);
|
|
|
|
FLAG("Guard", is_possible_guard);
|
|
|
|
FLAG("HSDir", is_hs_dir);
|
|
|
|
FLAG("Stable", is_stable);
|
|
|
|
FLAG("StaleDesc", is_staledesc);
|
|
|
|
FLAG("V2Dir", is_v2_dir);
|
|
|
|
|
|
|
|
// These flags are assumed to be set whether they're declared or not.
|
|
|
|
expected_val_when_unused = 1;
|
|
|
|
FLAG("Running", is_flagged_running);
|
|
|
|
FLAG("Valid", is_valid);
|
|
|
|
expected_val_when_unused = 0;
|
|
|
|
|
|
|
|
// These flags are no longer used, but still parsed.
|
|
|
|
FLAG("Named", is_named);
|
|
|
|
FLAG("Unnamed", is_unnamed);
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(s);
|
|
|
|
routerstatus_free(rs);
|
|
|
|
routerstatus_free(rs_noflags);
|
|
|
|
memarea_drop_all(area);
|
|
|
|
smartlist_free(tokens);
|
|
|
|
}
|
|
|
|
|
2016-09-13 15:45:55 +02:00
|
|
|
static void
|
|
|
|
test_dir_assumed_flags(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
smartlist_t *tokens = smartlist_new();
|
|
|
|
memarea_t *area = memarea_new();
|
|
|
|
routerstatus_t *rs = NULL;
|
|
|
|
|
2018-04-09 21:07:51 +02:00
|
|
|
/* We can assume that consensus method is higher than 24, so Running and
|
|
|
|
* Valid are always implicitly set */
|
2016-09-13 15:45:55 +02:00
|
|
|
const char *str1 =
|
|
|
|
"r example hereiswhereyouridentitygoes 2015-08-30 12:00:00 "
|
|
|
|
"192.168.0.1 9001 0\n"
|
|
|
|
"m thisoneislongerbecauseitisa256bitmddigest33\n"
|
2020-10-16 15:48:56 +02:00
|
|
|
"s Fast Guard Stable\n"
|
|
|
|
"pr Link=4\n";
|
2018-09-11 16:32:17 +02:00
|
|
|
const char *eos = str1 + strlen(str1);
|
2016-09-13 15:45:55 +02:00
|
|
|
|
|
|
|
const char *cp = str1;
|
2018-09-11 16:32:17 +02:00
|
|
|
rs = routerstatus_parse_entry_from_string(area, &cp, eos, tokens, NULL, NULL,
|
2016-09-13 15:45:55 +02:00
|
|
|
24, FLAV_MICRODESC);
|
|
|
|
tt_assert(rs);
|
|
|
|
tt_assert(rs->is_flagged_running);
|
|
|
|
tt_assert(rs->is_valid);
|
|
|
|
tt_assert(! rs->is_exit);
|
|
|
|
tt_assert(rs->is_fast);
|
|
|
|
|
|
|
|
done:
|
|
|
|
smartlist_free(tokens);
|
|
|
|
memarea_drop_all(area);
|
|
|
|
routerstatus_free(rs);
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:21:54 +02:00
|
|
|
static void
|
|
|
|
test_dir_post_parsing(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
/* Test the version parsing from an HS descriptor publish request. */
|
|
|
|
{
|
|
|
|
const char *end;
|
|
|
|
const char *prefix = "/tor/hs/";
|
|
|
|
int version = parse_hs_version_from_post("/tor/hs//publish", prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/a/publish", prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/3/publish", prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, 3);
|
|
|
|
tt_str_op(end, OP_EQ, "/publish");
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/42/publish", prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, 42);
|
|
|
|
tt_str_op(end, OP_EQ, "/publish");
|
2016-11-04 19:00:08 +01:00
|
|
|
version = parse_hs_version_from_post("/tor/hs/18163/publish",prefix, &end);
|
2016-08-11 21:21:54 +02:00
|
|
|
tt_int_op(version, OP_EQ, 18163);
|
|
|
|
tt_str_op(end, OP_EQ, "/publish");
|
|
|
|
version = parse_hs_version_from_post("JUNKJUNKJUNK", prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/3/publish", "blah", &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
/* Missing the '/' at the end of the prefix. */
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/3/publish", "/tor/hs", &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
version = parse_hs_version_from_post("/random/blah/tor/hs/3/publish",
|
|
|
|
prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/3/publish/random/junk",
|
|
|
|
prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, 3);
|
|
|
|
tt_str_op(end, OP_EQ, "/publish/random/junk");
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/-1/publish", prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
/* INT_MAX */
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/2147483647/publish",
|
|
|
|
prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, INT_MAX);
|
|
|
|
tt_str_op(end, OP_EQ, "/publish");
|
|
|
|
/* INT_MAX + 1*/
|
|
|
|
version = parse_hs_version_from_post("/tor/hs/2147483648/publish",
|
|
|
|
prefix, &end);
|
|
|
|
tt_int_op(version, OP_EQ, -1);
|
|
|
|
tt_ptr_op(end, OP_EQ, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2017-09-20 16:10:02 +02:00
|
|
|
static void
|
|
|
|
test_dir_platform_str(void *arg)
|
|
|
|
{
|
|
|
|
char platform[256];
|
|
|
|
(void)arg;
|
|
|
|
platform[0] = 0;
|
|
|
|
get_platform_str(platform, sizeof(platform));
|
|
|
|
tt_int_op((int)strlen(platform), OP_GT, 0);
|
|
|
|
tt_assert(!strcmpstart(platform, "Tor "));
|
|
|
|
|
|
|
|
tor_version_t ver;
|
|
|
|
// make sure this is a tor version, a real actual tor version.
|
|
|
|
tt_int_op(tor_version_parse_platform(platform, &ver, 1), OP_EQ, 1);
|
|
|
|
|
|
|
|
TT_BLATHER(("%d.%d.%d.%d", ver.major, ver.minor, ver.micro, ver.patchlevel));
|
|
|
|
|
|
|
|
// Handle an example version.
|
|
|
|
tt_int_op(tor_version_parse_platform(
|
|
|
|
"Tor 0.3.3.3 (foo) (git-xyzzy) on a potato", &ver, 1), OP_EQ, 1);
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2018-07-17 21:39:31 +02:00
|
|
|
static void
|
|
|
|
test_dir_format_versions_list(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
char *s = NULL;
|
|
|
|
config_line_t *lines = NULL;
|
|
|
|
|
|
|
|
setup_capture_of_logs(LOG_WARN);
|
|
|
|
s = format_recommended_version_list(lines, 1);
|
|
|
|
tt_str_op(s, OP_EQ, "");
|
|
|
|
|
|
|
|
tor_free(s);
|
|
|
|
config_line_append(&lines, "ignored", "0.3.4.1, 0.2.9.111-alpha, 4.4.4-rc");
|
|
|
|
s = format_recommended_version_list(lines, 1);
|
|
|
|
tt_str_op(s, OP_EQ, "0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
|
|
|
|
|
|
|
|
tor_free(s);
|
|
|
|
config_line_append(&lines, "ignored", "0.1.2.3,0.2.9.10 ");
|
|
|
|
s = format_recommended_version_list(lines, 1);
|
|
|
|
tt_str_op(s, OP_EQ, "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
|
|
|
|
|
|
|
|
/* There should be no warnings so far. */
|
|
|
|
expect_no_log_entry();
|
|
|
|
|
|
|
|
/* Now try a line with a space in it. */
|
|
|
|
tor_free(s);
|
|
|
|
config_line_append(&lines, "ignored", "1.3.3.8 1.3.3.7");
|
|
|
|
s = format_recommended_version_list(lines, 1);
|
|
|
|
tt_str_op(s, OP_EQ, "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,"
|
|
|
|
"1.3.3.7,1.3.3.8,4.4.4-rc");
|
|
|
|
|
|
|
|
expect_single_log_msg_containing(
|
|
|
|
"Unexpected space in versions list member \"1.3.3.8 1.3.3.7\"." );
|
|
|
|
|
|
|
|
/* Start over, with a line containing a bogus version */
|
|
|
|
config_free_lines(lines);
|
|
|
|
lines = NULL;
|
|
|
|
tor_free(s);
|
|
|
|
mock_clean_saved_logs();
|
|
|
|
config_line_append(&lines, "ignored", "0.1.2.3, alpha-complex, 0.1.1.8-rc");
|
|
|
|
s = format_recommended_version_list(lines,1);
|
|
|
|
tt_str_op(s, OP_EQ, "0.1.1.8-rc,0.1.2.3,alpha-complex");
|
|
|
|
expect_single_log_msg_containing(
|
|
|
|
"Recommended version \"alpha-complex\" does not look valid.");
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(s);
|
|
|
|
config_free_lines(lines);
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
}
|
|
|
|
|
2019-12-14 19:22:15 +01:00
|
|
|
static void
|
|
|
|
test_dir_add_fingerprint(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
authdir_config_t *list;
|
|
|
|
int ret;
|
|
|
|
ed25519_secret_key_t seckey;
|
|
|
|
ed25519_public_key_t pubkey_good, pubkey_bad;
|
|
|
|
|
|
|
|
authdir_init_fingerprint_list();
|
|
|
|
list = authdir_return_fingerprint_list();
|
|
|
|
|
|
|
|
setup_capture_of_logs(LOG_WARN);
|
|
|
|
|
|
|
|
/* RSA test - successful */
|
|
|
|
ret = add_rsa_fingerprint_to_dir("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
|
|
|
list, 0);
|
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
|
|
|
|
/* RSA test - failure */
|
|
|
|
ret = add_rsa_fingerprint_to_dir("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ",
|
|
|
|
list, 0);
|
|
|
|
tt_int_op(ret, OP_EQ, -1);
|
|
|
|
|
|
|
|
/* ed25519 test - successful */
|
|
|
|
ed25519_secret_key_generate(&seckey, 0);
|
|
|
|
ed25519_public_key_generate(&pubkey_good, &seckey);
|
|
|
|
|
|
|
|
ret = add_ed25519_to_dir(&pubkey_good, list, 0);
|
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
|
|
|
|
/* ed25519 test - failure */
|
|
|
|
digest256_from_base64((char *) pubkey_bad.pubkey, "gibberish");
|
|
|
|
|
|
|
|
ret = add_ed25519_to_dir(&pubkey_bad, list, 0);
|
|
|
|
tt_int_op(ret, OP_EQ, -1);
|
|
|
|
|
|
|
|
done:
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
dirserv_free_fingerprint_list();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_dirserv_load_fingerprint_file(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
char *fname = tor_strdup(get_fname("approved-routers"));
|
|
|
|
|
|
|
|
// Neither RSA nor ed25519
|
|
|
|
const char *router_lines_invalid =
|
|
|
|
"!badexit notafingerprint";
|
|
|
|
const char *router_lines_too_long =
|
|
|
|
"!badexit thisisareallylongstringthatislongerthanafingerprint\n";
|
|
|
|
const char *router_lines_bad_fmt_str =
|
|
|
|
"!badexit ABCDEFGH|%1$p|%2$p|%3$p|%4$p|%5$p|%6$p\n";
|
|
|
|
const char *router_lines_valid_rsa =
|
|
|
|
"!badexit AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
|
|
|
|
const char *router_lines_invalid_rsa =
|
|
|
|
"!badexit ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\n";
|
|
|
|
const char *router_lines_valid_ed25519 =
|
|
|
|
"!badexit wqfLzgfCtRfYNg88LsL1QpzxS0itapJ1aj6TbnByx/Q\n";
|
|
|
|
const char *router_lines_invalid_ed25519 =
|
|
|
|
"!badexit --fLzgfCtRfYNg88LsL1QpzxS0itapJ1aj6TbnByx--\n";
|
|
|
|
|
|
|
|
// Test: Invalid Fingerprint (not RSA or ed25519)
|
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_invalid, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
expect_log_msg_containing("Invalid fingerprint");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
// Test: Very long string (longer than RSA or ed25519 key)
|
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_too_long, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
expect_log_msg_containing("Invalid fingerprint");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
2020-11-11 12:38:19 +01:00
|
|
|
// Test: Format string exploit
|
2019-12-14 19:22:15 +01:00
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_bad_fmt_str, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
expect_log_msg_containing("Invalid fingerprint");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
// Test: Valid RSA
|
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_valid_rsa, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
// Test: Invalid RSA
|
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_invalid_rsa, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
expect_log_msg_containing("Invalid fingerprint");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
// Test: Valid ed25519
|
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_valid_ed25519, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
// Test: Invalid ed25519
|
|
|
|
setup_capture_of_logs(LOG_NOTICE);
|
|
|
|
write_str_to_file(fname, router_lines_invalid_ed25519, 0);
|
|
|
|
tt_int_op(dirserv_load_fingerprint_file(), OP_EQ, 0);
|
|
|
|
expect_log_msg_containing("Invalid fingerprint");
|
|
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(fname);
|
|
|
|
dirserv_free_fingerprint_list();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RESET_FP_LIST(list) STMT_BEGIN \
|
|
|
|
dirserv_free_fingerprint_list(); \
|
|
|
|
authdir_init_fingerprint_list(); \
|
|
|
|
list = authdir_return_fingerprint_list(); \
|
|
|
|
STMT_END
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_dirserv_router_get_status(void *arg)
|
|
|
|
{
|
|
|
|
authdir_config_t *list;
|
|
|
|
routerinfo_t *ri = NULL;
|
|
|
|
ed25519_keypair_t kp1, kp2;
|
|
|
|
char d[DIGEST_LEN];
|
|
|
|
char fp[HEX_DIGEST_LEN+1];
|
|
|
|
int ret;
|
|
|
|
const char *msg;
|
|
|
|
time_t now = time(NULL);
|
|
|
|
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
crypto_pk_t *pk = pk_generate(0);
|
|
|
|
|
|
|
|
authdir_init_fingerprint_list();
|
|
|
|
list = authdir_return_fingerprint_list();
|
|
|
|
|
|
|
|
/* Set up the routerinfo */
|
|
|
|
ri = tor_malloc_zero(sizeof(routerinfo_t));
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&ri->ipv4_addr, 0xc0a80001u);
|
|
|
|
ri->ipv4_orport = 9001;
|
2019-12-14 19:22:15 +01:00
|
|
|
ri->platform = tor_strdup("0.4.0.1-alpha");
|
|
|
|
ri->nickname = tor_strdup("Jessica");
|
|
|
|
ri->identity_pkey = crypto_pk_dup_key(pk);
|
|
|
|
|
|
|
|
curve25519_keypair_t ri_onion_keypair;
|
|
|
|
curve25519_keypair_generate(&ri_onion_keypair, 0);
|
|
|
|
ri->onion_curve25519_pkey = tor_memdup(&ri_onion_keypair.pubkey,
|
|
|
|
sizeof(curve25519_public_key_t));
|
|
|
|
|
|
|
|
ed25519_secret_key_from_seed(&kp1.seckey,
|
|
|
|
(const uint8_t*)"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY");
|
|
|
|
ed25519_public_key_generate(&kp1.pubkey, &kp1.seckey);
|
|
|
|
ed25519_secret_key_from_seed(&kp2.seckey,
|
|
|
|
(const uint8_t*)"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
|
|
|
|
ed25519_public_key_generate(&kp2.pubkey, &kp2.seckey);
|
2020-09-17 14:17:36 +02:00
|
|
|
ri->cache_info.signing_key_cert = tor_cert_create_ed25519(&kp1,
|
2019-12-14 19:22:15 +01:00
|
|
|
CERT_TYPE_ID_SIGNING,
|
|
|
|
&kp2.pubkey,
|
|
|
|
now, 86400,
|
|
|
|
CERT_FLAG_INCLUDE_SIGNING_KEY);
|
|
|
|
|
|
|
|
crypto_pk_get_digest(ri->identity_pkey, d);
|
|
|
|
base16_encode(fp, HEX_DIGEST_LEN + 1, d, DIGEST_LEN);
|
|
|
|
|
|
|
|
/* Try on an empty fingerprint list */
|
|
|
|
ret = dirserv_router_get_status(ri, &msg, LOG_INFO);
|
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
ret = dirserv_router_get_status(ri, &msg, LOG_INFO);
|
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
/* Try an accepted router */
|
|
|
|
add_rsa_fingerprint_to_dir(fp, list, 0);
|
|
|
|
ret = dirserv_router_get_status(ri, &msg, LOG_INFO);
|
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
add_ed25519_to_dir(&kp1.pubkey, list, 0);
|
|
|
|
ret = dirserv_router_get_status(ri, &msg, LOG_INFO);
|
|
|
|
tt_int_op(ret, OP_EQ, 0);
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
/* Try a rejected router */
|
|
|
|
add_rsa_fingerprint_to_dir(fp, list, RTR_REJECT);
|
|
|
|
ret = dirserv_router_get_status(ri, &msg, LOG_INFO);
|
|
|
|
tt_int_op(ret, OP_EQ, RTR_REJECT);
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
add_ed25519_to_dir(&kp1.pubkey, list, RTR_REJECT);
|
|
|
|
ret = dirserv_router_get_status(ri, &msg, LOG_INFO);
|
|
|
|
tt_int_op(ret, OP_EQ, RTR_REJECT);
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
done:
|
|
|
|
dirserv_free_fingerprint_list();
|
|
|
|
routerinfo_free(ri);
|
|
|
|
crypto_pk_free(pk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_dirserv_would_reject_router(void *arg)
|
|
|
|
{
|
|
|
|
authdir_config_t *list;
|
|
|
|
routerstatus_t rs;
|
|
|
|
vote_routerstatus_t vrs;
|
|
|
|
ed25519_keypair_t kp;
|
|
|
|
char fp[HEX_DIGEST_LEN+1];
|
|
|
|
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
authdir_init_fingerprint_list();
|
|
|
|
list = authdir_return_fingerprint_list();
|
|
|
|
|
|
|
|
/* Set up the routerstatus */
|
|
|
|
memset(&rs, 0, sizeof(rs));
|
2020-07-13 20:07:37 +02:00
|
|
|
tor_addr_from_ipv4h(&rs.ipv4_addr, 0xc0a80001u);
|
|
|
|
rs.ipv4_orport = 9001;
|
2019-12-14 19:22:15 +01:00
|
|
|
strlcpy(rs.nickname, "Nicole", sizeof(rs.nickname));
|
|
|
|
memcpy(rs.identity_digest, "Cloud nine is great ", DIGEST_LEN);
|
|
|
|
|
|
|
|
ed25519_secret_key_from_seed(&kp.seckey,
|
|
|
|
(const uint8_t*)"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY");
|
|
|
|
ed25519_public_key_generate(&kp.pubkey, &kp.seckey);
|
|
|
|
|
|
|
|
base16_encode(fp, HEX_DIGEST_LEN + 1, rs.identity_digest, DIGEST_LEN);
|
|
|
|
|
|
|
|
/* Setup the vote_routerstatus_t. */
|
|
|
|
memcpy(vrs.ed25519_id, &kp.pubkey, ED25519_PUBKEY_LEN);
|
|
|
|
|
|
|
|
/* Try an empty fingerprint list */
|
|
|
|
tt_assert(!dirserv_would_reject_router(&rs, &vrs));
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
tt_assert(!dirserv_would_reject_router(&rs, &vrs));
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
/* Try an accepted router */
|
|
|
|
add_rsa_fingerprint_to_dir(fp, list, 0);
|
|
|
|
tt_assert(!dirserv_would_reject_router(&rs, &vrs));
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
add_ed25519_to_dir(&kp.pubkey, list, 0);
|
|
|
|
tt_assert(!dirserv_would_reject_router(&rs, &vrs));
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
/* Try a rejected router */
|
|
|
|
add_rsa_fingerprint_to_dir(fp, list, RTR_REJECT);
|
|
|
|
tt_assert(dirserv_would_reject_router(&rs, &vrs));
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
add_ed25519_to_dir(&kp.pubkey, list, RTR_REJECT);
|
|
|
|
tt_assert(dirserv_would_reject_router(&rs, &vrs));
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
done:
|
|
|
|
dirserv_free_fingerprint_list();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dir_dirserv_add_own_fingerprint(void *arg)
|
|
|
|
{
|
|
|
|
authdir_config_t *list;
|
|
|
|
char digest[DIGEST_LEN];
|
|
|
|
crypto_pk_t *pk = pk_generate(0);
|
|
|
|
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
init_mock_ed_keys(pk);
|
|
|
|
authdir_init_fingerprint_list();
|
|
|
|
list = authdir_return_fingerprint_list();
|
|
|
|
dirserv_add_own_fingerprint(pk, get_master_identity_key());
|
|
|
|
|
|
|
|
/* Check if we have a RSA key. */
|
|
|
|
crypto_pk_get_digest(pk, digest);
|
|
|
|
tt_assert(digestmap_get(list->status_by_digest, digest));
|
|
|
|
|
|
|
|
/* Check if we have a ed25519 key. */
|
|
|
|
tt_assert(digest256map_get(list->status_by_digest256,
|
|
|
|
get_master_identity_key()->pubkey));
|
|
|
|
|
|
|
|
RESET_FP_LIST(list);
|
|
|
|
|
|
|
|
done:
|
|
|
|
dirserv_free_fingerprint_list();
|
|
|
|
crypto_pk_free(pk);
|
|
|
|
}
|
|
|
|
|
2019-10-09 16:58:03 +02:00
|
|
|
#ifndef COCCI
|
2016-05-19 03:31:03 +02:00
|
|
|
#define DIR_LEGACY(name) \
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
{ #name, test_dir_ ## name , TT_FORK, NULL, NULL }
|
2009-09-22 19:49:09 +02:00
|
|
|
|
2013-04-02 18:45:12 +02:00
|
|
|
#define DIR(name,flags) \
|
|
|
|
{ #name, test_dir_##name, (flags), NULL, NULL }
|
2009-10-18 21:45:57 +02:00
|
|
|
|
2016-05-19 03:31:03 +02:00
|
|
|
/* where arg is a string constant */
|
|
|
|
#define DIR_ARG(name,flags,arg) \
|
2016-05-19 14:27:11 +02:00
|
|
|
{ #name "_" arg, test_dir_##name, (flags), &passthrough_setup, (void*) arg }
|
2019-10-22 15:40:31 +02:00
|
|
|
#endif /* !defined(COCCI) */
|
2016-05-19 03:31:03 +02:00
|
|
|
|
2009-09-22 19:49:09 +02:00
|
|
|
struct testcase_t dir_tests[] = {
|
2009-09-22 20:02:19 +02:00
|
|
|
DIR_LEGACY(nicknames),
|
2019-02-19 06:56:09 +01:00
|
|
|
/* extrainfo without any stats */
|
|
|
|
DIR_ARG(formats_rsa_ed25519, TT_FORK, ""),
|
|
|
|
/* on a bridge */
|
|
|
|
DIR_ARG(formats_rsa_ed25519, TT_FORK, "b"),
|
|
|
|
/* extrainfo with basic stats */
|
|
|
|
DIR_ARG(formats_rsa_ed25519, TT_FORK, "e"),
|
|
|
|
DIR_ARG(formats_rsa_ed25519, TT_FORK, "be"),
|
|
|
|
/* extrainfo with all stats */
|
|
|
|
DIR_ARG(formats_rsa_ed25519, TT_FORK, "es"),
|
|
|
|
DIR_ARG(formats_rsa_ed25519, TT_FORK, "bes"),
|
2014-10-22 20:19:18 +02:00
|
|
|
DIR(routerinfo_parsing, 0),
|
2014-10-06 15:06:04 +02:00
|
|
|
DIR(extrainfo_parsing, 0),
|
|
|
|
DIR(parse_router_list, TT_FORK),
|
2014-10-07 15:20:44 +02:00
|
|
|
DIR(load_routers, TT_FORK),
|
|
|
|
DIR(load_extrainfo, TT_FORK),
|
2017-04-22 02:17:27 +02:00
|
|
|
DIR(getinfo_extra, 0),
|
2009-09-22 20:02:19 +02:00
|
|
|
DIR_LEGACY(versions),
|
2009-10-18 21:45:57 +02:00
|
|
|
DIR_LEGACY(fp_pairs),
|
2013-04-02 18:45:12 +02:00
|
|
|
DIR(split_fps, 0),
|
2013-04-11 17:43:40 +02:00
|
|
|
DIR_LEGACY(measured_bw_kb),
|
2018-06-20 14:29:38 +02:00
|
|
|
DIR_LEGACY(measured_bw_kb_line_is_after_headers),
|
2013-04-18 17:13:36 +02:00
|
|
|
DIR_LEGACY(measured_bw_kb_cache),
|
2018-06-20 14:29:38 +02:00
|
|
|
DIR_LEGACY(dirserv_read_measured_bandwidths),
|
2018-11-06 15:56:05 +01:00
|
|
|
DIR(bwauth_bw_file_digest256, 0),
|
2009-09-22 19:49:09 +02:00
|
|
|
DIR_LEGACY(param_voting),
|
2016-05-10 02:10:43 +02:00
|
|
|
DIR(param_voting_lookup, 0),
|
2009-09-22 19:49:09 +02:00
|
|
|
DIR_LEGACY(v3_networkstatus),
|
2013-04-02 18:45:12 +02:00
|
|
|
DIR(random_weighted, 0),
|
|
|
|
DIR(scale_bw, 0),
|
2013-04-11 17:43:40 +02:00
|
|
|
DIR_LEGACY(clip_unmeasured_bw_kb),
|
|
|
|
DIR_LEGACY(clip_unmeasured_bw_kb_alt),
|
2013-04-02 19:59:53 +02:00
|
|
|
DIR(fmt_control_ns, 0),
|
2019-12-19 16:42:44 +01:00
|
|
|
DIR(dirserv_set_routerstatus_testing, TT_FORK),
|
2013-09-03 02:14:43 +02:00
|
|
|
DIR(http_handling, 0),
|
2016-10-09 02:28:38 +02:00
|
|
|
DIR(purpose_needs_anonymity_returns_true_for_bridges, 0),
|
2016-10-26 01:30:50 +02:00
|
|
|
DIR(purpose_needs_anonymity_returns_false_for_own_bridge_desc, 0),
|
2016-10-19 02:04:22 +02:00
|
|
|
DIR(purpose_needs_anonymity_returns_true_by_default, 0),
|
2016-10-09 02:28:38 +02:00
|
|
|
DIR(purpose_needs_anonymity_ret_false_for_non_sensitive_conn, 0),
|
2016-08-11 21:21:54 +02:00
|
|
|
DIR(post_parsing, 0),
|
2014-09-23 18:22:36 +02:00
|
|
|
DIR(fetch_type, 0),
|
2015-01-09 17:36:47 +01:00
|
|
|
DIR(packages, 0),
|
2016-06-12 21:07:38 +02:00
|
|
|
DIR(download_status_random_backoff, 0),
|
2017-10-17 19:24:40 +02:00
|
|
|
DIR(download_status_random_backoff_ranges, 0),
|
2017-12-01 22:06:25 +01:00
|
|
|
DIR(download_status_increment, TT_FORK),
|
2015-09-07 21:04:51 +02:00
|
|
|
DIR(authdir_type_to_string, 0),
|
|
|
|
DIR(conn_purpose_to_string, 0),
|
|
|
|
DIR(should_use_directory_guards, 0),
|
|
|
|
DIR(should_not_init_request_to_ourselves, TT_FORK),
|
|
|
|
DIR(should_not_init_request_to_dir_auths_without_v3_info, 0),
|
|
|
|
DIR(should_init_request_to_dir_auths, 0),
|
2016-06-25 10:32:16 +02:00
|
|
|
DIR(dump_unparseable_descriptors, 0),
|
2016-06-30 08:13:44 +02:00
|
|
|
DIR(populate_dump_desc_fifo, 0),
|
2016-06-30 08:59:29 +02:00
|
|
|
DIR(populate_dump_desc_fifo_2, 0),
|
2018-04-18 17:26:40 +02:00
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bfd"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bad"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "cfd"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "cad"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bfr"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "bar"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "cfr"),
|
|
|
|
DIR_ARG(find_dl_min_delay, TT_FORK, "car"),
|
2016-09-13 15:45:55 +02:00
|
|
|
DIR(assumed_flags, 0),
|
2018-12-03 19:40:08 +01:00
|
|
|
DIR(matching_flags, 0),
|
2016-10-04 03:09:25 +02:00
|
|
|
DIR(networkstatus_compute_bw_weights_v10, 0),
|
2017-09-20 16:10:02 +02:00
|
|
|
DIR(platform_str, 0),
|
2018-07-17 21:39:31 +02:00
|
|
|
DIR(format_versions_list, TT_FORK),
|
2019-12-14 19:22:15 +01:00
|
|
|
DIR(add_fingerprint, TT_FORK),
|
|
|
|
DIR(dirserv_load_fingerprint_file, TT_FORK),
|
|
|
|
DIR(dirserv_router_get_status, TT_FORK),
|
|
|
|
DIR(dirserv_would_reject_router, TT_FORK),
|
|
|
|
DIR(dirserv_add_own_fingerprint, TT_FORK),
|
2009-09-22 19:49:09 +02:00
|
|
|
END_OF_TESTCASES
|
|
|
|
};
|