]> granicus.if.org Git - libevent/commitdiff
Make all tests that hit the network disabled by default
authorNick Mathewson <nickm@torproject.org>
Thu, 28 Jun 2012 17:18:28 +0000 (13:18 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 28 Jun 2012 17:18:28 +0000 (13:18 -0400)
To run only these tests, run test/regress with @live_net.  To run all
tests, run test/regress with @all.

test/regress_dns.c
test/regress_main.c
test/regress_util.c
test/test.sh

index ae1fc30a3fe4cd5e981f1463fc56da96ff020c3a..155e0f5511d054db28b6cf57ba3539846110a6d8 100644 (file)
@@ -1832,10 +1832,10 @@ end:
 
 struct testcase_t dns_testcases[] = {
        DNS_LEGACY(server, TT_FORK|TT_NEED_BASE),
-       DNS_LEGACY(gethostbyname, TT_FORK|TT_NEED_BASE|TT_NEED_DNS),
-       DNS_LEGACY(gethostbyname6, TT_FORK|TT_NEED_BASE|TT_NEED_DNS),
-       DNS_LEGACY(gethostbyaddr, TT_FORK|TT_NEED_BASE|TT_NEED_DNS),
-       { "resolve_reverse", dns_resolve_reverse, TT_FORK, NULL, NULL },
+       DNS_LEGACY(gethostbyname, TT_FORK|TT_NEED_BASE|TT_NEED_DNS|TT_OFF_BY_DEFAULT),
+       DNS_LEGACY(gethostbyname6, TT_FORK|TT_NEED_BASE|TT_NEED_DNS|TT_OFF_BY_DEFAULT),
+       DNS_LEGACY(gethostbyaddr, TT_FORK|TT_NEED_BASE|TT_NEED_DNS|TT_OFF_BY_DEFAULT),
+       { "resolve_reverse", dns_resolve_reverse, TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL },
        { "search", dns_search_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
        { "search_cancel", dns_search_cancel_test,
          TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
index 05e28433c0d48d403c0341f5f69b537202042898..c735b1e59e29f6b29080d44a673f44e63664bed7 100644 (file)
@@ -386,6 +386,19 @@ struct testgroup_t testgroups[] = {
        END_OF_GROUPS
 };
 
+const char *alltests[] = { "+..", NULL };
+const char *livenettests[] = {
+       "+util/getaddrinfo_live",
+       "+dns/gethostby..",
+       "+dns/resolve_reverse",
+       NULL
+};
+struct testlist_alias_t testaliases[] = {
+       { "all", alltests },
+       { "live_net", livenettests },
+       END_OF_ALIASES
+};
+
 int
 main(int argc, const char **argv)
 {
@@ -413,6 +426,8 @@ main(int argc, const char **argv)
                evthread_enable_lock_debuging();
 #endif
 
+       tinytest_set_aliases(testaliases);
+
        if (tinytest_main(argc,argv,testgroups))
                return 1;
 
index 6a6a39429c9963497e71389f98145209c7b73a81..0f49249c15740c7275adc1270713ad6550f683ac 100644 (file)
@@ -887,11 +887,6 @@ test_evutil_getaddrinfo(void *arg)
 {
        struct evutil_addrinfo *ai = NULL, *a;
        struct evutil_addrinfo hints;
-
-       struct sockaddr_in6 *sin6;
-       struct sockaddr_in *sin;
-       char buf[128];
-       const char *cp;
        int r;
 
        /* Try using it as a pton. */
@@ -1018,6 +1013,23 @@ test_evutil_getaddrinfo(void *arg)
                ai = NULL;
        }
 
+end:
+       if (ai)
+               evutil_freeaddrinfo(ai);
+}
+
+static void
+test_evutil_getaddrinfo_live(void *arg)
+{
+       struct evutil_addrinfo *ai = NULL;
+       struct evutil_addrinfo hints;
+
+       struct sockaddr_in6 *sin6;
+       struct sockaddr_in *sin;
+       char buf[128];
+       const char *cp;
+       int r;
+
        /* Now do some actual lookups. */
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = PF_INET;
@@ -1318,6 +1330,7 @@ struct testcase_t util_testcases[] = {
        { "integers", test_evutil_integers, 0, NULL, NULL },
        { "rand", test_evutil_rand, TT_FORK, NULL, NULL },
        { "getaddrinfo", test_evutil_getaddrinfo, TT_FORK, NULL, NULL },
+       { "getaddrinfo_live", test_evutil_getaddrinfo_live, TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL },
 #ifdef _WIN32
        { "loadsyslib", test_evutil_loadsyslib, TT_FORK, NULL, NULL },
 #endif
index 59748c00f6a8dc6da3b51c5f04f6587156cbfb90..d1e7e33645e3d4fbed14943d1a0bb8a3cb25f009 100755 (executable)
@@ -4,6 +4,7 @@ BACKENDS="EVPORT KQUEUE EPOLL DEVPOLL POLL SELECT WIN32"
 TESTS="test-eof test-weof test-time test-changelist test-fdleak"
 FAILED=no
 TEST_OUTPUT_FILE=${TEST_OUTPUT_FILE:-/dev/null}
+REGRESS_ARGS=${REGRESS_ARGS:-}
 
 # /bin/echo is a little more likely to support -n than sh's builtin echo,
 # printf is even more likely
@@ -94,9 +95,9 @@ run_tests () {
        announce_n " regress: "
        if test "$TEST_OUTPUT_FILE" = "/dev/null" ;
        then
-               $TEST_DIR/regress --quiet
+               $TEST_DIR/regress --quiet $REGRESS_ARGS
        else
-               $TEST_DIR/regress >>"$TEST_OUTPUT_FILE"
+               $TEST_DIR/regress $REGRESS_ARGS >>"$TEST_OUTPUT_FILE"
        fi
        if test "$?" = "0" ;
        then