Put the 'which' function into shared code.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/functional/qemu_test/__init__.py | 2 +-
tests/functional/qemu_test/cmd.py | 10 ++++++++++
tests/functional/test_acpi_bits.py | 13 +------------
tests/functional/test_ppc64_hv.py | 13 +------------
4 files changed, 13 insertions(+), 25 deletions(-)
+def which(tool):
+ """ looks up the full path for @tool, returns None if not found
+ or if @tool does not have executable permissions.
+ """
+ paths=os.getenv('PATH')
+ for p in paths.split(os.path.pathsep):
+ p = os.path.join(p, tool)
+ if os.path.exists(p) and os.access(p, os.X_OK):