]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: fix out-of-tree build 197/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Sat, 11 Feb 2017 00:03:57 +0000 (01:03 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Sat, 11 Feb 2017 00:03:57 +0000 (01:03 +0100)
Fix pytest with $(top_srcdir) != "."

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tests/Makefile.am
tests/helpers/python/frrtest.py

index 922ec37a249780a79f205c0eabd6f689072be3a8..f48abac47a935bf7c9e6d0a05a608178204b6c79 100644 (file)
@@ -144,5 +144,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
index 2814416d11822dc1da9c0480ce14cb1b8201b223..20c854f66c26040088253782851f50dcbc1d334f 100644 (file)
@@ -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)