]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: make each dmidecode a separate test
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Dec 2020 11:21:43 +0000 (12:21 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 17 Dec 2020 08:21:29 +0000 (09:21 +0100)
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.

src/udev/meson.build
test/dmidecode-dumps/Lenovo-ThinkPad-X280.bin [moved from test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin with 100% similarity]
test/dmidecode-dumps/Lenovo-ThinkPad-X280.bin.txt [moved from test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin.txt with 100% similarity]
test/dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin [moved from test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin with 100% similarity]
test/dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin.txt [moved from test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin.txt with 100% similarity]
test/meson.build
test/udev-dmi-memory-id-test.sh

index 0ed3b861356177788a5da0d64f44da66407a61d0..5a1d2149d7600816171bf721e68c15ba4b376dd6 100644 (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
index 3a930436f9655d1b25971998786f5e8ff024e34b..1e8a56aa90a8214e1be505446d5d637a2bb440ca 100644 (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')
index 2b6dee5b74896f994f73d99d1604afac88dd3377..e8b69245d83628a9deb53d98f77efee009cae910 100755 (executable)
@@ -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"
+)