Skip to content

Commit 5d2a17c

Browse files
committed
fix: Fix Lenovo T24v-10 monitor serial number inventory
Also enhance tests to output dump when expected value is empty
1 parent b5c8b66 commit 5d2a17c

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

Diff for: Changes

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ inventory:
2929
* Enhance #430 fix: Don't make edid mandatory if monitor SERIAL & CAPTION are still
3030
found. This fixes monitors inventory on Apple M1.
3131
* Fix MacOSX software arch should be set in ARCH field
32+
* Fix Lenovo T24v-10 monitor serial number inventory
3233

3334
remoteinventory:
3435
* Limit the number of attempts and reported errors when libssh2 fails but ssh command

Diff for: lib/GLPI/Agent/Tools/Screen.pm

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ sub new {
2828
# http://forge.fusioninventory.org/issues/1614
2929
if ($self->{edid}->{serial_number2} && $self->{edid}->{serial_number2}->[0]) {
3030
$self->{_serial} = $self->{edid}->{serial_number2}->[0];
31+
# Check if serial ends by 0x0A if it is shorter then 13 chars, problem found on Lenovo monitors
32+
my $lf = index($self->{_serial}, chr(0x0A));
33+
$self->{_serial} = substr($self->{_serial}, 0, $lf)
34+
unless $lf < 0;
3135
} else {
3236
$self->{_serial} = sprintf("%08x", $self->{edid}->{serial_number});
3337
}

Diff for: resources/generic/edid/lenovo-T24v-10

256 Bytes
Binary file not shown.

Diff for: t/tasks/inventory/generic/screen.t

+23-1
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,18 @@ my %edid_tests = (
820820
SERIAL => "68056070",
821821
DESCRIPTION => '28/2020'
822822
},
823+
'lenovo-LT2452' => {
824+
CAPTION => 'LEN LT2452pwC',
825+
DESCRIPTION => '51/2011',
826+
MANUFACTURER => 'Lenovo Group Limited',
827+
SERIAL => '5a485035'
828+
},
829+
'lenovo-T24v-10' => {
830+
CAPTION => 'T24v-10',
831+
DESCRIPTION => '51/2019',
832+
MANUFACTURER => 'Lenovo Group Limited',
833+
SERIAL => 'V905BAYH'
834+
},
823835
'samsung-s22e390' => {
824836
MANUFACTURER => 'Samsung Electric Company',
825837
CAPTION => 'S22E390',
@@ -897,11 +909,21 @@ my %macos_tests = (
897909
plan tests => (scalar keys %edid_tests) + (2 * scalar keys %macos_tests) + 1;
898910

899911
foreach my $test (sort keys %edid_tests) {
912+
my $dumper;
900913
my $file = "resources/generic/edid/$test";
901914
my $edid = getAllLines(file => $file)
902915
or die "Can't read $file: $!\n";
903916
my $info = GLPI::Agent::Task::Inventory::Generic::Screen::_getEdidInfo(edid => $edid, datadir => './share');
904-
cmp_deeply($info, $edid_tests{$test}, $test);
917+
if (!$edid_tests{$test} || !keys(%{$edid_tests{$test}})) {
918+
$dumper = Data::Dumper->new([$info], [$test])->Useperl(1)->Indent(1)->Quotekeys(0)->Sortkeys(1)->Pad(" ");
919+
$dumper->{xpad} = " ";
920+
print STDERR "====\n$test: Expecting ", $dumper->Dump();
921+
}
922+
SKIP: {
923+
skip "$test: Expecting ".$dumper->Dump(), 1
924+
if $dumper;
925+
cmp_deeply($info, $edid_tests{$test}, $test);
926+
}
905927
}
906928

907929
my $module = Test::MockModule->new(

0 commit comments

Comments
 (0)