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>
This commit is contained in:
Pavel Hrdina
2020-07-28 13:50:04 +02:00
parent b5dcd4af55
commit 7fe0c586ab
9 changed files with 98 additions and 101 deletions

View File

@@ -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/")
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)
builddir = os.path.dirname(libpath)
libname = os.path.basename(libpath)
def which(program):
def is_exe(fpath):
return (os.path.isfile(fpath) and
os.access(fpath, os.X_OK))
def get_subdir(dirname, subdir):
objectdir = ""
reg = re.compile(subdir)
for d in os.listdir(path=dirname):
if reg.match(d):
objectdir = d
break
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
if objectdir == "":
raise Exception("Failed to find '{0}' in '{1}'".format(subdir, dirname))
return None
return os.path.join(dirname, objectdir)
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)
# 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)))
proto_o = proto_lo.replace(".lo", ".o")
proto_o = get_subdir(objectdir, r'.*{0}\.c\.o'.format(name))
if not os.path.exists(proto_o):
raise Exception("Missing %s", proto_o)
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")