From 0cca31bd2b62bfa8ac636e41c06ab4e53b78bdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 14 Oct 2026 12:34:02 -0300 Subject: [PATCH] test(statelite): run the liteimg archive test with the native tests The liteimg archive test runs real cpio and gzip, and puts compressor and ctorrent fixtures in PATH. That is a native test, so it moves out of the unit suite. The pull-request workflow runs it explicitly. A missing Linux tool now fails the test instead of skipping it. An ilitefile fixture replaces the runcmd override, so liteimg runs its commands through the real runcmd. --- .github/workflows/xcat_test.yml | 3 +++ .../liteimg_ramdisk_archive.t | 21 ++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) rename xCAT-test/{unit => native}/liteimg_ramdisk_archive.t (94%) diff --git a/.github/workflows/xcat_test.yml b/.github/workflows/xcat_test.yml index b3c25ab77..68f8c3f5a 100644 --- a/.github/workflows/xcat_test.yml +++ b/.github/workflows/xcat_test.yml @@ -26,6 +26,9 @@ jobs: xCAT-test/native/ubuntu_genimage_debootstrap_arch.t xCAT-test/native/ubuntu_genimage_apt_mirror.t xCAT-test/native/ubuntu_genimage_resolver_libs.t + - name: Exercise the liteimg ramdisk archive + if: ${{ !cancelled() }} + run: prove xCAT-test/native/liteimg_ramdisk_archive.t - name: Run tests if: ${{ !cancelled() }} run: perl github_action_xcat_test.pl diff --git a/xCAT-test/unit/liteimg_ramdisk_archive.t b/xCAT-test/native/liteimg_ramdisk_archive.t similarity index 94% rename from xCAT-test/unit/liteimg_ramdisk_archive.t rename to xCAT-test/native/liteimg_ramdisk_archive.t index e23468c16..fa14c31cc 100644 --- a/xCAT-test/unit/liteimg_ramdisk_archive.t +++ b/xCAT-test/native/liteimg_ramdisk_archive.t @@ -23,7 +23,7 @@ sub tool { return $path; } for my $name (qw(cpio gzip find)) { - plan skip_all => "$name is required" unless tool($name); + die "The liteimg archive test requires $name\n" unless tool($name); } my $fixture = realpath(tempdir(CLEANUP => 1)); @@ -31,8 +31,8 @@ make_path("$fixture/db", "$fixture/root/lib/perl", "$fixture/root/share", "$fixt symlink(repo_path('perl-xCAT/xCAT'), "$fixture/root/lib/perl/xCAT") or die $!; symlink(repo_path('xCAT-server/share/xcat'), "$fixture/root/share/xcat") or die $!; write_text("$fixture/install/postscripts/xcatdsklspost", "#!/bin/sh\nexit 0\n"); -$ENV{XCATROOT} = "$fixture/root"; -$ENV{XCATCFG} = "SQLite:$fixture/db"; +local $ENV{XCATROOT} = "$fixture/root"; +local $ENV{XCATCFG} = "SQLite:$fixture/db"; require xCAT::Table; require(repo_path('xCAT-server/lib/xcat/plugins/statelite.pm')); xCAT::Table->new('site', -create => 1)->setAttribs({ key => 'installdir' }, { value => "$fixture/install" }); @@ -50,19 +50,8 @@ our ($HELD, @LOCKED); push @LOCKED, $dir; return $HELD ? (1, "failed to acquire lock, seems there is another genimage/packimage/rmimage process 4242 running on root image dir \"$dir\"") : (0, {}); }; - *xCAT::Utils::runcmd = sub { - my ($class, $command) = @_; - if ($command =~ /^ilitefile /) { - $::RUNCMD_RC = 0; - return ([ "$main::IMAGE tmpfs /etc/hosts" ]); - } - my @output = `$command 2>&1`; - $::RUNCMD_RC = $? >> 8; - return (\@output); - }; } -our $IMAGE; (my $host = hostname()) =~ s/[^A-Za-z0-9.-]/_/g; my $sequence = 0; @@ -91,6 +80,9 @@ $run SCRIPT chmod 0755, "$dest/bin/$compressor"; } + # ilitefile asks xcatd for the litefile entries of the image. + write_text("$dest/bin/ilitefile", "#!/bin/sh\necho '$name tmpfs /etc/hosts'\n"); + chmod 0755, "$dest/bin/ilitefile"; $osimage->setAttribs({ imagename => $name }, { osvers => 'rhels9.6', osarch => 'x86_64', profile => 'compute', provmethod => 'statelite', rootfstype => 'ramdisk' }); $linuximage->setAttribs({ imagename => $name }, { rootimgdir => $dest }); @@ -100,7 +92,6 @@ SCRIPT sub liteimg { my ($dest, $name, @args) = @_; my ($cwd, $mask) = (getcwd(), umask()); - local $IMAGE = $name; @LOCKED = (); my @responses; my $output = '';