Commit c0391bae authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

Merge remote-tracking branch 'public/fancy_test_tricks'

Conflicts:
	src/common/include.am

Conflict was from adding testsupport.h near where sandbox.h had
already been added.
parents 2cb59be9 ec6c155f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -128,10 +128,13 @@
/src/common/Makefile.in
/src/common/common_sha1.i
/src/common/libor.a
/src/common/libor-testing.a
/src/common/libor.lib
/src/common/libor-crypto.a
/src/common/libor-crypto-testing.a
/src/common/libor-crypto.lib
/src/common/libor-event.a
/src/common/libor-event-testing.a
/src/common/libor-event.lib
/src/common/libcurve25519_donna.a
/src/common/libcurve25519_donna.lib
@@ -149,7 +152,10 @@
/src/or/or_sha1.i
/src/or/tor
/src/or/tor.exe
/src/or/tor-cov
/src/or/tor-cov.exe
/src/or/libtor.a
/src/or/libtor-testing.a
/src/or/libtor.lib

# /src/test
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,12 @@ EXTRA_DIST+= \
	README						\
	ReleaseNotes

if COVERAGE_ENABLED
TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage
else
TEST_CFLAGS=
endif

#install-data-local:
#	$(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor

@@ -89,3 +95,5 @@ version:
	   (cd "$(top_srcdir)" && git rev-parse --short=16 HEAD); \
	fi

mostlyclean-local:
	rm -f src/*/*.gc{da,no}

changes/fancy_testing

0 → 100644
+27 −0
Original line number Diff line number Diff line
  o Build features:

    - Tor now builds each source file in two modes: a mode that avoids
      exposing identifiers needlessly, and another mode that exposes
      more identifiers for testing. This lets the compiler do better at
      optimizing the production code, while enabling us to take more
      radical measures to let the unit tests test things.

    - The production builds no longer include functions used only
      in the unit tests; all functions exposed from a module for
      unit-testing only are now static in production builds.

    - Add an --enable-coverage configuration option to make the unit
      tests (and a new src/or/tor-cov target) to build with gcov test
      coverage support.

  o Testing:

    - We now have rudimentary function mocking support that our unit
      tests can use to test functions in isolation. Function mocking
      lets the tests temporarily replace a function's dependencies with
      stub functions, so that the tests can check the function without
      invoking the other functions it calls.

    - Add more unit tests for the <circid,channel>->circuit map, and
      the destroy-cell-tracking code to fix bug 7912.
+15 −1
Original line number Diff line number Diff line
@@ -39,6 +39,15 @@ AC_ARG_ENABLE(static-tor,
   AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
AC_ARG_ENABLE(curve25519,
   AS_HELP_STRING(--disable-curve25519, Build Tor with no curve25519 elliptic-curve crypto support))
AC_ARG_ENABLE(unittests,
   AS_HELP_STRING(--disable-unittests, [Don't build unit tests for Tor. Risky!]))
AC_ARG_ENABLE(coverage,
   AS_HELP_STRING(--enable-coverage, [Enable coverage support in the unit-test build]))

AM_CONDITIONAL(UNITTESTS_ENABLED, test x$enable_unittests != xno)
AM_CONDITIONAL(COVERAGE_ENABLED, test x$enable_coverage = xyes)

echo "COVERAGE: $enable_coverage"

if test "$enable_static_tor" = "yes"; then
  enable_static_libevent="yes";
@@ -1459,7 +1468,12 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
# CFLAGS="$CFLAGS -Winline"
fi


if test "$enable_coverage" = yes && test "$have_clang" = "no"; then
   case "$host_os" in
    darwin*)
      AC_MSG_WARN([Tried to enable coverage on OSX without using the clang compiler. This might not work! If coverage fails, use CC=clang when configuring with --enable-profiling.])
   esac
fi

CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"

contrib/cov-diff

0 → 100755
+17 −0
Original line number Diff line number Diff line
#!/bin/sh
# Copyright 2013  The Tor Project, Inc.
# See LICENSE for licensing information.

# cov-diff -- compare two directories full of gcov files.

DIRA="$1"
DIRB="$2"

for A in $DIRA/*; do
  B=$DIRB/`basename $A`
  perl -pe 's/^\s*\d+:/        1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$A" > "$A.tmp"
  perl -pe 's/^\s*\d+:/        1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$B" > "$B.tmp"
  diff -u "$A.tmp" "$B.tmp"
  rm "$A.tmp" "$B.tmp"
done
Loading