summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2010-02-02 14:51:12 +0100
committerSebastian Hahn <sebastian@torproject.org>2010-02-03 05:44:05 +0100
commitc54e33e4422d9979c7f6d94f6b6aea3bc33380eb (patch)
tree9c74198bf7dc7f44de20801051de323adbaf8b26 /src/test
parent03bd98b3b1f92954c286f9d4dd5a2dd5f34a7e8b (diff)
downloadtor-c54e33e4422d9979c7f6d94f6b6aea3bc33380eb.tar.gz
tor-c54e33e4422d9979c7f6d94f6b6aea3bc33380eb.zip
New testcase for exit_policy_is_general_exit
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/test/test.c b/src/test/test.c
index d85f1f0f87..1aceffce03 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -647,7 +647,7 @@ static void
test_policies(void)
{
int i;
- smartlist_t *policy = NULL, *policy2 = NULL;
+ smartlist_t *policy = NULL, *policy2 = NULL, *policy3 = NULL;
addr_policy_t *p;
tor_addr_t tar;
config_line_t line;
@@ -678,9 +678,18 @@ test_policies(void)
test_assert(0 == policies_parse_exit_policy(NULL, &policy2, 1, NULL, 1));
test_assert(policy2);
+ policy3 = smartlist_create();
+ p = router_parse_addr_policy_item_from_string("reject *:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy3, p);
+ p = router_parse_addr_policy_item_from_string("accept *:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy3, p);
+
test_assert(!exit_policy_is_general_exit(policy));
test_assert(exit_policy_is_general_exit(policy2));
test_assert(!exit_policy_is_general_exit(NULL));
+ test_assert(!exit_policy_is_general_exit(policy3));
test_assert(cmp_addr_policies(policy, policy2));
test_assert(cmp_addr_policies(policy, NULL));
@@ -790,10 +799,9 @@ test_policies(void)
"490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522");
done:
- if (policy)
- addr_policy_list_free(policy);
- if (policy2)
- addr_policy_list_free(policy2);
+ addr_policy_list_free(policy);
+ addr_policy_list_free(policy2);
+ addr_policy_list_free(policy3);
tor_free(policy_str);
if (sm) {
SMARTLIST_FOREACH(sm, char *, s, tor_free(s));