summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPavel Hrdina <phrdina@redhat.com>2020-07-28 13:50:04 +0200
committerPavel Hrdina <phrdina@redhat.com>2020-08-03 09:27:05 +0200
commit7fe0c586ab0009af5ebb1536a824b390c807936f (patch)
treef020bb24819f842ffe9e2de8273ec52bdf89f108 /scripts
parentb5dcd4af557b8456afa02cc9451d75e244ad93e6 (diff)
downloadlibvirt-7fe0c586ab0009af5ebb1536a824b390c807936f.tar.gz
meson: src: add check*protocol tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check-remote-protocol.py71
1 files changed, 31 insertions, 40 deletions
diff --git a/scripts/check-remote-protocol.py b/scripts/check-remote-protocol.py
index e28fb80cdd..0a6135376e 100644
--- a/scripts/check-remote-protocol.py
+++ b/scripts/check-remote-protocol.py
@@ -31,55 +31,46 @@ import re
import subprocess
import sys
-cc = sys.argv[1]
-proto_lo = sys.argv[2]
-expected = sys.argv[3]
+name = sys.argv[1]
+targetname = sys.argv[2]
+libpath = sys.argv[3]
+pdwtags = sys.argv[4]
+expected = sys.argv[5]
-proto_lo = proto_lo.replace("/", "/.libs/")
+builddir = os.path.dirname(libpath)
+libname = os.path.basename(libpath)
-ccargv = cc.split(" ")
-ccargv.append("-v")
-ccproc = subprocess.Popen(ccargv, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
-out, err = ccproc.communicate()
-out = out.decode("utf-8")
-if out.find("clang") != -1:
- print("WARNING: skipping pdwtags test with Clang", file=sys.stderr)
- sys.exit(0)
+def get_subdir(dirname, subdir):
+ objectdir = ""
+ reg = re.compile(subdir)
+ for d in os.listdir(path=dirname):
+ if reg.match(d):
+ objectdir = d
+ break
-def which(program):
- def is_exe(fpath):
- return (os.path.isfile(fpath) and
- os.access(fpath, os.X_OK))
+ if objectdir == "":
+ raise Exception("Failed to find '{0}' in '{1}'".format(subdir, dirname))
- fpath, fname = os.path.split(program)
- if fpath:
- if is_exe(program):
- return program
- else:
- for path in os.environ["PATH"].split(os.pathsep):
- exe_file = os.path.join(path, program)
- if is_exe(exe_file):
- return exe_file
+ return os.path.join(dirname, objectdir)
- return None
+# Figure out where is the meson target private directory that contains
+# generated object files.
+# With meson version < 0.55.0 the directory pattern is:
+#
+# `hash_string@@target_name@bin_type` for example `25a6634@@vir_net_rpc@sta`
+#
+# but this was changed in meson 0.55.0 to a new pattern:
+#
+# `output_file_name.p` for example `libvirt_net_rpc.a.p`
+objectdir = get_subdir(
+ builddir,
+ r'(.*@{0}@.*|{1}\.p)'.format(targetname, re.escape(libname)))
-pdwtags = which("pdwtags")
-if pdwtags is None:
- print("WARNING: you lack pdwtags; skipping the protocol test",
- file=sys.stderr)
- print("WARNING: install the dwarves package to get pdwtags",
- file=sys.stderr)
- sys.exit(0)
-
-proto_o = proto_lo.replace(".lo", ".o")
-
-if not os.path.exists(proto_o):
- raise Exception("Missing %s", proto_o)
+proto_o = get_subdir(objectdir, r'.*{0}\.c\.o'.format(name))
-pdwtagsproc = subprocess.Popen(["pdwtags", "--verbose", proto_o],
+pdwtagsproc = subprocess.Popen([pdwtags, "--verbose", proto_o],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = pdwtagsproc.communicate()
out = out.decode("utf-8")