Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for analysis using the Clang and GCC analyzers #95

Merged
merged 3 commits into from
Oct 4, 2023
Merged
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
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
47 changes: 47 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions plans/ci.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: Basic analysis tests
discover:
how: fmf
execute:
how: tmt
11 changes: 11 additions & 0 deletions tests/simple_build/clang.fmf
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/simple_build/gcc.fmf
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions tests/simple_build/test.sh
Original file line number Diff line number Diff line change
@@ -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
Dismissed Show dismissed Hide dismissed

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