diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2017-02-11 01:03:57 +0100 |
---|---|---|
committer | Christian Franke <chris@opensourcerouting.org> | 2017-02-13 17:44:03 +0100 |
commit | 43dac2baaef0d7061befe8c98f708b108c4ae2c9 (patch) | |
tree | b04257440886326d8f26a085230aec0129b3ba93 /tests | |
parent | tests: add pytest testrunners (diff) | |
download | frr-43dac2baaef0d7061befe8c98f708b108c4ae2c9.tar.xz frr-43dac2baaef0d7061befe8c98f708b108c4ae2c9.zip |
tests: fix out-of-tree build
Fix pytest with $(top_srcdir) != "."
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/helpers/python/frrtest.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 0d7e324fb..e825090e1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -139,5 +139,5 @@ EXTRA_DIST = \ .PHONY: tests.xml tests.xml: $(check_PROGRAMS) - $(PYTHON) runtests.py --junitxml=$@ -v + $(PYTHON) $(srcdir)/runtests.py --junitxml=$@ -v $(srcdir) check: tests.xml diff --git a/tests/helpers/python/frrtest.py b/tests/helpers/python/frrtest.py index 2814416d1..20c854f66 100644 --- a/tests/helpers/python/frrtest.py +++ b/tests/helpers/python/frrtest.py @@ -35,6 +35,12 @@ import frrsix # See below for the definition of actual TestMultiOut tests. # +srcbase = os.path.abspath(inspect.getsourcefile(frrsix)) +for i in range(0, 3): + srcbase = os.path.dirname(srcbase) +def binpath(srcpath): + return os.path.relpath(os.path.abspath(srcpath), srcbase) + class MultiTestFailure(Exception): pass @@ -59,7 +65,7 @@ class _TestMultiOut(object): self.__class__.tests_run = True basedir = os.path.dirname(inspect.getsourcefile(type(self))) program = os.path.join(basedir, self.program) - proc = subprocess.Popen([program], stdout=subprocess.PIPE) + proc = subprocess.Popen([binpath(program)], stdout=subprocess.PIPE) self.output,_ = proc.communicate('') self.exitcode = proc.wait() @@ -167,7 +173,7 @@ class TestRefOut(object): with open(refout, 'rb') as f: reftext = f.read() - proc = subprocess.Popen([program], + proc = subprocess.Popen([binpath(program)], stdin=subprocess.PIPE, stdout=subprocess.PIPE) outtext,_ = proc.communicate(intext) |