From d7a56ae899a0370de7226e850cdcc7fe75a748c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= Date: Thu, 2 Feb 2023 13:51:06 +0100 Subject: [PATCH] tests: add a simple test for the Clang analyzer plugin Related: https://github.com/csutils/csmock/issues/93 --- .fmf/version | 1 + plans/example.fmf | 5 +++++ tests/clang/main.fmf | 9 +++++++++ tests/clang/test.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 .fmf/version create mode 100644 plans/example.fmf create mode 100644 tests/clang/main.fmf create mode 100755 tests/clang/test.sh 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/plans/example.fmf b/plans/example.fmf new file mode 100644 index 00000000..dcb78c2b --- /dev/null +++ b/plans/example.fmf @@ -0,0 +1,5 @@ +summary: Basic analysis tests +discover: + how: fmf +execute: + how: tmt diff --git a/tests/clang/main.fmf b/tests/clang/main.fmf new file mode 100644 index 00000000..cabeeb4d --- /dev/null +++ b/tests/clang/main.fmf @@ -0,0 +1,9 @@ +summary: Test analysis using Clang analyzer +test: ./test.sh +framework: beakerlib +component: + - csmock +recommend: + - csmock + - csmock-plugin-clang +duration: 1h diff --git a/tests/clang/test.sh b/tests/clang/test.sh new file mode 100755 index 00000000..e3a8ea15 --- /dev/null +++ b/tests/clang/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="csmock csmock-plugin-clang" + +TEST_PACKAGE="csrap" +TEST_USER="csmock" + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd \$tmp" + + rlRun "dnf -y update $TEST_PACKAGE" 0-255 + rlRun "rlFetchSrcForInstalled $TEST_PACKAGE" + rlRun "SRPM=\$(find . -name '$TEST_PACKAGE-*.src.rpm')" + + rlRun "userdel -r $TEST_USER" 0,6 + rlRun "useradd -m -d /home/$TEST_USER -G mock $TEST_USER" + rlRun "cp $SRPM /home/$TEST_USER" + rlPhaseEnd + + rlPhaseStartTest + rlRun "su - $TEST_USER -c 'csmock -t clang \"$SRPM\"'" 0 \ + "Analyze $SRPM using Clang analyzer" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel -r $TEST_USER" + rlRun "popd" + rlRun "rm -r \$tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd