Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
perl-version: 5.26
- test: compile
perl-version: 5.26
- test: compile-os-autoinst
perl-version: '5.40'
container:
image: perldocker/perl-tester:${{ matrix.perl-version }}
steps:
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ test-compile: check-links
test-compile-changed: os-autoinst/
export PERL5LIB=${PERL5LIB_}:$(shell ./tools/wheel --verify) ; for f in `git diff --name-only | grep '.pm'` ; do perl -c $$f 2>&1 | grep -v " OK$$" && exit 2; done ; true

.PHONY: test-compile-os-autoinst
test-compile-os-autoinst: os-autoinst/
prove tools/check_os_autoinst_compile

.PHONY: test_pod_whitespace_rule
test_pod_whitespace_rule:
tools/check_pod_whitespace_rule
Expand Down Expand Up @@ -120,6 +124,8 @@ ifeq ($(TESTS),compile)
test: test-compile
else ifeq ($(TESTS),compile-changed)
test: test-compile-changed
else ifeq ($(TESTS),compile-os-autoinst)
test: test-compile-os-autoinst
else ifeq ($(TESTS),static)
test: test-static
else ifeq ($(TESTS),unit)
Expand Down
3 changes: 3 additions & 0 deletions tests/cpu_bugs/kvm_guest_mitigations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

# Summary: CPU BUGS on Linux kernel check
# Maintainer: Qi Wang <qwang@suse.com>

## no os-autoinst compile-check

package kvm_guest_mitigations;
use base "consoletest";
use bootloader_setup;
Expand Down
2 changes: 2 additions & 0 deletions tests/cpu_bugs/mds_taa.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Summary: CPU BUGS on Linux kernel check
# Maintainer: James Wang <jnwang@suse.com>

## no os-autoinst compile-check


use base "consoletest";
use bootloader_setup;
Expand Down
2 changes: 2 additions & 0 deletions tests/cpu_bugs/mitigations.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Summary: CPU BUGS on Linux kernel check
# Maintainer: James Wang <jnwang@suse.com>

## no os-autoinst compile-check

use base "consoletest";
use bootloader_setup;
use testapi;
Expand Down
3 changes: 3 additions & 0 deletions tests/cpu_bugs/spectre_v2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

# Summary: CPU BUGS on Linux kernel check
# Maintainer: James Wang <jnwang@suse.com>

## no os-autoinst compile-check

package spectre_v2;

use base "consoletest";
Expand Down
3 changes: 3 additions & 0 deletions tests/cpu_bugs/spectre_v4.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

# Summary: CPU BUGS on Linux kernel check
# Maintainer: James Wang <jnwang@suse.com>

## no os-autoinst compile-check

package spectre_v4;

use base "consoletest";
Expand Down
2 changes: 2 additions & 0 deletions tests/cpu_bugs/xen_domu_mitigation_test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
# one by one execution checking.
#

## no os-autoinst compile-check

package xen_domu_mitigation_test;
use base "consoletest";
use bootloader_setup;
Expand Down
2 changes: 2 additions & 0 deletions tests/virt_autotest/esxi_open_vm_tools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Summary: Run open-vm-tools testing against VMware ESXi
# Maintainer: Nan Zhang <nan.zhang@suse.com>

## no os-autoinst compile-check

use base 'consoletest';
use testapi;
use transactional;
Expand Down
2 changes: 2 additions & 0 deletions tests/x11/user_defined_snapshot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# - Make sure machine is back to original system
# Maintainer: Dumitru Gutu <dgutu@suse.com>

## no os-autoinst compile-check

use base "x11test";
use testapi;
use utils;
Expand Down
2 changes: 2 additions & 0 deletions tests/xfstests/run_subtest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Summary: Run single xfstests subtest
# Maintainer: Yong Sun <yosun@suse.com>, An Long <lan@suse.com>

## no os-autoinst compile-check

use 5.018;
use base 'opensusebasetest';
use File::Basename;
Expand Down
83 changes: 83 additions & 0 deletions tools/check_os_autoinst_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/perl
# Copyright SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later
# Call as:
# prove tools/check_os_autoinst_compile
# perl tools/check_os_autoinst_compile tests/some/specifictest.pm
use Test::Most;
use FindBin '$Bin';
use lib "$Bin/../os-autoinst";
use lib "$Bin/../lib";

use Test::MockModule;
use File::Find;
use Mojo::File qw(path);

use autotest ();
use testapi ();

my $tests_dir = "$Bin/..";

testapi::set_var('ENABLE_MODERN_PERL_FEATURES', 1) if $ENV{ENABLE_MODERN_PERL_FEATURES};

# make compilation still work despite code like
# my @category = split(/,/, # get_required_var('CATEGORY'));
# at compile time (outside of run())
my $testapi_mock = Test::MockModule->new('testapi');
$testapi_mock->redefine(get_required_var => sub { testapi::get_var(@_) // '?' });

# Set some dummy variables to avoid errors (some modules die on missing variables
# already at compile time)
$bmwqemu::vars{VERSION} = 1;
$bmwqemu::vars{FLAVOR} = 'dev';
# Set CASEDIR needed by _make_test_code_to_eval
$bmwqemu::vars{CASEDIR} = $tests_dir;

my @tests;
sub wanted {
push @tests, $File::Find::name if -f $_ and m/\.pm$/;
}

if (@ARGV) {
@tests = @ARGV;
}
else {
find(\&wanted, "tests");
}

@tests = sort @tests;
for my $num (0 .. $#tests) {
my $test = $tests[$num];

my $module_code = path($test)->slurp;
if ($module_code =~ m/^ *## no os-autoinst compile-check/m) {
local $TODO = "skipping $test because of special comment";
fail "$test";
next;
}
my $header = '';

# lib/y2_base.pm uses Carp::Always, which makes every warning output the
# whole module code because it prints a stacktrace, and the code is used
# via a string eval. So we disable it again before every new test to reduce
# the noise
$header .= "no Carp::Always;\n";
# Set test name to n$num to avoid loading the same package name from
# different directories
$module_code = autotest::_make_test_code_to_eval("./$test", $test, "n$num", 0);

my $code = $header . $module_code;
my @warnings;
{
local $SIG{__WARN__} = sub { push @warnings, @_ };
eval $code;
}
my $err = $@;
if ($err) {
diag "########### ERROR: $err";
}
ok !$err, "$test - compiles";
is_deeply \@warnings, [], "$test - no warnings";
}

done_testing;
Loading