[tor-commits] [tor/master] When possible, run the ntor python integration tests too
nickm at torproject.org
nickm at torproject.org
Fri Oct 11 17:21:59 UTC 2013
commit f308adf8382bc7e61ea05a172057260cf8be9a6b
Author: Nick Mathewson <nickm at torproject.org>
Date: Fri Oct 11 13:21:42 2013 -0400
When possible, run the ntor python integration tests too
---
src/test/include.am | 17 ++++++++++++++---
src/test/ntor_ref.py | 16 +++++++++++++---
src/test/test_cmdline_args.py | 15 ++++++++++++---
3 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/src/test/include.am b/src/test/include.am
index ed0ef04..c452d26 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -74,11 +74,22 @@ src_test_test_ntor_cl_LDADD = src/or/libtor.a src/common/libor.a \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
src_test_test_ntor_cl_AM_CPPFLAGS = \
-I"$(top_srcdir)/src/or"
+NTOR_TEST_DEPS=src/test/test-ntor-cl
+else
+NTOR_TEST_DEPS=
+endif
+if COVERAGE_ENABLED
+CMDLINE_TEST_TOR = ./src/or/tor-cov
+else
+CMDLINE_TEST_TOR = ./src/or/tor
endif
-check-local:
+check-local: $(NTOR_TEST_DEPS) $(CMDLINE_TEST_TOR)
if USEPYTHON
- $(PYTHON) src/test/test_cmdline_args.py
+ $(PYTHON) src/test/test_cmdline_args.py $(CMDLINE_TEST_TOR) "${top_srcdir}"
+if CURVE25519_ENABLED
+ $(PYTHON) src/test/ntor_ref.py test-tor
+ $(PYTHON) src/test/ntor_ref.py self-test
+endif
endif
-
diff --git a/src/test/ntor_ref.py b/src/test/ntor_ref.py
old mode 100644
new mode 100755
index ade468d..2a5f984
--- a/src/test/ntor_ref.py
+++ b/src/test/ntor_ref.py
@@ -1,3 +1,4 @@
+#!/usr/bin/python
# Copyright 2012-2013, The Tor Project, Inc
# See LICENSE for licensing information
@@ -27,7 +28,13 @@ commands:
"""
import binascii
-import curve25519
+try:
+ import curve25519
+except ImportError:
+ curve25519 = None
+ print "SKIPPING: No Python curve25519 module installed"
+ import sys
+ sys.exit(0)
import hashlib
import hmac
import subprocess
@@ -286,6 +293,7 @@ def demo(node_id="iToldYouAboutStairs.", server_key=PrivateKey()):
assert len(skeys) == 72
assert len(ckeys) == 72
assert skeys == ckeys
+ print "OK"
# ======================================================================
def timing():
@@ -368,13 +376,15 @@ def test_tor():
assert c_keys == s_keys
assert len(c_keys) == 90
- print "We just interoperated."
+ print "OK"
# ======================================================================
if __name__ == '__main__':
import sys
- if sys.argv[1] == 'gen_kdf_vectors':
+ if len(sys.argv) < 2:
+ print __doc__
+ elif sys.argv[1] == 'gen_kdf_vectors':
kdf_vectors()
elif sys.argv[1] == 'timing':
timing()
diff --git a/src/test/test_cmdline_args.py b/src/test/test_cmdline_args.py
index 5767a82..1b0963f 100755
--- a/src/test/test_cmdline_args.py
+++ b/src/test/test_cmdline_args.py
@@ -6,11 +6,20 @@ import os
import re
import shutil
import subprocess
+import sys
import tempfile
import unittest
-TOR = "./src/or/tor-cov"
-TOPDIR = "."
+TOR = "./src/or/tor"
+TOP_SRCDIR = "."
+
+if len(sys.argv) > 1:
+ TOR = sys.argv[1]
+ del sys.argv[1]
+
+if len(sys.argv) > 1:
+ TOP_SRCDIR = sys.argv[1]
+ del sys.argv[1]
class UnexpectedSuccess(Exception):
pass
@@ -110,7 +119,7 @@ class CmdlineTests(unittest.TestCase):
self.assertEquals(hashlib.sha1(inp).digest(), hashed)
def test_digests(self):
- main_c = os.path.join(TOPDIR, "src", "or", "main.c")
+ main_c = os.path.join(TOP_SRCDIR, "src", "or", "main.c")
if os.stat(TOR).st_mtime < os.stat(main_c).st_mtime:
self.skipTest(TOR+" not up to date")
More information about the tor-commits
mailing list