]>
git.proxmox.com Git - pve-common.git/blob - test/procfs_tests.pl
20 $pve_common_tools = Test
::MockModule-
>new('PVE::Tools');
21 $pve_common_tools->mock(
22 file_read_firstline
=> sub {
25 $filename =~ s!^/proc/!!;
27 my $res = $proc->{$filename};
29 if (ref($res) eq 'CODE') {
41 my @kernel_versions = (
43 version
=> 'Linux version 5.3.10-1-pve (build@pve) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP PVE 5.3.10-1 (Thu, 14 Nov 2019 10:43:13 +0100)',
44 expect
=> [5, 3, 10, '1-pve', '5.3.10-1-pve'],
47 version
=> 'Linux version 5.0.21-5-pve (build@pve) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP PVE 5.0.21-10 (Wed, 13 Nov 2019 08:27:10 +0100)',
48 expect
=> [5, 0, 21, '5-pve', '5.0.21-5-pve'],
51 version
=> 'Linux version 5.0.21+ (build@pve) (gcc version 8.3.0 (Debian 8.3.0-6)) #27 SMP Tue Nov 12 10:30:36 CET 2019',
52 expect
=> [5, 0, 21, '+', '5.0.21+'],
55 version
=> 'Linu$ version 2 (build@pve) (gcc version 8.3.0 (Debian 8.3.0-6)) #27 SMP Tue Nov 12 10:30:36 CET 2019',
56 expect
=> [0, 0, 0, '', ''],
60 subtest
'test kernel_version parser' => sub {
61 for my $test (@kernel_versions) {
62 $proc->{version
} = $test->{version
};
64 my $res = [ PVE
::ProcFSTools
::kernel_version
() ];
66 is_deeply
($res, $test->{expect
}, "got verison <". $res->[4] ."> same as expected");