diff --git a/xCAT-test/unit/imgutils_nic_profiles.t b/xCAT-test/unit/imgutils_nic_profiles.t index bec60b5a3c..49a271027c 100644 --- a/xCAT-test/unit/imgutils_nic_profiles.t +++ b/xCAT-test/unit/imgutils_nic_profiles.t @@ -69,4 +69,19 @@ for my $os (qw(rhels10.1 rhels9.6)) { ok(!-e "$bare/etc/sysconfig" && !-e "$bare/etc/NetworkManager", "a $os image without either directory gets no profile"); } +for my $case (['rhels10.1', 1], ['rocky10.2', 1], ['rhels9.6', 0]) { + my ($os, $disabled) = @$case; + my $root = image('etc/NetworkManager/conf.d'); + imgutils::disable_auto_profiles($root, $os); + my $conf = "$root/etc/NetworkManager/conf.d/xcat.conf"; + if ($disabled) { + is(-f $conf ? read_text($conf) : '', "[main]\nno-auto-default=*\n", "a $os image turns off the automatic DHCP profiles"); + } else { + ok(!-e $conf, "a $os image keeps the NetworkManager defaults"); + } +} +my $without = image('etc'); +imgutils::disable_auto_profiles($without, 'rhels10.1'); +ok(!-e "$without/etc/NetworkManager", 'an image without NetworkManager gets no NetworkManager configuration'); + done_testing();