From c043c49cd3bd9b5b2f3c06c47694a0c80e90cf67 Mon Sep 17 00:00:00 2001 From: Alexandra Hájková Date: Apr 22 2021 13:01:48 +0000 Subject: Add bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through test to Fedora CI --- diff --git a/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/Makefile b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/Makefile new file mode 100644 index 0000000..6f2afaf --- /dev/null +++ b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/valgrind/Sanity/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through +# Description: Test for BZ#672959 ([RFE] Integrate valgrind with gdb possibly through) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 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/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE something.c error.gdb noerror.gdb + +.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: Test for BZ#672959 ([RFE] Integrate valgrind with gdb possibly through)" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: valgrind" >> $(METADATA) + @echo "Requires: valgrind gcc gdb glibc-debuginfo" >> $(METADATA) + @echo "Requires: glibc-devel" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 672959" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/PURPOSE b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/PURPOSE new file mode 100644 index 0000000..6d2c0bf --- /dev/null +++ b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/PURPOSE @@ -0,0 +1,7 @@ +PURPOSE of /tools/valgrind/Sanity/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through +Description: Test for BZ#672959 ([RFE] Integrate valgrind with gdb possibly through) +Author: Miroslav Franc +Bug summary: [RFE] Integrate valgrind with gdb possibly through gdbserver. +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=672959 + +This is small sanity test to make sure gdb works with valgrind gdb server. diff --git a/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/error.gdb b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/error.gdb new file mode 100644 index 0000000..199cc5c --- /dev/null +++ b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/error.gdb @@ -0,0 +1,5 @@ +target remote | vgdb +c +p var +c +q diff --git a/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/main.fmf b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/main.fmf new file mode 100644 index 0000000..c7989c5 --- /dev/null +++ b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/main.fmf @@ -0,0 +1,20 @@ +summary: Test for BZ#672959 ([RFE] Integrate valgrind with gdb possibly through) +description: | + Bug summary: [RFE] Integrate valgrind with gdb possibly through gdbserver. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=672959 + + This is small sanity test to make sure gdb works with valgrind gdb server. +contact: Miroslav Franc +component: +- valgrind +test: ./runtest.sh +framework: beakerlib +recommend: +- valgrind +- gcc +- gdb +- glibc-debuginfo +- glibc-devel +duration: 30m +extra-summary: /tools/valgrind/Sanity/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through +extra-task: /tools/valgrind/Sanity/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through diff --git a/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/noerror.gdb b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/noerror.gdb new file mode 100644 index 0000000..c471593 --- /dev/null +++ b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/noerror.gdb @@ -0,0 +1,6 @@ +target remote | vgdb +b 10 +c +set (a=5) +c +q diff --git a/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/runtest.sh b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/runtest.sh new file mode 100755 index 0000000..4e025fa --- /dev/null +++ b/tests/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through/runtest.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/valgrind/Sanity/bz672959-RFE-Integrate-valgrind-with-gdb-possibly-through +# Description: Test for BZ#672959 ([RFE] Integrate valgrind with gdb possibly through) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 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 + +PACKAGE=$(rpm --qf "%{name}\n" -qf $(which valgrind) | head -1) +PACKAGES=(valgrind gcc gdb) + +# Expect 1th argument as a path to binary to test with +_test_routine() +{ + local binary=$1 + + rlPhaseStartTest "$binary error" + rlAssertExists "$binary" + rlLog "valgrind gdb server..." + valgrind --vex-iropt-register-updates=allregs-at-mem-access --vgdb-error=0 ./$binary > vloge 2>&1 & + vpid=$! + sleep 5 + rlRun "gdb -x error.gdb ./$binary > gloge 2>&1" + [[ -d /proc/$vpid ]] && { kill -9 $vpid; rlFail "oops: valgrind still running..."; } + rlRun "wait $vpid" + rlAssertGrep '19.*if(x)' gloge + rlAssertGrep '$1 = 42' gloge + # there should be exactly one error + rlAssertGrep 'ERROR SUMMARY: 1 errors from 1 contexts' vloge + rlLog "> gdb output <" + rlLog "$( valgrind output <" + rlLog "$( vlogn 2>&1 & + vpid=$! + sleep 5 + rlRun "gdb -x noerror.gdb ./$binary > glogn 2>&1" + [[ -d /proc/$vpid ]] && { kill -9 $vpid; rlFail "oops: valgrind still running..."; } + rlRun "wait $vpid" + rlAssertGrep '10.*f(a);' glogn + # this time, no errors + rlAssertGrep 'ERROR SUMMARY: 0 errors from 0 contexts' vlogn + rlAssertGrep 'hello, world' vlogn + rlLog "> gdb output <" + rlLog "$( valgrind output <" + rlLog "$( + +void f (int x); + +int +main (int argc, char *argv[]) +{ + int a; + + f(a); + + return 0; +} + +void +f (int x) +{ + static int var __attribute__ ((used)) = 42; + if(x) + puts("hello, world"); +}