From b410fdab0326d845a5ba3807eaf9942a6b9dc00b Mon Sep 17 00:00:00 2001 From: Alexandra Hájková Date: Apr 16 2021 23:38:10 +0000 Subject: enable CI gating gating.yaml only use tier0.functional, not scratch-build.validation. The scratch-build.validation is for rebuilding the kernel, we don't really need that as gating rule, since valgrind isn't part of the kernel build chain. plans/ci.fmf: Use tmt, not beakerlib, for how. beakerlib is deprecated. tests/quick-valgrind-sanity/main.fmf recommend only valgrind[-devel], gcc and make This test doesn't use c++, fortran or 32bit glibc-devel. --- diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..8daf6e5 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,19 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 0000000..85710d6 --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,6 @@ +summary: CI Gating Plan +discover: + how: fmf + directory: tests +execute: + how: tmt diff --git a/tests/quick-valgrind-sanity/Makefile b/tests/quick-valgrind-sanity/Makefile new file mode 100644 index 0000000..e708552 --- /dev/null +++ b/tests/quick-valgrind-sanity/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/valgrind/Sanity/quick-valgrind-sanity +# Description: Very fast check that valgrind is working +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/valgrind/Sanity/quick-valgrind-sanity +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE unitialized.c rv.c alloc.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Miroslav Franc " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Very fast check that valgrind is working" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: valgrind" >> $(METADATA) + @echo "Requires: gcc valgrind-devel" >> $(METADATA) + @echo "Requires: glibc-devel glibc-devel.ppc glibc-devel.s390 glibc-devel.i686" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/quick-valgrind-sanity/PURPOSE b/tests/quick-valgrind-sanity/PURPOSE new file mode 100644 index 0000000..c87c6e6 --- /dev/null +++ b/tests/quick-valgrind-sanity/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/valgrind/Sanity/quick-valgrind-sanity +Description: Very fast check that valgrind is working +Author: Miroslav Franc diff --git a/tests/quick-valgrind-sanity/alloc.c b/tests/quick-valgrind-sanity/alloc.c new file mode 100644 index 0000000..3c03816 --- /dev/null +++ b/tests/quick-valgrind-sanity/alloc.c @@ -0,0 +1,10 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + void *buffer = malloc(atoi(argv[1])); + VALGRIND_DO_LEAK_CHECK; + free(buffer); + return 0; +} diff --git a/tests/quick-valgrind-sanity/main.fmf b/tests/quick-valgrind-sanity/main.fmf new file mode 100644 index 0000000..c80e992 --- /dev/null +++ b/tests/quick-valgrind-sanity/main.fmf @@ -0,0 +1,16 @@ +summary: Basic smoke test. +description: 'Very fast check that valgrind is working' +contact: +- Alexandra Petlanova Hajkova +component: +- valgrind +test: ./runtest.sh +framework: beakerlib +recommend: +- valgrind +- valgrind-devel +- gcc +- make +duration: 15m +extra-summary: /tools/valgrind/Sanity/quick-valgrind-sanity +extra-task: /tools/valgrind/Sanity/quick-valgrind-sanity diff --git a/tests/quick-valgrind-sanity/runtest.sh b/tests/quick-valgrind-sanity/runtest.sh new file mode 100755 index 0000000..bbbeab1 --- /dev/null +++ b/tests/quick-valgrind-sanity/runtest.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/valgrind/Sanity/quick-valgrind-sanity +# Description: Very fast check that valgrind is working +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +VALGRIND="${VALGRIND:-$(which valgrind)}" +PACKAGES="${PACKAGES:-$(rpm --qf '%{name}\n' -qf $(which $VALGRIND) | head -1)}" + +rlJournalStart + rlPhaseStartSetup + rlLogInfo "VALGRIND=$VALGRIND" + rlLogInfo "PACKAGES=$PACKAGES" + rlLogInfo "REQUIRES=$REQUIRES" + rlLogInfo "$(type valgrind)" + rlLogInfo "$(type gcc)" + + rlLogInfo "SKIP_COLLECTION_METAPACKAGE_CHECK=$SKIP_COLLECTION_METAPACKAGE_CHECK" + + # We optionally need to skip checking for the presence of the metapackage + # because that would pull in all the dependent toolset subrpms. We do not + # always want that, especially in CI. + _COLLECTIONS="$COLLECTIONS" + if ! test -z $SKIP_COLLECTION_METAPACKAGE_CHECK; then + for c in $SKIP_COLLECTION_METAPACKAGE_CHECK; do + rlLogInfo "ignoring metapackage check for collection $c" + export COLLECTIONS=$(shopt -s extglob && echo ${COLLECTIONS//$c/}) + done + fi + + rlLogInfo "(without skipped) COLLECTIONS=$COLLECTIONS" + + rlAssertRpm --all + + export COLLECTIONS="$_COLLECTIONS" + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp unitialized.c rv.c alloc.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -g unitialized.c -o unitialized" + rlPhaseEnd + + rlPhaseStartTest "good" + rlRun "valgrind --log-file=./log0 ./unitialized 0" 42 + rlAssertNotGrep 'contains uninitialised byte' ./log0 + rlAssertGrep 'ERROR SUMMARY: 0' ./log0 + rlLog "$( with-valgrind" + rlAssertGrep "I'm running on valgrind" with-valgrind + rlLog "$( without-valgrind" + rlAssertGrep "I'm not running on valgrind" without-valgrind + rlLog "$( +#include + +int main() +{ + if(RUNNING_ON_VALGRIND) + puts("I'm running on valgrind \\o/"); + else + puts("I'm not running on valgrind /o\\"); + + return 0; +} diff --git a/tests/quick-valgrind-sanity/unitialized.c b/tests/quick-valgrind-sanity/unitialized.c new file mode 100644 index 0000000..99de47e --- /dev/null +++ b/tests/quick-valgrind-sanity/unitialized.c @@ -0,0 +1,30 @@ +/* valgrind ./a.out 0 ~> no error */ +/* valgrind ./a.out 1 ~> error */ + +#include + +struct something { + char c; + int x; +}; +/* === 8 bytes === + * 42 + * garbage + * garbage + * garbage + * 42 + * 42 + * 42 + * 42 + */ + + +int main(int argc, char *argv[]) +{ + struct something st = { 0x2A, 0x2A2A2A2A }; + + struct something st_copy = st; + + return (int) *(&(st_copy.c)+atoi(argv[1])); +} +/* error generated after main returns */