1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

meson: make each dmidecode a separate test

This allows them to be executed in parallel and also gives us
better reporting.

The dump files are renamed to avoid repeating "dmidecode-dump", since that
string is already present in the subdirectory name.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-12-16 12:21:43 +01:00
parent 68f18549c5
commit 2b7b142e97
7 changed files with 51 additions and 37 deletions

View File

@ -184,15 +184,23 @@ if dmi_arches.contains(host_machine.cpu_family())
endif
foreach prog : udev_id_progs
executable(prog[0].split('/')[0],
prog,
include_directories : includes,
c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
dependencies : [versiondep],
link_with : udev_link_with,
install_rpath : udev_rpath,
install : true,
install_dir : udevlibexecdir)
name = prog[0].split('/')[0]
exe = executable(
name,
prog,
include_directories : includes,
c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
dependencies : [versiondep],
link_with : udev_link_with,
install_rpath : udev_rpath,
install : true,
install_dir : udevlibexecdir)
# TODO: let's use a dictionary instead as soon as we can depend on meson >= 0.47.
if name == 'dmi_memory_id'
dmi_memory_id_path = exe.full_path()
endif
endforeach
if install_sysconfdir

View File

@ -124,6 +124,8 @@ else
message('Skipping udev-test because perl is not available')
endif
############################################################
if conf.get('ENABLE_HWDB') == 1
hwdb_test_sh = find_program('hwdb-test.sh')
if want_tests != 'false'
@ -133,11 +135,29 @@ if conf.get('ENABLE_HWDB') == 1
endif
endif
if want_tests != false and dmi_arches.contains(host_machine.cpu_family())
############################################################
if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
test('udev-dmi-memory-id-test',
udev_dmi_memory_id_test,
timeout : 90)
if git.found()
out = run_command(
git,
'--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/test/dmidecode-dumps/*.bin')
else
out = run_command(
'sh', '-c', 'ls @0@/test/dmidecode-dumps/*.bin'.format(project_source_root))
endif
foreach p : out.stdout().split()
source = join_paths(project_source_root, p)
name = 'dmidecode_' + p.split('/')[-1].split('.')[0]
test(name,
udev_dmi_memory_id_test,
args : [dmi_memory_id_path, source, source + '.txt'])
endforeach
endif
subdir('fuzz')

View File

@ -1,31 +1,17 @@
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later
#
set -e
export SYSTEMD_LOG_LEVEL=info
ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
UDEV_DMI_MEMORY_ID=./src/udev/dmi_memory_id
dmi_memory_id="$1"
input="$2"
expected="$3"
if [ ! -x "$UDEV_DMI_MEMORY_ID" ]; then
echo "$UDEV_DMI_MEMORY_ID does not exist, please build first"
exit 1
fi
output=$(mktemp --tmpdir "test-udev-dmi-memory-id.XXXXXXXXXX")
trap "rm '$output'" EXIT INT QUIT PIPE
D=$(mktemp --tmpdir --directory "udev-dmi-memory-id.XXXXXXXXXX")
trap "rm -rf '$D'" EXIT INT QUIT PIPE
for i in $ROOTDIR/test/dmidecode-dumps/*.bin ; do
$("$UDEV_DMI_MEMORY_ID" -F "$i" 2>&1 > "$D"/out.txt) && rc= || rc=$?
if [ -n "$rc" ]; then
echo "$UDEV_DMI_MEMORY_ID returned $rc"
exit $rc
fi
err=$(diff -u "$D"/out.txt "$i.txt" 2>&1) && rc= || rc=$?
if [ -n "$rc" ]; then
echo "Parsing DMI memory information from \"$i\" didn't match expected:"
echo "$err"
exit $rc
fi
done
(
set -x
"$dmi_memory_id" -F "$input" >$output
diff -u "$output" "$expected"
)