summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.binbin0 -> 3081 bytes
-rw-r--r--test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin.txt33
-rw-r--r--test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.binbin0 -> 5074 bytes
-rw-r--r--test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin.txt67
-rw-r--r--test/meson.build7
-rwxr-xr-xtest/udev-dmi-memory-id-test.sh31
6 files changed, 138 insertions, 0 deletions
diff --git a/test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin b/test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin
new file mode 100644
index 0000000000..4c02fb71ce
--- /dev/null
+++ b/test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin
Binary files differ
diff --git a/test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin.txt b/test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin.txt
new file mode 100644
index 0000000000..26a8faf5d8
--- /dev/null
+++ b/test/dmidecode-dumps/Lenovo-ThinkPad-X280-dmidecode-dump.bin.txt
@@ -0,0 +1,33 @@
+MEMORY_ARRAY_LOCATION=System Board Or Motherboard
+MEMORY_ARRAY_MAX_CAPACITY=34359738368
+MEMORY_ARRAY_NUM_DEVICES=2
+MEMORY_DEVICE_0_TOTAL_WIDTH=64
+MEMORY_DEVICE_0_DATA_WIDTH=64
+MEMORY_DEVICE_0_SIZE=4294967296
+MEMORY_DEVICE_0_FORM_FACTOR=SODIMM
+MEMORY_DEVICE_0_LOCATOR=ChannelA-DIMM0
+MEMORY_DEVICE_0_BANK_LOCATOR=BANK 0
+MEMORY_DEVICE_0_TYPE=DDR4
+MEMORY_DEVICE_0_TYPE_DETAIL=Synchronous Unbuffered (Unregistered)
+MEMORY_DEVICE_0_SPEED_MTS=2400
+MEMORY_DEVICE_0_MANUFACTURER=0000
+MEMORY_DEVICE_0_SERIAL_NUMBER=00000000
+MEMORY_DEVICE_0_ASSET_TAG=None
+MEMORY_DEVICE_0_RANK=1
+MEMORY_DEVICE_0_CONFIGURED_SPEED_MTS=2400
+MEMORY_DEVICE_0_CONFIGURED_VOLTAGE=1
+MEMORY_DEVICE_1_TOTAL_WIDTH=64
+MEMORY_DEVICE_1_DATA_WIDTH=64
+MEMORY_DEVICE_1_SIZE=4294967296
+MEMORY_DEVICE_1_FORM_FACTOR=SODIMM
+MEMORY_DEVICE_1_LOCATOR=ChannelB-DIMM0
+MEMORY_DEVICE_1_BANK_LOCATOR=BANK 2
+MEMORY_DEVICE_1_TYPE=DDR4
+MEMORY_DEVICE_1_TYPE_DETAIL=Synchronous Unbuffered (Unregistered)
+MEMORY_DEVICE_1_SPEED_MTS=2400
+MEMORY_DEVICE_1_MANUFACTURER=0000
+MEMORY_DEVICE_1_SERIAL_NUMBER=00000000
+MEMORY_DEVICE_1_ASSET_TAG=None
+MEMORY_DEVICE_1_RANK=1
+MEMORY_DEVICE_1_CONFIGURED_SPEED_MTS=2400
+MEMORY_DEVICE_1_CONFIGURED_VOLTAGE=1
diff --git a/test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin b/test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin
new file mode 100644
index 0000000000..c07e7a29be
--- /dev/null
+++ b/test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin
Binary files differ
diff --git a/test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin.txt b/test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin.txt
new file mode 100644
index 0000000000..c90af66a7b
--- /dev/null
+++ b/test/dmidecode-dumps/Lenovo-Thinkcentre-m720s-dmidecode-dump.bin.txt
@@ -0,0 +1,67 @@
+MEMORY_ARRAY_LOCATION=System Board Or Motherboard
+MEMORY_ARRAY_MAX_CAPACITY=68719476736
+MEMORY_ARRAY_NUM_DEVICES=4
+MEMORY_DEVICE_0_TOTAL_WIDTH=64
+MEMORY_DEVICE_0_DATA_WIDTH=64
+MEMORY_DEVICE_0_SIZE=8589934592
+MEMORY_DEVICE_0_FORM_FACTOR=DIMM
+MEMORY_DEVICE_0_LOCATOR=ChannelA-DIMM0
+MEMORY_DEVICE_0_BANK_LOCATOR=BANK 0
+MEMORY_DEVICE_0_TYPE=DDR4
+MEMORY_DEVICE_0_TYPE_DETAIL=Synchronous
+MEMORY_DEVICE_0_SPEED_MTS=2667
+MEMORY_DEVICE_0_MANUFACTURER=Samsung
+MEMORY_DEVICE_0_SERIAL_NUMBER=416433E9
+MEMORY_DEVICE_0_ASSET_TAG=9876543210
+MEMORY_DEVICE_0_PART_NUMBER=M378A1K43CB2-CTD
+MEMORY_DEVICE_0_RANK=1
+MEMORY_DEVICE_0_CONFIGURED_SPEED_MTS=2400
+MEMORY_DEVICE_0_MINIMUM_VOLTAGE=1
+MEMORY_DEVICE_0_MAXIMUM_VOLTAGE=1
+MEMORY_DEVICE_0_CONFIGURED_VOLTAGE=1
+MEMORY_DEVICE_1_TOTAL_WIDTH=64
+MEMORY_DEVICE_1_DATA_WIDTH=64
+MEMORY_DEVICE_1_SIZE=8589934592
+MEMORY_DEVICE_1_FORM_FACTOR=DIMM
+MEMORY_DEVICE_1_LOCATOR=ChannelA-DIMM1
+MEMORY_DEVICE_1_BANK_LOCATOR=BANK 1
+MEMORY_DEVICE_1_TYPE=DDR4
+MEMORY_DEVICE_1_TYPE_DETAIL=Synchronous
+MEMORY_DEVICE_1_SPEED_MTS=2400
+MEMORY_DEVICE_1_MANUFACTURER=859B
+MEMORY_DEVICE_1_SERIAL_NUMBER=A02550A6
+MEMORY_DEVICE_1_ASSET_TAG=9876543210
+MEMORY_DEVICE_1_PART_NUMBER=BLT8G4D26AFTA.16FBD
+MEMORY_DEVICE_1_RANK=2
+MEMORY_DEVICE_1_CONFIGURED_SPEED_MTS=2400
+MEMORY_DEVICE_1_MINIMUM_VOLTAGE=1
+MEMORY_DEVICE_1_MAXIMUM_VOLTAGE=1
+MEMORY_DEVICE_1_CONFIGURED_VOLTAGE=1
+MEMORY_DEVICE_2_PRESENT=0
+MEMORY_DEVICE_2_FORM_FACTOR=Unknown
+MEMORY_DEVICE_2_LOCATOR=ChannelB-DIMM0
+MEMORY_DEVICE_2_BANK_LOCATOR=BANK 2
+MEMORY_DEVICE_2_TYPE=Unknown
+MEMORY_DEVICE_2_TYPE_DETAIL=None
+MEMORY_DEVICE_2_MANUFACTURER=Not Specified
+MEMORY_DEVICE_2_SERIAL_NUMBER=Not Specified
+MEMORY_DEVICE_2_ASSET_TAG=Not Specified
+MEMORY_DEVICE_2_PART_NUMBER=Not Specified
+MEMORY_DEVICE_3_TOTAL_WIDTH=64
+MEMORY_DEVICE_3_DATA_WIDTH=64
+MEMORY_DEVICE_3_SIZE=8589934592
+MEMORY_DEVICE_3_FORM_FACTOR=DIMM
+MEMORY_DEVICE_3_LOCATOR=ChannelB-DIMM1
+MEMORY_DEVICE_3_BANK_LOCATOR=BANK 3
+MEMORY_DEVICE_3_TYPE=DDR4
+MEMORY_DEVICE_3_TYPE_DETAIL=Synchronous
+MEMORY_DEVICE_3_SPEED_MTS=2400
+MEMORY_DEVICE_3_MANUFACTURER=859B
+MEMORY_DEVICE_3_SERIAL_NUMBER=A0254F38
+MEMORY_DEVICE_3_ASSET_TAG=9876543210
+MEMORY_DEVICE_3_PART_NUMBER=BLT8G4D26AFTA.16FBD
+MEMORY_DEVICE_3_RANK=2
+MEMORY_DEVICE_3_CONFIGURED_SPEED_MTS=2400
+MEMORY_DEVICE_3_MINIMUM_VOLTAGE=1
+MEMORY_DEVICE_3_MAXIMUM_VOLTAGE=1
+MEMORY_DEVICE_3_CONFIGURED_VOLTAGE=1
diff --git a/test/meson.build b/test/meson.build
index 799d74c7ae..a71cf24eaf 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -133,4 +133,11 @@ if conf.get('ENABLE_HWDB') == 1
endif
endif
+if want_tests != false
+ 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)
+endif
+
subdir('fuzz')
diff --git a/test/udev-dmi-memory-id-test.sh b/test/udev-dmi-memory-id-test.sh
new file mode 100755
index 0000000000..2b6dee5b74
--- /dev/null
+++ b/test/udev-dmi-memory-id-test.sh
@@ -0,0 +1,31 @@
+#!/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
+
+if [ ! -x "$UDEV_DMI_MEMORY_ID" ]; then
+ echo "$UDEV_DMI_MEMORY_ID does not exist, please build first"
+ exit 1
+fi
+
+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