Import RHEL's regression test for #1158713
Note: I've prefixed the test with "bz1158713-" because ltrace's repo
in Fedora ignores "ltrace-*/". See the .gitignore file.
This commit is contained in:
parent
9af7a027b2
commit
f20f6a9ea6
@ -0,0 +1,63 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
# Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
# Author: Martin Cermak <mcermak@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2015 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# 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, see http://www.gnu.org/licenses/.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.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: Martin Cermak <mcermak@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 10m" >> $(METADATA)
|
||||
@echo "RunFor: ltrace" >> $(METADATA)
|
||||
@echo "Requires: ltrace gcc gawk" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2+" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 1158713" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
||||
@ -0,0 +1,5 @@
|
||||
PURPOSE of /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
Author: Martin Cermak <mcermak@redhat.com>
|
||||
Bug summary: ltrace assigns wrong names to glibc PLT slots
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1158713
|
||||
@ -0,0 +1,18 @@
|
||||
summary: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
description: |
|
||||
Bug summary: ltrace assigns wrong names to glibc PLT slots
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1158713
|
||||
contact: Martin Cermak <mcermak@redhat.com>
|
||||
component:
|
||||
- ltrace
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- ltrace
|
||||
- gcc
|
||||
- gawk
|
||||
duration: 10m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1158713
|
||||
extra-summary: /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
extra-task: /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
# Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots
|
||||
# Author: Martin Cermak <mcermak@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2015 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# 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, see http://www.gnu.org/licenses/.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="$(rpm -qf $(which ltrace))"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlAssertRpm $(rpm -qf $(which gcc))
|
||||
rlRun "TMPD=$(mktemp -d)"
|
||||
rlRun "pushd $TMPD"
|
||||
|
||||
cat > test.c <<EOFA
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char *s = malloc(1000);
|
||||
|
||||
// trigger a free() call from libc:
|
||||
setpwent();
|
||||
getpwent();
|
||||
endpwent();
|
||||
|
||||
// print maps
|
||||
sprintf(s, "grep -F '[heap]' /proc/%d/maps", getpid());
|
||||
system (s);
|
||||
|
||||
free(s);
|
||||
}
|
||||
EOFA
|
||||
|
||||
cat > test.awk <<EOFB
|
||||
BEGIN {
|
||||
addrindex = 0
|
||||
}
|
||||
|
||||
/libc.*free\(0x[0-9a-f]+\)/ {
|
||||
match(\$0,/0x[0-9a-f]+/,m)
|
||||
addrs[addrindex++] = strtonum(m[0])
|
||||
}
|
||||
|
||||
/\[heap\]/ {
|
||||
sub("-", " ", \$0)
|
||||
split(\$0, a, " ")
|
||||
limit_min = strtonum("0x"a[1])
|
||||
limit_max = strtonum("0x"a[2])
|
||||
}
|
||||
|
||||
END {
|
||||
for (i=0; i<addrindex; i++) {
|
||||
if (addrs[i] < limit_min) {
|
||||
print "ERROR 1 ("addrs[i]"<"limit_min")"
|
||||
exit 1
|
||||
}
|
||||
if (addrs[i] > limit_max) {
|
||||
print "ERROR 2 ("addrs[i]">"limit_max")"
|
||||
exit 2
|
||||
}
|
||||
}
|
||||
}
|
||||
EOFB
|
||||
|
||||
rlRun "gcc test.c -o test"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "ltrace -e free ./test |& tee log | awk -f test.awk" || \
|
||||
rlRun "cat log"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TMPD"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
Loading…
Reference in New Issue
Block a user