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

@ -933,6 +933,7 @@ optional_programs = [
'mm-ctl',
'modprobe',
'ovs-vsctl',
'pdwtags',
'radvd',
'rmmod',
'scrub',

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")

View File

@ -20,65 +20,4 @@
# here. List them against the individual XXX_la_CFLAGS targets
# that actually use them.
RPC_PROBE_FILES =
include admin/Makefile.inc.am
# Keep this list synced with RPC_PROBE_FILES
PROTOCOL_STRUCTS = \
$(srcdir)/remote_protocol-structs \
$(srcdir)/lxc_protocol-structs \
$(srcdir)/qemu_protocol-structs \
$(srcdir)/virnetprotocol-structs \
$(srcdir)/virkeepaliveprotocol-structs \
$(srcdir)/lxc_monitor_protocol-structs \
$(srcdir)/lock_protocol-structs \
$(srcdir)/admin_protocol-structs \
$(NULL)
if WITH_REMOTE
check-protocol: $(PROTOCOL_STRUCTS) $(PROTOCOL_STRUCTS:structs=struct)
# Ensure that we don't change the struct or member names or member ordering
# in remote_protocol.x The check-remote-protocol.py script post-processes
# output to extract the bits we want.
CHECK_REMOTE_PROTOCOL = $(top_srcdir)/scripts/check-remote-protocol.py
# The .o file that pdwtags parses is created as a side effect of running
# libtool; but from make's perspective we depend on the .lo file.
$(srcdir)/remote_protocol-struct \
$(srcdir)/qemu_protocol-struct \
$(srcdir)/lxc_protocol-struct: \
$(srcdir)/%-struct: remote/libvirt_driver_remote_la-%.lo
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \
"$(CC)" $< $(@)s
$(srcdir)/virnetprotocol-struct $(srcdir)/virkeepaliveprotocol-struct: \
$(srcdir)/%-struct: rpc/libvirt_net_rpc_la-%.lo
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \
"$(CC)" $< $(@)s
if WITH_LXC
$(srcdir)/lxc_monitor_protocol-struct: \
$(srcdir)/%-struct: lxc/libvirt_driver_lxc_impl_la-%.lo
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \
"$(CC)" $< $(@)s
endif WITH_LXC
$(srcdir)/lock_protocol-struct: \
$(srcdir)/%-struct: locking/lockd_la-%.lo
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \
"$(CC)" $< $(@)s
$(srcdir)/admin_protocol-struct: \
$(srcdir)/%-struct: admin/libvirt_admin_la-%.lo
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \
"$(CC)" $< $(@)s
else !WITH_REMOTE
# The $(PROTOCOL_STRUCTS) files must live in git, because they cannot be
# re-generated when configured --without-remote.
check-protocol:
endif !WITH_REMOTE
check-local: check-protocol \
check-admin
.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct)

View File

@ -97,6 +97,11 @@ admin_driver_lib = static_library(
],
)
check_protocols += {
'name': 'admin_protocol',
'lib': admin_driver_lib,
}
virt_conf_files += files('libvirt-admin.conf')
admin_inc_dir = include_directories('.')

View File

@ -90,6 +90,11 @@ if conf.has('WITH_LIBVIRTD')
],
)
check_protocols += {
'name': 'lock_protocol',
'lib': lockd_lib_impl,
}
lockdriver_dir = libdir / 'libvirt' / 'lock-driver'
virt_modules += {

View File

@ -99,6 +99,11 @@ if conf.has('WITH_LXC')
],
)
check_protocols += {
'name': 'lxc_monitor_protocol',
'lib': lxc_driver_impl_lib,
}
virt_modules += {
'name': 'virt_driver_lxc',
'link_whole': [

View File

@ -225,6 +225,12 @@ driver_source_files = []
# stateful driver source files to check
stateful_driver_source_files = []
# check_protocols:
# check if $name.x is in sync with $name-structs
# name - name of the protocol (required)
# lib - library that this test depends on (required)
check_protocols = []
# list subdirectories
@ -924,3 +930,23 @@ if augparse_prog.found()
)
endforeach
endif
if pdwtags_prog.found() and cc.get_id() != 'clang'
foreach proto : check_protocols
lib = proto['lib']
test(
'check-@0@'.format(proto['name']),
python3_prog,
args: [
check_remote_protocol_prog.path(),
proto['name'],
lib.name(),
lib.full_path(),
pdwtags_prog.path(),
files('@0@-structs'.format(proto['name'])),
],
env: runutf8,
depends: [ lib ],
)
endforeach
endif

View File

@ -145,6 +145,21 @@ if conf.has('WITH_REMOTE')
],
)
check_protocols += {
'name': 'remote_protocol',
'lib': remote_driver_lib,
}
check_protocols += {
'name': 'qemu_protocol',
'lib': remote_driver_lib,
}
check_protocols += {
'name': 'lxc_protocol',
'lib': remote_driver_lib,
}
libvirt_libs += remote_driver_lib
if conf.has('WITH_LIBVIRTD')

View File

@ -81,6 +81,16 @@ virt_rpc_lib = static_library(
],
)
check_protocols += {
'name': 'virnetprotocol',
'lib': virt_rpc_lib,
}
check_protocols += {
'name': 'virkeepaliveprotocol',
'lib': virt_rpc_lib,
}
virt_rpc_server_lib = static_library(
'virt_net_rpc_server',
[