From 88579fbd771047438efa62445df054074817b025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Thu, 23 Apr 2026 15:10:40 -0300 Subject: [PATCH] Wire DHCP unit tests into xcattest --- perl-xCAT/xCAT/DHCP/Backend.pm | 9 +++++++-- xCAT-test/autotest/testcase/dhcp_unit/cases0 | 8 ++++++++ xCAT-test/debian/install | 1 + xCAT-test/xCAT-test.spec | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 xCAT-test/autotest/testcase/dhcp_unit/cases0 diff --git a/perl-xCAT/xCAT/DHCP/Backend.pm b/perl-xCAT/xCAT/DHCP/Backend.pm index 74d1c6f74..568fb6f19 100644 --- a/perl-xCAT/xCAT/DHCP/Backend.pm +++ b/perl-xCAT/xCAT/DHCP/Backend.pm @@ -93,9 +93,14 @@ sub new_backend { return $selection if $selection->{error}; my $backend_class = $class->backend_class( $selection->{name} ); - ( my $backend_file = "$backend_class.pm" ) =~ s{::}{/}g; my $loaded = eval { - require $backend_file; + if ( $selection->{name} eq 'isc' ) { + require xCAT::DHCP::Backend::ISC; + } elsif ( $selection->{name} eq 'kea' ) { + require xCAT::DHCP::Backend::Kea; + } else { + die "Unknown DHCP backend '$selection->{name}'"; + } 1; }; if (!$loaded) { diff --git a/xCAT-test/autotest/testcase/dhcp_unit/cases0 b/xCAT-test/autotest/testcase/dhcp_unit/cases0 new file mode 100644 index 000000000..b95fe7e68 --- /dev/null +++ b/xCAT-test/autotest/testcase/dhcp_unit/cases0 @@ -0,0 +1,8 @@ +start:dhcp_backend_unit_tests +description:Run the DHCP backend Perl unit tests through xcattest +os:Linux +label:mn_only,ci_test,dhcp,unit,dhcp_unit +cmd:prove -I/opt/xcat/lib/perl -I/opt/xcat/lib/perl/xCAT /opt/xcat/share/xcat/tools/autotest/unit/dhcp_*.t +check:rc==0 +check:output=~All tests successful +end diff --git a/xCAT-test/debian/install b/xCAT-test/debian/install index 5a16deaab..1a4c56a89 100644 --- a/xCAT-test/debian/install +++ b/xCAT-test/debian/install @@ -3,3 +3,4 @@ bin/xcatperftest opt/xcat/bin share/man/man1/* opt/xcat/share/man/man1 share/doc/man1/* opt/xcat/share/doc/man1 autotest opt/xcat/share/xcat/tools +unit opt/xcat/share/xcat/tools/autotest diff --git a/xCAT-test/xCAT-test.spec b/xCAT-test/xCAT-test.spec index 7b74bdeeb..ed97a2d0d 100644 --- a/xCAT-test/xCAT-test.spec +++ b/xCAT-test/xCAT-test.spec @@ -59,6 +59,7 @@ cp share/doc/man1/* $RPM_BUILD_ROOT/%{prefix}/share/doc/man1 chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/man1/* cp -r autotest $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools +cp -r unit $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools/autotest %clean