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.
This commit is contained in:
Alexandra Hájková 2021-03-12 22:49:48 +01:00 committed by Mark Wielaard
parent 7faf5f9863
commit b410fdab03
10 changed files with 265 additions and 0 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

19
gating.yaml Normal file
View File

@ -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}

6
plans/ci.fmf Normal file
View File

@ -0,0 +1,6 @@
summary: CI Gating Plan
discover:
how: fmf
directory: tests
execute:
how: tmt

View File

@ -0,0 +1,64 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/valgrind/Sanity/quick-valgrind-sanity
# Description: Very fast check that valgrind is working
# Author: Miroslav Franc <mfranc@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <mfranc@redhat.com>" > $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /tools/valgrind/Sanity/quick-valgrind-sanity
Description: Very fast check that valgrind is working
Author: Miroslav Franc <mfranc@redhat.com>

View File

@ -0,0 +1,10 @@
#include <stdlib.h>
#include <valgrind/memcheck.h>
int main(int argc, char *argv[])
{
void *buffer = malloc(atoi(argv[1]));
VALGRIND_DO_LEAK_CHECK;
free(buffer);
return 0;
}

View File

@ -0,0 +1,16 @@
summary: Basic smoke test.
description: 'Very fast check that valgrind is working'
contact:
- Alexandra Petlanova Hajkova <ahajkova@redhat.com>
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

View File

@ -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 <mfranc@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 "$(<log0)"
rlPhaseEnd
rlPhaseStartTest "bad"
rlRun "valgrind --log-file=./log2 ./unitialized 2" 0-41,43-255
rlAssertGrep 'contains uninitialised byte' ./log2
rlAssertGrep 'ERROR SUMMARY: 1' ./log2
rlLog "$(<log2)"
rlPhaseEnd
rlPhaseStartTest "client request"
rlRun "gcc -g rv.c -o rv"
rlRun "valgrind ./rv > with-valgrind"
rlAssertGrep "I'm running on valgrind" with-valgrind
rlLog "$(<with-valgrind)"
rlRun "./rv > without-valgrind"
rlAssertGrep "I'm not running on valgrind" without-valgrind
rlLog "$(<without-valgrind)"
rlPhaseEnd
rlPhaseStartTest "client request with leak checking"
rlRun "gcc -g alloc.c -o alloc"
rlRun "valgrind --log-file=./log ./alloc 42"
rlAssertGrep 'still reachable: 42 bytes in 1 blocks' log
rlLog "$(<log)"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd" # $TmpDir
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,12 @@
#include <valgrind/valgrind.h>
#include <stdio.h>
int main()
{
if(RUNNING_ON_VALGRIND)
puts("I'm running on valgrind \\o/");
else
puts("I'm not running on valgrind /o\\");
return 0;
}

View File

@ -0,0 +1,30 @@
/* valgrind ./a.out 0 ~> no error */
/* valgrind ./a.out 1 ~> error */
#include <stdlib.h>
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 */