Skip to content

Commit 2b7b142

Browse files
committed
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.
1 parent 68f1854 commit 2b7b142

File tree

7 files changed

+51
-37
lines changed

7 files changed

+51
-37
lines changed

src/udev/meson.build

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,23 @@ if dmi_arches.contains(host_machine.cpu_family())
184184
endif
185185

186186
foreach prog : udev_id_progs
187-
executable(prog[0].split('/')[0],
188-
prog,
189-
include_directories : includes,
190-
c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
191-
dependencies : [versiondep],
192-
link_with : udev_link_with,
193-
install_rpath : udev_rpath,
194-
install : true,
195-
install_dir : udevlibexecdir)
187+
name = prog[0].split('/')[0]
188+
189+
exe = executable(
190+
name,
191+
prog,
192+
include_directories : includes,
193+
c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
194+
dependencies : [versiondep],
195+
link_with : udev_link_with,
196+
install_rpath : udev_rpath,
197+
install : true,
198+
install_dir : udevlibexecdir)
199+
200+
# TODO: let's use a dictionary instead as soon as we can depend on meson >= 0.47.
201+
if name == 'dmi_memory_id'
202+
dmi_memory_id_path = exe.full_path()
203+
endif
196204
endforeach
197205

198206
if install_sysconfdir
File renamed without changes.

test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin.txt renamed to test/dmidecode-dumps/Lenovo-ThinkPad-X280.bin.txt

File renamed without changes.

test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin renamed to test/dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin

File renamed without changes.

test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin.txt renamed to test/dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin.txt

File renamed without changes.

test/meson.build

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ else
124124
message('Skipping udev-test because perl is not available')
125125
endif
126126

127+
############################################################
128+
127129
if conf.get('ENABLE_HWDB') == 1
128130
hwdb_test_sh = find_program('hwdb-test.sh')
129131
if want_tests != 'false'
@@ -133,11 +135,29 @@ if conf.get('ENABLE_HWDB') == 1
133135
endif
134136
endif
135137

136-
if want_tests != false and dmi_arches.contains(host_machine.cpu_family())
138+
############################################################
139+
140+
if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
137141
udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
138-
test('udev-dmi-memory-id-test',
139-
udev_dmi_memory_id_test,
140-
timeout : 90)
142+
143+
if git.found()
144+
out = run_command(
145+
git,
146+
'--git-dir=@0@/.git'.format(project_source_root),
147+
'ls-files', ':/test/dmidecode-dumps/*.bin')
148+
else
149+
out = run_command(
150+
'sh', '-c', 'ls @0@/test/dmidecode-dumps/*.bin'.format(project_source_root))
151+
endif
152+
153+
foreach p : out.stdout().split()
154+
source = join_paths(project_source_root, p)
155+
name = 'dmidecode_' + p.split('/')[-1].split('.')[0]
156+
157+
test(name,
158+
udev_dmi_memory_id_test,
159+
args : [dmi_memory_id_path, source, source + '.txt'])
160+
endforeach
141161
endif
142162

143163
subdir('fuzz')

test/udev-dmi-memory-id-test.sh

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: LGPL-2.1-or-later
3-
#
43

54
set -e
65

7-
export SYSTEMD_LOG_LEVEL=info
8-
ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
9-
UDEV_DMI_MEMORY_ID=./src/udev/dmi_memory_id
6+
dmi_memory_id="$1"
7+
input="$2"
8+
expected="$3"
109

11-
if [ ! -x "$UDEV_DMI_MEMORY_ID" ]; then
12-
echo "$UDEV_DMI_MEMORY_ID does not exist, please build first"
13-
exit 1
14-
fi
10+
output=$(mktemp --tmpdir "test-udev-dmi-memory-id.XXXXXXXXXX")
11+
trap "rm '$output'" EXIT INT QUIT PIPE
1512

16-
D=$(mktemp --tmpdir --directory "udev-dmi-memory-id.XXXXXXXXXX")
17-
trap "rm -rf '$D'" EXIT INT QUIT PIPE
18-
19-
for i in $ROOTDIR/test/dmidecode-dumps/*.bin ; do
20-
$("$UDEV_DMI_MEMORY_ID" -F "$i" 2>&1 > "$D"/out.txt) && rc= || rc=$?
21-
if [ -n "$rc" ]; then
22-
echo "$UDEV_DMI_MEMORY_ID returned $rc"
23-
exit $rc
24-
fi
25-
err=$(diff -u "$D"/out.txt "$i.txt" 2>&1) && rc= || rc=$?
26-
if [ -n "$rc" ]; then
27-
echo "Parsing DMI memory information from \"$i\" didn't match expected:"
28-
echo "$err"
29-
exit $rc
30-
fi
31-
done
13+
(
14+
set -x
15+
"$dmi_memory_id" -F "$input" >$output
16+
diff -u "$output" "$expected"
17+
)

0 commit comments

Comments
 (0)