From 53d4e89626856eabe235c50ffc3d6a697f176741 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 Dec 2016 15:21:21 -0500 Subject: [PATCH 1/2] Netbsd doesn't have ipfw, only the regular pf transport stuff. Attempted fix for 19960. Also, fixes a typo. --- changes/bug19960 | 4 ++++ src/or/config.c | 2 +- src/test/test_options.c | 13 +++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 changes/bug19960 diff --git a/changes/bug19960 b/changes/bug19960 new file mode 100644 index 000000000..5d655859a --- /dev/null +++ b/changes/bug19960 @@ -0,0 +1,4 @@ + o Minor bugfixes (netbsd, unit tests): + - Stop expecting NetBSD unit tests to report success for ipfw; + on NetBSD, it's only pf that's supported. + Part of a fix for bug 19960; bugfix on 0.2.9.5-alpha. diff --git a/src/or/config.c b/src/or/config.c index 8568ea9d6..3693cdf83 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3004,7 +3004,7 @@ options_validate(or_options_t *old_options, or_options_t *options, } else if (!strcasecmp(options->TransProxyType, "ipfw")) { #ifndef KERNEL_MAY_SUPPORT_IPFW /* Earlier versions of OS X have ipfw */ - REJECT("ipfw is a FreeBSD-specific" + REJECT("ipfw is a FreeBSD-specific " "and OS X/Darwin-specific feature."); #else options->TransProxyType_parsed = TPT_IPFW; diff --git a/src/test/test_options.c b/src/test/test_options.c index 6770c1614..2570f8ddb 100644 --- a/src/test/test_options.c +++ b/src/test/test_options.c @@ -1050,7 +1050,7 @@ test_options_validate__transproxy(void *ignored) tt_int_op(ret, OP_EQ, -1); #ifndef KERNEL_MAY_SUPPORT_IPFW - tt_str_op(msg, OP_EQ, "ipfw is a FreeBSD-specificand OS X/Darwin-specific " + tt_str_op(msg, OP_EQ, "ipfw is a FreeBSD-specific and OS X/Darwin-specific " "feature."); #else tt_int_op(tdata->opt->TransProxyType_parsed, OP_EQ, TPT_IPFW); @@ -1080,7 +1080,7 @@ test_options_validate__transproxy(void *ignored) TT_DIE(("Expected NULL but got '%s'", msg)); } #endif -#if defined(__FreeBSD_kernel__) || defined( DARWIN ) || defined(__NetBSD__) +#ifdef KERNEL_MAY_SUPPORT_IPFW tdata = get_options_test_data("TransProxyType ipfw\n" "TransPort 127.0.0.1:123\n"); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); @@ -1098,6 +1098,15 @@ test_options_validate__transproxy(void *ignored) TT_DIE(("Expected NULL but got '%s'", msg)); } #endif +#if defined(__NetBSD__) + tdata = get_options_test_data("TransProxyType default\n" + "TransPort 127.0.0.1:123\n"); + ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); + tt_int_op(ret, OP_EQ, -1); + if (msg) { + TT_DIE(("Expected NULL but got '%s'", msg)); + } +#endif // Assert that a test has run for some TransProxyType tt_assert(tdata); From 9fe6ffa58864b0719bdec9a55b84c11255fa505b Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Tue, 23 Aug 2016 13:07:03 +0000 Subject: [PATCH 2/2] Use the correct preprocessor macro for Linux Also combine all of the checks into one if-tree as only one of them should actually succeed. --- src/test/test_options.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/test/test_options.c b/src/test/test_options.c index 2570f8ddb..e85e11805 100644 --- a/src/test/test_options.c +++ b/src/test/test_options.c @@ -1071,7 +1071,7 @@ test_options_validate__transproxy(void *ignored) free_options_test_data(tdata); tdata = NULL; -#if defined(linux) +#if defined(__linux__) tdata = get_options_test_data("TransProxyType tproxy\n" "TransPort 127.0.0.1:123\n"); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); @@ -1079,8 +1079,7 @@ test_options_validate__transproxy(void *ignored) if (msg) { TT_DIE(("Expected NULL but got '%s'", msg)); } -#endif -#ifdef KERNEL_MAY_SUPPORT_IPFW +#elif defined(KERNEL_MAY_SUPPORT_IPFW) tdata = get_options_test_data("TransProxyType ipfw\n" "TransPort 127.0.0.1:123\n"); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); @@ -1088,8 +1087,7 @@ test_options_validate__transproxy(void *ignored) if (msg) { TT_DIE(("Expected NULL but got '%s'", msg)); } -#endif -#if defined(__OpenBSD__) +#elif defined(__OpenBSD__) tdata = get_options_test_data("TransProxyType pf-divert\n" "TransPort 127.0.0.1:123\n"); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); @@ -1097,8 +1095,7 @@ test_options_validate__transproxy(void *ignored) if (msg) { TT_DIE(("Expected NULL but got '%s'", msg)); } -#endif -#if defined(__NetBSD__) +#elif defined(__NetBSD__) tdata = get_options_test_data("TransProxyType default\n" "TransPort 127.0.0.1:123\n"); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg);