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
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'
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')
#!/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"
+)