diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml index 88590190..2344f21b 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -34,6 +34,53 @@ jobs: - fedora-all-s390x - fedora-all-x86_64 + # EPEL tests + - job: tests + trigger: pull_request + targets: + - epel-7-x86_64 + identifier: epel7 + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/g/codescan/csutils/repo/epel-7/group_codescan-csutils-epel-7 + - job: tests + trigger: pull_request + targets: + - epel-8-aarch64 + - epel-8-x86_64 + identifier: epel8 + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/g/codescan/csutils/repo/epel-8/group_codescan-csutils-epel-8 + - job: tests + trigger: pull_request + targets: + - epel-9-aarch64 + - epel-9-x86_64 + identifier: epel9 + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/g/codescan/csutils/repo/epel-9/group_codescan-csutils-epel-9 + + # Fedora tests + - job: tests + trigger: pull_request + targets: + - fedora-all-aarch64 + - fedora-all-x86_64 + identifier: fedora + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/g/codescan/csutils/repo/fedora/group_codescan-csutils-fedora + - <<: *copr trigger: commit owner: "@codescan" diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 00000000..dcb78c2b --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,5 @@ +summary: Basic analysis tests +discover: + how: fmf +execute: + how: tmt diff --git a/tests/simple_build/clang.fmf b/tests/simple_build/clang.fmf new file mode 100644 index 00000000..0825c8c0 --- /dev/null +++ b/tests/simple_build/clang.fmf @@ -0,0 +1,11 @@ +summary: Test analysis using Clang analyzer +test: ./test.sh +framework: beakerlib +environment: + TEST_PACKAGE: units + TEST_TOOL: clang +component: + - csmock-plugin-clang +recommend: + - csmock-plugin-clang +duration: 1h diff --git a/tests/simple_build/gcc.fmf b/tests/simple_build/gcc.fmf new file mode 100644 index 00000000..5e43c51e --- /dev/null +++ b/tests/simple_build/gcc.fmf @@ -0,0 +1,12 @@ +summary: Test analysis using GCC analyzer +test: ./test.sh +framework: beakerlib +environment: + TEST_PACKAGE: units + TEST_TOOL: gcc + CSMOCK_EXTRA_OPTS: --gcc-analyze +component: + - csmock +recommend: + - csmock +duration: 1h diff --git a/tests/simple_build/test.sh b/tests/simple_build/test.sh new file mode 100755 index 00000000..eddb9189 --- /dev/null +++ b/tests/simple_build/test.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +CSMOCK_EXTRA_OPTS="${CSMOCK_EXTRA_OPTS:-}" +TEST_PACKAGE="${TEST_PACKAGE:-}" +TEST_TOOL="${TEST_TOOL:-}" +TEST_USER="csmock" + +rlJournalStart + rlPhaseStartSetup + # use the latest csutils in the Testing Farm + if rlIsFedora || rlIsRHELLike '>7'; then + # By default the testing-farm-tag-repository has higher priority + # than our development COPR repo. Therefore, we need to flip the + # priorities and update the packages manually. + rlRun "dnf config-manager --save --setopt='copr:copr.fedorainfracloud.org:group_codescan:csutils.priority=1'" + rlRun "dnf upgrade -y 'cs*'" + fi + + if [ -z "$TEST_PACKAGE" ]; then + rlDie "TEST_PACKAGE parameter is empty or undefined" + fi + + if [ -z "$TEST_TOOL" ]; then + rlDie "TEST_TOOL parameter is empty or undefined" + fi + + # create a tmpdir + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd \$tmp" + + # fetch the SRPM + rlRun "yum -y install $TEST_PACKAGE" + rlRun "rlFetchSrcForInstalled $TEST_PACKAGE" + rlRun "SRPM=\$(find . -name '$TEST_PACKAGE-*.src.rpm')" + + # add a user for mock + rlRun "userdel -r $TEST_USER" 0,6 + rlRun "useradd -m -d /home/$TEST_USER -G mock $TEST_USER" + rlRun "cp $SRPM /home/$TEST_USER" + + if ! rlGetPhaseState; then + rlDie "'$TEST_PACKAGE' sources could not be fetched" + fi + rlPhaseEnd + + rlPhaseStartTest "Analyze $TEST_PACKAGE using $TEST_TOOL" + rlRun "su - $TEST_USER -c 'csmock -t $TEST_TOOL $CSMOCK_EXTRA_OPTS \"$SRPM\"'" 0 \ + "Analyze $SRPM using $TEST_TOOL analyzer" + rlFileSubmit "/home/$TEST_USER/$TEST_PACKAGE"*.tar.xz "$SRPM-$TEST_TOOL.tar.xz" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel -r $TEST_USER" + rlRun "popd" + rlRun "rm -r \$tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd