diff --git a/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/Makefile b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/Makefile new file mode 100644 index 0000000..f9f7029 --- /dev/null +++ b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5 +# Description: Calls getaddrinfo and verifies behavior as per BZ +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5 +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE tst-getaddrinfo.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Calls getaddrinfo and verifies behavior as per BZ" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1022022" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/PURPOSE b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/PURPOSE new file mode 100644 index 0000000..f55c98f --- /dev/null +++ b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5 +Description: Calls getaddrinfo and verifies behavior as per BZ +Author: Arjun Shankar diff --git a/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/main.fmf b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/main.fmf new file mode 100644 index 0000000..948e5ee --- /dev/null +++ b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/main.fmf @@ -0,0 +1,17 @@ +summary: Calls getaddrinfo and verifies behavior as per BZ +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1022022 +extra-summary: /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5 +extra-task: /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5 diff --git a/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/runtest.sh b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/runtest.sh new file mode 100755 index 0000000..8da787e --- /dev/null +++ b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/runtest.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5 +# Description: Calls getaddrinfo and verifies behavior as per BZ +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 + +PACKAGE=glibc +REQUIRES=(gcc glibc glibc-devel) + +rlJournalStart + rlPhaseStartSetup + for p in "${REQUIRES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp tst-getaddrinfo.c $TmpDir" + rlRun "pushd $TmpDir" + + rlRun "gcc -o tst-getaddrinfo tst-getaddrinfo.c" + rlAssertExists "tst-getaddrinfo" + + rlRun "ORIG_HOSTNAME=$(hostname)" + rlFileBackup --clean "/etc/hostname" + rlRun "echo 'www' > /etc/hostname" + rlRun "hostname -F /etc/hostname" + + rlFileBackup --clean "/etc/hosts" + rlRun "echo '127.0.0.1 www.fubar.redhat www' >> /etc/hosts" + rlRun "echo '::1 www.fubar.redhat www' >> /etc/hosts" + # Note that the 'canonical name' is always the first name entry in + # each tuple ^, i.e. 'www.fubar.redhat' in our case + rlPhaseEnd + + rlPhaseStartTest + rlRun "./tst-getaddrinfo > tst.out" + rlLog "$(cat tst.out)" + rlRun "OUT=($(cat tst.out))" + rlAssertEquals "Correct number of output lines" "${#OUT[@]}" "4" + + if rlIsRHEL 6; then + # The result 'www' for AF_INET is basically incorrect, but we want to + # keep it consistent during the life of RHEL 6 + rlAssertEquals "gethostname" "${OUT[0]}" "www" + rlAssertEquals "getaddrinfo, AF_INET" "${OUT[1]}" "www" + rlAssertEquals "getaddrinfo, AF_UNSPEC" "${OUT[3]}" "www.fubar.redhat" + + rlLog "We don't check (getaddrinfo, AF_INET6) on RHEL 6" + else + rlAssertEquals "gethostname" "${OUT[0]}" "www" + rlAssertEquals "getaddrinfo, AF_INET" "${OUT[1]}" "www.fubar.redhat" + rlAssertEquals "getaddrinfo, AF_INET6" "${OUT[2]}" "www.fubar.redhat" + rlAssertEquals "getaddrinfo, AF_UNSPEC" "${OUT[3]}" "www.fubar.redhat" + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlFileRestore "/etc/hosts" + rlFileRestore "/etc/hostname" + rlRun "hostname $ORIG_HOSTNAME" + + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/tst-getaddrinfo.c b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/tst-getaddrinfo.c new file mode 100644 index 0000000..0c11056 --- /dev/null +++ b/tests/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5/tst-getaddrinfo.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include + +#define SIZE 4096 + +#define exit_code_func_msg(c,f,m) \ + do \ + { \ + printf ("error %d: %s: %s\n", c, f, m); \ + exit (1); \ + } \ + while (0) + +static void +get_canon_name (char *hostname, int af) +{ + struct addrinfo hints, *result, *current; + int error; + + memset (&hints, 0, sizeof (hints)); + hints.ai_family = af; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_CANONNAME; + + error = getaddrinfo (hostname, NULL, &hints, &result); + + if (error != 0) + exit_code_func_msg (error, "getaddrinfo", gai_strerror (error)); + + if (result->ai_canonname == NULL) + exit_code_func_msg (-1, "getaddrinfo", "No canonical name returned"); + + for (current = result; + current != NULL && current->ai_canonname != NULL; + current = current->ai_next) + printf ("%s\n", current->ai_canonname); + + freeaddrinfo (result); + + return; +} + +int +main (int argc, char **argv) +{ + + char hostname[SIZE]; + int error; + + error = gethostname (hostname, SIZE); + + if (error) + exit_code_func_msg (error, "gethostname", ""); + + printf ("%s\n", hostname); + + get_canon_name (hostname, AF_INET); + get_canon_name (hostname, AF_INET6); + get_canon_name (hostname, AF_UNSPEC); + + return 0; +} diff --git a/tests/Regression/bz434601-timedlock-segfault/Makefile b/tests/Regression/bz434601-timedlock-segfault/Makefile new file mode 100644 index 0000000..bb73776 --- /dev/null +++ b/tests/Regression/bz434601-timedlock-segfault/Makefile @@ -0,0 +1,49 @@ +# Makefile - bz434601-timedlock-segfault - Bugzilla(s) 434601 +# Author: Petr Muller +# Location: /tools/glibc/Regression/bz434601-timedlock-segfault/Makefile + +# Description: Tests segfault in pthread_mutex_timedlock function + + +TOPLEVEL_NAMESPACE=/tools +PACKAGE_NAME=glibc +RELATIVE_PATH=Regression/bz434601-timedlock-segfault + +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile timedlock.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + + +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Tests segfault in pthread_mutex_timedlock function" >> $(METADATA) + @echo "Bug: 434601" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "License: GPLv3" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz434601-timedlock-segfault/PURPOSE b/tests/Regression/bz434601-timedlock-segfault/PURPOSE new file mode 100644 index 0000000..f37d527 --- /dev/null +++ b/tests/Regression/bz434601-timedlock-segfault/PURPOSE @@ -0,0 +1,9 @@ +Test Name: bz434601-timedlock-segfault - Bugzilla(s) 434601 +Author: Petr Muller +Location: /tools/glibc/Regression/bz434601-timedlock-segfault + +Short Description: Tests segfault in pthread_mutex_timedlock function + + +Long Description: +Tests segfault in pthread_mutex_timedlock function diff --git a/tests/Regression/bz434601-timedlock-segfault/main.fmf b/tests/Regression/bz434601-timedlock-segfault/main.fmf new file mode 100644 index 0000000..ffa3c96 --- /dev/null +++ b/tests/Regression/bz434601-timedlock-segfault/main.fmf @@ -0,0 +1,24 @@ +summary: Tests segfault in pthread_mutex_timedlock function +description: | + Test Name: bz434601-timedlock-segfault - Bugzilla(s) 434601 + Author: Petr Muller + Location: /tools/glibc/Regression/bz434601-timedlock-segfault + + Short Description: Tests segfault in pthread_mutex_timedlock function + + + Long Description: + Tests segfault in pthread_mutex_timedlock function +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - gcc +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=434601 +extra-summary: /tools/glibc/Regression/bz434601-timedlock-segfault +extra-task: /tools/glibc/Regression/bz434601-timedlock-segfault diff --git a/tests/Regression/bz434601-timedlock-segfault/runtest.sh b/tests/Regression/bz434601-timedlock-segfault/runtest.sh new file mode 100755 index 0000000..a451879 --- /dev/null +++ b/tests/Regression/bz434601-timedlock-segfault/runtest.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz434601-timedlock-segfault +# Description: Tests segfault in pthread_mutex_timedlock function bz434601 +# Author: Sergey Kolosov +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2022 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="glibc" +TESTPROG="timedlock" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG" + rlAssertExists "$TESTPROG" + rlRun -c "./${TESTPROG}" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + diff --git a/tests/Regression/bz434601-timedlock-segfault/timedlock.c b/tests/Regression/bz434601-timedlock-segfault/timedlock.c new file mode 100644 index 0000000..57d8842 --- /dev/null +++ b/tests/Regression/bz434601-timedlock-segfault/timedlock.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static volatile int counter = 0; +static volatile int stop = 0; + +static void * +testTimedLock(void *arg) +{ + int rc = 0; + struct timespec abstime; + abstime.tv_sec = time(0) + 10; + abstime.tv_nsec = 100000000; + + for ( ; stop == 0; ) { + rc = pthread_mutex_timedlock( &mutex, &abstime ); + if (rc != 0) { perror("Errno:"); }; + assert(rc == 0); + ++counter; + rc = pthread_mutex_unlock( &mutex ); + if (rc != 0) { perror("Errno:"); }; + assert(rc == 0); + } + return 0; +} + +void +createThreads(int nThreads, pthread_t *thr) +{ + int nt; + for ( nt = 0 ; nt < nThreads ; ++nt ) { + int rc = pthread_create( thr+nt, NULL, testTimedLock, NULL); + if (rc != 0) { perror("Errno:"); }; + assert( rc == 0 ); + } +} + +void +joinThreads(int nThreads, pthread_t *thr) +{ + int nt; + for ( nt = 0 ; nt < nThreads ; ++nt ) { + int rc = pthread_join( thr[nt], NULL); + if (rc != 0) { perror("Errno:"); }; + assert( rc == 0 ); + } +} + +int +main(void) +{ + int nThreads = 10; + pthread_t thr[nThreads]; + + createThreads(nThreads, thr); + usleep (1000000); // 1 second + stop = 1; + joinThreads(nThreads, thr); + printf("counter = %d\n", counter); + return 0; +} diff --git a/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/Makefile b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/Makefile new file mode 100644 index 0000000..452d4b4 --- /dev/null +++ b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive +# Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE testcase.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 455360" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/PURPOSE b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/PURPOSE new file mode 100644 index 0000000..2ac2c13 --- /dev/null +++ b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/PURPOSE @@ -0,0 +1,73 @@ +PURPOSE of /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive +Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive) +Author: Petr Muller +Bug summary: [RHEL4] vfprintf() call goes into recursive overflow and crashes with a segfault +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=455360 + +Description: + +Description of problem in short (details sent next thru IT): + +Sporadically, when under load, the client is seeing tibco EMS processes be +killed by segfaults. Getting a robust diagnosis has proven difficult, but from +what can be told, it appears that somehow a vfprintf() call is getting into a +state where it loops with: + + +6 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240 +#7 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=Variable "c" is not +available. +) at vfprintf.c:2058 + + +It recurses for quite some time in glibc and then crashes with a segfault. I've +just gotten the application binary (stripped unfortunately) and thus could +actually get something from the core. + +Customer's analysis: +we have seen this issue before. What's going wrong is that we are calling +vfprintf to perform a message trace including the body and the functions in +glibc are recursing approximately 373909 frames and then it crashed. + + + +#373902 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240 +#373903 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=-1) + at vfprintf.c:2058 +#373904 0x0086096f in _IO_default_xsputn (f=0xf7fe8688, data=0x32046928, + n=10285) at genops.c:478 +#373905 0x0083e88e in _IO_vfprintf (s=0xf7fe8688, + format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s +mode=%s %s='%s'%s%s", ap=0xf7feae90 "ïJ©\236À¦\004\204:Z\\Æ\\ò%$Ü\223K") + at vfprintf.c:1553 +#373906 0x0083b0ac in buffered_vfprintf (s=0x929460, + format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s +mode=%s %s='%s'%s%s", args=) at vfprintf.c:2144 +#373907 0x0083b2eb in _IO_vfprintf (s=0x929460, + format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s +mode=%s %s='%s'%s%s", ap=0xf7feae58 "Яþ÷lê2\bP°þ÷;\216K") at vfprintf.c:1264 +#373908 0x0811ba34 in _authenticate () +#373909 0x0811bc4c in _authenticate () +#373910 0x080f7f3c in _authenticate () +#373911 0x080e8e6a in _authenticate () +#373912 0x080e6d88 in _authenticate () +#373913 0x080e6ed0 in _authenticate () +#373914 0x0807d4fd in ?? () +#373915 0x2846afc8 in ?? () +#373916 0x0830e880 in _IO_stdin_used () +#373917 0x00000432 in ?? () +#373918 0x0830e86d in _IO_stdin_used () +#373919 0x0830e86d in _IO_stdin_used () +#373920 0x00000000 in ?? () + + + +Version-Release number of selected component (if applicable): +glibc-2.3.4-2.39 + +Additional info: + +I have the core and binary set up on a lab host which has the correct version of +glibc installed. Feel free to work on that host: + +dhcp139.gsslab.rdu.redhat.com (root:redhat) diff --git a/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/main.fmf b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/main.fmf new file mode 100644 index 0000000..f19de8a --- /dev/null +++ b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/main.fmf @@ -0,0 +1,84 @@ +summary: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive) +description: | + Bug summary: [RHEL4] vfprintf() call goes into recursive overflow and crashes with a segfault + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=455360 + + Description: + + Description of problem in short (details sent next thru IT): + + Sporadically, when under load, the client is seeing tibco EMS processes be + killed by segfaults. Getting a robust diagnosis has proven difficult, but from + what can be told, it appears that somehow a vfprintf() call is getting into a + state where it loops with: + + + 6 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240 + #7 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=Variable "c" is not + available. + ) at vfprintf.c:2058 + + + It recurses for quite some time in glibc and then crashes with a segfault. I've + just gotten the application binary (stripped unfortunately) and thus could + actually get something from the core. + + Customer's analysis: + we have seen this issue before. What's going wrong is that we are calling + vfprintf to perform a message trace including the body and the functions in + glibc are recursing approximately 373909 frames and then it crashed. + + + + #373902 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240 + #373903 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=-1) + at vfprintf.c:2058 + #373904 0x0086096f in _IO_default_xsputn (f=0xf7fe8688, data=0x32046928, + n=10285) at genops.c:478 + #373905 0x0083e88e in _IO_vfprintf (s=0xf7fe8688, + format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s + mode=%s %s='%s'%s%s", ap=0xf7feae90 "ïJ©\236À¦\004\204:Z\\Æ\\ò%$Ü\223K") + at vfprintf.c:1553 + #373906 0x0083b0ac in buffered_vfprintf (s=0x929460, + format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s + mode=%s %s='%s'%s%s", args=) at vfprintf.c:2144 + #373907 0x0083b2eb in _IO_vfprintf (s=0x929460, + format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s + mode=%s %s='%s'%s%s", ap=0xf7feae58 "Яþ÷lê2\bP°þ÷;\216K") at vfprintf.c:1264 + #373908 0x0811ba34 in _authenticate () + #373909 0x0811bc4c in _authenticate () + #373910 0x080f7f3c in _authenticate () + #373911 0x080e8e6a in _authenticate () + #373912 0x080e6d88 in _authenticate () + #373913 0x080e6ed0 in _authenticate () + #373914 0x0807d4fd in ?? () + #373915 0x2846afc8 in ?? () + #373916 0x0830e880 in _IO_stdin_used () + #373917 0x00000432 in ?? () + #373918 0x0830e86d in _IO_stdin_used () + #373919 0x0830e86d in _IO_stdin_used () + #373920 0x00000000 in ?? () + + + + Version-Release number of selected component (if applicable): + glibc-2.3.4-2.39 + + Additional info: + + I have the core and binary set up on a lab host which has the correct version of + glibc installed. Feel free to work on that host: + + dhcp139.gsslab.rdu.redhat.com (root:redhat) +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=455360 +extra-summary: /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive +extra-task: /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive diff --git a/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/runtest.sh b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/runtest.sh new file mode 100755 index 0000000..01236c4 --- /dev/null +++ b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/runtest.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive +# Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +rpm -Uvh http://nest.test.redhat.com/mnt/qa/scratch/pmuller/rhtslib/rhtslib.rpm +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart +rlPhaseStartSetup Setup + rlAssertRpm $PACKAGE + rlRun "gcc -O0 testcase.c -o tc0" + rlRun "gcc -O2 testcase.c -o tc2" +rlPhaseEnd + +rlPhaseStartTest Testing + rlRun "./tc0" + rlAssertNotEquals "Checking for the bug 455360 itself" $? 139 + rlAssertExists "abcd" + rlRun "rm -f abcd" + rlRun "./tc2" + rlAssertNotEquals "Checking for the bug 455360 itself" $? 139 + rlAssertExists "abcd" +rlPhaseEnd + +rlPhaseStartCleanup Cleanup + rlRun "rm -f tc0 tc2 abcd" +rlPhaseEnd diff --git a/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/testcase.c b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/testcase.c new file mode 100644 index 0000000..05c7a33 --- /dev/null +++ b/tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/testcase.c @@ -0,0 +1,16 @@ +#include +#include + +int +main (void) +{ + char str[8192+2048]; + memset (str, 'A', sizeof (str) - 1); + str[sizeof (str) - 1] = '\0'; + FILE *f = fopen ("abcd", "w"); + setvbuf (f, NULL, _IONBF, 0); + /* Force error on next overflow. */ + close (fileno (f)); + fprintf (f, "%s\n", str); + return 0; +} diff --git a/tests/Regression/bz464146-sp-corruption/Makefile b/tests/Regression/bz464146-sp-corruption/Makefile new file mode 100644 index 0000000..b5d4a4b --- /dev/null +++ b/tests/Regression/bz464146-sp-corruption/Makefile @@ -0,0 +1,66 @@ +# Makefile - bz464146-sp-corruption - Bugzilla(s) 464146 +# Author: Petr Muller +# Location: /tools/glibc/Regression/bz464146-sp-corruption/Makefile + +# Description: Test for bz464144, a stack pointer corruption problem + +# Copyright (c) 2008 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 v.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. + + + +TOPLEVEL_NAMESPACE=/tools +PACKAGE_NAME=glibc +RELATIVE_PATH=Regression/bz464146-sp-corruption + +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE testit.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + + +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Test for bz464144, a stack pointer corruption problem" >> $(METADATA) + @echo "Bug: 464146" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: quota-devel" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Architectures: x86_64 ia64 s390x" >> $(METADATA) + @echo "Releases: -RHEL3 -RHEL4" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz464146-sp-corruption/PURPOSE b/tests/Regression/bz464146-sp-corruption/PURPOSE new file mode 100644 index 0000000..514ba43 --- /dev/null +++ b/tests/Regression/bz464146-sp-corruption/PURPOSE @@ -0,0 +1,10 @@ +Test Name: bz464146-sp-corruption - Bugzilla(s) 464146 +Author: Petr Muller +Location: /tools/glibc/Regression/bz464146-sp-corruption + +Short Description: Test for bz464144, a stack pointer corruption problem + + +Long Description: + +In real life, the problem is only likely to occur with very large applications with hundreds of threads. The result of the bug is that a stack might suddenly jump to an area of virtual memory 4GB away from where it should be. diff --git a/tests/Regression/bz464146-sp-corruption/main.fmf b/tests/Regression/bz464146-sp-corruption/main.fmf new file mode 100644 index 0000000..14062ed --- /dev/null +++ b/tests/Regression/bz464146-sp-corruption/main.fmf @@ -0,0 +1,26 @@ +summary: Test for bz464144, a stack pointer corruption problem +description: | + Test Name: bz464146-sp-corruption - Bugzilla(s) 464146 + Author: Petr Muller + Location: /tools/glibc/Regression/bz464146-sp-corruption + + Short Description: Test for bz464144, a stack pointer corruption problem + + + Long Description: + + In real life, the problem is only likely to occur with very large applications with hundreds of threads. The result of the bug is that a stack might suddenly jump to an area of virtual memory 4GB away from where it should be. +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - quota-devel + - gcc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=464146 +extra-summary: /tools/glibc/Regression/bz464146-sp-corruption +extra-task: /tools/glibc/Regression/bz464146-sp-corruption diff --git a/tests/Regression/bz464146-sp-corruption/runtest.sh b/tests/Regression/bz464146-sp-corruption/runtest.sh new file mode 100755 index 0000000..3a39322 --- /dev/null +++ b/tests/Regression/bz464146-sp-corruption/runtest.sh @@ -0,0 +1,67 @@ +# runtest.sh - bz464146-sp-corruption - Bugzilla(s) 464146 +# Author: Petr Muller +# Location: /tools/glibc/Regression/bz464146-sp-corruption/runtest.sh + +# Description: Test for bz464144, a stack pointer corruption problem + +# Copyright (c) 2008 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 v.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. + + +PACKAGE=glibc + +# Include rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 +rlStartJournal + +###################### +# Prepare environment +###################### +rlPhaseStartSetup Preparation + rlAssertRpm ${PACKAGE} + ARCH=`uname -m` + if [ "$ARCH" == "ia64" -o "$ARCH" == "aarch64" -o "$ARCH" == "ppc64le" ] + then + FLAGS="" + else + FLAGS="-m64" + fi + rlRun "gcc $FLAGS testit.c -o testit -lpthread" 0 "Compiling the testcase" + +rlPhaseEnd + +###################### +# Begin Test-Case +###################### +rlPhaseStartTest Test + output=`mktemp` + ./testit > $output + RC=$? + + rlAssert0 "Testing for success of the testcases" $RC + rlAssertNotEquals "Testing for segfault (bug 464146)" $RC 139 + rlAssertEquals "Testing for correct output - output should contain 1 line" `cat $output | wc -l` 1 + cat $output > /tmp/mineminemine + rlAssertGrep "received \"Hello World\!\"" /tmp/mineminemine +rlPhaseEnd + +###################### +# Clean after the test +###################### +rlPhaseStartCleanup Clean-Up + rlRun "rm -f $output testit" + rlCreateLogFromJournal > ${OUTPUTFILE} + rlCompareJournalWithRCW +rlPhaseEnd + + diff --git a/tests/Regression/bz464146-sp-corruption/testit.c b/tests/Regression/bz464146-sp-corruption/testit.c new file mode 100644 index 0000000..54bf74b --- /dev/null +++ b/tests/Regression/bz464146-sp-corruption/testit.c @@ -0,0 +1,172 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +/* +In an attempt to situate a stack frame over a 4GB boundary, we +first create a memory region which spans that boundary. The +boundary which we are trying to span is arbitrarily chosen, +just make sure does not intersect with a region already in use. +*/ + +#define TARGET_BOUNDARY 0x3f600000000 +#define MEM_REGION_SIZE 0x200000 +#define MEM_REGION_START (TARGET_BOUNDARY - (MEM_REGION_SIZE/2)) +#define KLUDGE_SPACE (-0x6e68) + +int proto_tcp; +int port; + +void *receiver(void *); +void *sender(void *); + +main(argc,argv) +int argc; +char *argv[]; +{ + pthread_t server; + pthread_t client; + struct protoent *pe; + void *stack_region; + int ret; + + void *stack_addr=(void *)(TARGET_BOUNDARY+KLUDGE_SPACE); + size_t stack_size = 2 * PTHREAD_STACK_MIN; + pthread_attr_t attr; + + + /* set TCP port and protocol number */ + if (argc != 2 ) port=1027; + else port = atoi(argv[1]); + + pe = getprotobyname("tcp"); + proto_tcp=pe->p_proto; + + + if (pthread_attr_init(&attr) < 0) { + perror("pthread_attr_init\n"); + exit(1); + } + + /* creating the memory region */ + stack_region=mmap((void *)MEM_REGION_START, + MEM_REGION_SIZE, PROT_READ|PROT_WRITE, + MAP_PRIVATE | MAP_ANON, (-1), 0); + if (stack_region == MAP_FAILED) { + perror("mmap\n"); + exit(1); + } + + if (pthread_create(&server, NULL , sender, NULL) != 0){ + perror("pthread_create 1"); + exit(1); + } + + + if ((ret=pthread_attr_setstack(&attr,stack_addr,stack_size))!=0) + { + perror("pthread_attr_setstack"); + printf("ret = %d\n",ret); + exit(1); + } + + if ((ret=pthread_create(&client, &attr, receiver, NULL)) != 0){ + printf("pthread_create2 failed with %d\n",ret); + exit(1); + } + + pthread_join(server, NULL); + pthread_join(client, NULL); + + exit(0); +} + + +void *sender(void *context){ + int ret; + int sfd; /* socket descriptor */ + int cfd; /* connection descriptor */ + struct sockaddr_in addr; + char *p; + char buffer[] = "Hello World!"; + + if ((sfd = socket(PF_INET, SOCK_STREAM, proto_tcp)) < 0 ) { + perror("sender socket\n"); + return(NULL); + } + + addr.sin_family=AF_INET; + addr.sin_port=htons(port); + p=(gethostbyname("localhost")->h_addr_list[0]); + memcpy(&(addr.sin_addr.s_addr),p,sizeof(p)); + + if (bind(sfd, (struct sockaddr*)&addr, sizeof addr) < 0) { + perror("sender bind\n"); + return(NULL); + } + + if (listen(sfd, 1) == -1){ + perror("sender listen\n"); + return(NULL); + } + + cfd = accept(sfd, NULL, NULL); + if (cfd < 0 ) + { + perror("accept\n"); + return(NULL); + } + + if(send(cfd, (void*) buffer, sizeof(buffer), MSG_NOSIGNAL) == -1){ + perror("send"); + return(NULL); + } + + shutdown(cfd, SHUT_RDWR); + + return(NULL); +} + +void *receiver(void *context){ + + char buf[100]; + int sfd; + struct sockaddr_in addr; + char *p; + ssize_t ret; + + addr.sin_family=AF_INET; + addr.sin_port=htons(port); + p=(gethostbyname("localhost")->h_addr_list[0]); + memcpy(&(addr.sin_addr.s_addr),p,sizeof(p)); + + sleep(1); + + if ((sfd = socket(PF_INET, SOCK_STREAM, proto_tcp)) < 0 ) { + perror("receiver socket\n"); + return(NULL); + } + + if(connect(sfd, (struct sockaddr*)&addr, sizeof addr) == -1){ + perror("connect\n"); + return(NULL); + } + + if ((ret = recv(sfd, (void*)buf, sizeof(buf), MSG_WAITALL))<0) { + perror("recv"); + return(NULL); + } + + buf[ret]='\0'; + printf("received \"%s\"\n",buf); + + shutdown(sfd, SHUT_RDWR); + + return(NULL); +} diff --git a/tests/Regression/bz471298-pthread_cond/Makefile b/tests/Regression/bz471298-pthread_cond/Makefile new file mode 100644 index 0000000..0760835 --- /dev/null +++ b/tests/Regression/bz471298-pthread_cond/Makefile @@ -0,0 +1,64 @@ +# Makefile - bz471298-pthread_cond - Bugzilla(s) 471298 +# Author: Petr Muller +# Location: /tools/glibc/Regression/bz471298-pthread_cond/Makefile + +# Description: Contains one simple testcase, hanging when exhibiting the bug + +# Copyright (c) 2008 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 v.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. + + + +TOPLEVEL_NAMESPACE=/tools +PACKAGE_NAME=glibc +RELATIVE_PATH=Regression/bz471298-pthread_cond + +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE pthread_cond_test.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + + +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Contains one simple testcase, hanging when exhibiting the bug" >> $(METADATA) + @echo "Bug: 471298" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Releases: -RHEL2.1 -RHEL3 -RHEL4" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz471298-pthread_cond/PURPOSE b/tests/Regression/bz471298-pthread_cond/PURPOSE new file mode 100644 index 0000000..a82fbca --- /dev/null +++ b/tests/Regression/bz471298-pthread_cond/PURPOSE @@ -0,0 +1,10 @@ +Test Name: bz471298-pthread_cond - Bugzilla(s) 471298 +Author: Petr Muller +Location: /tools/glibc/Regression/bz471298-pthread_cond + +Short Description: Contains one simple testcase, hanging when exhibiting the bug + + +Long Description: + +Contains one simple testcase, hanging when exhibiting the bug diff --git a/tests/Regression/bz471298-pthread_cond/main.fmf b/tests/Regression/bz471298-pthread_cond/main.fmf new file mode 100644 index 0000000..8c75741 --- /dev/null +++ b/tests/Regression/bz471298-pthread_cond/main.fmf @@ -0,0 +1,25 @@ +summary: Contains one simple testcase, hanging when exhibiting the bug +description: | + Test Name: bz471298-pthread_cond - Bugzilla(s) 471298 + Author: Petr Muller + Location: /tools/glibc/Regression/bz471298-pthread_cond + + Short Description: Contains one simple testcase, hanging when exhibiting the bug + + + Long Description: + + Contains one simple testcase, hanging when exhibiting the bug +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - gcc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=471298 +extra-summary: /tools/glibc/Regression/bz471298-pthread_cond +extra-task: /tools/glibc/Regression/bz471298-pthread_cond diff --git a/tests/Regression/bz471298-pthread_cond/pthread_cond_test.c b/tests/Regression/bz471298-pthread_cond/pthread_cond_test.c new file mode 100644 index 0000000..08c96b1 --- /dev/null +++ b/tests/Regression/bz471298-pthread_cond/pthread_cond_test.c @@ -0,0 +1,240 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define PTHREAD_MUTEX_DEFAULT 0 +#define PTS_FAIL 1 + +/* The shared data */ +typedef struct +{ + int count; /* number of children currently waiting */ + pthread_cond_t cnd; + pthread_mutex_t mtx; + int predicate; /* Boolean associated to the condvar */ + clockid_t cid; /* clock used in the condvar */ + char fork; /* the children are processes */ +} testdata_t; + +testdata_t * td; + +int child(int arg); + +int main (int argc, char * argv[]) +{ + int ret; + + pthread_mutexattr_t ma; + pthread_condattr_t ca; + + pid_t pid, p_child; + int ch; + int status; + + pthread_t t_timer; + + char filename[] = "/tmp/cond_wait_stress-XXXXXX"; + size_t sz, ps; + void * mmaped; + int fd; + char * tmp; + + fd = mkstemp(filename); + if (fd < 0) { + perror("mkstemp"); + exit(EXIT_FAILURE); + } + unlink(filename); + + ps = (size_t)sysconf(_SC_PAGESIZE); + sz = ((sizeof(testdata_t) / ps) + 1) * ps; /* # pages needed to store the testdata */ + tmp = calloc( 1 , sz); + + if (tmp == NULL) { + perror("calloc"); + exit(EXIT_FAILURE); + } + + if (write (fd, tmp, sz) != (ssize_t) sz) { + perror("write"); + exit(EXIT_FAILURE); + } + + mmaped = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (mmaped == MAP_FAILED) { + perror("mmap"); + exit(EXIT_FAILURE); + } + td = (testdata_t *) mmaped; + memset(td, 0, sizeof(testdata_t)); + free(tmp); + + /* mutexattr & condattr init */ + ret = pthread_mutexattr_init(&ma); + if (ret != 0) { + perror("pthread_mutexattr_init"); + exit(EXIT_FAILURE); + } + ret = pthread_condattr_init(&ca); + if (ret != 0) { + perror("pthread_condattr_init"); + exit(EXIT_FAILURE); + } + + + ret = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_DEFAULT); + if (ret != 0) { + perror("pthread_mutexattr_settype"); + exit(EXIT_FAILURE); + } + + /* Set "PTHREAD_PROCESS_SHARED" */ + ret = pthread_mutexattr_setpshared(&ma, PTHREAD_PROCESS_SHARED); + if(ret != 0) { + perror("pthread_mutexattr_setpshared"); + exit(EXIT_FAILURE); + } + ret = pthread_condattr_setpshared(&ca, PTHREAD_PROCESS_SHARED); + if(ret != 0) { + perror("pthread_condattr_setpshared"); + exit(EXIT_FAILURE); + } + + + /* Set "CLOCK_MONOTONIC" */ + ret = pthread_condattr_setclock(&ca, CLOCK_MONOTONIC); + if(ret != 0) { + perror("pthread_condattr_setclock"); + exit(EXIT_FAILURE); + } + ret = pthread_condattr_getclock(&ca, &td->cid); + if(ret != 0) { + perror("pthread_condattr_getclock"); + exit(EXIT_FAILURE); + } + + + ret = pthread_cond_init(&td->cnd, &ca); + if(ret != 0) { + perror("pthread_cond_init"); + exit(EXIT_FAILURE); + } + ret = pthread_mutex_init(&td->mtx, &ma); + if(ret != 0) { + perror("pthread_mutex_init"); + exit(EXIT_FAILURE); + } + + ret = pthread_condattr_destroy(&ca); + if (ret != 0) { + perror("pthread_condattr_destroy"); + exit(EXIT_FAILURE); + } + ret = pthread_mutexattr_destroy(&ma); + if (ret != 0) { + perror("pthread_condattr_destroy"); + exit(EXIT_FAILURE); + } + + td->fork = 1; + p_child = fork(); + if (p_child < 0) { + perror("fork"); + exit(EXIT_FAILURE); + } + + if (p_child == 0) { + /* child process */ + child(0); + exit(EXIT_SUCCESS); + } + + + /* Parent process */ + + ret = pthread_mutex_lock(&td->mtx); + if (ret != 0) { + perror("pthread_mutex_lock"); + exit(EXIT_FAILURE); + } + + ch = td->count; + + ret = pthread_mutex_unlock(&td->mtx); + if (ret != 0) { + perror("pthread_mutex_unlock"); + exit(EXIT_FAILURE); + } + + sleep(5); + + ret = pthread_mutex_lock(&td->mtx); + if (ret != 0) { + perror("pthread_mutex_lock"); + exit(EXIT_FAILURE); + } + + td->predicate=1; + ret = pthread_cond_signal(&td->cnd); + printf("parent: pthread_cond_signal\n"); + if (ret != 0) { + perror("pthread_cond_signal"); + exit(EXIT_FAILURE); + } + + ret = pthread_mutex_unlock(&td->mtx); + if (ret != 0) { + perror("pthread_mutex_unlock"); + exit(EXIT_FAILURE); + } + + pid = waitpid(p_child, &status, 0); + if(pid != p_child) { + perror("waitpid"); + exit(EXIT_FAILURE); + } + + ret = pthread_cond_destroy(&td->cnd); + if (ret != 0) { + perror("pthread_cond_destroy"); + exit(EXIT_FAILURE); + } + ret = pthread_mutex_destroy(&td->mtx); + if (ret != 0) { + perror("pthread_mutex_destroy"); + exit(EXIT_FAILURE); + } + + return 0; +} + +int child(int arg) +{ + int ret=0; + struct timespec ts; + + /* lock the mutex */ + ret = pthread_mutex_lock(&td->mtx); + + printf("child: pthread_cond_wait\n"); + + do { + /* Wait while the predicate is false */ + ret = pthread_cond_wait(&td->cnd, &td->mtx); + } while ((ret == 0) && (td->predicate==0)); + + + ret = pthread_cond_signal(&td->cnd); + ret = pthread_mutex_unlock(&td->mtx); + + return 0; +} diff --git a/tests/Regression/bz471298-pthread_cond/runtest.sh b/tests/Regression/bz471298-pthread_cond/runtest.sh new file mode 100755 index 0000000..a5cc1ce --- /dev/null +++ b/tests/Regression/bz471298-pthread_cond/runtest.sh @@ -0,0 +1,46 @@ +# runtest.sh - bz471298-pthread_cond - Bugzilla(s) 471298 +# Author: Petr Muller +# Location: /tools/glibc/Regression/bz471298-pthread_cond/runtest.sh + +# Description: Contains one simple testcase, hanging when exhibiting the bug + +# Copyright (c) 2008 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 v.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. + + +PACKAGE=glibc + +# Include rhts environment +rpm -Uvh http://nest.test.redhat.com/mnt/qa/scratch/pmuller/rhtslib/rhtslib.rpm +. /usr/share/beakerlib/beakerlib.sh || exit 1 +rlStartJournal + +rlPhaseStartSetup Preparation + rlAssertRpm ${PACKAGE} + rlRun 'gcc -lpthread -lrt pthread_cond_test.c -o pthread_test' 0 "Comnpiling the testcase" +rlPhaseEnd + +###################### +# Begin Test-Case +###################### +rlPhaseStartTest Test + rlWatchdog './pthread_test' 10 + rlAssert0 "Checking if the command had to be killed (bug 471298)" $? +rlPhaseEnd + +###################### +# Clean after the test +###################### +rlPhaseStartCleanup Clean-Up + rlRun "rm -f pthread_test" 0 "Cleaning up the executable" +rlPhaseEnd diff --git a/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/Makefile b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/Makefile new file mode 100644 index 0000000..58011ea --- /dev/null +++ b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len +# Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE optinit.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 488748" >> $(METADATA) + @echo "Release: -RHEL4" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/PURPOSE b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/PURPOSE new file mode 100644 index 0000000..5603ef1 --- /dev/null +++ b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/PURPOSE @@ -0,0 +1,9 @@ +PURPOSE of /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len +Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header) +Author: Petr Muller +Bug summary: [RHEL5] inet6_opt_init() sets incorrect header extension length +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=488748 + +Description: + +Escalated to Bugzilla from IssueTracker diff --git a/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/main.fmf b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/main.fmf new file mode 100644 index 0000000..8dcda7d --- /dev/null +++ b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/main.fmf @@ -0,0 +1,20 @@ +summary: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header) +description: | + Bug summary: [RHEL5] inet6_opt_init() sets incorrect header extension length + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=488748 + + Description: + + Escalated to Bugzilla from IssueTracker +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=488748 +extra-summary: /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len +extra-task: /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len diff --git a/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/optinit.c b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/optinit.c new file mode 100644 index 0000000..f1de8f7 --- /dev/null +++ b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/optinit.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include + +#define LEN 16 +#define OPT_LEN(len) ((len - 8) >> 3) + +int main(int argc, char **argv) { + char extbuf[LEN], cbuf[LEN]; + int extlen; + uint8_t *len; + + memset(extbuf, 0, sizeof(extbuf)); + memset(cbuf, 0, sizeof(cbuf)); + len = (uint8_t *)(extbuf + 1); + + printf("== calculate the needed buffer size if extlen is: %d ==\n",LEN); + extlen = inet6_opt_init(extbuf, LEN); + if (extlen != 2) { + printf("ERROR: return invalid length %d, expect:2 \n", extlen); + printf("<=====NG=====>\n"); + exit(1); + } + + if (*len != OPT_LEN(LEN)) { + printf("ERROR: the length field of extension header is invalid, length %d, expect:%d \n", + *len, OPT_LEN(LEN)); + printf("<=====NG=====>\n"); + exit(1); + } + + printf("OK\n"); + return 0; +} diff --git a/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/runtest.sh b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/runtest.sh new file mode 100755 index 0000000..44962e1 --- /dev/null +++ b/tests/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len/runtest.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# vim: dict=/usr/lib/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len +# Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart +rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun 'gcc optinit.c -o optinit' 0 "Compiling the testcase" +rlPhaseEnd + +rlPhaseStartTest + rlRun "./optinit" 0 "Running the testcase" +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f optinit" +rlPhaseEnd +rlJournalEnd diff --git a/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/Makefile b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/Makefile new file mode 100644 index 0000000..65df609 --- /dev/null +++ b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/Makefile @@ -0,0 +1,66 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system +# Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE priv-mutex.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Requires: strace" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 495955" >> $(METADATA) + @echo "Releases: -RHEL3 -RHEL4" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/PURPOSE b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/PURPOSE new file mode 100644 index 0000000..89a880d --- /dev/null +++ b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/PURPOSE @@ -0,0 +1,46 @@ +PURPOSE of /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system +Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system) +Author: Petr Muller +Bug summary: [RHEL5] glibc doesn't use private futex system calls for pthread_mutex calls +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=495955 + +Description: + +Created an attachment (id=339722) +private mutex test case + +As I understand it, RHEL 5.3 is supposed to have pulled in the change to use PTHREAD_PROCESS_PRIVATE by default with the various pthread_mutex calls. While testing my recent requeue_pi code, I was seeing some unexpected behaviour on RHEL5.3 that didn't occur on FC10. Specifically, regardless of what I set the mutexattr pshared attribute to, glibc would make the shared versions of the futex calls. I've written the attached testcase to illustrate. It creates a PI mutex, and will set the pshared attribute to whatever you specify in the options, or use the OS default if you use no options. Using strace -f you can see which futex syscalls glibc used. + +Compile with: +# gcc -lrt -lpthread priv-mutex.c -o priv-mutex + +Note: the ETIMEDOUT is intentional in the output below. + +On Fedora Core 10 with glibc 2.9: + +Default is private: +[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI +[pid 13433] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out) + +Specifying private works: +[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI +[pid 13437] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out) + +Specifying shared works: +[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI +[pid 13441] futex(0x6015e0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) + + +On RHEL5.3: + +Default uses shared (I expected private here): +[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI +[pid 9051] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) + +Setting PTHREAD_PROCESS_PRIVATE has no effect: +[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI +[pid 9055] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) + +Specifying shared works as expected: +[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI +[pid 9059] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) diff --git a/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/main.fmf b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/main.fmf new file mode 100644 index 0000000..8fc25dd --- /dev/null +++ b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/main.fmf @@ -0,0 +1,58 @@ +summary: Test for bz495955 ([RHEL5] glibc doesn't use private futex system) +description: | + Bug summary: [RHEL5] glibc doesn't use private futex system calls for pthread_mutex calls + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=495955 + + Description: + + Created an attachment (id=339722) + private mutex test case + + As I understand it, RHEL 5.3 is supposed to have pulled in the change to use PTHREAD_PROCESS_PRIVATE by default with the various pthread_mutex calls. While testing my recent requeue_pi code, I was seeing some unexpected behaviour on RHEL5.3 that didn't occur on FC10. Specifically, regardless of what I set the mutexattr pshared attribute to, glibc would make the shared versions of the futex calls. I've written the attached testcase to illustrate. It creates a PI mutex, and will set the pshared attribute to whatever you specify in the options, or use the OS default if you use no options. Using strace -f you can see which futex syscalls glibc used. + + Compile with: + # gcc -lrt -lpthread priv-mutex.c -o priv-mutex + + Note: the ETIMEDOUT is intentional in the output below. + + On Fedora Core 10 with glibc 2.9: + + Default is private: + [root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI + [pid 13433] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out) + + Specifying private works: + [root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI + [pid 13437] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out) + + Specifying shared works: + [root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI + [pid 13441] futex(0x6015e0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) + + + On RHEL5.3: + + Default uses shared (I expected private here): + [root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI + [pid 9051] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) + + Setting PTHREAD_PROCESS_PRIVATE has no effect: + [root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI + [pid 9055] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) + + Specifying shared works as expected: + [root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI + [pid 9059] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out) +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - strace +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=495955 +extra-summary: /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system +extra-task: /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system diff --git a/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/priv-mutex.c b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/priv-mutex.c new file mode 100644 index 0000000..733830a --- /dev/null +++ b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/priv-mutex.c @@ -0,0 +1,181 @@ +/****************************************************************************** + * + * Copyright © International Business Machines Corp., 2009 + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * NAME + * priv-mutex.c + * + * DESCRIPTION + * Test the shared and private settings of pthread mutexes. + * + * USAGE: + * priv-mutex [-p][-s] + * + * AUTHOR + * Darren Hart + * + * HISTORY + * 2009-Apr-9: Initial version by Darren Hart + * + *****************************************************************************/ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#define MUTEX_PSHARED_FLAG 128 +#define MUTEX_PI_FLAG 32 + +pthread_mutex_t mutex; +pthread_barrier_t lock_barrier; +pthread_barrier_t unlock_barrier; + +void usage(char *arg0) +{ + printf("usage: %s [-p][-s]\n"); + printf("-p: use private mutexes\n"); + printf("-s: use shared mutexes\n"); + printf("no args: use system default\n"); +} + +void *lock_thread(void *arg) +{ + int ret; + if (pthread_mutex_lock(&mutex)) + { + perror("lock_thread failed to acquire the lock"); + return NULL; + } + /* Let the main thread know we took the lock. */ + ret = pthread_barrier_wait(&lock_barrier); + if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) { + perror("pthread_barrier_wait failed"); + return NULL; + } + /* Wait for the main thread to timeout trying to get the lock. */ + ret = pthread_barrier_wait(&unlock_barrier); + if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) { + perror("pthread_barrier_wait failed"); + return NULL; + } + if (pthread_mutex_unlock(&mutex)) + { + perror("main failed to release the lock"); + return NULL; + } + pthread_exit(0); +} + +int main(int argc, char *argv[]) +{ + int opt, pshared, child_ret, set_pshared = 0, ret = 0; + pthread_mutexattr_t attr; + struct timespec timeout; + pthread_t child; + + while ((opt = getopt(argc, argv, "ps")) != -1) { + switch (opt) { + case 'p': + pshared = PTHREAD_PROCESS_PRIVATE; + set_pshared = 1; + break; + case 's': + pshared = PTHREAD_PROCESS_SHARED; + set_pshared = 1; + break; + default: + usage(argv[0]); + return -1; + } + } + + /* Setup the mutex. */ + if (pthread_mutexattr_init(&attr)) { + perror("pthread_mutexattr_init failed"); + return -1; + } + if (pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) { + perror("pthread_mutexattr_setprotocol failed"); + return -1; + } + if (set_pshared) { + if (pthread_mutexattr_setpshared(&attr, pshared)) { + perror("pthread_mutexattr_setpshared failed"); + return -1; + } + } + if (pthread_mutex_init(&mutex, &attr)) { + perror("pthread_mutex_init failed"); + return -1; + } + + printf("Using %s mutexes\n", mutex.__data.__kind & MUTEX_PSHARED_FLAG ? + "PTHREAD_PROCESS_SHARED" : "PTHREAD_PROCESS_PRIVATE"); + + + /* Setup the barriers. */ + if (pthread_barrier_init(&lock_barrier, NULL, 2)) { + perror("failed to create lock_barrier"); + return -1; + } + if (pthread_barrier_init(&unlock_barrier, NULL, 2)) { + perror("failed to create lock_barrier"); + return -1; + } + + /* + * Spawn a thread to grab the lock and then try to grab it here, + * forcing glibc to make the appropriate futex system-call. + */ + if (pthread_create(&child, NULL, lock_thread, NULL)) { + perror("failed to create child thread"); + return -1; + } + ret = pthread_barrier_wait(&lock_barrier); + if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) { + perror("pthread_barrier_wait failed"); + return -1; + } + timeout.tv_sec = 0; + timeout.tv_nsec = 100000; + ret = pthread_mutex_timedlock(&mutex, &timeout); + if (ret && ret != ETIMEDOUT) { + perror("main failed to acquire the lock"); + return -1; + } + ret = pthread_barrier_wait(&unlock_barrier); + if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) { + perror("pthread_barrier_wait failed"); + return -1; + } + pthread_join(child, NULL); + + + /* Cleanup */ + if (pthread_mutex_destroy(&mutex)) { + perror("pthread_mutex_destroy failed"); + ret = -1; + } + if (pthread_mutexattr_destroy(&attr)) { + perror("pthread_mutexattr_destroy failed"); + ret = -1; + } + return ret; +} diff --git a/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/runtest.sh b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/runtest.sh new file mode 100755 index 0000000..feead28 --- /dev/null +++ b/tests/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system +# Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart +rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "gcc -lrt -lpthread priv-mutex.c -o priv-mutex" 0 "Compiling the testcase" +rlPhaseEnd + +rlPhaseStartTest + rlLog "Checking for the default: should be using PRIVATE_PI" + strace -f ./priv-mutex 2>&1 | grep FUTEX_LOCK_PI_PRIVATE + rlAssert0 "Checking that FUTEX_LOCK_PI_PRIVATE was in the output" $? + + rlLog "Checking for using PRIVATE_PI when asked for it" + strace -f ./priv-mutex -p 2>&1 | grep FUTEX_LOCK_PI_PRIVATE + rlAssert0 "Checking that FUTEX_LOCK_PI_PRIVATE was in the output" $? + + rlLog "Checking for using SHARED_PI when asked for it" + strace -f ./priv-mutex -s 2>&1 | grep "FUTEX_LOCK_PI," + rlAssert0 "Checking that just FUTEX_LOCK_PI was in the output" $? +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f priv-mutex" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/Makefile b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/Makefile new file mode 100644 index 0000000..23c4235 --- /dev/null +++ b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME +# Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE function-nodename-servname-null.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 501595" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/PURPOSE b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/PURPOSE new file mode 100644 index 0000000..8c135e6 --- /dev/null +++ b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/PURPOSE @@ -0,0 +1,48 @@ +PURPOSE of /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME +Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME) +Author: Petr Muller +Bug summary: [RHEL4] getnameinfo() should return EAI_NONAME when both nodename and servname are set to null and flag is set to NI_NAMEREQD +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=501595 + +Description: + ++++ This bug was initially created as a clone of Bug #489419 +++ + +Description of Problem: +glibc getnameinfo() returns 0 when both nodename and servname are set to null and flag is set to 'NI_NAMEREQD'. + +The synopsis of function getnameinfo is: + int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_t nodelen, char *service, socklen_t servicelen, int flags); + +RFC3493 tells that getnameinfo() should returns 'EAI_NONAME' when both nodename and servname are null. So when use getnameinfo() with both nodename and servname are null and the NI_NAMEREQD flag is set, glibc should return 'EAI_NONAME' rather than 0. + + +Version-Release number of selected component: +glibc-2.3.4-2.43 + + +How reproducible: +every time + + +Step to Reproduce: +1. gcc function-nodename-servname-null.c +2. ./a.out + + +Actual Results: +# ./a.out +==Both nodename and servname are null if the NI_NAMEREQD flag is set== +ERROR:return 0, expect error EAI_NONAME +<=== NG ===> + + +Expected Results: +# ./a.out +==Both nodename and servname are null if the NI_NAMEREQD flag is set== +<=== OK ===> + + +Additional Info: +Upstream patch: +http://sourceware.org/cgi-bin/cvsweb.cgi/libc/inet/getnameinfo.c.diff?r1=1.36&r2=1.37&cvsroot=glibc diff --git a/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/function-nodename-servname-null.c b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/function-nodename-servname-null.c new file mode 100644 index 0000000..d389936 --- /dev/null +++ b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/function-nodename-servname-null.c @@ -0,0 +1,33 @@ + +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + struct sockaddr_in6 addr6; + socklen_t size = sizeof(addr6); + int ret; + + memset(&addr6, 0, size); + addr6.sin6_family = AF_INET6; + addr6.sin6_port = 0; + addr6.sin6_addr = in6addr_loopback; + + printf("==Both nodename and servname are null if the NI_NAMEREQD flag is set==\n"); + ret = getnameinfo((struct sockaddr *) &addr6, size, NULL, 0, NULL, 0, NI_NAMEREQD); + if(ret != EAI_NONAME) + { + printf("ERROR:return %d, expect error EAI_NONAME\n", ret); + printf("<=== NG ===>\n"); + exit(1); + } + + printf("<=== OK ===>\n"); + + return 0; +} diff --git a/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/main.fmf b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/main.fmf new file mode 100644 index 0000000..4599d31 --- /dev/null +++ b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/main.fmf @@ -0,0 +1,59 @@ +summary: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME) +description: | + Bug summary: [RHEL4] getnameinfo() should return EAI_NONAME when both nodename and servname are set to null and flag is set to NI_NAMEREQD + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=501595 + + Description: + + +++ This bug was initially created as a clone of Bug #489419 +++ + + Description of Problem: + glibc getnameinfo() returns 0 when both nodename and servname are set to null and flag is set to 'NI_NAMEREQD'. + + The synopsis of function getnameinfo is: + int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_t nodelen, char *service, socklen_t servicelen, int flags); + + RFC3493 tells that getnameinfo() should returns 'EAI_NONAME' when both nodename and servname are null. So when use getnameinfo() with both nodename and servname are null and the NI_NAMEREQD flag is set, glibc should return 'EAI_NONAME' rather than 0. + + + Version-Release number of selected component: + glibc-2.3.4-2.43 + + + How reproducible: + every time + + + Step to Reproduce: + 1. gcc function-nodename-servname-null.c + 2. ./a.out + + + Actual Results: + # ./a.out + ==Both nodename and servname are null if the NI_NAMEREQD flag is set== + ERROR:return 0, expect error EAI_NONAME + <=== NG ===> + + + Expected Results: + # ./a.out + ==Both nodename and servname are null if the NI_NAMEREQD flag is set== + <=== OK ===> + + + Additional Info: + Upstream patch: + http://sourceware.org/cgi-bin/cvsweb.cgi/libc/inet/getnameinfo.c.diff?r1=1.36&r2=1.37&cvsroot=glibc +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=501595 +extra-summary: /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME +extra-task: /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME diff --git a/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/runtest.sh b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/runtest.sh new file mode 100755 index 0000000..3cdccd6 --- /dev/null +++ b/tests/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME/runtest.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME +# Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh + +PACKAGE="glibc" + +rlJournalStart + +rlPhaseStartSetup + rlRun "gcc function-nodename-servname-null.c -o repro" +rlPhaseEnd + +rlPhaseStartTest + rlRun "./repro" +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f repro" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/Makefile b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/Makefile new file mode 100644 index 0000000..5cff447 --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases +# Description: Test for bz503723 (fopen mode 'x' ignored in some cases) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE fopen.c expected.py2 expected.py3 + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz503723 (fopen mode 'x' ignored in some cases)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 90m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc perl strace python python3 python38" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 503723" >> $(METADATA) + @echo "Releases: -RHEL4" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/PURPOSE b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/PURPOSE new file mode 100644 index 0000000..a3bbae3 --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/PURPOSE @@ -0,0 +1,38 @@ +PURPOSE of /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases +Description: Test for bz503723 (fopen mode 'x' ignored in some cases) +Author: Petr Muller +Bug summary: fopen mode 'x' ignored in some cases +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=503723 + +Description: + +Created an attachment (id=346240) +fopen.c - test for fopen modes + +Description of problem: +O_EXCL is not used if mode is "wbex", but O_EXCL is used if mode is "wbxe". + +This bug can cause security vulnerabilities in software relying on this glibc extension. + +Version-Release number of selected component (if applicable): +2.10.1-2, 2.9.90-3 + +How reproducible: +always + +Steps to Reproduce: +1. compile attached C source file +2. run with options ababab wbex, and ababab wbxe +3. + +Actual results: +'x' may be ignored + +Expected results: +'x' not ignored + +Additional info: +$ strace -eopen ./a.out ababab wbxe 2>&1 | grep ababab ; rm -f ababab +open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0666) = 3 +$ strace -eopen ./a.out ababab wbex 2>&1 | grep ababab ; rm -f ababab +open("ababab", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3 diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py2 b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py2 new file mode 100755 index 0000000..742fc77 --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py2 @@ -0,0 +1,109 @@ +#!/usr/bin/python + +exists = { 'r' : 'open("ababab", O_RDONLY) = 3', + 'rx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'rm' : 'open("ababab", O_RDONLY) = 3', + 'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'rc' : 'open("ababab", O_RDONLY) = 3', + 'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'rcm' : 'open("ababab", O_RDONLY) = 3', + 'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'r+' : 'open("ababab", O_RDWR) = 3', + 'r+x' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'r+m' : 'open("ababab", O_RDWR) = 3', + 'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'r+c' : 'open("ababab", O_RDWR) = 3', + 'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'r+cm' : 'open("ababab", O_RDWR) = 3', + 'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', } + +nexists= { 'r' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'rm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'rc' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'rcm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+x' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+m' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+c' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+cm' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', } + +import sys + +var = sys.argv[1] +what = sys.argv[2] + +if var == "ex": + print exists[what] +elif var == "nex": + print nexists[what] diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py3 b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py3 new file mode 100755 index 0000000..9180657 --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py3 @@ -0,0 +1,109 @@ +#!/usr/bin/python3 + +exists = { 'r' : 'open("ababab", O_RDONLY) = 3', + 'rx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'rm' : 'open("ababab", O_RDONLY) = 3', + 'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'rc' : 'open("ababab", O_RDONLY) = 3', + 'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'rcm' : 'open("ababab", O_RDONLY) = 3', + 'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3', + 'r+' : 'open("ababab", O_RDWR) = 3', + 'r+x' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'r+m' : 'open("ababab", O_RDWR) = 3', + 'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'r+c' : 'open("ababab", O_RDWR) = 3', + 'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'r+cm' : 'open("ababab", O_RDWR) = 3', + 'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = 3', + 'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)', + 'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', + 'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', } + +nexists= { 'r' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'rm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'rc' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'rcm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)', + 'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+x' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+m' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+c' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'r+cm' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)', + 'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)', + 'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3', + 'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3', + 'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3', + 'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3', + 'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', + 'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3', + 'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', } + +import sys + +var = sys.argv[1] +what = sys.argv[2] + +if var == "ex": + print (exists[what]) +elif var == "nex": + print (nexists[what]) diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/fopen.c b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/fopen.c new file mode 100644 index 0000000..c39d30b --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/fopen.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + FILE* f; + + if (argc != 3) return 1; + + f = fopen (argv[1], argv[2]); + if (f == NULL) { + return 1; + } + if (fclose (f)) { + return 1; + } + + return 0; +} + diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/main.fmf b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/main.fmf new file mode 100644 index 0000000..ad867f2 --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/main.fmf @@ -0,0 +1,54 @@ +summary: Test for bz503723 (fopen mode 'x' ignored in some cases) +description: | + Bug summary: fopen mode 'x' ignored in some cases + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=503723 + + Description: + + Created an attachment (id=346240) + fopen.c - test for fopen modes + + Description of problem: + O_EXCL is not used if mode is "wbex", but O_EXCL is used if mode is "wbxe". + + This bug can cause security vulnerabilities in software relying on this glibc extension. + + Version-Release number of selected component (if applicable): + 2.10.1-2, 2.9.90-3 + + How reproducible: + always + + Steps to Reproduce: + 1. compile attached C source file + 2. run with options ababab wbex, and ababab wbxe + 3. + + Actual results: + 'x' may be ignored + + Expected results: + 'x' not ignored + + Additional info: + $ strace -eopen ./a.out ababab wbxe 2>&1 | grep ababab ; rm -f ababab + open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0666) = 3 + $ strace -eopen ./a.out ababab wbex 2>&1 | grep ababab ; rm -f ababab + open("ababab", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3 +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - perl + - strace + - python + - python3 + - python38 +duration: 90m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=503723 +extra-summary: /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases +extra-task: /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases diff --git a/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/runtest.sh b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/runtest.sh new file mode 100755 index 0000000..937ff43 --- /dev/null +++ b/tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/runtest.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases +# Description: Test for bz503723 (fopen mode 'x' ignored in some cases) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart +rlPhaseStartSetup + rlAssertRpm $PACKAGE + if rlIsRHEL ">=8" || rlIsFedora + then + rlRun -c "cp expected.py3 expected.py" + else + rlRun -c "cp expected.py2 expected.py" + fi + rlAssertExists "expected.py" + rlRun "gcc fopen.c -o fopen" +rlPhaseEnd + +rlPhaseStartTest "Testing modes on existing file" + rlLog "Trying all variants of modes in open" + rlRun "touch ababab" 0 "Creating a test file" + for mode in "r" "r+" "w" "w+" "a" "a+" + do + for f in "" "c" + do + for s in "" "m" + do + for t in "" "x" + do + golden="`./expected.py ex $mode$f$s$t | tr --squeeze ' '`" + for variant in "$mode$f$s$t" "$mode$f$t$s" "$mode$s$f$t" "$mode$s$t$f" "$mode$t$f$s" "$mode$t$s$f" + do + try="`strace -e open,openat ./fopen ababab $variant 2>&1 | grep ababab | tr --squeeze ' ' | perl -pe 's/openat\(AT_FDCWD, /open\(/'`" + echo $try + rlAssertEquals "Checking mode [$variant] is identical to golden [$mode$f$s$t]" "$golden" "$try" + done + done + done + done + done +rlPhaseEnd + +rlPhaseStartTest "Testing modes on nonexisting file" + rlLog "Trying all variants of modes in open" + + for mode in "r" "r+" "w" "w+" "a" "a+" + do + for f in "" "c" + do + for s in "" "m" + do + for t in "" "x" + do + golden="`./expected.py nex $mode$f$s$t | tr --squeeze ' '`" + for variant in "$mode$f$s$t" "$mode$f$t$s" "$mode$s$f$t" "$mode$s$t$f" "$mode$t$f$s" "$mode$t$s$f" + do + rlRun "rm -f ababab" + try="`strace -e open,openat ./fopen ababab $variant 2>&1 | grep ababab | tr --squeeze ' ' | perl -pe 's/openat\(AT_FDCWD, /open\(/'`" + echo $try + rlAssertEquals "Checking mode [$variant] is identical to golden [$mode$f$s$t]" "$golden" "$try" + done + done + done + done + done +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f fopen" + rlRun "rm -f ababab" + rlRun "rm expected.py" +rlPhaseEnd +rlJournalEnd diff --git a/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/Makefile b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/Makefile new file mode 100644 index 0000000..1443a2b --- /dev/null +++ b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid +# Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid()) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE reproducer.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid())" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 75m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 522528" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/PURPOSE b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/PURPOSE new file mode 100644 index 0000000..94e4c56 --- /dev/null +++ b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/PURPOSE @@ -0,0 +1,59 @@ +PURPOSE of /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid +Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid()) +Author: Petr Muller +Bug summary: pthread_join() hangs if a thread calls setuid() +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=522528 + +Description: + +Created an attachment (id=360523) +reproducer's source file + +Description of problem: + +When a program creates a thread which calls setuid() and terminates, the other +thread trying to wait for it hangs. + + +Version-Release number of selected component (if applicable): + +RHEL5 (2.5-34), also RHEL4 and the newest upstream sources + + +How reproducible: + +always + + +Steps to Reproduce: + +1. Compile attached source file of reproducer: + +$ gcc -o reproducer reproducer.c -lpthread + +2. and run it: + +$ ./reproducer + + +Actual results: + +program hangs + + +Expected results: + +program should end without hanging + + +Additional info: + +This bug has appeared quite a long ago, you can find it in a sourceware BZ with existing patch at: + +http://sources.redhat.com/bugzilla/show_bug.cgi?id=3270#c2 + +The patch solves the problem, but I have no idea why this hasn't been applied in the upstream already. I have attached a slightly modiffied version of the patch to be able to be applied and built on RHEL5 glibc sources and it works and solves the problem. + +There is also existing BZ for RHEL4: + +https://bugzilla.redhat.com/show_bug.cgi?id=248671 diff --git a/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/main.fmf b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/main.fmf new file mode 100644 index 0000000..b38df20 --- /dev/null +++ b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/main.fmf @@ -0,0 +1,70 @@ +summary: Test for bz522528 (pthread_join() hangs if a thread calls setuid()) +description: | + Bug summary: pthread_join() hangs if a thread calls setuid() + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=522528 + + Description: + + Created an attachment (id=360523) + reproducer's source file + + Description of problem: + + When a program creates a thread which calls setuid() and terminates, the other + thread trying to wait for it hangs. + + + Version-Release number of selected component (if applicable): + + RHEL5 (2.5-34), also RHEL4 and the newest upstream sources + + + How reproducible: + + always + + + Steps to Reproduce: + + 1. Compile attached source file of reproducer: + + $ gcc -o reproducer reproducer.c -lpthread + + 2. and run it: + + $ ./reproducer + + + Actual results: + + program hangs + + + Expected results: + + program should end without hanging + + + Additional info: + + This bug has appeared quite a long ago, you can find it in a sourceware BZ with existing patch at: + + http://sources.redhat.com/bugzilla/show_bug.cgi?id=3270#c2 + + The patch solves the problem, but I have no idea why this hasn't been applied in the upstream already. I have attached a slightly modiffied version of the patch to be able to be applied and built on RHEL5 glibc sources and it works and solves the problem. + + There is also existing BZ for RHEL4: + + https://bugzilla.redhat.com/show_bug.cgi?id=248671 +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc +duration: 75m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=522528 +extra-summary: /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid +extra-task: /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid diff --git a/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/reproducer.c b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/reproducer.c new file mode 100644 index 0000000..a46152d --- /dev/null +++ b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/reproducer.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +#define LOOPS 1000 + +uid_t uid; + +void *subthread(void *dummy) +{ + setuid(uid); +} + +int main(void) +{ + pthread_t tid[LOOPS]; + int i, ret; + + uid = getuid(); + + for(i=0; i < LOOPS; i++) { + ret = pthread_create(&tid[i], NULL, &subthread, NULL); + if(ret != 0) { + perror("pthread_create"); + return 1; + } + } + for(i=0; i < LOOPS; i++) { + ret = pthread_join(tid[i], NULL); + if(ret != 0) { + perror("pthread_join"); + } + } + return 0; +} + diff --git a/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/runtest.sh b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/runtest.sh new file mode 100755 index 0000000..9353d16 --- /dev/null +++ b/tests/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid/runtest.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid +# Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid()) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROG="reproducer" + +rlJournalStart + +rlPhaseStartSetup + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" + + PRARCH=$(rlGetPrimaryArch) + if [[ $PRARCH =~ ia64 || $PRARCH =~ armv7 || $PRARCH =~ i.86 || $PRARCH =~ aarch64 ]] + then + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG -lpthread" + else + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG -lpthread -m64" + fi + + if [[ $PRARCH =~ s390x ]] + then + sleeptime=60 + else + sleeptime=10 + fi +rlPhaseEnd + +rlPhaseStartTest + rlLog "Running the testcase 20 times" + export FAILURES=0 + for i in `seq 20` + do + rlLog "Running the reproducer: try $i" + ./${TESTPROG} & + PID=$! + sleep $sleeptime + NAME=`ps -p $PID -o comm=` + + [ "$NAME" != "`basename ${TESTPROG}`" ] + RESULT=$? + rlAssert0 "Testing if the program is running" $RESULT + + if [ "$RESULT" != "0" ] + then + rlLog "Killing the stray process" + kill -9 $PID + + rlLog "The program is still running" + FAILURES=$((FAILURES+1)) + fi + done + rlAssert0 "Checking that no process had to be killed" $FAILURES +rlPhaseEnd + +rlPhaseStartCleanup + rlLog "Killing all reproducers, just to be sure" + killall ${TESTPROG} + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/Makefile b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/Makefile new file mode 100644 index 0000000..b2422b6 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time +# Description: Test for bz529997 (assembler implementation of sem_timedwait() on) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/bz529997-sem_timedwait-with-invalid-time +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE newrepr.c oldrepr.c real-reproducer.c golden-repro.out golden-real.out + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz529997 (assembler implementation of sem_timedwait() on)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 529997" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/PURPOSE b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/PURPOSE new file mode 100644 index 0000000..0a6f3f0 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/PURPOSE @@ -0,0 +1,148 @@ +PURPOSE of /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time +Description: Test for bz529997 (assembler implementation of sem_timedwait() on) +Author: Petr Muller +Bug summary: assembler implementation of sem_timedwait() on x86/x86_64 reveals a bug when invalid nanosecond argument is used +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=529997 + +Description: + +Created an attachment (id=365459) +the reproducer's source code + +Description of problem: + +An assembler implementation of seg_timedwait() for x86/x86_64 wrongly decrements the number of waiting threads stored in block of memory pointed by (sem_t *) when invalid nanosecond value is passed through the second argument. This is caused by jumping over the code, which increments (new_sem *)->nwaiters (because of wrong nanosecond argument) to the end of the seg_timedwait() function, where (new_sem *)->nwaiters is finally decremented. This breaks the subsequent semaphore operations. Please, see the `Additional info' for more details. + + +Version-Release number of selected component (if applicable): + +RHEL5(2,3,4), Fedora 11, the newest upstream sources from ftp.gnu.org (2.10.1) + + +How reproducible: + +always + + +Steps to Reproduce: + +1. compile attached reproducer: + + $ gcc -o reproducer reproducer.c -lpthread + +2. run it: + + $ ./reproducer + + +Actual results: + +$ ./reproducer +before sem_timedwait(): new_sem->nwaiters = 0x0 +ERR: sem_timedwait() failed (errno=22: Invalid argument) +after sem_timedwait(): new_sem->nwaiters = 0xffffffff +$ + + +Expected results: + +$ ./reproducer +before sem_timedwait(): new_sem->nwaiters = 0x0 +ERR: sem_timedwait() failed (errno=22: Invalid argument) +after sem_timedwait(): new_sem->nwaiters = 0x0 +$ + + +Additional info: + +The bug was introduced by implementation of private futexes into glibc by a patch: +glibc/RHEL-5/glibc-private-futex.patch + +this patch relates to the following BZ: +https://bugzilla.redhat.com/show_bug.cgi?id=433353 + +and was introduced in: +glibc-2.5-29/RHEL2 (it enables the above patch in spec.file) + + +I have attached proposed patch, which fixes the bug and also more real-world reproducer (gcc -o real-reproducer real-reproducer.c -lrt). + +Some details from investigation of the real world reproducer: + +The output: + +$ ./real-reproducer +main: top of loop: sval = 0 +main: calling sem_timedwait +thread: calling sem_timedwait with bogus tv_nsec +thread: sem_timedwait: errno = 22 strerror = Invalid argument +thread: calling sem_post +main: sem_timedwait: errno = 110 strerror = Connection timed out <<< --- it waits here until timeouts, even if the thread calls sem_post() +main: top of loop: sval = 1 +main: calling sem_timedwait +main: sem_timedwait: success <<< --- passes +main: calling sem_post +$ + +If the value of nanosecond field is greater than 1000000000d, it directly jumps to the end of the function and executes the code which decrements the number of waiters, but remember the number of waiters wasn't incremented at the beginning. + +See the rosponsible code with comments: + +glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: +=== snip === +... +/* Check for invalid nanosecond field. */ +cmpq $1000000000, 8(%r13) +movl $EINVAL, %r14d +jae 6f <<< the value is invalid it jumps to 6: + +LOCK +addq $1, NWAITERS(%r12) <<< see this incrementation is after jump to 6: + +... +6: +movq errno@gottpoff(%rip), %rdx +movl %r14d, %fs:(%rdx) +orl $-1, %eax +jmp 10b <<< jumping to 10: + +... +10: LOCK +subq $1, NWAITERS(%r12) <<< we shouldn't increment here + +addq $24, %rsp +.Laddq: +popq %r14 +.Lpop_r14: +popq %r13 +.Lpop_r13: +popq %r12 +.Lpop_r12: +retq <<< end of sem_timedwait() +=== end of snip === + +If we move the incrementation of number of waiting threads before checking for the correct value of nanosecond field or change the logic of the code to not decrement the waiters, it works correctly. + +The reason why the sem_post() doesn't work in the func() function is that, the sem_timedwait() decreases the number of waiters as described above and the sem_post() checks this value and if it is zero, it jumps over the code, which would otherwise wake the other threads: + +glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S: +=== snip === +... +cmpq $0, NWAITERS(%rdi) <<< this makes the call to sem_post() in func() useless +je 2f <<< jump to 2: + +movl $SYS_futex, %eax +movl $FUTEX_WAKE, %esi +orl PRIVATE(%rdi), %esi +movl $1, %edx +syscall + +testq %rax, %rax +js 1f + +2: +xorl %eax, %eax <<< do exit clearly +retq +=== end of snip === + +so the sem_timedwait() in main() timeouts and the next call to sem_timedwait() passes immediately. diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/golden-real.out b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/golden-real.out new file mode 100644 index 0000000..98d27d8 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/golden-real.out @@ -0,0 +1,11 @@ +main: top of loop: sval = 0 +main: calling sem_timedwait +thread: calling sem_timedwait with bogus tv_nsec +thread: sem_timedwait: errno = 22 strerror = Invalid argument +thread: calling sem_post +main: sem_timedwait: success +main: calling sem_post +main: top of loop: sval = 1 +main: calling sem_timedwait +main: sem_timedwait: success +main: calling sem_post diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/golden-repro.out b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/golden-repro.out new file mode 100644 index 0000000..7236993 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/golden-repro.out @@ -0,0 +1,3 @@ +before sem_timedwait(): new_sem->nwaiters = 0x0 +ERR: sem_timedwait() failed (errno=22: Invalid argument) +after sem_timedwait(): new_sem->nwaiters = 0x0 diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/main.fmf b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/main.fmf new file mode 100644 index 0000000..dccf27b --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/main.fmf @@ -0,0 +1,159 @@ +summary: Test for bz529997 (assembler implementation of sem_timedwait() on) +description: | + Bug summary: assembler implementation of sem_timedwait() on x86/x86_64 reveals a bug when invalid nanosecond argument is used + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=529997 + + Description: + + Created an attachment (id=365459) + the reproducer's source code + + Description of problem: + + An assembler implementation of seg_timedwait() for x86/x86_64 wrongly decrements the number of waiting threads stored in block of memory pointed by (sem_t *) when invalid nanosecond value is passed through the second argument. This is caused by jumping over the code, which increments (new_sem *)->nwaiters (because of wrong nanosecond argument) to the end of the seg_timedwait() function, where (new_sem *)->nwaiters is finally decremented. This breaks the subsequent semaphore operations. Please, see the `Additional info' for more details. + + + Version-Release number of selected component (if applicable): + + RHEL5(2,3,4), Fedora 11, the newest upstream sources from ftp.gnu.org (2.10.1) + + + How reproducible: + + always + + + Steps to Reproduce: + + 1. compile attached reproducer: + + $ gcc -o reproducer reproducer.c -lpthread + + 2. run it: + + $ ./reproducer + + + Actual results: + + $ ./reproducer + before sem_timedwait(): new_sem->nwaiters = 0x0 + ERR: sem_timedwait() failed (errno=22: Invalid argument) + after sem_timedwait(): new_sem->nwaiters = 0xffffffff + $ + + + Expected results: + + $ ./reproducer + before sem_timedwait(): new_sem->nwaiters = 0x0 + ERR: sem_timedwait() failed (errno=22: Invalid argument) + after sem_timedwait(): new_sem->nwaiters = 0x0 + $ + + + Additional info: + + The bug was introduced by implementation of private futexes into glibc by a patch: + glibc/RHEL-5/glibc-private-futex.patch + + this patch relates to the following BZ: + https://bugzilla.redhat.com/show_bug.cgi?id=433353 + + and was introduced in: + glibc-2.5-29/RHEL2 (it enables the above patch in spec.file) + + + I have attached proposed patch, which fixes the bug and also more real-world reproducer (gcc -o real-reproducer real-reproducer.c -lrt). + + Some details from investigation of the real world reproducer: + + The output: + + $ ./real-reproducer + main: top of loop: sval = 0 + main: calling sem_timedwait + thread: calling sem_timedwait with bogus tv_nsec + thread: sem_timedwait: errno = 22 strerror = Invalid argument + thread: calling sem_post + main: sem_timedwait: errno = 110 strerror = Connection timed out <<< --- it waits here until timeouts, even if the thread calls sem_post() + main: top of loop: sval = 1 + main: calling sem_timedwait + main: sem_timedwait: success <<< --- passes + main: calling sem_post + $ + + If the value of nanosecond field is greater than 1000000000d, it directly jumps to the end of the function and executes the code which decrements the number of waiters, but remember the number of waiters wasn't incremented at the beginning. + + See the rosponsible code with comments: + + glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: + === snip === + ... + /* Check for invalid nanosecond field. */ + cmpq $1000000000, 8(%r13) + movl $EINVAL, %r14d + jae 6f <<< the value is invalid it jumps to 6: + + LOCK + addq $1, NWAITERS(%r12) <<< see this incrementation is after jump to 6: + + ... + 6: + movq errno@gottpoff(%rip), %rdx + movl %r14d, %fs:(%rdx) + orl $-1, %eax + jmp 10b <<< jumping to 10: + + ... + 10: LOCK + subq $1, NWAITERS(%r12) <<< we shouldn't increment here + + addq $24, %rsp + .Laddq: + popq %r14 + .Lpop_r14: + popq %r13 + .Lpop_r13: + popq %r12 + .Lpop_r12: + retq <<< end of sem_timedwait() + === end of snip === + + If we move the incrementation of number of waiting threads before checking for the correct value of nanosecond field or change the logic of the code to not decrement the waiters, it works correctly. + + The reason why the sem_post() doesn't work in the func() function is that, the sem_timedwait() decreases the number of waiters as described above and the sem_post() checks this value and if it is zero, it jumps over the code, which would otherwise wake the other threads: + + glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S: + === snip === + ... + cmpq $0, NWAITERS(%rdi) <<< this makes the call to sem_post() in func() useless + je 2f <<< jump to 2: + + movl $SYS_futex, %eax + movl $FUTEX_WAKE, %esi + orl PRIVATE(%rdi), %esi + movl $1, %edx + syscall + + testq %rax, %rax + js 1f + + 2: + xorl %eax, %eax <<< do exit clearly + retq + === end of snip === + + so the sem_timedwait() in main() timeouts and the next call to sem_timedwait() passes immediately. +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=529997 +extra-summary: /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time +extra-task: /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/newrepr.c b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/newrepr.c new file mode 100644 index 0000000..e1f8495 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/newrepr.c @@ -0,0 +1,100 @@ + +#include +#include +#include +#include + +#include +#include + +//#define TST_TEST_MODE 1 + +#define __HAVE_64B_ATOMICS 1 + +/* Semaphore variable structure. */ +// taken from nptl/sysdeps/unix/sysv/linux/internaltypes.h +struct new_sem +{ +#if __HAVE_64B_ATOMICS + /* The data field holds both value (in the least-significant 32 bytes) and + nwaiters. */ +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define SEM_VALUE_OFFSET 0 +# elif __BYTE_ORDER == __BIG_ENDIAN +# define SEM_VALUE_OFFSET 1 +# else +# error Unsupported byte order. +# endif +# define SEM_NWAITERS_SHIFT 32 +# define SEM_VALUE_MASK (~(unsigned int)0) + unsigned long int data; + int private; + int pad; +#else +# define SEM_VALUE_SHIFT 1 +# define SEM_NWAITERS_MASK ((unsigned int)1) + unsigned int value; + int private; + int pad; + unsigned int nwaiters; +#endif +}; + +#if TST_TEST_MODE +void func(sem_t *semp) { + struct timespec ts1 = {10, 1}; + struct timespec ts2 = {10, 1}; + struct timespec ts3 = {10, 1}; + + printf("Starting thread\n"); + + if (sem_post(semp) == -1) { + printf("sem_post error\n"); + sem_timedwait(semp, &ts1); + } + + if (sem_post(semp) == -1) { + printf("sem_post error\n"); + sem_timedwait(semp, &ts2); + } + if (sem_timedwait(semp, &ts3) < 0) + printf("THREAD ERR: sem_timedwait() failed (errno=%d: %s)\n", errno, strerror(errno)); + + sleep(10); + printf("Finishing thread\n"); +} +#endif + + +int main(void) +{ +#if TST_TEST_MODE + pthread_t thread1,thread2,thread3; + struct timespec ts = {10, 1}; // set incorrect nanoseconds +#else + struct timespec ts = {0, -1}; // set incorrect nanoseconds +#endif + sem_t sem; + struct new_sem *isem = (struct new_sem *)&sem; + + sem_init(&sem, 0, 0); + +#if TST_TEST_MODE + + pthread_create(&thread1, NULL, (void *)&func, (void *)&sem); + sleep(1); + pthread_create(&thread2, NULL, (void *)&func, (void *)&sem); + sleep(1); + pthread_create(&thread3, NULL, (void *)&func, (void *)&sem); + sleep(1); +#endif + unsigned int *pres; + pres=(unsigned int*) &isem->data; + printf("before sem_timedwait(): new_sem->nwaiters = 0x%x\n", *pres ); + if (sem_timedwait(&sem, &ts) < 0) + printf("ERR: sem_timedwait() failed (errno=%d: %s)\n", errno, strerror(errno)); + pres=(unsigned int*) &isem->data; + printf("after sem_timedwait(): new_sem->nwaiters = 0x%x\n", *pres ); + return 0; +} + diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/oldrepr.c b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/oldrepr.c new file mode 100644 index 0000000..5ee283c --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/oldrepr.c @@ -0,0 +1,32 @@ + +#include +#include +#include +#include + +/* Semaphore variable structure. */ +// taken from nptl/sysdeps/unix/sysv/linux/internaltypes.h +struct new_sem +{ + unsigned int value; + int private; + unsigned long int nwaiters; +}; + +int main(void) +{ + struct timespec ts = {0, -1}; // set incorrect nanoseconds + sem_t sem; + int ret = 0; + struct new_sem *isem = (struct new_sem *)&sem; + + sem_init(&sem, 0, 0); + + printf("before sem_timedwait(): new_sem->nwaiters = 0x%x\n", isem->nwaiters); + if (sem_timedwait(&sem, &ts) < 0) + printf("ERR: sem_timedwait() failed (errno=%d: %s)\n", errno, strerror(errno)); + printf("after sem_timedwait(): new_sem->nwaiters = 0x%x\n", isem->nwaiters); + + return (isem->nwaiters != 0); +} + diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/real-reproducer.c b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/real-reproducer.c new file mode 100644 index 0000000..471fe16 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/real-reproducer.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include +#include + +void func(sem_t *semp) +{ + struct timespec ts; + + sleep(2); + ts.tv_sec = 0; + ts.tv_nsec = -1; + + errno = 0; + printf("thread: calling sem_timedwait with bogus tv_nsec\n"); + if (sem_timedwait(semp, &ts) != 0) + printf("thread: sem_timedwait: errno = %d strerror = %s\n", + errno, strerror(errno)); + + printf("thread: calling sem_post\n"); + if (sem_post(semp) != 0) + printf("thread: sem_post: errno = %d strerror = %s\n", errno, + strerror(errno)); +} + +int main() +{ + struct timespec ts; + pthread_t thread; + sem_t sem; + int i = 0, sval = 0; + + sem_init(&sem, 0, 0); + + pthread_create(&thread, NULL, (void *)&func, (void *)&sem); + + /* two passes to illustrate that only the processes that are already + waiting for the semaphore when the call to sem_timedwait with the + bogus args is made are negatively impacted, i.e. subsequent calls + to sem_timedwait succeed */ + for (i = 0; i < 2; i++) { + sem_getvalue(&sem, &sval); + printf("main: top of loop: sval = %d\n", sval); + + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 10; + ts.tv_nsec = 0; + + printf("main: calling sem_timedwait\n"); + if (sem_timedwait(&sem, &ts) != 0) { + printf("main: sem_timedwait: errno = %d strerror = " + "%s\n", errno, strerror(errno)); + } else { + printf("main: sem_timedwait: success\n"); + printf("main: calling sem_post\n"); + if (sem_post(&sem) != 0) + printf("thread: sem_post: errno = %d strerror " + "= %s\n", errno, strerror(errno)); + } + } +} diff --git a/tests/Regression/bz529997-sem_timedwait-with-invalid-time/runtest.sh b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/runtest.sh new file mode 100755 index 0000000..5dc78e4 --- /dev/null +++ b/tests/Regression/bz529997-sem_timedwait-with-invalid-time/runtest.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time +# Description: Test for bz529997 (assembler implementation of sem_timedwait() on) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + PRARCH="$(rlGetPrimaryArch)" + rlLog "Architecture : $PRARCH" + rlAssertRpm $PACKAGE + if rlIsRHEL 5 6 + then + rlRun "gcc oldrepr.c -o repro1 -lpthread" + else + rlRun "gcc newrepr.c -o repro1 -lpthread" + fi + rlRun "gcc real-reproducer.c -o repro2 -lrt -lpthread" + + # just adding --copy-dt-needed-entries to the linker would work as well + # rlRun "gcc -Wl,--copy-dt-needed-entries reproducer.c -o repro1 -lrt" + # rlRun "gcc -Wl,--copy-dt-needed-entries real-reproducer.c -o repro2 -lrt" + # https://fedoraproject.org/wiki/UnderstandingDSOLinkChange + rlPhaseEnd + + rlPhaseStartTest + rlLog "Running reproducers" + ./repro1 > repro.out + ./repro2 > real.out + rlAssertNotDiffer "golden-repro.out" "repro.out" + if [ $? -ne 0 ] + then + rlLog "The first repro output differs from golden:" + diff -u "golden-repro.out" "repro.out" | while read line + do + rlLog "$line" + done + fi + + rlAssertNotDiffer "golden-real.out" "real.out" || + if [ $? -ne 0 ] + then + rlLog "The second repro output differs from golden:" + diff -u "golden-real.out" "real.out" | while read line + do + rlLog "$line" + done + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm repro1 repro2 real.out repro.out" + rlPhaseEnd +rlJournalEnd diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/Makefile b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/Makefile new file mode 100644 index 0000000..3462b85 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/Makefile @@ -0,0 +1,67 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts +# Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE p2.pl p1.pl p3_3.py p3.py p4_3.py p4.py + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 90m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Requires: glibc-utils" >> $(METADATA) + @echo "Requires: python python3" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 531576" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/PURPOSE b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/PURPOSE new file mode 100644 index 0000000..a17f408 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/PURPOSE @@ -0,0 +1,101 @@ +PURPOSE of /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts +Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl) +Author: Petr Muller +Bug summary: [RHEL5] memusage cmd segfaults if run on a perl script that has 'use' in it +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=531576 + +Description: + +Description of problem: + +memusage utility is part of glibc-devel + +memusage cmd segfaults if run on a perl script that has 'use' in it. + +Examples: + +[my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl + +This works (contents of perltest.pl): + + #!/usr/bin/perl -w + print "my_name\n"; + +This segfaults: + + #!/usr/bin/perl -w + use Net::SSH::Perl; + print "my_name\n"; + +Version-Release number of selected component (if applicable): + + +How reproducible: + +very + +Steps to Reproduce: +1.create perl script: + + #!/usr/bin/perl -w + # perltest.pl + use Net::SSH::Perl; + print "my_name\n"; + +2. run memusage on script: + [my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl + +Actual results: + + +my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl +/usr/bin/memusage: line 253: 29483 Segmentation fault (core dumped) LD_PRELOAD=/usr/\$LIB/libmemusage.so MEMUSAGE_OUTPUT=/tmp/memusage.S29480 "$@" +/usr/bin/memusage: line 265: 29484 Floating point exception(core dumped) $memusagestat $memusagestat_args "$datafile" "$png" + + +Expected results: + +my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl +my_name + +Memory usage summary: heap total: 278236, heap peak: 271027, stack peak: 10816 + total calls total memory failed calls + malloc| 684 277100 0 +realloc| 14 1136 0 (nomove:6, dec:1, free:0) + calloc| 0 0 0 + free| 94 20735 +Histogram for block sizes: + 0-15 215 30% ================================================== + 16-31 110 15% ========================= + 32-47 36 5% ======== + 48-63 110 15% ========================= + 64-79 34 4% ======= + 80-95 64 9% ============== + 96-111 63 9% ============== + 112-127 3 <1% + 128-143 8 1% = + 144-159 2 <1% + 160-175 4 <1% + 240-255 4 <1% + 256-271 8 1% = + 512-527 2 <1% + 592-607 1 <1% + 800-815 3 <1% + 1024-1039 3 <1% + 1568-1583 1 <1% + 2400-2415 1 <1% + 4032-4047 2 <1% + 4048-4063 1 <1% + 4064-4079 1 <1% + 4080-4095 7 1% = + 4096-4111 10 1% == + 4224-4239 1 <1% + 4368-4383 2 <1% + 7904-7919 1 <1% + large 1 <1% + + + +Additional info: + +I have no ulimit and yet there does not appear to be a core file. diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/main.fmf b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/main.fmf new file mode 100644 index 0000000..5f0a155 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/main.fmf @@ -0,0 +1,116 @@ +summary: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl) +description: | + Bug summary: [RHEL5] memusage cmd segfaults if run on a perl script that has 'use' in it + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=531576 + + Description: + + Description of problem: + + memusage utility is part of glibc-devel + + memusage cmd segfaults if run on a perl script that has 'use' in it. + + Examples: + + [my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl + + This works (contents of perltest.pl): + + #!/usr/bin/perl -w + print "my_name\n"; + + This segfaults: + + #!/usr/bin/perl -w + use Net::SSH::Perl; + print "my_name\n"; + + Version-Release number of selected component (if applicable): + + + How reproducible: + + very + + Steps to Reproduce: + 1.create perl script: + + #!/usr/bin/perl -w + # perltest.pl + use Net::SSH::Perl; + print "my_name\n"; + + 2. run memusage on script: + [my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl + + Actual results: + + + my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl + /usr/bin/memusage: line 253: 29483 Segmentation fault (core dumped) LD_PRELOAD=/usr/\$LIB/libmemusage.so MEMUSAGE_OUTPUT=/tmp/memusage.S29480 "$@" + /usr/bin/memusage: line 265: 29484 Floating point exception(core dumped) $memusagestat $memusagestat_args "$datafile" "$png" + + + Expected results: + + my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl + my_name + + Memory usage summary: heap total: 278236, heap peak: 271027, stack peak: 10816 + total calls total memory failed calls + malloc| 684 277100 0 + realloc| 14 1136 0 (nomove:6, dec:1, free:0) + calloc| 0 0 0 + free| 94 20735 + Histogram for block sizes: + 0-15 215 30% ================================================== + 16-31 110 15% ========================= + 32-47 36 5% ======== + 48-63 110 15% ========================= + 64-79 34 4% ======= + 80-95 64 9% ============== + 96-111 63 9% ============== + 112-127 3 <1% + 128-143 8 1% = + 144-159 2 <1% + 160-175 4 <1% + 240-255 4 <1% + 256-271 8 1% = + 512-527 2 <1% + 592-607 1 <1% + 800-815 3 <1% + 1024-1039 3 <1% + 1568-1583 1 <1% + 2400-2415 1 <1% + 4032-4047 2 <1% + 4048-4063 1 <1% + 4064-4079 1 <1% + 4080-4095 7 1% = + 4096-4111 10 1% == + 4224-4239 1 <1% + 4368-4383 2 <1% + 7904-7919 1 <1% + large 1 <1% + + + + Additional info: + + I have no ulimit and yet there does not appear to be a core file. +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-utils + - python + - python3 + - gcc +duration: 90m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=531576 +extra-summary: /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts +extra-task: /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p1.pl b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p1.pl new file mode 100644 index 0000000..5f09f58 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p1.pl @@ -0,0 +1,5 @@ +#!/usr/bin/perl -w + +use strict; + +print "P1\n"; diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p2.pl b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p2.pl new file mode 100644 index 0000000..b92bb9b --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p2.pl @@ -0,0 +1,6 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +print "P2\n"; diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p3.py b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p3.py new file mode 100644 index 0000000..bd57bbb --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p3.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import os + +print "P3" diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p3_3.py b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p3_3.py new file mode 100644 index 0000000..bc49026 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p3_3.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import os + +print ("P3") diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p4.py b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p4.py new file mode 100644 index 0000000..b77ea8c --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p4.py @@ -0,0 +1,3 @@ +#!/usr/bin/python + +print "P4" diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p4_3.py b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p4_3.py new file mode 100644 index 0000000..aeb9778 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/p4_3.py @@ -0,0 +1,3 @@ +#!/usr/bin/python + +print ("P4") diff --git a/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/runtest.sh b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/runtest.sh new file mode 100755 index 0000000..21ae171 --- /dev/null +++ b/tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/runtest.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts +# Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + +rlPhaseStartSetup + TEMPC=`mktemp`.c + echo "int main(){ return 0; }" > $TEMPC + echo "int result() { return 1; }" >> $TEMPC + for i in `seq 10000` + do + echo "int fction$i(){ return result(); }" >> $TEMPC + done +rlPhaseEnd + +rlPhaseStartTest + if rlIsRHEL ">=8" || rlIsFedora + then + CURPYTHON="python3" + P3="p3_3.py" + P4="p4_3.py" + else + CURPYTHON="python" + P3="p3.py" + P4="p4.py" + fi + + for testcase in "perl p1.pl" "perl p2.pl" "$CURPYTHON $P3" "$CURPYTHON $P4" "$CURPYTHON -V" "ps" "gcc -O0 $TEMPC -o /dev/null" + do + for output in "" "--png=out.png" "--png=out.png -x 800 -y 300" "--data=out.dat" + do + for mmap in "" "--mmap" + do + rlRun "memusage $output $mmap $testcase" + done + done + done +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f out.png out.dat $TEMPC" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz549813-dl-close-race-with-C-destructor/C_Only.tar b/tests/Regression/bz549813-dl-close-race-with-C-destructor/C_Only.tar new file mode 100644 index 0000000..76a5dda Binary files /dev/null and b/tests/Regression/bz549813-dl-close-race-with-C-destructor/C_Only.tar differ diff --git a/tests/Regression/bz549813-dl-close-race-with-C-destructor/Makefile b/tests/Regression/bz549813-dl-close-race-with-C-destructor/Makefile new file mode 100644 index 0000000..169faf9 --- /dev/null +++ b/tests/Regression/bz549813-dl-close-race-with-C-destructor/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor +# Description: Test for bz549813 (dl_close() race with C++ destructor) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz549813-dl-close-race-with-C-destructor +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE C_Only.tar + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz549813 (dl_close() race with C++ destructor)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 549813" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz549813-dl-close-race-with-C-destructor/PURPOSE b/tests/Regression/bz549813-dl-close-race-with-C-destructor/PURPOSE new file mode 100644 index 0000000..5327c21 --- /dev/null +++ b/tests/Regression/bz549813-dl-close-race-with-C-destructor/PURPOSE @@ -0,0 +1,91 @@ +PURPOSE of /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor +Description: Test for bz549813 (dl_close() race with C++ destructor) +Author: Petr Muller +Bug summary: dl_close() race with C++ destructor +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=549813 + +Description: + +This looks like a dup of + +http://sources.redhat.com/bugzilla/show_bug.cgi?id=654 + + +Create a pthread in the library init. In fini, cancel the pthread and then join. If the main thread does a dlclose(), the program hangs at pthread_join(). +It is stuck in a futex. I tried the testcase from http://sources.redhat.com/bugzilla/show_bug.cgi?id=654 and that fails too. + +One thing that may be relevant is that if dlopen is called with RTLD_NODELETE, pthread_join will not hang. + + +main program-> + +#include +#include + +int main(int argc, char *argv[]) { + void *handle; + + handle = dlopen("tiny.so",RTLD_NOW); + if (handle) + printf("loaded shared library\n"); + else { + printf("could not load shared library\n"); + return (-1); + } + sleep(1); + dlclose(handle); + +} + +the lib -> + +#include +#include +#include +#include +#include +pthread_t t; + + +void *F(void *arg) { + + int old; + if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old) == 0) { + printf("> cancelability enabled.\n"); + } + else { + printf("> could not set cancelability\n"); + return (0); + } + + sleep(2); +} /*end F */ + +int _init_rick (void) { + +printf("in init\n"); + if (pthread_create(&t, NULL, (void *(*)(void *)) F, NULL) == 0) + printf("started thread\n"); +else + printf("could not start thread\n"); + +} /* end _init_rick */ + +int _fini_rick (void) { + + printf("in fini\n"); + + printf("canceling thread\n"); + if (pthread_cancel(t) == 0) + printf("canceled thread\n"); + else + printf("could not cancel thread \n"); + + printf("joining thread\n"); + if (pthread_join(t, NULL) == 0) + printf("joined with thread\n"); + else + printf("could not join with thread\n"); + + +} /* end _fini_rick */ diff --git a/tests/Regression/bz549813-dl-close-race-with-C-destructor/main.fmf b/tests/Regression/bz549813-dl-close-race-with-C-destructor/main.fmf new file mode 100644 index 0000000..aaf3792 --- /dev/null +++ b/tests/Regression/bz549813-dl-close-race-with-C-destructor/main.fmf @@ -0,0 +1,102 @@ +summary: Test for bz549813 (dl_close() race with C++ destructor) +description: | + Bug summary: dl_close() race with C++ destructor + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=549813 + + Description: + + This looks like a dup of + + http://sources.redhat.com/bugzilla/show_bug.cgi?id=654 + + + Create a pthread in the library init. In fini, cancel the pthread and then join. If the main thread does a dlclose(), the program hangs at pthread_join(). + It is stuck in a futex. I tried the testcase from http://sources.redhat.com/bugzilla/show_bug.cgi?id=654 and that fails too. + + One thing that may be relevant is that if dlopen is called with RTLD_NODELETE, pthread_join will not hang. + + + main program-> + + #include + #include + + int main(int argc, char *argv[]) { + void *handle; + + handle = dlopen("tiny.so",RTLD_NOW); + if (handle) + printf("loaded shared library\n"); + else { + printf("could not load shared library\n"); + return (-1); + } + sleep(1); + dlclose(handle); + + } + + the lib -> + + #include + #include + #include + #include + #include + pthread_t t; + + + void *F(void *arg) { + + int old; + if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old) == 0) { + printf("> cancelability enabled.\n"); + } + else { + printf("> could not set cancelability\n"); + return (0); + } + + sleep(2); + } /*end F */ + + int _init_rick (void) { + + printf("in init\n"); + if (pthread_create(&t, NULL, (void *(*)(void *)) F, NULL) == 0) + printf("started thread\n"); + else + printf("could not start thread\n"); + + } /* end _init_rick */ + + int _fini_rick (void) { + + printf("in fini\n"); + + printf("canceling thread\n"); + if (pthread_cancel(t) == 0) + printf("canceled thread\n"); + else + printf("could not cancel thread \n"); + + printf("joining thread\n"); + if (pthread_join(t, NULL) == 0) + printf("joined with thread\n"); + else + printf("could not join with thread\n"); + + + } /* end _fini_rick */ +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=549813 +extra-summary: /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor +extra-task: /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor diff --git a/tests/Regression/bz549813-dl-close-race-with-C-destructor/runtest.sh b/tests/Regression/bz549813-dl-close-race-with-C-destructor/runtest.sh new file mode 100755 index 0000000..fef2149 --- /dev/null +++ b/tests/Regression/bz549813-dl-close-race-with-C-destructor/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor +# Description: Test for bz549813 (dl_close() race with C++ destructor) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh + +PACKAGE="glibc" + +rlJournalStart + +rlPhaseStartSetup + rlRun "tar xfv C_Only.tar" + rlRun "pushd C_Only" && rlRun "make it" +rlPhaseEnd + +rlPhaseStartTest + export LD_LIBRARY_PATH=. + rlLog "Checking that the command does not hang" + rlRun "rlWatchdog ./c_only 5" && rlRun "./c_only" 0 "Checking that the testcase works correctly" + unset LD_LIRBARY_PATH +rlPhaseEnd + +rlPhaseStartCleanup + rlLog "Killing possible remnants" + killall -9 c_only + rlRun "make clean" + rlRun "popd" + rlRun "rm -rf C_Only" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz566712-aio-write-ll-corruption/Makefile b/tests/Regression/bz566712-aio-write-ll-corruption/Makefile new file mode 100644 index 0000000..df7da0e --- /dev/null +++ b/tests/Regression/bz566712-aio-write-ll-corruption/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz566712-aio-write-ll-corruption +# Description: Test for bz566712 (If pthread_create fails in aio_write, requests) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz566712-aio-write-ll-corruption +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE aio_write.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz566712 (If pthread_create fails in aio_write, requests)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 566712" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz566712-aio-write-ll-corruption/PURPOSE b/tests/Regression/bz566712-aio-write-ll-corruption/PURPOSE new file mode 100644 index 0000000..7a3f2e6 --- /dev/null +++ b/tests/Regression/bz566712-aio-write-ll-corruption/PURPOSE @@ -0,0 +1,33 @@ +PURPOSE of /tools/glibc/Regression/bz566712-aio-write-ll-corruption +Description: Test for bz566712 (If pthread_create fails in aio_write, requests) +Author: Petr Muller +Bug summary: If pthread_create fails in aio_write, requests linked list is corrupted +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=566712 + +Description: + +Description of problem: +When one calls aio_write, it internally calls __aio_enqueue_request, which will in turn call aio_create_helper_thread. If thread creation fails, the newly created request (newp in the code) will still be in the requests linked list, but it will be freed later in __aio_enqueue_request. + +A subsequent call to aio_write will cause a segmentation fault. + +Version-Release number of selected component (if applicable): +glibc-2.5-*.el5 + +How reproducible: +100% + +Steps to Reproduce: +There's a test case from Neil Vachharajani in upstream bugzilla: + +http://sources.redhat.com/bugzilla/attachment.cgi?id=4198&action=view + + +Actual results: +If compiled -DCRASH the program segfaults. + +Expected results: +If compiled -DCRASH the program does not segfault. + +Additional info: +http://sources.redhat.com/bugzilla/show_bug.cgi?id=10643 diff --git a/tests/Regression/bz566712-aio-write-ll-corruption/aio_write.c b/tests/Regression/bz566712-aio-write-ll-corruption/aio_write.c new file mode 100644 index 0000000..981c245 --- /dev/null +++ b/tests/Regression/bz566712-aio-write-ll-corruption/aio_write.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +__thread int x[4096]; + +struct aiocb * do_aio_write(int fd, char *buf, int len, int offset) +{ + + struct aiocb *op = calloc(1, sizeof(struct aiocb)); + + if (!op) { + printf("Could not allocate memory\n"); + exit(1); + } + + op->aio_fildes = fd; + op->aio_buf = buf; + op->aio_nbytes = len; + op->aio_offset = offset; + + if (aio_write(op) == -1) + printf("aio_write() err\n"); + else + printf("aio_write() success\n"); + + return op; +} + +int main() +{ + char buf1[] = "Hello World\n"; + char buf2[] = "Goodbye World\n"; + int fd; + struct aiocb *op1, *op2; + + fd = open("foo.txt", O_CREAT | O_WRONLY | O_TRUNC); + + if (fd == -1) { + perror("open"); + exit(1); + } + + op1 = do_aio_write(fd, buf1, strlen(buf1), 0); + op2 = do_aio_write(fd, buf2, strlen(buf2), strlen(buf1)); + + close(fd); + return 0; +} diff --git a/tests/Regression/bz566712-aio-write-ll-corruption/main.fmf b/tests/Regression/bz566712-aio-write-ll-corruption/main.fmf new file mode 100644 index 0000000..08d97c3 --- /dev/null +++ b/tests/Regression/bz566712-aio-write-ll-corruption/main.fmf @@ -0,0 +1,44 @@ +summary: Test for bz566712 (If pthread_create fails in aio_write, requests) +description: | + Bug summary: If pthread_create fails in aio_write, requests linked list is corrupted + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=566712 + + Description: + + Description of problem: + When one calls aio_write, it internally calls __aio_enqueue_request, which will in turn call aio_create_helper_thread. If thread creation fails, the newly created request (newp in the code) will still be in the requests linked list, but it will be freed later in __aio_enqueue_request. + + A subsequent call to aio_write will cause a segmentation fault. + + Version-Release number of selected component (if applicable): + glibc-2.5-*.el5 + + How reproducible: + 100% + + Steps to Reproduce: + There's a test case from Neil Vachharajani in upstream bugzilla: + + http://sources.redhat.com/bugzilla/attachment.cgi?id=4198&action=view + + + Actual results: + If compiled -DCRASH the program segfaults. + + Expected results: + If compiled -DCRASH the program does not segfault. + + Additional info: + http://sources.redhat.com/bugzilla/show_bug.cgi?id=10643 +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=566712 +extra-summary: /tools/glibc/Regression/bz566712-aio-write-ll-corruption +extra-task: /tools/glibc/Regression/bz566712-aio-write-ll-corruption diff --git a/tests/Regression/bz566712-aio-write-ll-corruption/runtest.sh b/tests/Regression/bz566712-aio-write-ll-corruption/runtest.sh new file mode 100755 index 0000000..40d6985 --- /dev/null +++ b/tests/Regression/bz566712-aio-write-ll-corruption/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz566712-aio-write-ll-corruption +# Description: Test for bz566712 (If pthread_create fails in aio_write, requests) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + +rlPhaseStartSetup + rlRun "gcc aio_write.c -o aio-rt -lrt" + if rlIsRHEL 5 + then + rlRun "gcc aio_write.c -o aio-rtkaio -lrtkaio -lpthread" + fi +rlPhaseEnd + +rlPhaseStartTest + rlRun "./aio-rt" + if rlIsRHEL 5 + then + rlRun "./aio-rtkaio" + fi +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "rm -f aio-rt aio-rtkaio foo.txt" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/Makefile b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/Makefile new file mode 100644 index 0000000..b75558f --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer +# Description: Calls ftell after write and verifies that buf is not flushed +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE tst-write-ftell.c tst-ftell-with-fdopen.c tst-ftell-with-fdopen.expected + +.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Calls ftell after write and verifies that buf is not flushed" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers strace" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 577950" >> $(METADATA) + @echo "Releases: -RHELServer5 -RHELClient5 -RHEL6" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/PURPOSE b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/PURPOSE new file mode 100644 index 0000000..a52a189 --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer +Description: Calls ftell after write and verifies that buf is not flushed +Author: Arjun Shankar diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/main.fmf b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/main.fmf new file mode 100644 index 0000000..28f004f --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/main.fmf @@ -0,0 +1,18 @@ +summary: Calls ftell after write and verifies that buf is not flushed +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers + - strace +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=577950 +extra-summary: /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer +extra-task: /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/runtest.sh b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/runtest.sh new file mode 100755 index 0000000..9a6c135 --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/runtest.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer +# Description: Calls ftell after write and verifies that buf is not flushed +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 + +PACKAGE="glibc" +REQUIRES=(gcc glibc glibc-devel strace) + +rlJournalStart + rlPhaseStartSetup + for p in ${REQUIRES[@]}; do + rlAssertRpm $p + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp *.c *.expected $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -o tst-write-ftell tst-write-ftell.c" + rlAssertExists "tst-write-ftell" + rlRun "gcc -o tst-ftell-with-fdopen tst-ftell-with-fdopen.c" + rlAssertExists "tst-ftell-with-fdopen" + rlPhaseEnd + + rlPhaseStartTest + rlRun "strace ./tst-write-ftell /dev/null 40 0 &> strace.out" + rlAssertEquals "Do not expect any writes of size 208 bytes" "$(cat strace.out | grep '^write.*208$' | wc -l)" "0" + rlLog "$(cat strace.out | grep ^write | head)" + rlRun "strace ./tst-write-ftell /dev/null 40 1 &> strace.out" + rlAssertEquals "Do not expect any writes of size 208 bytes" "$(cat strace.out | grep '^write.*208$' | wc -l)" "0" + rlLog "$(cat strace.out | grep ^write | head)" + for f1 in "" "-f"; do + for f2 in "" "-o"; do + rlRun "./tst-ftell-with-fdopen $f1 $f2" + rlRun "cmp tst-ftell-with-fdopen.out tst-ftell-with-fdopen.expected" + done + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-ftell-with-fdopen.c b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-ftell-with-fdopen.c new file mode 100644 index 0000000..518bd64 --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-ftell-with-fdopen.c @@ -0,0 +1,59 @@ +/* Test case from: + https://sourceware.org/bugzilla/show_bug.cgi?id=16532#c0 */ + +#include +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + FILE *fp; + size_t written; + off_t off; + int do_flush = 0, do_fopen = 0; + int opt; + const char *const fname = "tst-ftell-with-fdopen.out"; + + while ((opt = getopt (argc, argv, "fo")) != -1) + { + switch (opt) + { + case 'f': + do_flush = 1; + break; + case 'o': + do_fopen = 1; + break; + } + } + + fp = fopen (fname, "w"); + written = fwrite ("abcabc", 1, 6, fp); + assert (written == 6); + + fclose (fp); + + if (do_fopen) + fp = fopen (fname, "a"); + else + { + int fd = open (fname, O_WRONLY, 0); + assert (fd != -1); + fp = fdopen (fd, "a"); + } + + assert (fp != NULL); + + written = fwrite ("ghi", 1, 3, fp); + assert (written == 3); + + if (do_flush) + fflush (NULL); + + off = ftello (fp); + assert (off == 9); + + return 0; +} diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-ftell-with-fdopen.expected b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-ftell-with-fdopen.expected new file mode 100644 index 0000000..1e0c9ce --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-ftell-with-fdopen.expected @@ -0,0 +1 @@ +abcabcghi \ No newline at end of file diff --git a/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-write-ftell.c b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-write-ftell.c new file mode 100644 index 0000000..b238472 --- /dev/null +++ b/tests/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer/tst-write-ftell.c @@ -0,0 +1,105 @@ +#include +#include +#include + +#define MEGABYTE 1048576 +#define KILOBYTE 1024 + +/* How to call: + ./tst-write-ftell DESTFILE SIZE_KB 0|1 + + 0 => do not call ftell; + 1 => call ftell; + + SIZE_KB must be in range [10,200]. */ + +int +main (int argc, char *argv[]) +{ + int ret; + char *filename; + char *data; + int dsize, writesize, chunksize, count; + FILE *file; + + int ftell_on = 0; + chunksize = 208; + + if (argc < 3) + { + fprintf (stderr, "Invalid arguments\n"); + exit (1); + } + + filename = argv[1]; + + errno = 0; + dsize = strtol (argv[2], NULL, 0); + if (errno) + { + perror ("strtol() failed"); + return 1; + } + if ((dsize < 10) + || (dsize > 200)) + { + fprintf (stderr, "Invalid SIZE_KB: %d\n", dsize); + exit (1); + } + dsize *= KILOBYTE; + + ftell_on = strtol (argv[3], NULL, 0); + if (errno) + { + perror ("strtol() failed"); + exit (1); + } + + data = malloc (sizeof (char) * dsize); + if (!data) + { + perror ("malloc() failed"); + exit (1); + } + + file = fopen (filename, "w"); + if (file == NULL) + { + perror ("fopen failed()"); + exit (1); + } + + for (count = 0; count < dsize; count += chunksize) + { + if (count + chunksize <= dsize) + { + writesize = chunksize; + } + else + { + writesize = dsize - count; + } + + ret = fwrite (data, writesize, 1, file); + + if (ret != 1) + { + perror ("Write failed"); + abort (); + } + + if (ftell_on) + { + int pos; + pos = ftell (file); + if (pos < 0) + { + perror ("ftell() failed"); + abort (); + + } + } + + } + ret = fclose (file); +} diff --git a/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/Makefile b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/Makefile new file mode 100644 index 0000000..561ff82 --- /dev/null +++ b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return +# Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE pthread_rwlock_timedwrlock.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + 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 bz580498 (pthread_rwlock_timedwrlock/rdlock() never return)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 580498" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/PURPOSE b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/PURPOSE new file mode 100644 index 0000000..66b5d4a --- /dev/null +++ b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/PURPOSE @@ -0,0 +1,27 @@ +PURPOSE of /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return +Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return) +Author: Miroslav Franc +Bug summary: pthread_rwlock_timedwrlock/rdlock() never return +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=580498 + +Description: + +Different behavior between RHEL5 and RHEL6 in both pthread_rwlock_timedwrlock() +and pthread_rwlock_timedrdlock() functions. + +If you call one of them with setting a negative number to abs_timeout->tv_sec, +and a write lock to the specified rwlock has already been acquired by a different thread: + +RHEL 5) the function returns with ETIMEDOUT errno, but +RHEL 6) the function never return (spinning). + +According to the man page and specs, EINVAL should be the return value on a negative timespec. + + + EINVAL The value specified by rwlock does not refer to an initialized + read-write lock object, or the abs_timeout nanosecond value is + less than zero or greater than or equal to 1000 million. + + +Apparently this change caused the issue: + http://sourceware.org/ml/glibc-cvs/2009-q3/msg00036.html diff --git a/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/main.fmf b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/main.fmf new file mode 100644 index 0000000..fc9765f --- /dev/null +++ b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/main.fmf @@ -0,0 +1,39 @@ +summary: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return) +description: | + Bug summary: pthread_rwlock_timedwrlock/rdlock() never return + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=580498 + + Description: + + Different behavior between RHEL5 and RHEL6 in both pthread_rwlock_timedwrlock() + and pthread_rwlock_timedrdlock() functions. + + If you call one of them with setting a negative number to abs_timeout->tv_sec, + and a write lock to the specified rwlock has already been acquired by a different thread: + + RHEL 5) the function returns with ETIMEDOUT errno, but + RHEL 6) the function never return (spinning). + + According to the man page and specs, EINVAL should be the return value on a negative timespec. + + + EINVAL The value specified by rwlock does not refer to an initialized + read-write lock object, or the abs_timeout nanosecond value is + less than zero or greater than or equal to 1000 million. + + + Apparently this change caused the issue: + http://sourceware.org/ml/glibc-cvs/2009-q3/msg00036.html +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=580498 +extra-summary: /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return +extra-task: /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return diff --git a/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/pthread_rwlock_timedwrlock.c b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/pthread_rwlock_timedwrlock.c new file mode 100644 index 0000000..e65966c --- /dev/null +++ b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/pthread_rwlock_timedwrlock.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include + +pthread_rwlock_t rwlock; + +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} + +void * func() +{ + int ret = 0; + struct timeval tv; + struct timespec ts; + + (void)gettimeofday(&tv, NULL); + TIMEVAL_TO_TIMESPEC(&tv, &ts); + + ts.tv_sec = -1; + + ret = pthread_rwlock_timedwrlock(&rwlock, &ts); + if (ret == ETIMEDOUT) { + printf("pthread_rwlock_timedwrlock:TIME OUT.\n"); + pthread_exit(0); + } else if (ret == EINVAL) { + printf("pthread_rwlock_timedwrlock:INVALID ARG.\n"); + pthread_exit(0); + } + printf("pthread_rwlock_timedwrlock:return = %d\n", ret); + pthread_exit(0); +} + +int main(int argv, char *argc[]) +{ + pthread_t tid; + + if (pthread_rwlock_init(&rwlock, NULL) != 0) { + printf("pthread_rwlock_init error\n"); + exit(-1); + } + pthread_rwlock_wrlock(&rwlock); + pthread_create(&tid, NULL, func, NULL); + pthread_join(tid, NULL); + + return 0; +} diff --git a/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/runtest.sh b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/runtest.sh new file mode 100755 index 0000000..21f71d9 --- /dev/null +++ b/tests/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return/runtest.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return +# Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +PACKAGE0="gcc" +SOURCEFILE="pthread_rwlock_timedwrlock.c" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlAssertRpm $PACKAGE0 + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp $SOURCEFILE $TmpDir" 0 "Copying reproducer $SOURCEFILE into $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -o pthread_rwlock_timedwrlock_a.out $SOURCEFILE -lpthread" + rlPhaseEnd + + rlPhaseStartTest + ./pthread_rwlock_timedwrlock_a.out > log & + pidaout=$! + # poor man's watchdog, cannot rely on beakerlib on this one + sleep 5 + if test -d /proc/$pidaout && + test "`cat /proc/$pidaout/cmdline`" = "./pthread_rwlock_timedwrlock_a.out"; then + rlFail "Fuction should return and errno=ETIMEDOUT (not returning anything, it's spinning instead)" + kill -9 $pidaout + elif grep -q 'TIME OUT' log; then + rlPass "Fuction should return and errno=ETIMEDOUT" + else + ReprOut=`cat log` + rlFail "Fuction should return and errno=ETIMEDOUT ($ReprOut)" + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz585674-free-race-in-mcheck-hooks/Makefile b/tests/Regression/bz585674-free-race-in-mcheck-hooks/Makefile new file mode 100644 index 0000000..52e0573 --- /dev/null +++ b/tests/Regression/bz585674-free-race-in-mcheck-hooks/Makefile @@ -0,0 +1,66 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks +# Description: Test for bz585674 (free() race in mcheck hooks) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz585674-free-race-in-mcheck-hooks +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE malloc_check.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz585674 (free() race in mcheck hooks)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 90m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "Requires: libgomp" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 585674" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz585674-free-race-in-mcheck-hooks/PURPOSE b/tests/Regression/bz585674-free-race-in-mcheck-hooks/PURPOSE new file mode 100644 index 0000000..5d3f225 --- /dev/null +++ b/tests/Regression/bz585674-free-race-in-mcheck-hooks/PURPOSE @@ -0,0 +1,49 @@ +PURPOSE of /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks +Description: Test for bz585674 (free() race in mcheck hooks) +Author: Petr Muller +Bug summary: free() race in mcheck hooks +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=585674 + +Description: + +Description of problem: +segfaults can occur with MEMCHECK_ALLOC_=3 enabled. This was reported and fixed upstream at +http://sourceware.org/bugzilla/show_bug.cgi?id=10282 +http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cc49a5a8837be1f9307b167d9bf4399798a847c9 + +Version-Release number of selected component (if applicable): +glibc-2.5-49 + +How reproducible: +every time + +Steps to Reproduce: +1. cat malloc_test.c +#include +#include + +int main(void) +{ +#pragma omp parallel num_threads(256) + while (1) { + void *ptr = malloc(rand() % 65536); + usleep((rand() % 100) * 100); + free(ptr); + usleep((rand() % 100) * 100); + } + return 0; +} + +2. gcc -fopenmp -g -o malloc_check malloc_check.c + +3. MALLOC_CHECK_=3 ./malloc_test + +Actual results: +malloc: using debugging hooks +*** glibc detected *** ./malloc_test: free(): invalid pointer: 0x00000000043e9c90 *** + + +Expected results: +no segfaults + +Additional info: diff --git a/tests/Regression/bz585674-free-race-in-mcheck-hooks/main.fmf b/tests/Regression/bz585674-free-race-in-mcheck-hooks/main.fmf new file mode 100644 index 0000000..fea4212 --- /dev/null +++ b/tests/Regression/bz585674-free-race-in-mcheck-hooks/main.fmf @@ -0,0 +1,62 @@ +summary: Test for bz585674 (free() race in mcheck hooks) +description: | + Bug summary: free() race in mcheck hooks + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=585674 + + Description: + + Description of problem: + segfaults can occur with MEMCHECK_ALLOC_=3 enabled. This was reported and fixed upstream at + http://sourceware.org/bugzilla/show_bug.cgi?id=10282 + http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cc49a5a8837be1f9307b167d9bf4399798a847c9 + + Version-Release number of selected component (if applicable): + glibc-2.5-49 + + How reproducible: + every time + + Steps to Reproduce: + 1. cat malloc_test.c + #include + #include + + int main(void) + { + #pragma omp parallel num_threads(256) + while (1) { + void *ptr = malloc(rand() % 65536); + usleep((rand() % 100) * 100); + free(ptr); + usleep((rand() % 100) * 100); + } + return 0; + } + + 2. gcc -fopenmp -g -o malloc_check malloc_check.c + + 3. MALLOC_CHECK_=3 ./malloc_test + + Actual results: + malloc: using debugging hooks + *** glibc detected *** ./malloc_test: free(): invalid pointer: 0x00000000043e9c90 *** + + + Expected results: + no segfaults + + Additional info: +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - libgomp +duration: 90m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=585674 +extra-summary: /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks +extra-task: /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks diff --git a/tests/Regression/bz585674-free-race-in-mcheck-hooks/malloc_check.c b/tests/Regression/bz585674-free-race-in-mcheck-hooks/malloc_check.c new file mode 100644 index 0000000..ee5c6f0 --- /dev/null +++ b/tests/Regression/bz585674-free-race-in-mcheck-hooks/malloc_check.c @@ -0,0 +1,20 @@ +#include +#include + +int main(void) +{ + unsigned int i; +#pragma omp parallel num_threads(256) private(i) + { + i = 1; + while (i != 2000) { + void *ptr = malloc(rand() % 65536); + usleep((rand() % 100) * 100); + free(ptr); + usleep((rand() % 100) * 100); + i++; + } + #pragma omp barrier + } + return 0; +} diff --git a/tests/Regression/bz585674-free-race-in-mcheck-hooks/runtest.sh b/tests/Regression/bz585674-free-race-in-mcheck-hooks/runtest.sh new file mode 100755 index 0000000..d01ddac --- /dev/null +++ b/tests/Regression/bz585674-free-race-in-mcheck-hooks/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks +# Description: Test for bz585674 (free() race in mcheck hooks) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +TESTPROG="malloc_check" + +rlJournalStart + +rlPhaseStartSetup + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun "cp ${TESTPROG}.c $TESTTMPDIR" + rlRun "pushd $TESTTMPDIR" +rlPhaseEnd + +rlPhaseStartTest + rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG -g -fopenmp" + export MALLOC_CHECK_=3 + for i in `seq 10` + do + rlRun -c "./${TESTPROG}" 0 "Testcase attempt $i" + done +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz587360-digraph-matching-differs-across-archs/Makefile b/tests/Regression/bz587360-digraph-matching-differs-across-archs/Makefile new file mode 100644 index 0000000..d4f4d38 --- /dev/null +++ b/tests/Regression/bz587360-digraph-matching-differs-across-archs/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs +# Description: Test for bz587360 (Pattern matching of digraphs differs across archs) +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz587360-digraph-matching-differs-across-archs +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) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Splichal " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz587360 (Pattern matching of digraphs differs across archs)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-langpack-cs" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 587360" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz587360-digraph-matching-differs-across-archs/PURPOSE b/tests/Regression/bz587360-digraph-matching-differs-across-archs/PURPOSE new file mode 100644 index 0000000..a928bea --- /dev/null +++ b/tests/Regression/bz587360-digraph-matching-differs-across-archs/PURPOSE @@ -0,0 +1,16 @@ +PURPOSE of /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs +Description: Test for bz587360 (Pattern matching of digraphs differs across archs) +Author: Petr Splichal +Bug summary: Pattern matching of digraphs inconsistent and differs across architectures +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=587360 + +Description: + +The "ch" character is treated strangely by the latest sed while +in the Czech locale. Seems to be a glibc issue. I was able to +reproduce it on s390x & ppc only. + +The test was updated because of new behaviour or glibc-2.28 (and RHEL8 +accordingly). For more information: +https://bugzilla.redhat.com/show_bug.cgi?id=1653745 +https://bugzilla.redhat.com/show_bug.cgi?id=1601681 diff --git a/tests/Regression/bz587360-digraph-matching-differs-across-archs/main.fmf b/tests/Regression/bz587360-digraph-matching-differs-across-archs/main.fmf new file mode 100644 index 0000000..eca14e9 --- /dev/null +++ b/tests/Regression/bz587360-digraph-matching-differs-across-archs/main.fmf @@ -0,0 +1,28 @@ +summary: Test for bz587360 (Pattern matching of digraphs differs across archs) +description: | + Bug summary: Pattern matching of digraphs inconsistent and differs across architectures + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=587360 + + Description: + + The "ch" character is treated strangely by the latest sed while + in the Czech locale. Seems to be a glibc issue. I was able to + reproduce it on s390x & ppc only. + + The test was updated because of new behaviour or glibc-2.28 (and RHEL8 + accordingly). For more information: + https://bugzilla.redhat.com/show_bug.cgi?id=1653745 + https://bugzilla.redhat.com/show_bug.cgi?id=1601681 +contact: Petr Splichal +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-langpack-cs +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=587360 +extra-summary: /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs +extra-task: /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs diff --git a/tests/Regression/bz587360-digraph-matching-differs-across-archs/runtest.sh b/tests/Regression/bz587360-digraph-matching-differs-across-archs/runtest.sh new file mode 100755 index 0000000..197186f --- /dev/null +++ b/tests/Regression/bz587360-digraph-matching-differs-across-archs/runtest.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs +# Description: Test for bz587360 (Pattern matching of digraphs differs across archs) +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +if rlIsRHEL ">=8" || rlIsFedora > 28 +then + AtoZ="abcčČdefghchcHChCHijklmnopqrřŘsšŠtuvwxyzžŽ" + POSPATTERN="^---čČ--------HC-CH----------řŘ-šŠ-------žŽ$" + NEGPATTERN="^abc--defgh----ijklmnopqr--s--tuvwxyz--$" +else + AtoZ="abcdefghchijklmnopqrstuvwxyz" + POSPATTERN="^--*$" + NEGPATTERN=$AtoZ +fi +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + if rlIsRHEL 8 || rlIsFedora > 20 + then + rlAssertRpm glibc-langpack-cs + fi + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "export LANG=cs_CZ.UTF-8" + rlPhaseEnd + + rlPhaseStartTest + # positive range + rlRun "echo $AtoZ | sed 's/[a-z]/-/g' | tee output" \ + 0 "Testing positive range" + rlAssertGrep "$POSPATTERN" "output" + + # negative range + rlRun "echo $AtoZ | sed 's/[^a-z]/-/g' | tee output" \ + 0 "Testing negative range" + rlAssertGrep "$NEGPATTERN" "output" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/Makefile b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/Makefile new file mode 100644 index 0000000..5b49812 --- /dev/null +++ b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz600457-locally-defined-symbol-resolving-failure +# Description: Test for bz600457 ([4.8] Unexpected failure of resolving a) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/glibc/Regression/bz600457-locally-defined-symbol-resolving-failure +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE reproducer.tar.gz golden.out + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz600457 ([4.8] Unexpected failure of resolving a)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 600457" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/PURPOSE b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/PURPOSE new file mode 100644 index 0000000..74ca16a --- /dev/null +++ b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/PURPOSE @@ -0,0 +1,126 @@ +PURPOSE of /tools/glibc/Regression/bz600457-locally-defined-symbol-resolving-failure +Description: Test for bz600457 ([4.8] Unexpected failure of resolving a) +Author: Petr Muller +Bug summary: [4.8] Unexpected failure of resolving a locally-defined symbol. +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=600457 + +Description: + +Customer Contact Name: +Naoki Yanagimoto + +Description of Problem: +This problem is the same as issue #580553 of RHEL5. +This ticket is for RHEL4. + +We hit a failure of resolving a symbol which is locally defined in a library, +in a complex case that I'll describe below. +If the dynamic linker, glibc or something else has a bug in it, please fix it. +If we did something wrong on creating a program, please point it out. + +We wrote a program that consists of an executable file and four libraries. +The executable file a.out requires two libraries, libA and libX. +The library libA requires another library libB. +The library libB requires another library libC. + +The program operates in the following steps. + ++------+ +-------+ +------+ +------+ +-----------------------------------+ +| libX | (2) | a.out | (1) | libA |----| libB |------| libC (5) (7) | +| | <=== | (8) | ===> | | | | <=== | atexit(libC_fini)--> _libC_fini() | ++------+ (3) +-------+ (6) +------+ +------+ (4) +-----------------------------------+ + +(1) a.out calls dlopen() for libA. + libB and libC shall be loaded, too. +(2) a.out calls dlopen() for libX. +(3) a.out calls dlclose() for libX. +(4) libC calls dlopen() for libB. +(5) libC calls atexit() to register libC_fini(). +(6) a.out calls dlclose() for libA. + libB and libC are no longer needed, so both libraries shall be getting unloaded. +(7) libC_fini() shall be called when libC is getting unloaded. +(8) a.out exits. + +But when we run the program, unexpectedly + +a) step (7) is executed _after_ step (8) +b) libC cannot resolve a locally-defined symbol _libC_fini at executing (7) + +Version-Release number of selected component: +- Red Hat Enterprise Linux Version Number: 4 +- Release Number: 8 +- Architecture: x86 +- Kernel Version: 2.6.9-89.ELsmp +- Related Package Version: glibc-2.3.4-2.43.el4_8.2 +- Related Middleware / Application: None + +Drivers or hardware or architecture dependency: +None. + +How reproducible: +always. + +Step to Reproduce: +1) Extract the reproducer. + $ tar zxvf reproducer.tar.gz + +2) Compile it. + $ cd reproducer + $ make + +3) Run it. + $ ./run.sh + +Actual Results: +$ ./run.sh +1)main:dlopen libA.so +2)main:dlopen libX.so +3)main:dlclose libX.so +4)libC:dlopen libB.so +5)libC:atexit(libC_fini) +6)main:dlclose libA.so +8)main:finish main +./main: symbol lookup error: ./libC.so: undefined symbol: _libC_fini + +Expected Results: +$ ./run.sh +1)main:dlopen libA.so +2)main:dlopen libX.so +3)main:dlclose libX.so +4)libC:dlopen libB.so +5)libC:atexit(libC_fini) +6)main:dlclose libA.so +7)libC:finish - atexit() +8)main:finish main + +Summary of actions taken to resolve issue: +None. + +Location of diagnostic data: +None. + +Hardware configuration: +Model: PRIMERGY RX300 S5 +CPU Info: Xeon(R) 2.27GHz x2 +Memory Info: 3GB +Hardware Component Information: None +Configuration Info: None +Guest Configuration Info: None + +Business Impact: +The application suffering this issue cannot call the function registered +by atexit() because of the failure of resolving its symbol. It causes two +severe problems, a) the failure of cooperation with other processes by +notifying them of its completion, and b) the system resource leaks by not +freeing them. + +Target Release: 4.9 + +Errata Request: async errata for 4.8 + +Hotfix Request: None. + +Additional Info: +Sosreport and reproducer are attached. + +This is the same bug as IT #580553 https://bugzilla.redhat.com/show_bug.cgi?id=593675 (RHEL5) diff --git a/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/golden.out b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/golden.out new file mode 100644 index 0000000..4fe6cde --- /dev/null +++ b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/golden.out @@ -0,0 +1,8 @@ +1)main:dlopen libA.so +2)main:dlopen libX.so +3)main:dlclose libX.so +4)libC:dlopen libB.so +5)libC:atexit(libC_fini) +6)main:dlclose libA.so +8)main:finish main +7)libC:finish - atexit() diff --git a/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/main.fmf b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/main.fmf new file mode 100644 index 0000000..6adb034 --- /dev/null +++ b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/main.fmf @@ -0,0 +1,137 @@ +summary: Test for bz600457 ([4.8] Unexpected failure of resolving a) +description: | + Bug summary: [4.8] Unexpected failure of resolving a locally-defined symbol. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=600457 + + Description: + + Customer Contact Name: + Naoki Yanagimoto + + Description of Problem: + This problem is the same as issue #580553 of RHEL5. + This ticket is for RHEL4. + + We hit a failure of resolving a symbol which is locally defined in a library, + in a complex case that I'll describe below. + If the dynamic linker, glibc or something else has a bug in it, please fix it. + If we did something wrong on creating a program, please point it out. + + We wrote a program that consists of an executable file and four libraries. + The executable file a.out requires two libraries, libA and libX. + The library libA requires another library libB. + The library libB requires another library libC. + + The program operates in the following steps. + + +------+ +-------+ +------+ +------+ +-----------------------------------+ + | libX | (2) | a.out | (1) | libA |----| libB |------| libC (5) (7) | + | | <=== | (8) | ===> | | | | <=== | atexit(libC_fini)--> _libC_fini() | + +------+ (3) +-------+ (6) +------+ +------+ (4) +-----------------------------------+ + + (1) a.out calls dlopen() for libA. + libB and libC shall be loaded, too. + (2) a.out calls dlopen() for libX. + (3) a.out calls dlclose() for libX. + (4) libC calls dlopen() for libB. + (5) libC calls atexit() to register libC_fini(). + (6) a.out calls dlclose() for libA. + libB and libC are no longer needed, so both libraries shall be getting unloaded. + (7) libC_fini() shall be called when libC is getting unloaded. + (8) a.out exits. + + But when we run the program, unexpectedly + + a) step (7) is executed _after_ step (8) + b) libC cannot resolve a locally-defined symbol _libC_fini at executing (7) + + Version-Release number of selected component: + - Red Hat Enterprise Linux Version Number: 4 + - Release Number: 8 + - Architecture: x86 + - Kernel Version: 2.6.9-89.ELsmp + - Related Package Version: glibc-2.3.4-2.43.el4_8.2 + - Related Middleware / Application: None + + Drivers or hardware or architecture dependency: + None. + + How reproducible: + always. + + Step to Reproduce: + 1) Extract the reproducer. + $ tar zxvf reproducer.tar.gz + + 2) Compile it. + $ cd reproducer + $ make + + 3) Run it. + $ ./run.sh + + Actual Results: + $ ./run.sh + 1)main:dlopen libA.so + 2)main:dlopen libX.so + 3)main:dlclose libX.so + 4)libC:dlopen libB.so + 5)libC:atexit(libC_fini) + 6)main:dlclose libA.so + 8)main:finish main + ./main: symbol lookup error: ./libC.so: undefined symbol: _libC_fini + + Expected Results: + $ ./run.sh + 1)main:dlopen libA.so + 2)main:dlopen libX.so + 3)main:dlclose libX.so + 4)libC:dlopen libB.so + 5)libC:atexit(libC_fini) + 6)main:dlclose libA.so + 7)libC:finish - atexit() + 8)main:finish main + + Summary of actions taken to resolve issue: + None. + + Location of diagnostic data: + None. + + Hardware configuration: + Model: PRIMERGY RX300 S5 + CPU Info: Xeon(R) 2.27GHz x2 + Memory Info: 3GB + Hardware Component Information: None + Configuration Info: None + Guest Configuration Info: None + + Business Impact: + The application suffering this issue cannot call the function registered + by atexit() because of the failure of resolving its symbol. It causes two + severe problems, a) the failure of cooperation with other processes by + notifying them of its completion, and b) the system resource leaks by not + freeing them. + + Target Release: 4.9 + + Errata Request: async errata for 4.8 + + Hotfix Request: None. + + Additional Info: + Sosreport and reproducer are attached. + + This is the same bug as IT #580553 https://bugzilla.redhat.com/show_bug.cgi?id=593675 (RHEL5) +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=600457 +extra-summary: /tools/glibc/Regression/bz600457-locally-defined-symbol-resolving-failure +extra-task: /tools/glibc/Regression/bz600457-locally-defined-symbol-resolving-failure diff --git a/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/reproducer.tar.gz b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/reproducer.tar.gz new file mode 100644 index 0000000..9551435 Binary files /dev/null and b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/reproducer.tar.gz differ diff --git a/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/runtest.sh b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/runtest.sh new file mode 100755 index 0000000..d7ab15b --- /dev/null +++ b/tests/Regression/bz600457-locally-defined-symbol-resolving-failure/runtest.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz600457-locally-defined-symbol-resolving-failure +# Description: Test for bz600457 ([4.8] Unexpected failure of resolving a) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + +rlPhaseStartSetup + rlRun "tar xfz reproducer.tar.gz" + rlRun "pushd reproducer" + rlRun "make" +rlPhaseEnd + +rlPhaseStartTest + rlRun "./run.sh &> output.out" + rlAssertNotDiffer ../golden.out output.out + if [ "$?" != "0" ] + then + rlLog "Difference between outputs:" + diff -u ../golden.out output.out | while read line + do + rlLog "$line" + done + fi +rlPhaseEnd + +rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -rf reproducer" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/Makefile b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/Makefile new file mode 100644 index 0000000..6122763 --- /dev/null +++ b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some +# Description: Test for bz656530 (sqrtl returns highly incorrect results for some) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE sqrt.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + 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 bz656530 (sqrtl returns highly incorrect results for some)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 656530" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/PURPOSE b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/PURPOSE new file mode 100644 index 0000000..0739a92 --- /dev/null +++ b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/PURPOSE @@ -0,0 +1,9 @@ +PURPOSE of /tools/glibc/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some +Description: Test for bz656530 (sqrtl returns highly incorrect results for some) +Author: Miroslav Franc +Bug summary: sqrtl returns highly incorrect results for some inputs +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=656530 + +Description: + +Escalated to Bugzilla from IssueTracker diff --git a/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/main.fmf b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/main.fmf new file mode 100644 index 0000000..1b55a3d --- /dev/null +++ b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/main.fmf @@ -0,0 +1,21 @@ +summary: Test for bz656530 (sqrtl returns highly incorrect results for some) +description: | + Bug summary: sqrtl returns highly incorrect results for some inputs + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=656530 + + Description: + + Escalated to Bugzilla from IssueTracker +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=656530 +extra-summary: /tools/glibc/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some +extra-task: /tools/glibc/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some diff --git a/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/runtest.sh b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/runtest.sh new file mode 100755 index 0000000..6ed2b60 --- /dev/null +++ b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some +# Description: Test for bz656530 (sqrtl returns highly incorrect results for some) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" +result='0x1.49p+504' +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp sqrt.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc sqrt.c -lm" 0 "Compiling reproducer" + rlRun "ActualResult=\`./a.out\`" 0 "Running reproducer" + rlRun "test '$ActualResult' = '$result'" 0 "Output is: '$ActualResult', it should be '$result'" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/sqrt.c b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/sqrt.c new file mode 100644 index 0000000..76a5b34 --- /dev/null +++ b/tests/Regression/bz656530-sqrtl-returns-highly-incorrect-results-for-some/sqrt.c @@ -0,0 +1,24 @@ +/* + * bz#656530 + * Fix comparison in sqrtl for IBM long double 128 + * http://sourceware.org/ml/libc-alpha/2010-11/msg00033.html + */ +#include +#include + +int main() +{ + long double x, y, sum, root; + + x = 0x1.c30000000029p-175; + y = 0x1.49p+504; + + sum = x*x + y*y; + root = sqrtl(sum); + + printf("%a\n", (double)root); + /* should produce 0x1.49p+504 and not -inf */ + + return 0; +} + diff --git a/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/Makefile b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/Makefile new file mode 100644 index 0000000..0e43dbe --- /dev/null +++ b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy +# Description: Test for bz657570 (strptime()'s '%b' descriptor should be greedy) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE strptime.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: Test for bz657570 (strptime()'s '%b' descriptor should be greedy)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc glibc-langpack-fi" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 657570" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/PURPOSE b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/PURPOSE new file mode 100644 index 0000000..8e9b2a0 --- /dev/null +++ b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy +Description: Test for bz657570 (strptime()'s '%b' descriptor should be greedy) +Author: Miroslav Franc +Bug summary: strptime()'s '%b' descriptor should be greedy +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=657570 diff --git a/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/main.fmf b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/main.fmf new file mode 100644 index 0000000..6d91228 --- /dev/null +++ b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/main.fmf @@ -0,0 +1,18 @@ +summary: Test for bz657570 (strptime()'s '%b' descriptor should be greedy) +description: | + Bug summary: strptime()'s '%b' descriptor should be greedy + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=657570 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - glibc-langpack-fi +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=657570 +extra-summary: /tools/glibc/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy +extra-task: /tools/glibc/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy diff --git a/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/runtest.sh b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/runtest.sh new file mode 100755 index 0000000..2350638 --- /dev/null +++ b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy +# Description: Test for bz657570 (strptime()'s '%b' descriptor should be greedy) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp strptime.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -std=gnu99 -o strptime strptime.c" + rlAssertExists "./strptime" + rlRun "./strptime > log 2>&1" + rlAssertGrep 'r-s = 6, tm.tm_mon = 10' log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/strptime.c b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/strptime.c new file mode 100644 index 0000000..56126f8 --- /dev/null +++ b/tests/Regression/bz657570-strptime-s-b-descriptor-should-be-greedy/strptime.c @@ -0,0 +1,22 @@ +#define _XOPEN_SOURCE +#include +#include +#include +#include +#include + +int +main (void) +{ + if (setlocale (LC_ALL, "fi_FI.utf8") == NULL) + { + puts ("cannot set locale"); + return 1; + } + struct tm tm; + static const char s[] = "marras"; + char *r = strptime (s, "%b", &tm); + printf ("r = %p, r-s = %ju, tm.tm_mon = %d\n", r, (uintmax_t)(r - s), +tm.tm_mon); + return r == NULL || r - s != strlen(s) || tm.tm_mon != 10; +} diff --git a/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/Makefile b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/Makefile new file mode 100644 index 0000000..f8d52b2 --- /dev/null +++ b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing +# Description: Test for bz657572 (Finnish locale includes unnecessary, confusing) +# 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/glibc/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE golden.out + +.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 bz657572 (Finnish locale includes unnecessary, confusing)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-langpack-fi" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 657572" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/PURPOSE b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/PURPOSE new file mode 100644 index 0000000..bf155d0 --- /dev/null +++ b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing +Description: Test for bz657572 (Finnish locale includes unnecessary, confusing) +Author: Miroslav Franc +Bug summary: Finnish locale includes unnecessary, confusing trailing spaces in the abbreviated months +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=657572 diff --git a/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/golden.out b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/golden.out new file mode 100644 index 0000000..fcc4c51 --- /dev/null +++ b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/golden.out @@ -0,0 +1,12 @@ +.tammi. +.helmi. +.maalis. +.huhti. +.touko. +.kesä. +.heinä. +.elo. +.syys. +.loka. +.marras. +.joulu. diff --git a/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/main.fmf b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/main.fmf new file mode 100644 index 0000000..c5cc62a --- /dev/null +++ b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz657572 (Finnish locale includes unnecessary, confusing) +description: | + Bug summary: Finnish locale includes unnecessary, confusing trailing spaces in the abbreviated months + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=657572 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-langpack-fi +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=657572 +extra-summary: /tools/glibc/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing +extra-task: /tools/glibc/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing diff --git a/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/runtest.sh b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/runtest.sh new file mode 100755 index 0000000..a4a4b65 --- /dev/null +++ b/tests/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz657572-Finnish-locale-includes-unnecessary-confusing +# Description: Test for bz657572 (Finnish locale includes unnecessary, confusing) +# 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 || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp golden.out $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "for ((i=1;i<=12;++i)); do LC_TIME=fi_FI.utf8 date -d \$(printf 2010%02d01 \$i) '+.%b.';done > log" + rlAssertNotDiffer golden.out log + rlLog "$(diff -u golden.out log)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/676039-resolver.c b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/676039-resolver.c new file mode 100644 index 0000000..a1f52ef --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/676039-resolver.c @@ -0,0 +1,59 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void +dump_res (struct addrinfo *p_res) +{ + struct addrinfo *iter = p_res; + while (iter != 0) + { + struct sockaddr_in *addr1b; + addr1b = (struct sockaddr_in *) iter->ai_addr; + printf ("getaddrinfo returns: %s %d %d\n", inet_ntoa (addr1b->sin_addr), + iter->ai_family, iter->ai_protocol); + iter = iter->ai_next; + } +} + +int +main (int argc, char *argv[]) +{ + if (argc != 2) + { + printf ("Usage prog hostname\n"); + exit (7); + } + + struct addrinfo hints, *res; + int error, i; + + bzero (&hints, sizeof (hints)); + hints.ai_flags = AI_CANONNAME; + hints.ai_family = AF_UNSPEC; + + for (i = 0; i < 2; i++) + { + printf ("======== ATTEMPT %d ===============\n", i); + + if ((error = getaddrinfo (argv[1], NULL, &hints, &res))) + { + perror ("getaddrinfo"); + exit (-1); + } + + dump_res (res); + freeaddrinfo (res); + } + /* not such a bad idea ;-) */ + return 0; +} diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/Makefile b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/Makefile new file mode 100644 index 0000000..391ce2a --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz676039-Resolver-fails-to-return-all-addresses-of +# Description: Test for bz676039 (Resolver fails to return all addresses of) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz676039-Resolver-fails-to-return-all-addresses-of +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE 676039-resolver.c a.out-gold getent-gold + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + 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 bz676039 (Resolver fails to return all addresses of)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-common gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 676039" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/PURPOSE b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/PURPOSE new file mode 100644 index 0000000..38df2dc --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/PURPOSE @@ -0,0 +1,143 @@ +PURPOSE of /tools/glibc/Regression/bz676039-Resolver-fails-to-return-all-addresses-of +Description: Test for bz676039 (Resolver fails to return all addresses of) +Author: Miroslav Franc +Bug summary: Resolver fails to return all addresses of multi-homed hosts in /etc/hosts +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=676039 + +Description: + +getaddrinfo does not return all ip addresses on first call when name resolution is done from /etc/hosts. + +This has been fixed by the following commits upstream: + +1f0398248c1c581a1203c0d294acde295b949fea +1ce7d80ddc62d4bb3e8e4f89fbcb6fa21361733d + +1ce7d80ddc62d4bb3e8e4f89fbcb6fa21361733d is needed because nscd links in getaddrinfo. The side-effect is that a similar bug in nscd will also be fixed (upstream bug #4814). + +Private branch: private-spoyarek-ROS00401237 +Build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=3051905 + + +Customer has verified that the patch works + +This issue was first reported to Oracle as a problem with Java. The public link to the report can be found here: +http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7007462 + +Consider the following setup on RedHat Enterprise Linux 5.5 x64. +1) Add the following lines to /etc/hosts: +multihost 1.1.1.1 +multihost 2.2.2.2 +multihost 3.3.3.3 + +2) Add the following line to /etc/host.conf: +multi on + +3) Compile and execute the following program (provided by Oracle Java engineering team): + +/* This test code is to be used for demonstrating the +* issue associated with SR 2-8229521. +*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void dump_res(struct addrinfo * p_res){ +struct addrinfo *iter = p_res; +while(iter != 0){ +struct sockaddr_in *addr1b; +addr1b = (struct sockaddr_in *)iter->ai_addr; +printf("getaddrinfo returns: %s %d %d\n", inet_ntoa(addr1b->sin_addr) , iter->ai_family, iter->ai_protocol ); +iter=iter->ai_next; +} +} + +int main(int argc, char *argv[]){ +if (argc != 2){ +printf("Usage prog hostname\n"); +exit(7); +} + +struct addrinfo hints, *res; +int error; + +bzero(&hints, sizeof(hints)); +hints.ai_flags = AI_CANONNAME; +hints.ai_family = AF_UNSPEC; + +printf("======== RH BUG ===============\n"); + +if ( (error = getaddrinfo(argv[1], NULL, &hints, &res) ) ){ +perror("getaddrinfo"); +exit(-1); +} + +dump_res(res); +freeaddrinfo(res); + +printf("======== WORKAROUND ===============\n"); + +hints.ai_family = AF_INET; + +if ( (error = getaddrinfo(argv[1], NULL, &hints, &res) ) ){ +perror("getaddrinfo"); +exit(-1); +} + +dump_res(res); +freeaddrinfo(res); +} + +4) You can see the following output from the above program: +# ./a.out multihost +======== RH BUG =============== +getaddrinfo returns: 1.1.1.1 2 6 +getaddrinfo returns: 1.1.1.1 2 17 +getaddrinfo returns: 1.1.1.1 2 0 +======== WORKAROUND =============== +getaddrinfo returns: 1.1.1.1 2 6 +getaddrinfo returns: 1.1.1.1 2 17 +getaddrinfo returns: 1.1.1.1 2 0 +getaddrinfo returns: 2.2.2.2 2 6 +getaddrinfo returns: 2.2.2.2 2 17 +getaddrinfo returns: 2.2.2.2 2 0 +getaddrinfo returns: 3.3.3.3 2 6 +getaddrinfo returns: 3.3.3.3 2 17 +getaddrinfo returns: 3.3.3.3 2 0 + + +Note that a similarly configured Ubuntu 10.10 Server (x64), provides the following - correct - output: +$ ./a.out multihost +======== RH BUG =============== +getaddrinfo returns: 1.1.1.1 2 6 +getaddrinfo returns: 1.1.1.1 2 17 +getaddrinfo returns: 1.1.1.1 2 0 +getaddrinfo returns: 2.2.2.2 2 6 +getaddrinfo returns: 2.2.2.2 2 17 +getaddrinfo returns: 2.2.2.2 2 0 +getaddrinfo returns: 3.3.3.3 2 6 +getaddrinfo returns: 3.3.3.3 2 17 +getaddrinfo returns: 3.3.3.3 2 0 +======== WORKAROUND =============== +getaddrinfo returns: 1.1.1.1 2 6 +getaddrinfo returns: 1.1.1.1 2 17 +getaddrinfo returns: 1.1.1.1 2 0 +getaddrinfo returns: 2.2.2.2 2 6 +getaddrinfo returns: 2.2.2.2 2 17 +getaddrinfo returns: 2.2.2.2 2 0 +getaddrinfo returns: 3.3.3.3 2 6 +getaddrinfo returns: 3.3.3.3 2 17 +getaddrinfo returns: 3.3.3.3 2 0 + +In other words, hints.ai_family / hints.ai_flags for getaddrinfo are not working properly. + +According to the manual of getaddrinfo (excerpts): "AF_UNSPEC in ai_family specifies any protocol family (either IPv4 or IPv6, for example)." diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/a.out-gold b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/a.out-gold new file mode 100644 index 0000000..e30352f --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/a.out-gold @@ -0,0 +1,20 @@ +======== ATTEMPT 0 =============== +getaddrinfo returns: 1.1.1.1 2 6 +getaddrinfo returns: 1.1.1.1 2 17 +getaddrinfo returns: 1.1.1.1 2 0 +getaddrinfo returns: 2.2.2.2 2 6 +getaddrinfo returns: 2.2.2.2 2 17 +getaddrinfo returns: 2.2.2.2 2 0 +getaddrinfo returns: 3.3.3.3 2 6 +getaddrinfo returns: 3.3.3.3 2 17 +getaddrinfo returns: 3.3.3.3 2 0 +======== ATTEMPT 1 =============== +getaddrinfo returns: 1.1.1.1 2 6 +getaddrinfo returns: 1.1.1.1 2 17 +getaddrinfo returns: 1.1.1.1 2 0 +getaddrinfo returns: 2.2.2.2 2 6 +getaddrinfo returns: 2.2.2.2 2 17 +getaddrinfo returns: 2.2.2.2 2 0 +getaddrinfo returns: 3.3.3.3 2 6 +getaddrinfo returns: 3.3.3.3 2 17 +getaddrinfo returns: 3.3.3.3 2 0 diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/getent-gold b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/getent-gold new file mode 100644 index 0000000..beaee8e --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/getent-gold @@ -0,0 +1,18 @@ +1.1.1.1 STREAM multihost +1.1.1.1 DGRAM +1.1.1.1 RAW +2.2.2.2 STREAM +2.2.2.2 DGRAM +2.2.2.2 RAW +3.3.3.3 STREAM +3.3.3.3 DGRAM +3.3.3.3 RAW +1.1.1.1 STREAM multihost +1.1.1.1 DGRAM +1.1.1.1 RAW +2.2.2.2 STREAM +2.2.2.2 DGRAM +2.2.2.2 RAW +3.3.3.3 STREAM +3.3.3.3 DGRAM +3.3.3.3 RAW diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/main.fmf b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/main.fmf new file mode 100644 index 0000000..499e473 --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/main.fmf @@ -0,0 +1,156 @@ +summary: Test for bz676039 (Resolver fails to return all addresses of) +description: | + Bug summary: Resolver fails to return all addresses of multi-homed hosts in /etc/hosts + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=676039 + + Description: + + getaddrinfo does not return all ip addresses on first call when name resolution is done from /etc/hosts. + + This has been fixed by the following commits upstream: + + 1f0398248c1c581a1203c0d294acde295b949fea + 1ce7d80ddc62d4bb3e8e4f89fbcb6fa21361733d + + 1ce7d80ddc62d4bb3e8e4f89fbcb6fa21361733d is needed because nscd links in getaddrinfo. The side-effect is that a similar bug in nscd will also be fixed (upstream bug #4814). + + Private branch: private-spoyarek-ROS00401237 + Build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=3051905 + + + Customer has verified that the patch works + + This issue was first reported to Oracle as a problem with Java. The public link to the report can be found here: + http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7007462 + + Consider the following setup on RedHat Enterprise Linux 5.5 x64. + 1) Add the following lines to /etc/hosts: + multihost 1.1.1.1 + multihost 2.2.2.2 + multihost 3.3.3.3 + + 2) Add the following line to /etc/host.conf: + multi on + + 3) Compile and execute the following program (provided by Oracle Java engineering team): + + /* This test code is to be used for demonstrating the + * issue associated with SR 2-8229521. + */ + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + void dump_res(struct addrinfo * p_res){ + struct addrinfo *iter = p_res; + while(iter != 0){ + struct sockaddr_in *addr1b; + addr1b = (struct sockaddr_in *)iter->ai_addr; + printf("getaddrinfo returns: %s %d %d\n", inet_ntoa(addr1b->sin_addr) , iter->ai_family, iter->ai_protocol ); + iter=iter->ai_next; + } + } + + int main(int argc, char *argv[]){ + if (argc != 2){ + printf("Usage prog hostname\n"); + exit(7); + } + + struct addrinfo hints, *res; + int error; + + bzero(&hints, sizeof(hints)); + hints.ai_flags = AI_CANONNAME; + hints.ai_family = AF_UNSPEC; + + printf("======== RH BUG ===============\n"); + + if ( (error = getaddrinfo(argv[1], NULL, &hints, &res) ) ){ + perror("getaddrinfo"); + exit(-1); + } + + dump_res(res); + freeaddrinfo(res); + + printf("======== WORKAROUND ===============\n"); + + hints.ai_family = AF_INET; + + if ( (error = getaddrinfo(argv[1], NULL, &hints, &res) ) ){ + perror("getaddrinfo"); + exit(-1); + } + + dump_res(res); + freeaddrinfo(res); + } + + 4) You can see the following output from the above program: + # ./a.out multihost + ======== RH BUG =============== + getaddrinfo returns: 1.1.1.1 2 6 + getaddrinfo returns: 1.1.1.1 2 17 + getaddrinfo returns: 1.1.1.1 2 0 + ======== WORKAROUND =============== + getaddrinfo returns: 1.1.1.1 2 6 + getaddrinfo returns: 1.1.1.1 2 17 + getaddrinfo returns: 1.1.1.1 2 0 + getaddrinfo returns: 2.2.2.2 2 6 + getaddrinfo returns: 2.2.2.2 2 17 + getaddrinfo returns: 2.2.2.2 2 0 + getaddrinfo returns: 3.3.3.3 2 6 + getaddrinfo returns: 3.3.3.3 2 17 + getaddrinfo returns: 3.3.3.3 2 0 + + + Note that a similarly configured Ubuntu 10.10 Server (x64), provides the following - correct - output: + $ ./a.out multihost + ======== RH BUG =============== + getaddrinfo returns: 1.1.1.1 2 6 + getaddrinfo returns: 1.1.1.1 2 17 + getaddrinfo returns: 1.1.1.1 2 0 + getaddrinfo returns: 2.2.2.2 2 6 + getaddrinfo returns: 2.2.2.2 2 17 + getaddrinfo returns: 2.2.2.2 2 0 + getaddrinfo returns: 3.3.3.3 2 6 + getaddrinfo returns: 3.3.3.3 2 17 + getaddrinfo returns: 3.3.3.3 2 0 + ======== WORKAROUND =============== + getaddrinfo returns: 1.1.1.1 2 6 + getaddrinfo returns: 1.1.1.1 2 17 + getaddrinfo returns: 1.1.1.1 2 0 + getaddrinfo returns: 2.2.2.2 2 6 + getaddrinfo returns: 2.2.2.2 2 17 + getaddrinfo returns: 2.2.2.2 2 0 + getaddrinfo returns: 3.3.3.3 2 6 + getaddrinfo returns: 3.3.3.3 2 17 + getaddrinfo returns: 3.3.3.3 2 0 + + In other words, hints.ai_family / hints.ai_flags for getaddrinfo are not working properly. + + According to the manual of getaddrinfo (excerpts): "AF_UNSPEC in ai_family specifies any protocol family (either IPv4 or IPv6, for example)." +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-common + - gcc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=676039 +extra-summary: /tools/glibc/Regression/bz676039-Resolver-fails-to-return-all-addresses-of +extra-task: /tools/glibc/Regression/bz676039-Resolver-fails-to-return-all-addresses-of diff --git a/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/runtest.sh b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/runtest.sh new file mode 100755 index 0000000..547e2c6 --- /dev/null +++ b/tests/Regression/bz676039-Resolver-fails-to-return-all-addresses-of/runtest.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz676039-Resolver-fails-to-return-all-addresses-of +# Description: Test for bz676039 (Resolver fails to return all addresses of) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=(glibc gcc glibc-common) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + # currently cannot count on beakerlib, it could be more stable + rlRun "cp -f /etc/hosts /etc/hosts.backup" + rlRun "cp -f /etc/host.conf /etc/host.conf.backup" + rlRun "echo -e '1.1.1.1 multihost\n2.2.2.2 multihost\n3.3.3.3 multihost' >> /etc/hosts" + rlRun "grep -q 'multi on' /etc/host.conf || echo 'multi on' >> /etc/host.conf" + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp 676039-resolver.c a.out-gold getent-gold $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc 676039-resolver.c" + rlAssertExists "./a.out" + rlPhaseEnd + + rlPhaseStartTest "Reproducer from bugzilla" + rlRun "./a.out multihost > a.out-log" + rlAssertNotDiffer "a.out-log" "a.out-gold" + rlLog "$(diff a.out-log a.out-gold)" + rlPhaseEnd + + rlPhaseStartTest "getent ahosts" + rlRun "getent ahosts multihost multihost > getent-log" + # trailing spaces can sometimes cause problems + # different versions have different output + # that's why I decided to get rid of them + rlRun "sed -i 's/ *$//' getent-log" + rlAssertNotDiffer "getent-log" "getent-gold" + rlLog "$(diff getent-log getent-gold)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "cp -f /etc/hosts.backup /etc/hosts" + rlRun "cp -f /etc/host.conf.backup /etc/host.conf" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz689471-SSE4-strncmp-failure/Makefile b/tests/Regression/bz689471-SSE4-strncmp-failure/Makefile new file mode 100644 index 0000000..e00273e --- /dev/null +++ b/tests/Regression/bz689471-SSE4-strncmp-failure/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz689471-SSE4-strncmp-failure +# Description: Test for bz689471 (SSE4 strncmp failure) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz689471-SSE4-strncmp-failure +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE repr.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + 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 bz689471 (SSE4 strncmp failure)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 689471" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz689471-SSE4-strncmp-failure/PURPOSE b/tests/Regression/bz689471-SSE4-strncmp-failure/PURPOSE new file mode 100644 index 0000000..2de0bad --- /dev/null +++ b/tests/Regression/bz689471-SSE4-strncmp-failure/PURPOSE @@ -0,0 +1,54 @@ +PURPOSE of /tools/glibc/Regression/bz689471-SSE4-strncmp-failure +Description: Test for bz689471 (SSE4 strncmp failure) +Author: Miroslav Franc +Bug summary: SSE4 strncmp failure +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=689471 + +Description: + +H.J. Lu 2011-03-21 05:42:34 CET +On Intel Core i7, I got + +[hjl@gnu-6 997]$ cat saved.c +#include +#include +#include +#include + +int main() +{ + char *buf, *buf2; + + buf = (char*)mmap((void*)0x100000000, 0x2000 * 2, + PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + buf = mmap((char *)buf, 0x2000, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + memset(buf, 'a', 0x2000); + buf[0x1fff] = 0; + buf2 = strdup(buf); + if (strncmp (buf + 3994, buf2 + 2635, 6241) >= 0) + abort (); + + return 0; +} +[hjl@gnu-6 997]$ gcc saved.c +[hjl@gnu-6 997]$ ./a.out +Segmentation fault +[hjl@gnu-6 997]$ gdb a.out +GNU gdb (GDB) 7.2.50.20110312-cvs +Copyright (C) 2011 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. Type "show copying" +and "show warranty" for details. +This GDB was configured as "x86_64-unknown-linux-gnu". +For bug reporting instructions, please see: +... +Reading symbols from /export/home/hjl/bugs/libc/997/a.out...(no debugging +symbols found)...done. +(gdb) r +Starting program: /export/home/hjl/bugs/libc/997/a.out + +Program received signal SIGSEGV, Segmentation fault. +0x0000003f7d3214a0 in __strncmp_sse42 () from /lib64/libc.so.6 +(gdb) diff --git a/tests/Regression/bz689471-SSE4-strncmp-failure/main.fmf b/tests/Regression/bz689471-SSE4-strncmp-failure/main.fmf new file mode 100644 index 0000000..c62404d --- /dev/null +++ b/tests/Regression/bz689471-SSE4-strncmp-failure/main.fmf @@ -0,0 +1,66 @@ +summary: Test for bz689471 (SSE4 strncmp failure) +description: | + Bug summary: SSE4 strncmp failure + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=689471 + + Description: + + H.J. Lu 2011-03-21 05:42:34 CET + On Intel Core i7, I got + + [hjl@gnu-6 997]$ cat saved.c + #include + #include + #include + #include + + int main() + { + char *buf, *buf2; + + buf = (char*)mmap((void*)0x100000000, 0x2000 * 2, + PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + buf = mmap((char *)buf, 0x2000, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + memset(buf, 'a', 0x2000); + buf[0x1fff] = 0; + buf2 = strdup(buf); + if (strncmp (buf + 3994, buf2 + 2635, 6241) >= 0) + abort (); + + return 0; + } + [hjl@gnu-6 997]$ gcc saved.c + [hjl@gnu-6 997]$ ./a.out + Segmentation fault + [hjl@gnu-6 997]$ gdb a.out + GNU gdb (GDB) 7.2.50.20110312-cvs + Copyright (C) 2011 Free Software Foundation, Inc. + License GPLv3+: GNU GPL version 3 or later + This is free software: you are free to change and redistribute it. + There is NO WARRANTY, to the extent permitted by law. Type "show copying" + and "show warranty" for details. + This GDB was configured as "x86_64-unknown-linux-gnu". + For bug reporting instructions, please see: + ... + Reading symbols from /export/home/hjl/bugs/libc/997/a.out...(no debugging + symbols found)...done. + (gdb) r + Starting program: /export/home/hjl/bugs/libc/997/a.out + + Program received signal SIGSEGV, Segmentation fault. + 0x0000003f7d3214a0 in __strncmp_sse42 () from /lib64/libc.so.6 + (gdb) +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=689471 +extra-summary: /tools/glibc/Regression/bz689471-SSE4-strncmp-failure +extra-task: /tools/glibc/Regression/bz689471-SSE4-strncmp-failure diff --git a/tests/Regression/bz689471-SSE4-strncmp-failure/repr.c b/tests/Regression/bz689471-SSE4-strncmp-failure/repr.c new file mode 100644 index 0000000..b0bdd8b --- /dev/null +++ b/tests/Regression/bz689471-SSE4-strncmp-failure/repr.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +int main() +{ + char *buf, *buf2; + + buf = (char*)mmap((void*)0x100000000, 0x2000 * 2, + PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + buf = mmap((char *)buf, 0x2000, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + memset(buf, 'a', 0x2000); + buf[0x1fff] = 0; + buf2 = strdup(buf); + if (strncmp (buf + 3994, buf2 + 2635, 6241) >= 0) + abort (); + + return 0; +} diff --git a/tests/Regression/bz689471-SSE4-strncmp-failure/runtest.sh b/tests/Regression/bz689471-SSE4-strncmp-failure/runtest.sh new file mode 100755 index 0000000..90bfbfa --- /dev/null +++ b/tests/Regression/bz689471-SSE4-strncmp-failure/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz689471-SSE4-strncmp-failure +# Description: Test for bz689471 (SSE4 strncmp failure) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp repr.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -o bug repr.c" + rlPhaseEnd + + rlPhaseStartTest "Shouldn't segfault (ret=139), just end with 0." + rlRun "./bug" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/Makefile b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/Makefile new file mode 100644 index 0000000..d6b081c --- /dev/null +++ b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on +# Description: Test for bz692177 (sysconf(_SC_*CACHE) returns 0 for all caches on) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on +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) + 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 bz692177 (sysconf(_SC_*CACHE) returns 0 for all caches on)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 692177" >> $(METADATA) + @echo "Architectures: x86_64 i386" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/PURPOSE b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/PURPOSE new file mode 100644 index 0000000..3876cd6 --- /dev/null +++ b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/PURPOSE @@ -0,0 +1,44 @@ +PURPOSE of /tools/glibc/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on +Description: Test for bz692177 (sysconf(_SC_*CACHE) returns 0 for all caches on) +Author: Miroslav Franc +Bug summary: sysconf(_SC_*CACHE) returns 0 for all caches on some CPUs. +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=692177 + +Description: + +Description of problem: + The mechanism that sysconf(3) uses to get the various CACHE parameters + fails on the Xen 5670 + +Version-Release number of selected component (if applicable): 2.12-1.7.el6_0.4 + +How reproducible: + Every time + +Steps to Reproduce: +1. Find a machine whose /proc/cpuinfo starts something like this: + + vendor_id : GenuineIntel + cpu family : 6 + model : 44 + model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz + stepping : 2 + +2. run "getconf -a | grep CACHE" +3. Observe values printed + +Actual results: + All the cache parameter values are zero. + +Expected results: + Non-zero values for all but the level 4 cache + +Additional info: + Recent CPUs no longer have useful cpuid leaf 2 cache descriptors. For this + particular machine, cpuid 2 returns 0x55035a01 0xf0b2ff 0x0 0xca0000 in eax, + ebx, ecx and edx respectively. The 0xff in the least significant byte of + ebx indicates that you need to use cpuid leaf 4. Actually, for all but + somewhat old CPUs you're better off using cpuid leaf 4 anyway (the only + machines I have access to that have a cpuid level less than four are a + "Intel(R) Pentium(R) 4 CPU 1.70GHz" and "Intel(R) Pentium(R) 4 CPU 2.40GHz" + both of which are long past their use-by date). diff --git a/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/main.fmf b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/main.fmf new file mode 100644 index 0000000..477bc40 --- /dev/null +++ b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/main.fmf @@ -0,0 +1,55 @@ +summary: Test for bz692177 (sysconf(_SC_*CACHE) returns 0 for all caches on) +description: | + Bug summary: sysconf(_SC_*CACHE) returns 0 for all caches on some CPUs. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=692177 + + Description: + + Description of problem: + The mechanism that sysconf(3) uses to get the various CACHE parameters + fails on the Xen 5670 + + Version-Release number of selected component (if applicable): 2.12-1.7.el6_0.4 + + How reproducible: + Every time + + Steps to Reproduce: + 1. Find a machine whose /proc/cpuinfo starts something like this: + + vendor_id : GenuineIntel + cpu family : 6 + model : 44 + model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz + stepping : 2 + + 2. run "getconf -a | grep CACHE" + 3. Observe values printed + + Actual results: + All the cache parameter values are zero. + + Expected results: + Non-zero values for all but the level 4 cache + + Additional info: + Recent CPUs no longer have useful cpuid leaf 2 cache descriptors. For this + particular machine, cpuid 2 returns 0x55035a01 0xf0b2ff 0x0 0xca0000 in eax, + ebx, ecx and edx respectively. The 0xff in the least significant byte of + ebx indicates that you need to use cpuid leaf 4. Actually, for all but + somewhat old CPUs you're better off using cpuid leaf 4 anyway (the only + machines I have access to that have a cpuid level less than four are a + "Intel(R) Pentium(R) 4 CPU 1.70GHz" and "Intel(R) Pentium(R) 4 CPU 2.40GHz" + both of which are long past their use-by date). +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=692177 +extra-summary: /tools/glibc/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on +extra-task: /tools/glibc/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on diff --git a/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/runtest.sh b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/runtest.sh new file mode 100755 index 0000000..1d193f9 --- /dev/null +++ b/tests/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz692177-sysconf-SC-CACHE-returns-0-for-all-caches-on +# Description: Test for bz692177 (sysconf(_SC_*CACHE) returns 0 for all caches on) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc-common" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlPhaseEnd + + rlPhaseStartTest "Cache sizes are reported with nonzero sizes" + rlRun "test $(getconf -a | grep -i cache | awk '{i+=$2} END{print i}') != 0" 0\ + "Sum of cache sizes is non-zero." + rlLog "$(getconf -a | grep -i cache)" + rlPhaseEnd + + rlPhaseStartTest "(Xeon 5670 only - only L4 is missing)" + if grep 'model name' /proc/cpuinfo | grep -q 5670; then + rlRun "getconf -a | grep -i cache | grep -vi LEVEL4 | awk '0 == \$2 {exit 1}'" 0\ + "All caches on Xeon 5670 are non-zero." + rlLog "$(getconf -a | grep -i cache | grep -vi LEVEL4)" + else + rlLog "This machine is not Xeon 5670" + rlLog "$(grep 'model name' /proc/cpuinfo)" + fi + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/Makefile b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/Makefile new file mode 100644 index 0000000..42390d1 --- /dev/null +++ b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte +# Description: Test for bz694386 (POWER4 strncmp crashes reading past zero byte) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE strncmp.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: Test for bz694386 (POWER4 strncmp crashes reading past zero byte)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-headers glibc-devel glibc-common gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 694386" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/PURPOSE b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/PURPOSE new file mode 100644 index 0000000..8dda079 --- /dev/null +++ b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte +Description: Test for bz694386 (POWER4 strncmp crashes reading past zero byte) +Author: Miroslav Franc +Bug summary: POWER4 strncmp crashes reading past zero byte +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=694386 diff --git a/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/main.fmf b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/main.fmf new file mode 100644 index 0000000..9572be9 --- /dev/null +++ b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/main.fmf @@ -0,0 +1,20 @@ +summary: Test for bz694386 (POWER4 strncmp crashes reading past zero byte) +description: | + Bug summary: POWER4 strncmp crashes reading past zero byte + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=694386 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-headers + - glibc-devel + - glibc-common + - gcc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=694386 +extra-summary: /tools/glibc/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte +extra-task: /tools/glibc/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte diff --git a/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/runtest.sh b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/runtest.sh new file mode 100755 index 0000000..750054b --- /dev/null +++ b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte +# Description: Test for bz694386 (POWER4 strncmp crashes reading past zero byte) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc glibc-devel glibc-common gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp strncmp.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -fno-builtin -g strncmp.c -o repr" + rlRun "gcc -fno-builtin -g -O2 strncmp.c -o repr2" + rlAssertExists "./repr" + rlAssertExists "./repr2" + rlPhaseEnd + + rlPhaseStartTest "If PASS, doesn't mean the bug is gone!" + rlRun "./repr" + rlRun "./repr2" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/strncmp.c b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/strncmp.c new file mode 100644 index 0000000..8c7b608 --- /dev/null +++ b/tests/Regression/bz694386-POWER4-strncmp-crashes-reading-past-zero-byte/strncmp.c @@ -0,0 +1,18 @@ +#define __NO_STRING_INLINES +#include +#include +#include + +int +main (void) +{ + char *p1; + int ps = getpagesize (); + + p1 = mmap (0, ps * 2, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + mprotect (p1 + ps, ps, PROT_NONE); + p1 += ps - 10; + strcpy (p1, "123456789"); + return (strncmp (p1, "1234567890", 11) == 0 + || strncmp ("1234567890", p1, 11) == 0); +} diff --git a/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/Makefile b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/Makefile new file mode 100644 index 0000000..1805d2b --- /dev/null +++ b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by +# Description: Test for bz699724 (Memory leak within NSSLOW_Init, as called by) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test_crypt.py + +.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 bz699724 (Memory leak within NSSLOW_Init, as called by)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 60m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc python python-test python3 python3-test valgrind" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 699724" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/PURPOSE b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/PURPOSE new file mode 100644 index 0000000..e143347 --- /dev/null +++ b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by +Description: Test for bz699724 (Memory leak within NSSLOW_Init, as called by) +Author: Miroslav Franc +Bug summary: Memory leak within NSSLOW_Init, as called by glibc's crypt, when using stronger salts +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=699724 diff --git a/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/main.fmf b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/main.fmf new file mode 100644 index 0000000..471e141 --- /dev/null +++ b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/main.fmf @@ -0,0 +1,21 @@ +summary: Test for bz699724 (Memory leak within NSSLOW_Init, as called by) +description: | + Bug summary: Memory leak within NSSLOW_Init, as called by glibc's crypt, when using stronger salts + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=699724 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - python + - python-test + - python3 + - python3-test + - valgrind +duration: 60m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=699724 +extra-summary: /tools/glibc/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by +extra-task: /tools/glibc/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by diff --git a/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/runtest.sh b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/runtest.sh new file mode 100755 index 0000000..8991a97 --- /dev/null +++ b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/runtest.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by +# Description: Test for bz699724 (Memory leak within NSSLOW_Init, as called by) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc valgrind) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp test_crypt.py $TmpDir" + rlRun "pushd $TmpDir" + if rlIsRHEL 9 + then + CURPYTHON="python3" + CURPYTEST="/usr/lib64/python3.9/test/test_crypt.py" + elif rlIsRHEL 8 + then + CURPYTHON="python3" + CURPYTEST="/usr/lib64/python3.6/test/test_crypt.py" + elif rlIsRHEL 7 + then + CURPYTHON="python" + CURPYTEST="/usr/lib64/python2.7/test/test_crypt.py" + elif rlIsRHEL 6 + then + CURPYTHON="python" + if [ "$(rlGetPrimaryArch)" == "i686" ] + then + CURPYTEST="/usr/lib/python2.6/test/test_crypt.py" + else + CURPYTEST="/usr/lib64/python2.6/test/test_crypt.py" + fi + else + # guess it's Fedora + CURPYTHON="python3" + CURPYPRETEST=$(python3 -m site |grep -o -E /usr/lib64/python3\\.[0-9]+|head -n 1) + CURPYTEST="${CURPYPRETEST}/test/test_crypt.py" + fi + + rlPhaseEnd + + rlPhaseStartTest "python-test package" + #rlRun "valgrind python /usr/lib64/python2.6/test/test_crypt.py 2>&1| grep -A2 'LEAK SUMMARY' > log 2>&1" + rlAssertExists $CURPYTEST + rlRun "valgrind $CURPYTHON $CURPYTEST > valgrind1.out 2>&1" + rlRun "grep -A2 'LEAK SUMMARY' valgrind1.out > log 2>&1" + rlRun "grep -q 'definitely lost: 0' log" + rlRun "grep -q 'indirectly lost: 0' log" + rlFileSubmit valgrind1.out + rlFileSubmit log + rlPhaseEnd + + rlPhaseStartTest "test_crypt.py bundled with the test case (50 x)" + #rlRun "valgrind --num-callers=50 --leak-check=full python test_crypt.py 50 2>&1| grep -A2 'LEAK SUMMARY' > log2 2>&1" + rlRun "valgrind --num-callers=50 --leak-check=full $CURPYTHON test_crypt.py 50 > valgrind2.out 2>&1" 0,1 + rlRun "grep -A2 'LEAK SUMMARY' valgrind2.out > log2 2>&1" + rlRun "grep -q 'definitely lost: 0' log2" + rlRun "grep -q 'indirectly lost: 0' log2" + rlFileSubmit valgrind2.out + rlFileSubmit log2 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/test_crypt.py b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/test_crypt.py new file mode 100644 index 0000000..05eac95 --- /dev/null +++ b/tests/Regression/bz699724-Memory-leak-within-NSSLOW-Init-as-called-by/test_crypt.py @@ -0,0 +1,37 @@ +from test import test_support +import unittest +import crypt +import sys + +class CryptTestCase(unittest.TestCase): + + def test_crypt(self): + c = crypt.crypt('mypassword', 'ab') + if test_support.verbose: + print 'Test encryption: ', c + + def test_salt(self): + self.assertEqual(len(crypt._saltchars), 64) + for method in crypt.methods: + salt = crypt.mksalt(method) + self.assertEqual(len(salt), + method.salt_chars + (3 if method.ident else 0)) + + def test_saltedcrypt(self): + for method in crypt.methods: + pw = crypt.crypt('assword', method) + self.assertEqual(len(pw), method.total_size) + pw = crypt.crypt('assword', crypt.mksalt(method)) + self.assertEqual(len(pw), method.total_size) + + def test_methods(self): + # Gurantee that METHOD_CRYPT is the last method in crypt.methods. + self.assertTrue(len(crypt.methods) >= 1) + self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1]) + +def test_main(): + test_support.run_unittest(CryptTestCase) + +if __name__ == "__main__": + for i in xrange(int(sys.argv[1])): + test_main() diff --git a/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/Makefile b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/Makefile new file mode 100644 index 0000000..9bdd683 --- /dev/null +++ b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used +# Description: Test for bz705465 (fix for handle overflows of temporary buffer used) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE repr.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + 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 bz705465 (fix for handle overflows of temporary buffer used)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc nss_db gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 705465" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/PURPOSE b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/PURPOSE new file mode 100644 index 0000000..551ac25 --- /dev/null +++ b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/PURPOSE @@ -0,0 +1,41 @@ +PURPOSE of /tools/glibc/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used +Description: Test for bz705465 (fix for handle overflows of temporary buffer used) +Author: Miroslav Franc +Bug summary: fix for handle overflows of temporary buffer used to handle multi lookups locally. +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=705465 + +Description: + +Description of problem: + +An issue in glibc causes threaded processes to not get all the groups assigned to that process. Because the pointer to the next group entry can be moved we have seen applications with incomplete group membership. + +This issue is resolved by several upstream patches including: + +http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commit;h=ab8eed78a6614f7e7e5a908efdcb9f390f849563 + +Also, it is resolved with the patch for glibc BZ 10484: + +[BZ #10484] +* nss/nss_files/files-hosts.c (HOST_DB_LOOKUP): Handle overflows of temporary buffer used to handle multi lookups locally. +* Versions [libc] (GLIBC_PRIVATE): Export __libc_alloca_cutoff. + +I will attach the two patches that apply to the RHEL 6 glibc that resolve this problem. +Version-Release number of selected component (if applicable): + + +How reproducible: + + +Steps to Reproduce: +1. +2. +3. + +Actual results: + + +Expected results: + + +Additional info: diff --git a/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/main.fmf b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/main.fmf new file mode 100644 index 0000000..c364430 --- /dev/null +++ b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/main.fmf @@ -0,0 +1,54 @@ +summary: Test for bz705465 (fix for handle overflows of temporary buffer used) +description: | + Bug summary: fix for handle overflows of temporary buffer used to handle multi lookups locally. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=705465 + + Description: + + Description of problem: + + An issue in glibc causes threaded processes to not get all the groups assigned to that process. Because the pointer to the next group entry can be moved we have seen applications with incomplete group membership. + + This issue is resolved by several upstream patches including: + + http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commit;h=ab8eed78a6614f7e7e5a908efdcb9f390f849563 + + Also, it is resolved with the patch for glibc BZ 10484: + + [BZ #10484] + * nss/nss_files/files-hosts.c (HOST_DB_LOOKUP): Handle overflows of temporary buffer used to handle multi lookups locally. + * Versions [libc] (GLIBC_PRIVATE): Export __libc_alloca_cutoff. + + I will attach the two patches that apply to the RHEL 6 glibc that resolve this problem. + Version-Release number of selected component (if applicable): + + + How reproducible: + + + Steps to Reproduce: + 1. + 2. + 3. + + Actual results: + + + Expected results: + + + Additional info: +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - nss_db + - gcc +duration: 30m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=705465 +extra-summary: /tools/glibc/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used +extra-task: /tools/glibc/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used diff --git a/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/repr.c b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/repr.c new file mode 100644 index 0000000..fb9fa61 --- /dev/null +++ b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/repr.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULE "db" +#define NUMTHREADS 512 + +static pthread_rwlock_t startlock, outlock; + +static int +compare_gid(const void *a, const void *b) +{ + gid_t ga, gb; + long la, lb; + ga = *(gid_t *) a; + gb = *(gid_t *) b; + la = ga; + lb = gb; + return (int)(la - lb); +} + +static void * +thread_main(void *arg) +{ + gid_t *groups; + int result, n_groups, i; + pthread_rwlock_rdlock(&startlock); + + n_groups = 32; + groups = malloc(sizeof(groups[0]) * n_groups); + + if (groups != NULL) { + do { + result = getgrouplist((const char *)arg, 0, + groups, &n_groups); + if ((result == -1) && (errno == ERANGE)) { + n_groups += 2; + free(groups); + groups = malloc(sizeof(groups[0]) * n_groups); + } + } while ((result == -1) && (errno == ERANGE)); + } + + if (result >= 0) { + qsort(groups, n_groups, sizeof(groups[0]), &compare_gid); + pthread_rwlock_wrlock(&outlock); + for (i = 0; i < n_groups; i++) { + if (i > 0) { + printf(":"); + } + printf("%lu", (unsigned long)groups[i]); + } + printf("\n"); + pthread_rwlock_unlock(&outlock); + } else { + result = errno; + pthread_rwlock_wrlock(&outlock); + printf("%s: %s\n", (const char *)arg, strerror(result)); + pthread_rwlock_unlock(&outlock); + } + return NULL; +} + +int +main(int argc, char **argv) +{ + unsigned int i, j; + char *guser; + pthread_t tids[NUMTHREADS]; + + __nss_configure_lookup("group", MODULE); + + guser = argc > 1 ? argv[1] : "root"; + + if (pthread_rwlock_init(&startlock, NULL) != 0) { + fprintf(stderr, "pthread_rwlock_init: %s\n", strerror(errno)); + return 1; + } + pthread_rwlock_wrlock(&startlock); + if (pthread_rwlock_init(&outlock, NULL) != 0) { + fprintf(stderr, "pthread_rwlock_init: %s\n", strerror(errno)); + return 1; + } + + for (i = 0; i < sizeof(tids) / sizeof(tids[0]); i++) { + if (pthread_create(&tids[i], NULL, &thread_main, guser) != 0) { + break; + } + } + if (i < sizeof(tids) / sizeof(tids[0])) { + fprintf(stderr, "error starting thread #%d, continuing\n", i); + } + + pthread_rwlock_unlock(&startlock); + + for (j = 0; j < i; j++) { + pthread_join(tids[j], NULL); + } + + return 0; +} diff --git a/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/runtest.sh b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/runtest.sh new file mode 100755 index 0000000..90b55e8 --- /dev/null +++ b/tests/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used/runtest.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz705465-fix-for-handle-overflows-of-temporary-buffer-used +# Description: Test for bz705465 (fix for handle overflows of temporary buffer used) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + if rlIsRHEL 5 || rlIsRHEL 6 + then + rlAssertRpm nss_db + fi + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp repr.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc repr.c -lpthread" + rlAssertExists "a.out" + for i in one two three four five six seven; do + rlRun "groupadd $i" + done; unset i + rlRun "useradd lotsofgroups -G one,two,three,four,five,six,seven" + sleep 1 + rlLog "$(id lotsofgroups)" + rlLog "$(id root)" + rlFileBackup /etc/nsswitch.conf + for s in passwd shadow group; do + sed -i "s/^\($s:\s*\)\(.*\)$/\1db \2/" /etc/nsswitch.conf + done; unset s + rlRun "make -f /var/db/Makefile" + rlPhaseEnd + + rlPhaseStartTest "./a.out should always return all lines identical" + test "x$(arch)" = "xi686" && ulimit -s 1024 # 32b systems should die! + for ((i=0;i<30;i++)); do + rlRun "test \$(./a.out lotsofgroups | sort -u | wc -l) -eq 1" 0\ + "Attempt $i: user lotsofgroups (all lines should be identical)" + rlRun "test \$(./a.out root | sort -u | wc -l) -eq 1" 0\ + "Attempt $i: user root (all lines should be identical)" + done; unset i + rlPhaseEnd + + rlPhaseStartCleanup + rlFileRestore + rlRun "rm -f /var/db/*.db" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "userdel -r lotsofgroups" + for i in one two three four five six seven; do + rlRun "groupdel $i" + done + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/Makefile b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/Makefile new file mode 100644 index 0000000..aecdf7b --- /dev/null +++ b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency +# Description: Test for BZ#710216 (Wrong decimal point symbol in Portuguese currency) +# 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/glibc/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE mf.c log.golden + +.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#710216 (Wrong decimal point symbol in Portuguese currency)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-devel gcc glibc-langpack-pt" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 710216" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/PURPOSE b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/PURPOSE new file mode 100644 index 0000000..fb5cc4f --- /dev/null +++ b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency +Description: Test for BZ#710216 (Wrong decimal point symbol in Portuguese currency) +Author: Miroslav Franc +Bug summary: Wrong decimal point symbol in Portuguese currency +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=710216 diff --git a/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/log.golden b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/log.golden new file mode 100644 index 0000000..2250865 --- /dev/null +++ b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/log.golden @@ -0,0 +1,2 @@ +5,95 € +5,95 diff --git a/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/main.fmf b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/main.fmf new file mode 100644 index 0000000..c5ba4b9 --- /dev/null +++ b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/main.fmf @@ -0,0 +1,19 @@ +summary: Test for BZ#710216 (Wrong decimal point symbol in Portuguese currency) +description: | + Bug summary: Wrong decimal point symbol in Portuguese currency + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=710216 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-devel + - gcc + - glibc-langpack-pt +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=710216 +extra-summary: /tools/glibc/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency +extra-task: /tools/glibc/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency diff --git a/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/mf.c b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/mf.c new file mode 100644 index 0000000..9e44d87 --- /dev/null +++ b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/mf.c @@ -0,0 +1,20 @@ +#include "stdio.h" +#include +#include +#define MAX_OUT 10 +int main (){ + ssize_t out_size; + char out[MAX_OUT]; + if(setlocale(LC_ALL, "pt_PT.utf8") == NULL ) { + puts("Cannot set locale"); + return 1; + } else { + out_size = strfmon(out,MAX_OUT, "%n", 5.95); + if (out_size == -1 ) return 2; + printf("%s\n",out); + out_size = strfmon(out,MAX_OUT, "%!n", 5.95); + if (out_size == -1 ) return 2; + printf("%s\n",out); + return 0; + } +} diff --git a/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/runtest.sh b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/runtest.sh new file mode 100755 index 0000000..c378784 --- /dev/null +++ b/tests/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz710216-Wrong-decimal-point-symbol-in-Portuguese-currency +# Description: Test for BZ#710216 (Wrong decimal point symbol in Portuguese currency) +# 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 || exit 1 + +PACKAGES=glibc + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm "$PACKAGES" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp mf.c log.golden $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun -c "gcc mf.c -o mf" + rlRun -c "./mf &> log" + rlAssertNotDiffer log.golden log || rlLog "$(diff -u log.golden log)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/Makefile b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/Makefile new file mode 100644 index 0000000..d08b558 --- /dev/null +++ b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork +# Description: Test for bz711531 (shared, robust mutexes fail in child fork) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test_robust.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: Test for bz711531 (shared, robust mutexes fail in child fork)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc glibc-devel" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 711531" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/PURPOSE b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/PURPOSE new file mode 100644 index 0000000..a9db60f --- /dev/null +++ b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork +Description: Test for bz711531 (shared, robust mutexes fail in child fork) +Author: Miroslav Franc +Bug summary: shared, robust mutexes fail in child fork +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=711531 diff --git a/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/main.fmf b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/main.fmf new file mode 100644 index 0000000..7e9ae71 --- /dev/null +++ b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/main.fmf @@ -0,0 +1,18 @@ +summary: Test for bz711531 (shared, robust mutexes fail in child fork) +description: | + Bug summary: shared, robust mutexes fail in child fork + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=711531 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - glibc-devel +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=711531 +extra-summary: /tools/glibc/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork +extra-task: /tools/glibc/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork diff --git a/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/runtest.sh b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/runtest.sh new file mode 100755 index 0000000..37a288a --- /dev/null +++ b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork +# Description: Test for bz711531 (shared, robust mutexes fail in child fork) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc gcc glibc-devel) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp test_robust.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -g2 -O0 -Werror -pthread -D_GNU_SOURCE test_robust.c -o test_robust" + rlAssertExists "test_robust" + rlWatchdog "./test_robust -v > log 2>&1" 30 || rlFail "reproducer shouldn't hang" + rlAssertNotGrep 'robust list not set' log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/test_robust.c b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/test_robust.c new file mode 100644 index 0000000..987b670 --- /dev/null +++ b/tests/Regression/bz711531-shared-robust-mutexes-fail-in-child-fork/test_robust.c @@ -0,0 +1,223 @@ +/* gcc -g2 -O0 -Werror -pthread -D_GNU_SOURCE test_robust.c -o test_robust */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int level; +static int set_list; +static int verbose; + +struct lock { + pthread_mutex_t mutex; +}; + +#define LOCKFN "/tmp/test_robust.shm" +#define MAP_SIZE 4096 + +static void +show_robust_list () +{ + struct robust_list_head* h; + size_t hlen; + + if (!verbose) return; + syscall(SYS_get_robust_list,0,&h,&hlen); + if (h) { + printf("%*c robust pid=%d self=%lx &head=%p head=%p offset=%ld pending=%p\n", + level,' ',getpid(),pthread_self(),h,h->list,h->futex_offset,h->list_op_pending); + } else { + printf("%*c robust list not set\n",level,' '); + } +} + + +static void +where (const char* what, int incr) +{ + if (!verbose) return; + if (incr < 0) { + show_robust_list(); + level += incr; + } + printf("%*c%s pid=%d self=%lx\n",level+1,' ',what,getpid(),pthread_self()); + if (incr > 0) { + level += incr; + show_robust_list(); + } +} + +struct lock* +map (int create) +{ + int fd; + struct lock* lp; + + fd = open(LOCKFN,O_RDWR|(create ? O_CREAT : 0),0666); + if (fd < 0) { + perror(LOCKFN); + exit(2); + } + if (create) { + ftruncate(fd,MAP_SIZE); + } + lp = (struct lock*)mmap(0,MAP_SIZE,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); + if (lp == MAP_FAILED) { + perror("mmap"); + exit(2); + } + if (create) { + int err; + pthread_mutexattr_t attr; + + pthread_mutexattr_init(&attr); + pthread_mutexattr_setpshared(&attr,PTHREAD_PROCESS_SHARED); + pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_ERRORCHECK); + pthread_mutexattr_setrobust(&attr,PTHREAD_MUTEX_ROBUST_NP); + pthread_mutex_init(&lp->mutex,&attr); + pthread_mutexattr_destroy(&attr); + + munmap(map,MAP_SIZE); + close(fd); + lp = NULL; + } + return lp; +} + + +static void* +test (void* arg) +{ + struct lock* lp; + int err; + + where("test start",1); + + lp = map(0); + err = pthread_mutex_lock(&lp->mutex); + if (err) { + if (err == EOWNERDEAD) { + printf(" claimed lock from dead owner\n"); + pthread_mutex_consistent(&lp->mutex); + } else { + perror("pthread_mutex_lock"); + return NULL; + } + } + + where("test end",-1); +} + + +static void* +run_thread (void* arg) +{ + where("thread start",1); + test(arg); + where("thread end",-1); +} + + +static void +task (int thread) +{ + where("fork start",1); + if (thread) { + pthread_t t; + void* res; + + pthread_create(&t,NULL,run_thread,NULL); + pthread_join(t,&res); + } else { + test(NULL); + } + where("fork end",-1); +} + +static void +run_tasks (int ntasks, int thread, int set) +{ + int status; + int i; + + set_list = set; + where("run start",1); + for (i = 0; i < ntasks; ++i) { + if (!fork()) { + task(thread); + exit(0); + } + } + while (wait4(-1,&status,0,NULL) > 0); + where("run end",-1); +} + + +struct robust_list_head* robust_head; +size_t robust_head_len; + +static void +prepare_fork (void) +{ + where("prepare fork",0); + syscall(SYS_get_robust_list,0,&robust_head,&robust_head_len); +} + +static void +child_fork (void) +{ + void* h; + size_t hlen; + where("child fork",0); + if (set_list) { + syscall(SYS_get_robust_list,0,&h,&hlen); + if (!h) { + syscall(SYS_set_robust_list,robust_head,robust_head_len); + } + } +} + + +int +main (int argc, char** argv) +{ + int i, thread; + int ntasks = 2; + int opt; + + while ((opt = getopt(argc,argv,"n:v")) != -1) { + switch (opt) { + case 'n': + ntasks = atoi(optarg); + break; + + case 'v': + verbose = 1; + break; + } + } + + setbuf(stdout,NULL); + map(1); + + pthread_atfork(prepare_fork,NULL,child_fork); + printf("#1: threads with post-fork set_robust_list -- should complete\n"); + run_tasks(ntasks,1,1); + printf("#2: threads with NO post-fork set_robust_list -- should complete\n"); + run_tasks(ntasks,1,0); + printf("#3: forks with post-fork set_robust_list -- should complete\n"); + run_tasks(ntasks,0,1); + printf("#4: forks with NO post-fork set_robust_list -- hangs (no owner-death cleanup)\n"); + run_tasks(ntasks,0,0); + return 0; +} diff --git a/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/Makefile b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/Makefile new file mode 100644 index 0000000..efd0e56 --- /dev/null +++ b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector +# Description: Test for bz730379 (libresolv is not compiled with the stack protector) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector +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: Miroslav Franc " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz730379 (libresolv is not compiled with the stack protector)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 3m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc binutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 730379" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/PURPOSE b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/PURPOSE new file mode 100644 index 0000000..ed27eec --- /dev/null +++ b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector +Description: Test for bz730379 (libresolv is not compiled with the stack protector) +Author: Miroslav Franc +Bug summary: libresolv is not compiled with the stack protector enabled +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=730379 diff --git a/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/main.fmf b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/main.fmf new file mode 100644 index 0000000..ef8b6af --- /dev/null +++ b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz730379 (libresolv is not compiled with the stack protector) +description: | + Bug summary: libresolv is not compiled with the stack protector enabled + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=730379 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - binutils +duration: 3m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=730379 +extra-summary: /tools/glibc/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector +extra-task: /tools/glibc/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector diff --git a/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/runtest.sh b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/runtest.sh new file mode 100755 index 0000000..9120bb9 --- /dev/null +++ b/tests/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz730379-libresolv-is-not-compiled-with-the-stack-protector +# Description: Test for bz730379 (libresolv is not compiled with the stack protector) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc binutils) +test -d /lib64 && dlib="/lib64" || dlib="/lib" +TSTLIB="libresolv.so.2" + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + if rlIsRHEL "<9" + then + TSTLIB="libresolv-2.*.so" + fi + rlPhaseEnd + + rlPhaseStartTest + rlRun -l "readelf -sW /$dlib/${TSTLIB} 2>/dev/null | grep -q '__stack_chk_fail'" 0 "Canary found" + rlRun -l "readelf -Wl /$dlib/${TSTLIB} 2>/dev/null | grep GNU_STACK | grep RWX" 1 "NX enabled" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/Makefile b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/Makefile new file mode 100644 index 0000000..f084a66 --- /dev/null +++ b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set +# Description: Test for bz731042 (pthread_create dumps core when it fails to set) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE repr.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: Test for bz731042 (pthread_create dumps core when it fails to set)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 731042" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/PURPOSE b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/PURPOSE new file mode 100644 index 0000000..d5360fe --- /dev/null +++ b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set +Description: Test for bz731042 (pthread_create dumps core when it fails to set) +Author: Miroslav Franc +Bug summary: pthread_create dumps core when it fails to set real time policy +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=731042 diff --git a/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/main.fmf b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/main.fmf new file mode 100644 index 0000000..88a4233 --- /dev/null +++ b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz731042 (pthread_create dumps core when it fails to set) +description: | + Bug summary: pthread_create dumps core when it fails to set real time policy + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=731042 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=731042 +extra-summary: /tools/glibc/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set +extra-task: /tools/glibc/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set diff --git a/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/repr.c b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/repr.c new file mode 100644 index 0000000..31d59fc --- /dev/null +++ b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/repr.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +static void *dummy_thread (void *arg) { printf ("started\n"); return arg; } + +static int start (int policy, int priority) +{ + pthread_attr_t attr; + struct sched_param param; + pthread_t thread_id; + int r; + + pthread_attr_init(&attr); + pthread_attr_setschedpolicy (&attr, policy); + param.sched_priority = priority; + pthread_attr_setschedparam (&attr, ¶m); + pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED); + r = pthread_create(&thread_id, &attr, dummy_thread, NULL); + pthread_attr_destroy(&attr); + if (r == 0) { pthread_join(thread_id, NULL); } + else { errno = r; perror ("pthread_create"); } + return r; +} + +int main(int argc, char **argv) +{ + if (argc > 1) { + switch (atoi (argv[1])) { + case 0: start (SCHED_OTHER, 0); break; + case 1: start (SCHED_OTHER, 10); break; + case 2: start (SCHED_FIFO, 0); break; + case 3: start (SCHED_FIFO, 10); break; + case 4: if (start (SCHED_FIFO, 10) != 0) start (SCHED_OTHER, 0); break; + } + } + return 0; +} diff --git a/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/runtest.sh b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/runtest.sh new file mode 100755 index 0000000..5872bdb --- /dev/null +++ b/tests/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz731042-pthread-create-dumps-core-when-it-fails-to-set +# Description: Test for bz731042 (pthread_create dumps core when it fails to set) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp repr.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -pthread repr.c -o repr" + rlAssertExists "repr" + for ((i=0;i<5;i++)); do + rlRun "./repr $i" + done; unset i + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/4151-sourceware.c b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/4151-sourceware.c new file mode 100644 index 0000000..f5d092b --- /dev/null +++ b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/4151-sourceware.c @@ -0,0 +1,87 @@ +#include +#include + +#include +#include +#include +#include + +pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER, cond2 = PTHREAD_COND_INITIALIZER; +pthread_mutex_t mut1 = PTHREAD_MUTEX_INITIALIZER, mut2 = PTHREAD_MUTEX_INITIALIZER; + +void dump_ids(const char* head) +{ + gid_t groups[32]; + int ngroups, i; + + printf("%s: ", head); + + if ((ngroups = getgroups(sizeof(groups)/sizeof(groups[0]), groups)) < 0) + { + perror("getgroups"); + exit(1); + } + + for (i = 0; i < ngroups; i++) + printf("%d%s", groups[i], (i < ngroups - 1 ? ", " : "")); + printf("\n\n"); +} + +void* body(void* arg) +{ + printf("Launched a new thread\n\n"); + + pthread_mutex_lock(&mut1); + pthread_mutex_lock(&mut2); + + pthread_cond_signal(&cond1); + pthread_mutex_unlock(&mut1); + + pthread_cond_wait(&cond2, &mut2); + pthread_mutex_unlock(&mut2); + + dump_ids("Launched thread groups"); + + return NULL; +} + +int main(void) +{ + pthread_t thread; + int err; + + dump_ids("Initial groups"); + + pthread_mutex_lock(&mut1); + + if ((err = pthread_create(&thread, NULL, &body, NULL))) + { + errno = err; + perror("pthread_create"); + return 1; + } + + pthread_cond_wait(&cond1, &mut1); + pthread_mutex_unlock(&mut1); + + printf("Changing groups in the main thread...\n\n"); + { + gid_t gid[] = { 20, 15 }; + + if (setgroups(2, gid) < 0) + { + perror("setgroups"); + return 1; + } + } + + dump_ids("Main thread groups"); + + pthread_mutex_lock(&mut2); + pthread_cond_signal(&cond2); + pthread_mutex_unlock(&mut2); + + pthread_join(thread, NULL); + + return 0; +} diff --git a/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/Makefile b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/Makefile new file mode 100644 index 0000000..42c3ff5 --- /dev/null +++ b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz736346-make-initgroups-setgroups-thread-aware +# Description: Test for bz736346 (make initgroups (setgroups) thread aware) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz736346-make-initgroups-setgroups-thread-aware +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE 4151-sourceware.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: Test for bz736346 (make initgroups (setgroups) thread aware)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 736346" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/PURPOSE b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/PURPOSE new file mode 100644 index 0000000..863db9b --- /dev/null +++ b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz736346-make-initgroups-setgroups-thread-aware +Description: Test for bz736346 (make initgroups (setgroups) thread aware) +Author: Miroslav Franc +Bug summary: make initgroups (setgroups) thread aware +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=736346 diff --git a/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/main.fmf b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/main.fmf new file mode 100644 index 0000000..d82707a --- /dev/null +++ b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz736346 (make initgroups (setgroups) thread aware) +description: | + Bug summary: make initgroups (setgroups) thread aware + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=736346 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=736346 +extra-summary: /tools/glibc/Regression/bz736346-make-initgroups-setgroups-thread-aware +extra-task: /tools/glibc/Regression/bz736346-make-initgroups-setgroups-thread-aware diff --git a/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/runtest.sh b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/runtest.sh new file mode 100755 index 0000000..9902168 --- /dev/null +++ b/tests/Regression/bz736346-make-initgroups-setgroups-thread-aware/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz736346-make-initgroups-setgroups-thread-aware +# Description: Test for bz736346 (make initgroups (setgroups) thread aware) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp 4151-sourceware.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc 4151-sourceware.c -lpthread" + rlAssertExists "a.out" + rlRun "./a.out > log" + rlRun "test \"$(grep '^Launched thread' log | cut -d: -f2)\" = \"$(grep '^Main thread' log | cut -d: -f2)\"" + rlRun "test \"$(grep '^Launched thread' log | cut -d: -f2)\" != \"$(grep '^Initial groups' log | cut -d: -f2)\"" + rlLog "$( +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE locale.c gold.txt + +.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 bz737778 (setlocale() fails if LC_CTYPE is set to Turkish)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc diffutils glibc-langpack-tr" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 737778" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/PURPOSE b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/PURPOSE new file mode 100644 index 0000000..5951a5c --- /dev/null +++ b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish +Description: Test for bz737778 (setlocale() fails if LC_CTYPE is set to Turkish) +Author: Miroslav Franc +Bug summary: setlocale() fails if LC_CTYPE is set to Turkish locale +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=737778 diff --git a/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/gold.txt b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/gold.txt new file mode 100644 index 0000000..66f1664 --- /dev/null +++ b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/gold.txt @@ -0,0 +1,3 @@ +tr_TR +tr_TR +tr_TR.ISO8859-9 diff --git a/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/locale.c b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/locale.c new file mode 100644 index 0000000..110b3ce --- /dev/null +++ b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/locale.c @@ -0,0 +1,13 @@ +#include +#include +int +main(void) +{ + char *s; + printf("%s\n", setlocale(LC_CTYPE, "tr_TR")); + // printf("%s\n", setlocale(LC_CTYPE, "tr_TR.ISO8859-9")); + printf("%s\n", setlocale(LC_CTYPE, NULL)); + s = setlocale(LC_CTYPE, "tr_TR.ISO8859-9"); + printf("%s\n", s ? s : "null"); + return 0; +} diff --git a/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/main.fmf b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/main.fmf new file mode 100644 index 0000000..8d3360b --- /dev/null +++ b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/main.fmf @@ -0,0 +1,19 @@ +summary: Test for bz737778 (setlocale() fails if LC_CTYPE is set to Turkish) +description: | + Bug summary: setlocale() fails if LC_CTYPE is set to Turkish locale + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=737778 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - diffutils + - glibc-langpack-tr +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=737778 +extra-summary: /tools/glibc/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish +extra-task: /tools/glibc/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish diff --git a/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/runtest.sh b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/runtest.sh new file mode 100755 index 0000000..d864434 --- /dev/null +++ b/tests/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz737778-setlocale-fails-if-LC-CTYPE-is-set-to-Turkish +# Description: Test for bz737778 (setlocale() fails if LC_CTYPE is set to Turkish) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc gcc diffutils) + + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp gold.txt locale.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc locale.c" + rlAssertExists "./a.out" + rlRun "./a.out > log" + rlAssertNotDiffer gold.txt log || rlLog "$(diff -u gold.txt log)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/Makefile b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/Makefile new file mode 100644 index 0000000..767c259 --- /dev/null +++ b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname +# Description: Test for bz739184 (Statically-linked binaries that call gethostbyname) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE chk-gethost.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: Test for bz739184 (Statically-linked binaries that call gethostbyname)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc glibc-static" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 739184" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/PURPOSE b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/PURPOSE new file mode 100644 index 0000000..4604006 --- /dev/null +++ b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname +Description: Test for bz739184 (Statically-linked binaries that call gethostbyname) +Author: Miroslav Franc +Bug summary: Statically-linked binaries that call gethostbyname crash when executed. +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=739184 diff --git a/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/chk-gethost.c b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/chk-gethost.c new file mode 100644 index 0000000..066bc87 --- /dev/null +++ b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/chk-gethost.c @@ -0,0 +1,7 @@ +#include + +int main(int ac, char **av) +{ + gethostbyname("fedoraproject.org"); + return 0; +} diff --git a/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/main.fmf b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/main.fmf new file mode 100644 index 0000000..1754c58 --- /dev/null +++ b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/main.fmf @@ -0,0 +1,18 @@ +summary: Test for bz739184 (Statically-linked binaries that call gethostbyname) +description: | + Bug summary: Statically-linked binaries that call gethostbyname crash when executed. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=739184 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - glibc-static +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=739184 +extra-summary: /tools/glibc/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname +extra-task: /tools/glibc/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname diff --git a/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/runtest.sh b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/runtest.sh new file mode 100755 index 0000000..843e909 --- /dev/null +++ b/tests/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname/runtest.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz739184-Statically-linked-binaries-that-call-gethostbyname +# Description: Test for bz739184 (Statically-linked binaries that call gethostbyname) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc gcc) +GLIBC_STATIC_PACKAGE=glibc-static + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + if ! rlIsRHEL 5 + then + rlAssertRpm $GLIBC_STATIC_PACKAGE; + fi + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp chk-gethost.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -static chk-gethost.c" + rlAssertExists "a.out" + for ((i=0;i<20;i++)); do + rlRun "./a.out" + done; unset i + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/Makefile b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/Makefile new file mode 100644 index 0000000..29683a6 --- /dev/null +++ b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc +# Description: Test for bz750531 (htons() gives warning if compiled with gcc) +# 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/glibc/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test.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: Test for bz750531 (htons() gives warning if compiled with gcc)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 18m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 750531" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/PURPOSE b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/PURPOSE new file mode 100644 index 0000000..ee81e49 --- /dev/null +++ b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc +Description: Test for bz750531 (htons() gives warning if compiled with gcc) +Author: Miroslav Franc +Bug summary: htons() gives warning if compiled with gcc -Wconversion +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=750531 diff --git a/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/main.fmf b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/main.fmf new file mode 100644 index 0000000..cef249d --- /dev/null +++ b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz750531 (htons() gives warning if compiled with gcc) +description: | + Bug summary: htons() gives warning if compiled with gcc -Wconversion + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=750531 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 18m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=750531 +extra-summary: /tools/glibc/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc +extra-task: /tools/glibc/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc diff --git a/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/runtest.sh b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/runtest.sh new file mode 100755 index 0000000..3fe960e --- /dev/null +++ b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc +# Description: Test for bz750531 (htons() gives warning if compiled with gcc) +# 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 || exit 1 + +PACKAGE="gcc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp test.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + for i in 0 1 2 3 + do + rlPhaseStartTest "Compiling_test_case_with_-O${i}" + rlRun "gcc -O${i} -Wconversion test.c -o test.${i} > log.${i} 2>&1" + rlAssertExists "./test.${i}" + rlAssertNotGrep warning log.${i} + rlAssertNotGrep error log.${i} + rlPhaseEnd + done; unset i + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/test.c b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/test.c new file mode 100644 index 0000000..5c4ba8d --- /dev/null +++ b/tests/Regression/bz750531-htons-gives-warning-if-compiled-with-gcc/test.c @@ -0,0 +1,9 @@ +#include +#include + +int main(void) +{ + uint16_t portnbr=0; + uint16_t n_portnbr = htons(portnbr); + exit(0); +} diff --git a/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/Makefile b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/Makefile new file mode 100644 index 0000000..5ecda47 --- /dev/null +++ b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain +# Description: Test for bz785984 (Short month names in the zh_CN locale contain) +# 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/glibc/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE golden.out + +.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 bz785984 (Short month names in the zh_CN locale contain)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-langpack-zh" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 785984" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/PURPOSE b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/PURPOSE new file mode 100644 index 0000000..1ec0f90 --- /dev/null +++ b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain +Description: Test for bz785984 (Short month names in the zh_CN locale contain) +Author: Miroslav Franc +Bug summary: Short month names in the zh_CN locale contain space +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=785984 diff --git a/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/golden.out b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/golden.out new file mode 100644 index 0000000..20224cf --- /dev/null +++ b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/golden.out @@ -0,0 +1,12 @@ +1月 +2月 +3月 +4月 +5月 +6月 +7月 +8月 +9月 +10月 +11月 +12月 diff --git a/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/main.fmf b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/main.fmf new file mode 100644 index 0000000..a0bdad8 --- /dev/null +++ b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz785984 (Short month names in the zh_CN locale contain) +description: | + Bug summary: Short month names in the zh_CN locale contain space + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=785984 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-langpack-zh +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=785984 +extra-summary: /tools/glibc/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain +extra-task: /tools/glibc/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain diff --git a/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/runtest.sh b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/runtest.sh new file mode 100755 index 0000000..221cfaa --- /dev/null +++ b/tests/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz785984-Short-month-names-in-the-zh-CN-locale-contain +# Description: Test for bz785984 (Short month names in the zh_CN locale contain) +# 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 || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp golden.out $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "for ((i=1;i<=12;++i)); do LC_TIME=zh_CN.utf8 date -d \$(printf 2010%02d01 \$i) '+%b'; done > log 2>&1" + rlAssertNotDiffer golden.out log || rlLog "$(diff -u golden.out log)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/Makefile b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/Makefile new file mode 100644 index 0000000..d5f37df --- /dev/null +++ b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of +# Description: Test for bz789238 ([FJ6.2 Bug] malloc() deadlock in case of) +# 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/glibc/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE mallocstress.c redshirt-process.sh + +.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 bz789238 ([FJ6.2 Bug] malloc() deadlock in case of)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30h" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-devel glibc-headers gcc coreutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 789238" >> $(METADATA) + @echo "Releases: -RHELServer5 -RHELClient5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/PURPOSE b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/PURPOSE new file mode 100644 index 0000000..4d5f96e --- /dev/null +++ b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of +Description: Test for bz789238 ([FJ6.2 Bug] malloc() deadlock in case of) +Author: Miroslav Franc +Bug summary: [FJ6.2 Bug]: malloc() deadlock in case of allocation failure from main_arena. +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=789238 diff --git a/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/main.fmf b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/main.fmf new file mode 100644 index 0000000..953e121 --- /dev/null +++ b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/main.fmf @@ -0,0 +1,20 @@ +summary: Test for bz789238 ([FJ6.2 Bug] malloc() deadlock in case of) +description: | + Bug summary: [FJ6.2 Bug]: malloc() deadlock in case of allocation failure from main_arena. + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=789238 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-devel + - glibc-headers + - gcc + - coreutils +duration: 30h +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=789238 +extra-summary: /tools/glibc/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of +extra-task: /tools/glibc/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of diff --git a/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/mallocstress.c b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/mallocstress.c new file mode 100644 index 0000000..40fc103 --- /dev/null +++ b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/mallocstress.c @@ -0,0 +1,439 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) International Business Machines Corp., 2001 */ +/* */ +/* 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, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/******************************************************************************/ + +/******************************************************************************/ +/* */ +/* History: Nov - 04 - 2001 Created - Manoj Iyer, IBM Austin TX. */ +/* email:manjo@austin.ibm.com */ +/* */ +/* Nov - 06 - 2001 Modified - Manoj Iyer, IBM Austin TX. */ +/* - added function alloc_mem() */ +/* */ +/* Nov - 08 - 2001 Modified - Manoj Iyer, IBM Austin TX. */ +/* - added logic to allocate memory in the size */ +/* of fibanocci numbers. */ +/* - fixed segmetation fault. */ +/* */ +/* Nov - 09 - 2001 Modified - Manoj Iyer, IBM Austin TX. */ +/* - separated alocation logic to allocate_free()*/ +/* function. */ +/* - introduced logic to randomly pick allocation*/ +/* scheme. size = fibannoci number, pow of 2 or*/ +/* power of 3. */ +/* - changed comments. */ +/* - Added test to LTP. */ +/* */ +/* Nov - 09 - 2001 Modified - Manoj Iyer,IBM Austin TX. */ +/* - Removed compile errors. */ +/* - too many missing arguments. */ +/* */ +/* Nov - 19 - 2001 Modified - Manoj Iyer, IBM Austin TX. */ +/* - fixed segmentation fault. */ +/* changed variable th_status from dynamic to */ +/* static array. */ +/* */ +/* May - 15 - 2002 Dan Kegel (dank@kegel.com) */ +/* - Fixed crash on > 30 threads */ +/* - Cleaned up, fixed compiler warnings */ +/* - Removed mallocs that could fail */ +/* - Note that pthread_create fails with EINTR */ +/* */ +/* File: mallocstress.c */ +/* */ +/* Description: This program stresses the VMM and C library */ +/* by spawning N threads which */ +/* malloc blocks of increasing size until malloc returns NULL. */ +/******************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXL 100 /* default number of loops to do malloc and free */ +#define MAXT 60 /* default number of threads to create. */ + +#ifdef DEBUG +#define dprt(args) printf args +#else +#define dprt(args) +#endif + +#define OPT_MISSING(prog, opt) do{\ + fprintf(stderr, "%s: option -%c ", prog, opt); \ + fprintf(stderr, "requires an argument\n"); \ + usage(prog); \ + } while (0) + +int num_loop = MAXL;/* number of loops to perform */ +int semid; + +/* Define SPEW_SIGNALS to tickle thread_create bug (it fails if interrupted). */ +#define SPEW_SIGNALS + +/******************************************************************************/ +/* */ +/* Function: my_yield */ +/* */ +/* Description: Yield control to another thread. */ +/* Generate a signal, too. */ +/* */ +/******************************************************************************/ +static void +my_yield() +{ +#ifdef SPEW_SIGNALS + /* usleep just happens to use signals in glibc at moment. + * This is good because it allows us to test whether pthread_create + * improperly returns EINTR (which would violate SUSv3) + */ + usleep(0); +#else + /* If you want this test to pass, don't define SPEW_SIGNALS, + * as pthread_create is broken at moment, and fails if interrupted + */ + static const struct timespec t0 = {0, 0}; + nanosleep(&t0, NULL); +#endif +} + +/******************************************************************************/ +/* */ +/* Function: usage */ +/* */ +/* Description: Print the usage message. */ +/* */ +/* Input: char *progname - name of this program */ +/* */ +/* Return: exits with -1 */ +/* */ +/******************************************************************************/ +static void +usage(char *progname) /* name of this program */ +{ + fprintf(stderr, + "Usage: %s -d NUMDIR -f NUMFILES -h -t NUMTHRD\n" + "\t -h Help!\n" + "\t -l Number of loops: Default: 1000\n" + "\t -t Number of threads to generate: Default: 30\n", + progname); + exit(-1); +} + +/******************************************************************************/ +/* Function: allocate_free */ +/* */ +/* Description: This function does the allocation and free by calling malloc */ +/* and free fuctions. The size of the memory to be malloced is */ +/* determined by the caller of this function. The size can be */ +/* a number from the fibannoaci series, power of 2 or 3 or 5 */ +/* */ +/* Input: int repeat - number of times the alloc/free is repeated. */ +/* int scheme - 0 to 3; selects how fast memory size grows */ +/* */ +/* Return: 1 on failure */ +/* 0 on success */ +/******************************************************************************/ +int +allocate_free(int repeat, /* number of times to repeat allocate/free */ + int scheme) /* how fast to increase block size */ +{ + int loop; + const int MAXPTRS = 50; /* only 42 or so get used on 32 bit machine */ + + dprt(("pid[%d]: allocate_free: repeat %d, scheme %d\n", getpid(), repeat, scheme)); + + for (loop = 0; loop < repeat; loop++) + { + size_t oldsize = 5; /* remember size for fibannoci series */ + size_t size = sizeof(long); /* size of next block in ptrs[] */ + long *ptrs[MAXPTRS]; /* the pointers allocated in this loop */ + int num_alloc; /* number of elements in ptrs[] so far */ + int i; + + dprt(("pid[%d]: allocate_free: loop %d of %d\n", getpid(), loop, repeat)); + + /* loop terminates in one of three ways: + * 1. after MAXPTRS iterations + * 2. if malloc fails + * 3. if new size overflows + */ + for (num_alloc=0; num_alloc < MAXPTRS; num_alloc++) + { + size_t newsize = 0; + + dprt(("pid[%d]: loop %d/%d; num_alloc=%d; size=%u\n", + getpid(), loop, repeat, num_alloc, size)); + + /* Malloc the next block */ +#ifdef MEMALIGN + ptrs[num_alloc] = (long *)memalign(sysconf(_SC_PAGESIZE), size); +#elif CALLOC + ptrs[num_alloc] = (long *)calloc(size, 1); +#elif VALLOC + ptrs[num_alloc] = (long *)valloc(size); +#else + ptrs[num_alloc] = (long *)malloc(size); +#endif + if (ptrs[num_alloc] == NULL) + { + /* terminate loop if malloc couldn't give us the memory we asked for */ + break; + } + ptrs[num_alloc][0] = num_alloc; + + /* Increase size according to one of four schedules. */ + switch (scheme) { + case 0: + newsize = size + oldsize; + oldsize = size; + break; + case 1: + newsize = size * 2; + break; + case 2: + newsize = size * 3; + break; + case 3: + newsize = size * 5; + break; + default: + assert(0); + } + /* terminate loop on overflow */ + if (newsize < size) + break; + size = newsize; + + my_yield(); + } + + for (i = 0; i < num_alloc; i++) + { + dprt(("pid[%d]: freeing ptrs[i] %p\n", getpid(), ptrs[i])); + if (ptrs[i][0] != i) { + fprintf(stderr, "pid[%d]: fail: bad sentinel value\n", getpid()); + return 1; + } + free(ptrs[i]); + my_yield(); + } + + my_yield(); + } + /* Success! */ + return 0; +} + +/******************************************************************************/ +/* Function: alloc_mem */ +/* */ +/* Description: Decide how fast to increase block sizes, then call */ +/* allocate_free() to actually to the test. */ +/* */ +/* Input: threadnum is the thread number, 0...N-1 */ +/* global num_loop is how many iterations to run */ +/* */ +/* Return: pthread_exit -1 on failure */ +/* pthread_exit 0 on success */ +/* */ +/******************************************************************************/ +void * +alloc_mem(void * threadnum) +{ + struct sembuf sop[1]; + sop[0].sem_num = 0; + sop[0].sem_op = 0; + sop[0].sem_flg = 0; + /* waiting for other threads starting */ + if (semop(semid, sop, 1) == -1) { + if (errno != EIDRM) + perror("semop"); + return (void *) -1; + } + + /* thread N will use growth scheme N mod 4 */ + int err = allocate_free(num_loop, ((uintptr_t)threadnum) % 4); + fprintf(stdout, + "Thread [%d]: allocate_free() returned %d, %s. Thread exiting.\n", + (int)(uintptr_t)threadnum, err, (err ? "failed" : "succeeded")); + return (void *)(uintptr_t)(err ? -1 : 0); +} + +/******************************************************************************/ +/* */ +/* Function: main */ +/* */ +/* Description: This is the entry point to the program. This function will */ +/* parse the input arguments and set the values accordingly. If */ +/* no arguments (or desired) are provided default values are used*/ +/* refer the usage function for the arguments that this program */ +/* takes. It also creates the threads which do most of the dirty */ +/* work. If the threads exits with a value '0' the program exits */ +/* with success '0' else it exits with failure '-1'. */ +/* */ +/* Return: -1 on failure */ +/* 0 on success */ +/* */ +/******************************************************************************/ +int +main(int argc, /* number of input parameters */ + char **argv) /* pointer to the command line arguments. */ +{ + int c; /* command line options */ + int num_thrd = MAXT;/* number of threads to create */ + int thrd_ndx; /* index into the array of thread ids */ + pthread_t *thrdid; /* the threads */ + extern int optopt; /* options to the program */ + struct sembuf sop[1]; + int ret = 0; + + while ((c = getopt(argc, argv, "hl:t:")) != -1) + { + switch(c) + { + case 'h': + usage(argv[0]); + break; + case 'l': + if ((num_loop = atoi(optarg)) == 0) + OPT_MISSING(argv[0], optopt); + else + if (num_loop < 1) + { + fprintf(stdout, + "WARNING: bad argument. Using default\n"); + num_loop = MAXL; + } + break; + case 't': + if ((num_thrd = atoi(optarg)) == 0) + OPT_MISSING(argv[0], optopt); + else + if (num_thrd < 1) + { + fprintf(stdout, + "WARNING: bad argument. Using default\n"); + num_thrd = MAXT; + } + break; + default : + usage(argv[0]); + break; + } + } + + dprt(("number of times to loop in the thread = %d\n", num_loop)); + +#ifdef MEMALIGN + thrdid = memalign(sysconf(_SC_PAGESIZE), sizeof(pthread_t) * num_thrd); +#elif CALLOC + thrdid = calloc(sizeof(pthread_t), num_thrd); +#elif VALLOC + thrdid = valloc(sizeof(pthread_t) * num_thrd); +#else + thrdid = malloc(sizeof(pthread_t) * num_thrd); +#endif + if (thrdid == NULL) + { + perror("main(): allocating space for thrdid[]"); + return 1; + } + + semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0666); + if (semid < 0) { + perror("Semaphore creation failed Reason:"); + } + + sop[0].sem_num = 0; + sop[0].sem_op = 1; + sop[0].sem_flg = 0; + if (semop(semid, sop, 1) == -1) { + perror("semop"); + ret = -1; + goto out; + } + + for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) + { + if (pthread_create(&thrdid[thrd_ndx], NULL, alloc_mem, + (void *)(uintptr_t)thrd_ndx)) + { + int err = errno; + if (err == EINTR) { + fprintf(stderr, "main(): pthread_create failed with EINTR!\n"); + ret = -1; + goto out; + } + perror("main(): pthread_create()"); + ret = -11; + goto out; + } + } + my_yield(); + + sop[0].sem_op = -1; + if (semop(semid, sop, 1) == -1) { + perror("semop"); + ret = -1; + goto out; + } + + for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) + { + void *th_status; /* exit status of LWP */ + if (pthread_join(thrdid[thrd_ndx], &th_status) != 0) + { + perror("main(): pthread_join()"); + ret = -1; + goto out; + } + else + { + if ((intptr_t)th_status != 0) + { + fprintf(stderr, + "main(): thread [%d] - exited with errors\n", thrd_ndx); + ret = -1; + goto out; + } + dprt(("main(): thread [%d]: exited without errors\n", thrd_ndx)); + } + my_yield(); + } + printf("main(): test passed.\n"); +out: + if (semctl(semid, 0, IPC_RMID) == -1) { + perror("semctl\n"); + ret = -1; + } + if (thrdid) { + free(thrdid); + thrdid = NULL; + } + exit(ret); +} diff --git a/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/redshirt-process.sh b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/redshirt-process.sh new file mode 100755 index 0000000..1c66bc6 --- /dev/null +++ b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/redshirt-process.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo 1000 > /proc/self/oom_score_adj +exec $@ diff --git a/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/runtest.sh b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/runtest.sh new file mode 100755 index 0000000..8c83f40 --- /dev/null +++ b/tests/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of/runtest.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz789238-FJ6-2-Bug-malloc-deadlock-in-case-of +# Description: Test for bz789238 ([FJ6.2 Bug] malloc() deadlock in case of) +# 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 || exit 1 + +PACKAGE=glibc +REQUIRES=(glibc gcc glibc-devel coreutils) + +# calloc keep trigering OOM killer, disabling for now +# FUNCTIONS=(MALLOC CALLOC VALLOC MEMALIGN) +FUNCTIONS=(MALLOC VALLOC MEMALIGN) +: ${ITERATIONS:=16} +TSTTIMEOUT=900 + +rlJournalStart + rlPhaseStartSetup + for p in "${REQUIRES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp mallocstress.c redshirt-process.sh $TmpDir" + rlRun "pushd $TmpDir" + for f in "${FUNCTIONS[@]}"; do + rlRun "gcc -D$f -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall mallocstress.c -lm -lpthread -o mallocstress.$f" + done; unset f + rlPhaseEnd + + rlPhaseStartTest + for ((i=0;idmesg.before + + # Either the program runs to successful completion (RC=0), + # or gets killed by OOM killer (RC=137 i.e., SIGKILL) + + # The redshirt-process.sh is just a wrapper that sets the + # process up to have a high chance of being selected by the + # OOM killer, so that the killer doesn't accidentally kill + # something important instead, like beaker apparatus + rlRun "timeout $TSTTIMEOUT env MALLOC_ARENA_MAX=2 ./redshirt-process.sh ./mallocstress.$f >log 2>&1" 0,137 + + if [ $? -eq 137 ]; then + dmesg >dmesg.after + diff dmesg.before dmesg.after | grep '^>' >dmesg.log + if grep -i "out of memory" dmesg.log; then + rlLogWarning "Killed by OOM killer; but this is NOT a test failure" + else + rlFail "Received SIGKILL but no corresponding dmesg log" + fi + else + rlAssertGrep 'main(): test passed' log || break 2 + fi + done; unset f + done; unset i + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/Makefile b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/Makefile new file mode 100644 index 0000000..7182880 --- /dev/null +++ b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz799853-Slovakia-uses-Euro-as-currency +# Description: Test for BZ#799853 (Slovakia uses Euro as currency) +# 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/glibc/Regression/bz799853-Slovakia-uses-Euro-as-currency +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE testcase.c log.golden + +.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#799853 (Slovakia uses Euro as currency)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc glibc-langpack-sk" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 799853" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/PURPOSE b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/PURPOSE new file mode 100644 index 0000000..ffdace4 --- /dev/null +++ b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz799853-Slovakia-uses-Euro-as-currency +Description: Test for BZ#799853 (Slovakia uses Euro as currency) +Author: Miroslav Franc +Bug summary: Slovakia uses Euro as currency +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=799853 diff --git a/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/log.golden b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/log.golden new file mode 100644 index 0000000..34ca26b --- /dev/null +++ b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/log.golden @@ -0,0 +1,2 @@ +Local currency symbol: EUR +International currency symbol: EUR diff --git a/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/main.fmf b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/main.fmf new file mode 100644 index 0000000..484c16c --- /dev/null +++ b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/main.fmf @@ -0,0 +1,18 @@ +summary: Test for BZ#799853 (Slovakia uses Euro as currency) +description: | + Bug summary: Slovakia uses Euro as currency + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=799853 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - glibc-langpack-sk +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=799853 +extra-summary: /tools/glibc/Regression/bz799853-Slovakia-uses-Euro-as-currency +extra-task: /tools/glibc/Regression/bz799853-Slovakia-uses-Euro-as-currency diff --git a/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/runtest.sh b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/runtest.sh new file mode 100755 index 0000000..b277386 --- /dev/null +++ b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz799853-Slovakia-uses-Euro-as-currency +# Description: Test for BZ#799853 (Slovakia uses Euro as currency) +# 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 || exit 1 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp testcase.c log.golden $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc testcase.c -o testcase" + rlAssertExists "./testcase" + rlPhaseEnd + + rlPhaseStartTest + rlRun "LC_MONETARY=sk_SK ./testcase > log 2>&1" + rlAssertNotDiffer log.golden log || rlLog "$(diff -u log.golden log)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/testcase.c b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/testcase.c new file mode 100644 index 0000000..f9f9e48 --- /dev/null +++ b/tests/Regression/bz799853-Slovakia-uses-Euro-as-currency/testcase.c @@ -0,0 +1,15 @@ +#include +#include +int main() +{ + if( setlocale(LC_MONETARY, "") == NULL ) { + puts("Cannot set locale"); + return 1; + } else { + struct lconv *l = localeconv(); + printf("Local currency symbol: %s\n", l->currency_symbol); + printf("International currency symbol: %s\n", l->int_curr_symbol); + } + + return 0; +} diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/Makefile b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/Makefile new file mode 100644 index 0000000..e9b0f8e --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/Makefile @@ -0,0 +1,66 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in +# Description: Test for BZ#804630 (Bad resolution with IPv6 and rotate option in) +# 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/glibc/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE named.conf named.taktik resolv.conf testcase.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: Test for BZ#804630 (Bad resolution with IPv6 and rotate option in)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 90m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: bind bind-utils gcc glibc policycoreutils" >> $(METADATA) + @echo "RhtsRequires: library(glibc/gtu)" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 804630" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/PURPOSE b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/PURPOSE new file mode 100644 index 0000000..b560b29 --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in +Description: Test for BZ#804630 (Bad resolution with IPv6 and rotate option in) +Author: Miroslav Franc +Bug summary: Bad resolution with IPv6 and rotate option in resolv.conf +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=804630 diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/main.fmf b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/main.fmf new file mode 100644 index 0000000..2584dee --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/main.fmf @@ -0,0 +1,20 @@ +summary: Test for BZ#804630 (Bad resolution with IPv6 and rotate option in) +description: | + Bug summary: Bad resolution with IPv6 and rotate option in resolv.conf + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=804630 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - bind + - bind-utils + - gcc + - glibc + - policycoreutils +duration: 90m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=804630 +extra-summary: /tools/glibc/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in +extra-task: /tools/glibc/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/named.conf b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/named.conf new file mode 100644 index 0000000..f67c9ad --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/named.conf @@ -0,0 +1,13 @@ +options { + listen-on port 53 { ::1; }; + directory "/var/named"; + listen-on-v6 { any; }; + allow-query { any; }; +}; + + +zone "tak.tik.com" IN { + type master; + file "named.taktik"; + allow-update { none; }; +}; diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/named.taktik b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/named.taktik new file mode 100644 index 0000000..4bb4071 --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/named.taktik @@ -0,0 +1,51 @@ +$TTL 0 +tak.tik.com. IN SOA tak.tik.com. splasky.tak.tik.com. ( + 1 ; serial + 0 ; refresh + 0 ; retry + 0 ; expire + 0 ) ; minimum + + NS tak.tik.com. + A 10.6.172.1 + A 10.6.172.32 + A 10.4.64.161 + A 10.1.0.32 + A 10.2.66.44 + A 10.2.194.33 + A 10.4.16.161 + A 10.2.128.33 + A 141.160.218.235 + A 10.0.100.33 + A 10.4.72.33 + A 10.4.32.55 + A 141.160.156.235 + A 10.2.96.60 + A 10.3.34.33 + A 141.160.126.201 + A 10.0.192.33 + A 10.3.2.33 + A 10.2.224.33 + A 10.1.96.33 + A 10.8.133.204 + A 141.160.135.223 + A 10.8.132.59 + A 10.2.32.37 + A 10.6.44.33 + A 10.0.128.33 + A 10.6.44.144 + A 141.160.202.235 + A 10.0.224.37 + A 10.3.164.33 + A 141.160.172.235 + A 141.160.201.235 + A 10.1.32.34 + A 10.0.128.80 + A 10.1.192.33 + A 10.0.160.161 + AAAA 2002:8da0:caeb::8da0:caeb + AAAA 2002:8da0:87df::8da0:87df + AAAA 2002:8da0:daeb::8da0:daeb + AAAA 2002:8da0:aceb::8da0:aceb + AAAA 2002:8da0:9ceb::8da0:9ceb + AAAA 2002:8da0:7ec9::8da0:7ec9 diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/resolv.conf b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/resolv.conf new file mode 100644 index 0000000..8c48838 --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/resolv.conf @@ -0,0 +1,3 @@ +search tak.tik.com +options rotate +nameserver ::1 diff --git a/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/runtest.sh b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/runtest.sh new file mode 100755 index 0000000..380a312 --- /dev/null +++ b/tests/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in/runtest.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz804630-Bad-resolution-with-IPv6-and-rotate-option-in +# Description: Test for BZ#804630 (Bad resolution with IPv6 and rotate option in) +# 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 || exit 1 + +PACKAGES=(bind glibc policycoreutils) + +rlJournalStart + rlPhaseStartSetup +# rlRun "rlImport glibc/gtu" + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlFileBackup /etc/hosts +# gtuAddLabController + rlFileBackup /etc/resolv.conf + [ -e /etc/named.conf ] && rlFileBackup /etc/named.conf # RHEL5... no comment ;-) + rlRun "cp -f named.conf /etc && restorecon /etc/named.conf && chgrp named /etc/named.conf" + rlRun "cp -f resolv.conf /etc && restorecon /etc/resolv.conf" + rlRun "cp -f named.taktik /var/named && restorecon -R /var/named" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp testcase.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -g testcase.c -o testcase" + rlAssertExists "./testcase" + # bz#678227 etc. - start and stop are not idempotent operations for many initscripts (RHEL5) + service named stop + sleep 3 + rlPhaseEnd + + rlPhaseStartTest + rlRun "service named start" + rlRun "./testcase > log 2>&1" + rlLog "$( +#include +#include +#include +#include + +int main(void) +{ + struct addrinfo *result; + struct addrinfo *res; + int error; + + /* resolve the domain name into a list of addresses */ + error = getaddrinfo("tak.tik.com", NULL, NULL, &result); + if (error != 0) + { + fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error)); + return EXIT_FAILURE; + } + else + { + printf("Test OK\n"); + } + + freeaddrinfo(result); + return EXIT_SUCCESS; +} diff --git a/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/Makefile b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/Makefile new file mode 100644 index 0000000..b7e5b5b --- /dev/null +++ b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1 +# Description: Test for bz804689 (getaddrinfo("localhost6") returns 127.0.0.1) +# 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/glibc/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1 +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE get.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: Test for bz804689 (getaddrinfo(\"localhost6\") returns 127.0.0.1)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 804689" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/PURPOSE b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/PURPOSE new file mode 100644 index 0000000..431ba26 --- /dev/null +++ b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1 +Description: Test for bz804689 (getaddrinfo("localhost6") returns 127.0.0.1) +Author: Miroslav Franc +Bug summary: getaddrinfo("localhost6") returns 127.0.0.1 +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=804689 diff --git a/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/get.c b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/get.c new file mode 100644 index 0000000..87973ee --- /dev/null +++ b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/get.c @@ -0,0 +1,47 @@ +/* from Jan Safranek */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define BUF_SIZE 500 + +int +main(int argc, char *argv[]) +{ + struct addrinfo hints; + struct addrinfo *result, *rp; + int s; + char buf[BUF_SIZE]; + + if (argc != 2) { + fprintf(stderr, "Usage: %s host\n", argv[0]); + exit(EXIT_FAILURE); + } + + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = 0; + hints.ai_protocol = 0; + + s = getaddrinfo(argv[1], NULL, &hints, &result); + if (s != 0) { + fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s)); + exit(EXIT_FAILURE); + } + + for (rp = result; rp != NULL; rp = rp->ai_next) { + if (rp->ai_family == PF_INET6) + inet_ntop(PF_INET6, &((struct sockaddr_in6 *) rp->ai_addr)->sin6_addr, buf, BUF_SIZE); + else + inet_ntop(PF_INET, &((struct sockaddr_in *) rp->ai_addr)->sin_addr, buf, BUF_SIZE); + printf("Address: %s\n", buf); + } + return 0; +} diff --git a/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/main.fmf b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/main.fmf new file mode 100644 index 0000000..13f11b6 --- /dev/null +++ b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/main.fmf @@ -0,0 +1,17 @@ +summary: Test for bz804689 (getaddrinfo("localhost6") returns 127.0.0.1) +description: | + Bug summary: getaddrinfo("localhost6") returns 127.0.0.1 + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=804689 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=804689 +extra-summary: /tools/glibc/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1 +extra-task: /tools/glibc/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1 diff --git a/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/runtest.sh b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/runtest.sh new file mode 100755 index 0000000..156d933 --- /dev/null +++ b/tests/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1/runtest.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz804689-getaddrinfo-localhost6-returns-127-0-0-1 +# Description: Test for bz804689 (getaddrinfo("localhost6") returns 127.0.0.1) +# 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 || exit 1 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "rlFileBackup /etc/hosts" + rlRun "echo '127.0.0.1 localhost.localdomain localhost' > /etc/hosts" + rlRun "echo '::1 localhost6.localdomain6 localhost6' >> /etc/hosts" + rlRun "cp get.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc get.c -o get" + rlAssertExists "./get" + rlPhaseEnd + + rlPhaseStartTest + # honestly we clearly need something more elaborate than this to test it + rlRun "./get localhost6 > log 2>&1" + rlAssertGrep '::1' log + rlAssertNotGrep '127.0.0.1' log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "rlFileRestore /etc/hosts" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/Makefile b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/Makefile new file mode 100644 index 0000000..2c3176c --- /dev/null +++ b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on +# Description: Test for BZ#819430 (fnmatch() fails when '*' wildcard is applied on) +# 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/glibc/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE arf.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: Test for BZ#819430 (fnmatch() fails when '*' wildcard is applied on)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 819430" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/PURPOSE b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/PURPOSE new file mode 100644 index 0000000..1bcf189 --- /dev/null +++ b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on +Description: Test for BZ#819430 (fnmatch() fails when '*' wildcard is applied on) +Author: Miroslav Franc +Bug summary: fnmatch() fails when '*' wildcard is applied on the file name containing multi-byte character(s) +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=819430 diff --git a/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/arf.c b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/arf.c new file mode 100644 index 0000000..bd1cc4f --- /dev/null +++ b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/arf.c @@ -0,0 +1,13 @@ +/* taken from bugzilla and modified */ + +#include +#include + +int main() +{ + int flags = 0; + char *pattern = "*.csv"; + char *string = "\366.csv"; + setlocale (LC_ALL, "en_US.UTF-8"); + return fnmatch (pattern, string, flags); +} diff --git a/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/main.fmf b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/main.fmf new file mode 100644 index 0000000..798b1b4 --- /dev/null +++ b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/main.fmf @@ -0,0 +1,17 @@ +summary: Test for BZ#819430 (fnmatch() fails when '*' wildcard is applied on) +description: | + Bug summary: fnmatch() fails when '*' wildcard is applied on the file name containing multi-byte character(s) + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=819430 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=819430 +extra-summary: /tools/glibc/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on +extra-task: /tools/glibc/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on diff --git a/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/runtest.sh b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/runtest.sh new file mode 100755 index 0000000..5ef2a4d --- /dev/null +++ b/tests/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on/runtest.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz819430-fnmatch-fails-when-wildcard-is-applied-on +# Description: Test for BZ#819430 (fnmatch() fails when '*' wildcard is applied on) +# 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 || exit 1 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp arf.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc arf.c -o arf" + rlAssertExists "./arf" + rlPhaseEnd + + rlPhaseStartTest "c reproducer" + rlRun "./arf" + rlPhaseEnd + + rlPhaseStartTest "original issue" + rlRun "cat /dev/null > $'\366'.csv" + backup_lc_all=$LC_ALL + LC_ALL=en_US + rlRun "find . -name *.csv > log" + LC_ALL=$backup_lc_all + rlAssertGrep 'csv' log + rlLog "$( +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte +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: Miroslav Franc " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for BZ#823905 (iconv() segfaults if the invalid multibyte)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-common vim-common" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 823905" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/PURPOSE b/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/PURPOSE new file mode 100644 index 0000000..18a5b0e --- /dev/null +++ b/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte +Description: Test for BZ#823905 (iconv() segfaults if the invalid multibyte) +Author: Miroslav Franc +Bug summary: iconv() segfaults if the invalid multibyte character 0xffff is input when converting from IBM930 +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=823905 diff --git a/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/main.fmf b/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/main.fmf new file mode 100644 index 0000000..e242d2d --- /dev/null +++ b/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/main.fmf @@ -0,0 +1,18 @@ +summary: Test for BZ#823905 (iconv() segfaults if the invalid multibyte) +description: | + Bug summary: iconv() segfaults if the invalid multibyte character 0xffff is input when converting from IBM930 + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=823905 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-common + - vim-common +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=823905 +extra-summary: /tools/glibc/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte +extra-task: /tools/glibc/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte diff --git a/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/runtest.sh b/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/runtest.sh new file mode 100755 index 0000000..4f430d0 --- /dev/null +++ b/tests/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte/runtest.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz823905-iconv-segfaults-if-the-invalid-multibyte +# Description: Test for BZ#823905 (iconv() segfaults if the invalid multibyte) +# 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 || exit 1 + +PACKAGES=(glibc glibc-common vim-common) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlPhaseEnd + + rlPhaseStartTest "Shouldn't segfault (rc=139)" + rlRun "echo '0x0e 0x43 0x8c 0xff 0xff 0x43 0xbd 0x43 0xbd' | xxd -r | iconv -f IBM930 -t UTF-8" 1 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/Makefile b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/Makefile new file mode 100644 index 0000000..d108a43 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a +# Description: Test for BZ#827362 ([RHEL6.2] ftell after fseek moves the offset on a) +# 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/glibc/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test.c fseek-wchar.c fseek-wchar-j.c\ + output.golden output.seeking fw.golden fw.input fw.j.golden + +.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#827362 ([RHEL6.2] ftell after fseek moves the offset on a)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 20m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 827362" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/PURPOSE b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/PURPOSE new file mode 100644 index 0000000..0f0515c --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a +Description: Test for BZ#827362 ([RHEL6.2] ftell after fseek moves the offset on a) +Author: Miroslav Franc +Bug summary: [RHEL6.2] ftell after fseek moves the offset on a stream using wide characters +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=827362 diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fseek-wchar-j.c b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fseek-wchar-j.c new file mode 100644 index 0000000..1c833c1 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fseek-wchar-j.c @@ -0,0 +1,361 @@ +#include +#include +#include +#include +#include + +wchar_t *numbers[301] = { + L"ゼロ\n", + L"いち\n", + L"に\n", + L"さん\n", + L"よん\n", + L"ご\n", + L"ろく\n", + L"なな\n", + L"はち\n", + L"きゅう\n", + L"じゅう\n", + L"じゅういち\n", + L"じゅうに\n", + L"じゅうさん\n", + L"じゅうよん\n", + L"じゅうご\n", + L"じゅうろく\n", + L"じゅうなな\n", + L"じゅうはち\n", + L"じゅうきゅう\n", + L"にじゅう\n", + L"にじゅういち\n", + L"にじゅうに\n", + L"にじゅうさん\n", + L"にじゅうよん\n", + L"にじゅうご\n", + L"にじゅうろく\n", + L"にじゅうなな\n", + L"にじゅうはち\n", + L"にじゅうきゅう\n", + L"さんじゅう\n", + L"さんじゅういち\n", + L"さんじゅうに\n", + L"さんじゅうさん\n", + L"さんじゅうよん\n", + L"さんじゅうご\n", + L"さんじゅうろく\n", + L"さんじゅうなな\n", + L"さんじゅうはち\n", + L"さんじゅうきゅう\n", + L"よんじゅう\n", + L"よんじゅういち\n", + L"よんじゅうに\n", + L"よんじゅうさん\n", + L"よんじゅうよん\n", + L"よんじゅうご\n", + L"よんじゅうろく\n", + L"よんじゅうなな\n", + L"よんじゅうはち\n", + L"よんじゅうきゅう\n", + L"ごじゅう\n", + L"ごじゅういち\n", + L"ごじゅうに\n", + L"ごじゅうさん\n", + L"ごじゅうよん\n", + L"ごじゅうご\n", + L"ごじゅうろく\n", + L"ごじゅうなな\n", + L"ごじゅうはち\n", + L"ごじゅうきゅう\n", + L"ろくじゅう\n", + L"ろくじゅういち\n", + L"ろくじゅうに\n", + L"ろくじゅうさん\n", + L"ろくじゅうよん\n", + L"ろくじゅうご\n", + L"ろくじゅうろく\n", + L"ろくじゅうなな\n", + L"ろくじゅうはち\n", + L"ろくじゅうきゅう\n", + L"ななじゅう\n", + L"ななじゅういち\n", + L"ななじゅうに\n", + L"ななじゅうさん\n", + L"ななじゅうよん\n", + L"ななじゅうご\n", + L"ななじゅうろく\n", + L"ななじゅうなな\n", + L"ななじゅうはち\n", + L"ななじゅうきゅう\n", + L"はちじゅう\n", + L"はちじゅういち\n", + L"はちじゅうに\n", + L"はちじゅうさん\n", + L"はちじゅうよん\n", + L"はちじゅうご\n", + L"はちじゅうろく\n", + L"はちじゅうなな\n", + L"はちじゅうはち\n", + L"はちじゅうきゅう\n", + L"きゅうじゅう\n", + L"きゅうじゅういち\n", + L"きゅうじゅうに\n", + L"きゅうじゅうさん\n", + L"きゅうじゅうよん\n", + L"きゅうじゅうご\n", + L"きゅうじゅうろく\n", + L"きゅうじゅうなな\n", + L"きゅうじゅうはち\n", + L"きゅうじゅうきゅう\n", + L"ひゃく\n", + L"ひゃくいち\n", + L"ひゃくに\n", + L"ひゃくさん\n", + L"ひゃくよん\n", + L"ひゃくご\n", + L"ひゃくろく\n", + L"ひゃくなな\n", + L"ひゃくはち\n", + L"ひゃくきゅう\n", + L"ひゃくじゅう\n", + L"ひゃくじゅういち\n", + L"ひゃくじゅうに\n", + L"ひゃくじゅうさん\n", + L"ひゃくじゅうよん\n", + L"ひゃくじゅうご\n", + L"ひゃくじゅうろく\n", + L"ひゃくじゅうなな\n", + L"ひゃくじゅうはち\n", + L"ひゃくじゅうきゅう\n", + L"ひゃくにじゅう\n", + L"ひゃくにじゅういち\n", + L"ひゃくにじゅうに\n", + L"ひゃくにじゅうさん\n", + L"ひゃくにじゅうよん\n", + L"ひゃくにじゅうご\n", + L"ひゃくにじゅうろく\n", + L"ひゃくにじゅうなな\n", + L"ひゃくにじゅうはち\n", + L"ひゃくにじゅうきゅう\n", + L"ひゃくさんじゅう\n", + L"ひゃくさんじゅういち\n", + L"ひゃくさんじゅうに\n", + L"ひゃくさんじゅうさん\n", + L"ひゃくさんじゅうよん\n", + L"ひゃくさんじゅうご\n", + L"ひゃくさんじゅうろく\n", + L"ひゃくさんじゅうなな\n", + L"ひゃくさんじゅうはち\n", + L"ひゃくさんじゅうきゅう\n", + L"ひゃくよんじゅう\n", + L"ひゃくよんじゅういち\n", + L"ひゃくよんじゅうに\n", + L"ひゃくよんじゅうさん\n", + L"ひゃくよんじゅうよん\n", + L"ひゃくよんじゅうご\n", + L"ひゃくよんじゅうろく\n", + L"ひゃくよんじゅうなな\n", + L"ひゃくよんじゅうはち\n", + L"ひゃくよんじゅうきゅう\n", + L"ひゃくごじゅう\n", + L"ひゃくごじゅういち\n", + L"ひゃくごじゅうに\n", + L"ひゃくごじゅうさん\n", + L"ひゃくごじゅうよん\n", + L"ひゃくごじゅうご\n", + L"ひゃくごじゅうろく\n", + L"ひゃくごじゅうなな\n", + L"ひゃくごじゅうはち\n", + L"ひゃくごじゅうきゅう\n", + L"ひゃくろくじゅう\n", + L"ひゃくろくじゅういち\n", + L"ひゃくろくじゅうに\n", + L"ひゃくろくじゅうさん\n", + L"ひゃくろくじゅうよん\n", + L"ひゃくろくじゅうご\n", + L"ひゃくろくじゅうろく\n", + L"ひゃくろくじゅうなな\n", + L"ひゃくろくじゅうはち\n", + L"ひゃくろくじゅうきゅう\n", + L"ひゃくななじゅう\n", + L"ひゃくななじゅういち\n", + L"ひゃくななじゅうに\n", + L"ひゃくななじゅうさん\n", + L"ひゃくななじゅうよん\n", + L"ひゃくななじゅうご\n", + L"ひゃくななじゅうろく\n", + L"ひゃくななじゅうなな\n", + L"ひゃくななじゅうはち\n", + L"ひゃくななじゅうきゅう\n", + L"ひゃくはちじゅう\n", + L"ひゃくはちじゅういち\n", + L"ひゃくはちじゅうに\n", + L"ひゃくはちじゅうさん\n", + L"ひゃくはちじゅうよん\n", + L"ひゃくはちじゅうご\n", + L"ひゃくはちじゅうろく\n", + L"ひゃくはちじゅうなな\n", + L"ひゃくはちじゅうはち\n", + L"ひゃくはちじゅうきゅう\n", + L"ひゃくきゅうじゅう\n", + L"ひゃくきゅうじゅういち\n", + L"ひゃくきゅうじゅうに\n", + L"ひゃくきゅうじゅうさん\n", + L"ひゃくきゅうじゅうよん\n", + L"ひゃくきゅうじゅうご\n", + L"ひゃくきゅうじゅうろく\n", + L"ひゃくきゅうじゅうなな\n", + L"ひゃくきゅうじゅうはち\n", + L"ひゃくきゅうじゅうきゅう\n", + L"にひゃく\n", + L"にひゃくいち\n", + L"にひゃくに\n", + L"にひゃくさん\n", + L"にひゃくよん\n", + L"にひゃくご\n", + L"にひゃくろく\n", + L"にひゃくなな\n", + L"にひゃくはち\n", + L"にひゃくきゅう\n", + L"にひゃくじゅう\n", + L"にひゃくじゅういち\n", + L"にひゃくじゅうに\n", + L"にひゃくじゅうさん\n", + L"にひゃくじゅうよん\n", + L"にひゃくじゅうご\n", + L"にひゃくじゅうろく\n", + L"にひゃくじゅうなな\n", + L"にひゃくじゅうはち\n", + L"にひゃくじゅうきゅう\n", + L"にひゃくにじゅう\n", + L"にひゃくにじゅういち\n", + L"にひゃくにじゅうに\n", + L"にひゃくにじゅうさん\n", + L"にひゃくにじゅうよん\n", + L"にひゃくにじゅうご\n", + L"にひゃくにじゅうろく\n", + L"にひゃくにじゅうなな\n", + L"にひゃくにじゅうはち\n", + L"にひゃくにじゅうきゅう\n", + L"にひゃくさんじゅう\n", + L"にひゃくさんじゅういち\n", + L"にひゃくさんじゅうに\n", + L"にひゃくさんじゅうさん\n", + L"にひゃくさんじゅうよん\n", + L"にひゃくさんじゅうご\n", + L"にひゃくさんじゅうろく\n", + L"にひゃくさんじゅうなな\n", + L"にひゃくさんじゅうはち\n", + L"にひゃくさんじゅうきゅう\n", + L"にひゃくよんじゅう\n", + L"にひゃくよんじゅういち\n", + L"にひゃくよんじゅうに\n", + L"にひゃくよんじゅうさん\n", + L"にひゃくよんじゅうよん\n", + L"にひゃくよんじゅうご\n", + L"にひゃくよんじゅうろく\n", + L"にひゃくよんじゅうなな\n", + L"にひゃくよんじゅうはち\n", + L"にひゃくよんじゅうきゅう\n", + L"にひゃくごじゅう\n", + L"にひゃくごじゅういち\n", + L"にひゃくごじゅうに\n", + L"にひゃくごじゅうさん\n", + L"にひゃくごじゅうよん\n", + L"にひゃくごじゅうご\n", + L"にひゃくごじゅうろく\n", + L"にひゃくごじゅうなな\n", + L"にひゃくごじゅうはち\n", + L"にひゃくごじゅうきゅう\n", + L"にひゃくろくじゅう\n", + L"にひゃくろくじゅういち\n", + L"にひゃくろくじゅうに\n", + L"にひゃくろくじゅうさん\n", + L"にひゃくろくじゅうよん\n", + L"にひゃくろくじゅうご\n", + L"にひゃくろくじゅうろく\n", + L"にひゃくろくじゅうなな\n", + L"にひゃくろくじゅうはち\n", + L"にひゃくろくじゅうきゅう\n", + L"にひゃくななじゅう\n", + L"にひゃくななじゅういち\n", + L"にひゃくななじゅうに\n", + L"にひゃくななじゅうさん\n", + L"にひゃくななじゅうよん\n", + L"にひゃくななじゅうご\n", + L"にひゃくななじゅうろく\n", + L"にひゃくななじゅうなな\n", + L"にひゃくななじゅうはち\n", + L"にひゃくななじゅうきゅう\n", + L"にひゃくはちじゅう\n", + L"にひゃくはちじゅういち\n", + L"にひゃくはちじゅうに\n", + L"にひゃくはちじゅうさん\n", + L"にひゃくはちじゅうよん\n", + L"にひゃくはちじゅうご\n", + L"にひゃくはちじゅうろく\n", + L"にひゃくはちじゅうなな\n", + L"にひゃくはちじゅうはち\n", + L"にひゃくはちじゅうきゅう\n", + L"にひゃくきゅうじゅう\n", + L"にひゃくきゅうじゅういち\n", + L"にひゃくきゅうじゅうに\n", + L"にひゃくきゅうじゅうさん\n", + L"にひゃくきゅうじゅうよん\n", + L"にひゃくきゅうじゅうご\n", + L"にひゃくきゅうじゅうろく\n", + L"にひゃくきゅうじゅうなな\n", + L"にひゃくきゅうじゅうはち\n", + L"にひゃくきゅうじゅうきゅう\n", + L"さんびゃく\n", +}; + +long offset[301]; + +int main(int argc, char **argv) +{ + int i, n; + FILE *fp; + char *s, buf[256]; + wchar_t wbuf[64]; + +#ifdef UTF8 + setlocale(LC_ALL, "en_US.utf8"); +#else + setlocale(LC_ALL, "en_US"); +#endif + fp = fopen("output.txt", "w+"); + if (fp == NULL) { + perror("fopen"); + exit(1); + } + for (i = 0; i <= 300; i++) { + offset[i] = ftell(fp); + if (fputws(numbers[i], fp) == -1) { + perror("fputws"); + exit(1); + } + } +#ifdef TESTREAD + fclose(fp); + fp = fopen("output.txt", "r"); +#endif + for ( ; ; ) { + s = fgets(buf, 256, stdin); + n = atoi(buf); + if (s == NULL || n < 0 || n > 300) + break; + if (fseek(fp, offset[n], SEEK_SET) == -1) { + perror("fseek"); + exit(1); + } +#ifdef NOFTELL + printf("%d: (%ld) ", n, offset[n]); +#else + printf("%d: (%ld->%ld) ", n, offset[n], ftell(fp)); +#endif + fgetws(wbuf, 64, fp); + wcstombs(buf, wbuf, 256); + printf("%s", buf); + } + fclose(fp); + return 0; +} diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fseek-wchar.c b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fseek-wchar.c new file mode 100644 index 0000000..a088b1d --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fseek-wchar.c @@ -0,0 +1,357 @@ +#include +#include +#include +#include +#include + +wchar_t *numbers[301] = { + L"zero\n", + L"one\n", + L"two\n", + L"three\n", + L"four\n", + L"five\n", + L"six\n", + L"seven\n", + L"eight\n", + L"nine\n", + L"ten\n", + L"eleven\n", + L"twelve\n", + L"thirteen\n", + L"fourteen\n", + L"fifteen\n", + L"sixteen\n", + L"seventeen\n", + L"eighteen\n", + L"nineteen\n", + L"twenty\n", + L"twenty one\n", + L"twenty two\n", + L"twenty three\n", + L"twenty four\n", + L"twenty five\n", + L"twenty six\n", + L"twenty seven\n", + L"twenty eight\n", + L"twenty nine\n", + L"thirty\n", + L"thirty one\n", + L"thirty two\n", + L"thirty three\n", + L"thirty four\n", + L"thirty five\n", + L"thirty six\n", + L"thirty seven\n", + L"thirty eight\n", + L"thirty nine\n", + L"forty\n", + L"forty one\n", + L"forty two\n", + L"forty three\n", + L"forty four\n", + L"forty five\n", + L"forty six\n", + L"forty seven\n", + L"forty eight\n", + L"forty nine\n", + L"fifty\n", + L"fifty one\n", + L"fifty two\n", + L"fifty three\n", + L"fifty four\n", + L"fifty five\n", + L"fifty six\n", + L"fifty seven\n", + L"fifty eight\n", + L"fifty nine\n", + L"sixty\n", + L"sixty one\n", + L"sixty two\n", + L"sixty three\n", + L"sixty four\n", + L"sixty five\n", + L"sixty six\n", + L"sixty seven\n", + L"sixty eight\n", + L"sixty nine\n", + L"seventy\n", + L"seventy one\n", + L"seventy two\n", + L"seventy three\n", + L"seventy four\n", + L"seventy five\n", + L"seventy six\n", + L"seventy seven\n", + L"seventy eight\n", + L"seventy nine\n", + L"eighty\n", + L"eighty one\n", + L"eighty two\n", + L"eighty three\n", + L"eighty four\n", + L"eighty five\n", + L"eighty six\n", + L"eighty seven\n", + L"eighty eight\n", + L"eighty nine\n", + L"ninety\n", + L"ninety one\n", + L"ninety two\n", + L"ninety three\n", + L"ninety four\n", + L"ninety five\n", + L"ninety six\n", + L"ninety seven\n", + L"ninety eight\n", + L"ninety nine\n", + L"one hundred\n", + L"one hundred and one\n", + L"one hundred and two\n", + L"one hundred and three\n", + L"one hundred and four\n", + L"one hundred and five\n", + L"one hundred and six\n", + L"one hundred and seven\n", + L"one hundred and eight\n", + L"one hundred and nine\n", + L"one hundred and ten\n", + L"one hundred and eleven\n", + L"one hundred and twelve\n", + L"one hundred and thirteen\n", + L"one hundred and fourteen\n", + L"one hundred and fifteen\n", + L"one hundred and sixteen\n", + L"one hundred and seventeen\n", + L"one hundred and eighteen\n", + L"one hundred and nineteen\n", + L"one hundred and twenty\n", + L"one hundred and twenty one\n", + L"one hundred and twenty two\n", + L"one hundred and twenty three\n", + L"one hundred and twenty four\n", + L"one hundred and twenty five\n", + L"one hundred and twenty six\n", + L"one hundred and twenty seven\n", + L"one hundred and twenty eight\n", + L"one hundred and twenty nine\n", + L"one hundred and thirty\n", + L"one hundred and thirty one\n", + L"one hundred and thirty two\n", + L"one hundred and thirty three\n", + L"one hundred and thirty four\n", + L"one hundred and thirty five\n", + L"one hundred and thirty six\n", + L"one hundred and thirty seven\n", + L"one hundred and thirty eight\n", + L"one hundred and thirty nine\n", + L"one hundred and forty\n", + L"one hundred and forty one\n", + L"one hundred and forty two\n", + L"one hundred and forty three\n", + L"one hundred and forty four\n", + L"one hundred and forty five\n", + L"one hundred and forty six\n", + L"one hundred and forty seven\n", + L"one hundred and forty eight\n", + L"one hundred and forty nine\n", + L"one hundred and fifty\n", + L"one hundred and fifty one\n", + L"one hundred and fifty two\n", + L"one hundred and fifty three\n", + L"one hundred and fifty four\n", + L"one hundred and fifty five\n", + L"one hundred and fifty six\n", + L"one hundred and fifty seven\n", + L"one hundred and fifty eight\n", + L"one hundred and fifty nine\n", + L"one hundred and sixty\n", + L"one hundred and sixty one\n", + L"one hundred and sixty two\n", + L"one hundred and sixty three\n", + L"one hundred and sixty four\n", + L"one hundred and sixty five\n", + L"one hundred and sixty six\n", + L"one hundred and sixty seven\n", + L"one hundred and sixty eight\n", + L"one hundred and sixty nine\n", + L"one hundred and seventy\n", + L"one hundred and seventy one\n", + L"one hundred and seventy two\n", + L"one hundred and seventy three\n", + L"one hundred and seventy four\n", + L"one hundred and seventy five\n", + L"one hundred and seventy six\n", + L"one hundred and seventy seven\n", + L"one hundred and seventy eight\n", + L"one hundred and seventy nine\n", + L"one hundred and eighty\n", + L"one hundred and eighty one\n", + L"one hundred and eighty two\n", + L"one hundred and eighty three\n", + L"one hundred and eighty four\n", + L"one hundred and eighty five\n", + L"one hundred and eighty six\n", + L"one hundred and eighty seven\n", + L"one hundred and eighty eight\n", + L"one hundred and eighty nine\n", + L"one hundred and ninety\n", + L"one hundred and ninety one\n", + L"one hundred and ninety two\n", + L"one hundred and ninety three\n", + L"one hundred and ninety four\n", + L"one hundred and ninety five\n", + L"one hundred and ninety six\n", + L"one hundred and ninety seven\n", + L"one hundred and ninety eight\n", + L"one hundred and ninety nine\n", + L"two hundred\n", + L"two hundred and one\n", + L"two hundred and two\n", + L"two hundred and three\n", + L"two hundred and four\n", + L"two hundred and five\n", + L"two hundred and six\n", + L"two hundred and seven\n", + L"two hundred and eight\n", + L"two hundred and nine\n", + L"two hundred and ten\n", + L"two hundred and eleven\n", + L"two hundred and twelve\n", + L"two hundred and thirteen\n", + L"two hundred and fourteen\n", + L"two hundred and fifteen\n", + L"two hundred and sixteen\n", + L"two hundred and seventeen\n", + L"two hundred and eighteen\n", + L"two hundred and nineteen\n", + L"two hundred and twenty\n", + L"two hundred and twenty one\n", + L"two hundred and twenty two\n", + L"two hundred and twenty three\n", + L"two hundred and twenty four\n", + L"two hundred and twenty five\n", + L"two hundred and twenty six\n", + L"two hundred and twenty seven\n", + L"two hundred and twenty eight\n", + L"two hundred and twenty nine\n", + L"two hundred and thirty\n", + L"two hundred and thirty one\n", + L"two hundred and thirty two\n", + L"two hundred and thirty three\n", + L"two hundred and thirty four\n", + L"two hundred and thirty five\n", + L"two hundred and thirty six\n", + L"two hundred and thirty seven\n", + L"two hundred and thirty eight\n", + L"two hundred and thirty nine\n", + L"two hundred and forty\n", + L"two hundred and forty one\n", + L"two hundred and forty two\n", + L"two hundred and forty three\n", + L"two hundred and forty four\n", + L"two hundred and forty five\n", + L"two hundred and forty six\n", + L"two hundred and forty seven\n", + L"two hundred and forty eight\n", + L"two hundred and forty nine\n", + L"two hundred and fifty\n", + L"two hundred and fifty one\n", + L"two hundred and fifty two\n", + L"two hundred and fifty three\n", + L"two hundred and fifty four\n", + L"two hundred and fifty five\n", + L"two hundred and fifty six\n", + L"two hundred and fifty seven\n", + L"two hundred and fifty eight\n", + L"two hundred and fifty nine\n", + L"two hundred and sixty\n", + L"two hundred and sixty one\n", + L"two hundred and sixty two\n", + L"two hundred and sixty three\n", + L"two hundred and sixty four\n", + L"two hundred and sixty five\n", + L"two hundred and sixty six\n", + L"two hundred and sixty seven\n", + L"two hundred and sixty eight\n", + L"two hundred and sixty nine\n", + L"two hundred and seventy\n", + L"two hundred and seventy one\n", + L"two hundred and seventy two\n", + L"two hundred and seventy three\n", + L"two hundred and seventy four\n", + L"two hundred and seventy five\n", + L"two hundred and seventy six\n", + L"two hundred and seventy seven\n", + L"two hundred and seventy eight\n", + L"two hundred and seventy nine\n", + L"two hundred and eighty\n", + L"two hundred and eighty one\n", + L"two hundred and eighty two\n", + L"two hundred and eighty three\n", + L"two hundred and eighty four\n", + L"two hundred and eighty five\n", + L"two hundred and eighty six\n", + L"two hundred and eighty seven\n", + L"two hundred and eighty eight\n", + L"two hundred and eighty nine\n", + L"two hundred and ninety\n", + L"two hundred and ninety one\n", + L"two hundred and ninety two\n", + L"two hundred and ninety three\n", + L"two hundred and ninety four\n", + L"two hundred and ninety five\n", + L"two hundred and ninety six\n", + L"two hundred and ninety seven\n", + L"two hundred and ninety eight\n", + L"two hundred and ninety nine\n", + L"three hundred\n" +}; + +long offset[301]; + +int main(int argc, char **argv) +{ + int i, n; + FILE *fp; + char *s, buf[256]; + wchar_t wbuf[64]; + +#ifdef UTF8 + setlocale(LC_ALL, "en_US.utf8"); +#else + setlocale(LC_ALL, "en_US"); +#endif + fp = fopen("output.txt", "w+"); + if (fp == NULL) { + perror("fopen"); + exit(1); + } + for (i = 0; i <= 300; i++) { + offset[i] = ftell(fp); + if (fputws(numbers[i], fp) == -1) { + perror("fputws"); + exit(1); + } + } +#ifdef TESTREAD + fclose(fp); + fp = fopen("output.txt", "r"); +#endif + for ( ; ; ) { + s = fgets(buf, 256, stdin); + n = atoi(buf); + if (s == NULL || n < 0 || n > 300) + break; + if (fseek(fp, offset[n], SEEK_SET) == -1) { + perror("fseek"); + exit(1); + } + printf("%d: (%ld->%ld) ", n, offset[n], ftell(fp)); + fgetws(wbuf, 64, fp); + wcstombs(buf, wbuf, 256); + printf("%s", buf); + } + fclose(fp); + return 0; +} diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.golden b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.golden new file mode 100644 index 0000000..8c7ef8a --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.golden @@ -0,0 +1,13 @@ +1: (5->5) one +2: (9->9) two +3: (13->13) three +4: (19->19) four +5: (24->24) five +6: (29->29) six +7: (33->33) seven +8: (39->39) eight +9: (45->45) nine +255: (5036->5036) two hundred and fifty five +256: (5063->5063) two hundred and fifty six +0: (0->0) zero +3: (13->13) three diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.input b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.input new file mode 100644 index 0000000..c1746f4 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.input @@ -0,0 +1,13 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +255 +256 +0 +3 diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.j.golden b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.j.golden new file mode 100644 index 0000000..f752777 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/fw.j.golden @@ -0,0 +1,13 @@ +1: (7->7) いち +2: (14->14) に +3: (18->18) さん +4: (25->25) よん +5: (32->32) ご +6: (36->36) ろく +7: (43->43) なな +8: (50->50) はち +9: (57->57) きゅう +255: (6207->6207) にひゃくごじゅうご +256: (6235->6235) にひゃくごじゅうろく +0: (0->0) ゼロ +3: (18->18) さん diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/main.fmf b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/main.fmf new file mode 100644 index 0000000..10a5909 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/main.fmf @@ -0,0 +1,17 @@ +summary: Test for BZ#827362 ([RHEL6.2] ftell after fseek moves the offset on a) +description: | + Bug summary: [RHEL6.2] ftell after fseek moves the offset on a stream using wide characters + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=827362 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 20m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=827362 +extra-summary: /tools/glibc/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a +extra-task: /tools/glibc/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/output.golden b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/output.golden new file mode 100644 index 0000000..4aee153 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/output.golden @@ -0,0 +1,2 @@ +abc +xyz diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/output.seeking b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/output.seeking new file mode 100644 index 0000000..ff8e960 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/output.seeking @@ -0,0 +1,3 @@ +before=4 +fseek=4 +after=8 diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/runtest.sh b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/runtest.sh new file mode 100755 index 0000000..a99b064 --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/runtest.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a +# Description: Test for BZ#827362 ([RHEL6.2] ftell after fseek moves the offset on a) +# 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 + +PACKAGES=(glibc gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp test.c fseek-wchar* fw.* output.* $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest "reproducer" + rlRun "gcc -DUTF8 -o test test.c" + rlRun "./test > log 2>&1" + rlAssertNotDiffer output.seeking log + rlLog "$(diff -u output.seeking log)" + rlAssertNotDiffer output.golden output.txt + rlLog "$(diff -u output.golden output.txt)" + rlPhaseEnd + + for o in '-DTESTREAD -DUTF8' '-DUTF8'; do + rlPhaseStartTest "another reproducer : $o" + rlRun "gcc $o -o fseek-wchar fseek-wchar.c" + rlRun "./fseek-wchar log 2>&1" + rlAssertNotDiffer log fw.golden + rlLog "$(diff -u log fw.golden)" + rlPhaseEnd + + rlPhaseStartTest "yet another reproducer : $o" + rlRun "gcc $o -o fseek-wchar-j fseek-wchar-j.c" + rlRun "./fseek-wchar-j log 2>&1" + rlAssertNotDiffer log fw.j.golden + rlLog "$(diff -u log fw.j.golden)" + rlPhaseEnd + done; unset o + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/test.c b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/test.c new file mode 100644 index 0000000..496fe4c --- /dev/null +++ b/tests/Regression/bz827362-RHEL6-2-ftell-after-fseek-moves-the-offset-on-a/test.c @@ -0,0 +1,36 @@ +#include +#include +#include + +int main(int argc, char** argv) +{ + FILE *fp; + +#ifdef UTF8 + setlocale(LC_ALL, "en_US.utf8"); +#else + setlocale(LC_ALL, "en_US"); +#endif + fp = fopen("output.txt", "w+"); + if (fp == NULL) { + perror("fopen"); + exit(1); + } + if (fputws(L"abc\n", fp) == -1) { + perror("fputws"); + exit(1); + } + printf("before=%d\n", ftell(fp)); + if (fseek(fp, 0L, SEEK_END) == -1) { + perror("fseek"); + exit(1); + } + printf("fseek=%d\n", ftell(fp)); + if (fputws(L"xyz\n", fp) == -1) { + perror("fputws"); + exit(1); + } + printf("after=%d\n", ftell(fp)); + fclose(fp); + return 0; +} diff --git a/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/Makefile b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/Makefile new file mode 100644 index 0000000..10df528 --- /dev/null +++ b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file +# Description: Checks if the /etc/rpc file is marked as a configuration file after updating of glibc. +# Author: David Kaspar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file +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: David Kaspar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Checks if the /etc/rpc file is marked as a configuration file after updating of glibc." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Medium" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 829222" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/PURPOSE b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/PURPOSE new file mode 100644 index 0000000..2cc1a64 --- /dev/null +++ b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file +Description: Checks if the /etc/rpc file is marked as a configuration file after updating of glibc. +Author: David Kaspar diff --git a/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/main.fmf b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/main.fmf new file mode 100644 index 0000000..026f897 --- /dev/null +++ b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/main.fmf @@ -0,0 +1,15 @@ +summary: Checks if the /etc/rpc file is marked as a configuration file after updating + of glibc. +description: '' +contact: David Kaspar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=829222 +extra-summary: /tools/glibc/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file +extra-task: /tools/glibc/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file diff --git a/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/runtest.sh b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/runtest.sh new file mode 100755 index 0000000..0b66a48 --- /dev/null +++ b/tests/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file/runtest.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz829222-rpc-file-in-etc-folder-not-marked-as-configuration-file +# Description: Checks if the /etc/rpc file is marked as a configuration file after updating of glibc. +# Author: David Kaspar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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="glibc" + +rlJournalStart + + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlPhaseEnd + + rlPhaseStartTest + rlRun "rpm -qc glibc | grep -x /etc/rpc" 0 \ + "Checking if /etc/rpc is marked as config file" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/Makefile b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/Makefile new file mode 100644 index 0000000..4e6c6d1 --- /dev/null +++ b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x +# Description: Test for BZ#839572 (Anaconda traceback when installing on s390x) +# 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/glibc/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x +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: Miroslav Franc " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for BZ#839572 (Anaconda traceback when installing on s390x)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 45m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc python python2 python3 python36" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 839572" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/PURPOSE b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/PURPOSE new file mode 100644 index 0000000..fb4adc1 --- /dev/null +++ b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x +Description: Test for BZ#839572 (Anaconda traceback when installing on s390x) +Author: Miroslav Franc +Bug summary: Anaconda traceback when installing on s390x: ValueError: (3, 'No such process') +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=839572 diff --git a/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/main.fmf b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/main.fmf new file mode 100644 index 0000000..85c05f6 --- /dev/null +++ b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/main.fmf @@ -0,0 +1,20 @@ +summary: Test for BZ#839572 (Anaconda traceback when installing on s390x) +description: | + Bug summary: Anaconda traceback when installing on s390x: ValueError: (3, 'No such process') + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=839572 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - python + - python2 + - python3 + - python36 +duration: 45m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=839572 +extra-summary: /tools/glibc/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x +extra-task: /tools/glibc/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x diff --git a/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/runtest.sh b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/runtest.sh new file mode 100755 index 0000000..5b89a8f --- /dev/null +++ b/tests/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x/runtest.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz839572-Anaconda-traceback-when-installing-on-s390x +# Description: Test for BZ#839572 (Anaconda traceback when installing on s390x) +# 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 +rlJournalStart + rlPhaseStartSetup + rlAssertRpm glibc + if rlIsRHEL 8; then + rlAssertExists "/usr/bin/python3" + USEPYTHON="python3" + else + rlAssertExists "/usr/bin/python" + USEPYTHON="python" + fi + rlPhaseEnd + + rlPhaseStartTest + rlRun -l "$USEPYTHON -c 'import math; print (math.exp(-0.5))'" + rlRun -l "$USEPYTHON -c 'import math; print (math.exp(10))'" + rlRun -l "$USEPYTHON -c 'import math; print (math.sqrt(2.0))'" + rlRun -l "$USEPYTHON -c 'import math; math.exp(0)'" + rlRun -l "$USEPYTHON -c 'import random;'" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/Makefile b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/Makefile new file mode 100644 index 0000000..b0de5b1 --- /dev/null +++ b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not +# Description: Test for BZ#842280 (posix_spawn() invokes sh when it should not) +# 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/glibc/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE reproducer.c # from Michal Hlavinka + +.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#842280 (posix_spawn() invokes sh when it should not)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 842280" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/PURPOSE b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/PURPOSE new file mode 100644 index 0000000..c2c5200 --- /dev/null +++ b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/PURPOSE @@ -0,0 +1,7 @@ +PURPOSE of /tools/glibc/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not +Description: Test for BZ#842280 (posix_spawn() invokes sh when it should not) +Author: Miroslav Franc +Bug summary: posix_spawn() invokes sh when it should not +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=842280 + +Uses reproducer from Michal Hlavinka. diff --git a/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/main.fmf b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/main.fmf new file mode 100644 index 0000000..448b0f9 --- /dev/null +++ b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/main.fmf @@ -0,0 +1,19 @@ +summary: Test for BZ#842280 (posix_spawn() invokes sh when it should not) +description: | + Bug summary: posix_spawn() invokes sh when it should not + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=842280 + + Uses reproducer from Michal Hlavinka. +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=842280 +extra-summary: /tools/glibc/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not +extra-task: /tools/glibc/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not diff --git a/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/reproducer.c b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/reproducer.c new file mode 100644 index 0000000..0cfba0d --- /dev/null +++ b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/reproducer.c @@ -0,0 +1,114 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +/* if it uses fork() why bother? */ +#undef fork +#define NOTE(a) fprintf(stderr,"%s\n",a) +pid_t fork (void) { NOTE("uses fork()"); return -1; } +pid_t _fork (void) { NOTE("uses _fork()"); return -1; } +pid_t __fork (void) { NOTE("uses __fork()"); return -1; } +int +main(argc, argv) +int argc; +char** argv; +{ + char* s; + pid_t pid; + posix_spawnattr_t attr; + int n; + int status; + char* cmd[3]; + char tmp[1024]; + if (argv[1]) + _exit(signal(SIGHUP, SIG_DFL) != SIG_IGN); + signal(SIGHUP, SIG_IGN); + if (posix_spawnattr_init(&attr)) + { + NOTE("posix_spawnattr_init() FAILED"); + _exit(0); + } + if (posix_spawnattr_setpgroup(&attr, 0)) + { + NOTE("posix_spawnattr_setpgroup() FAILED"); + _exit(0); + } + if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETPGROUP)) + { + NOTE("posix_spawnattr_setflags() FAILED"); + _exit(0); + } + /* first try an a.out and verify that SIGHUP is ignored */ + cmd[0] = argv[0]; + cmd[1] = "test"; + cmd[2] = 0; + if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0)) + { + NOTE("posix_spawn() FAILED"); + _exit(0); + } + status = 1; + if (wait(&status) < 0) + { + NOTE("wait() FAILED"); + _exit(0); + } + if (status != 0) + { + NOTE("SIGHUP ignored in parent not ignored in child"); + _exit(0); + } + /* must return exec-type errors or its useless to us *unless* there is no [v]fork() */ + n = strlen(cmd[0]); + if (n >= (sizeof(tmp) - 3)) + { + NOTE("test executable path too long"); + _exit(0); + } + strcpy(tmp, cmd[0]); + tmp[n] = '.'; + tmp[n+1] = 's'; + tmp[n+2] = 'h'; + tmp[n+3] = 0; + if ((n = open(tmp, O_CREAT|O_WRONLY, S_IRWXU|S_IRWXG|S_IRWXO)) < 0 || + chmod(tmp, S_IRWXU|S_IRWXG|S_IRWXO) < 0 || + write(n, "exit 99\n", 8) != 8 || + close(n) < 0) + { + NOTE("test script create FAILED"); + _exit(0); + } + cmd[0] = tmp; + n = 0; /* 0 means reject */ + pid = -1; + if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0)) { + n = 2; /* ENOEXEC produces posix_spawn() error => BEST */ + NOTE("ENOEXEC produces posix_spawn() error => BEST"); + } + else if (pid == -1) + NOTE("ENOEXEC returns pid == -1"); + else if (wait(&status) != pid) + NOTE("ENOEXEC produces no child process"); + else if (!WIFEXITED(status)) + NOTE("ENOEXEC produces signal exit"); + else + { + status = WEXITSTATUS(status); + if (status == 127) + { + NOTE("ENOEXEC produces exist status 127 => GOOD"); + n = 1; /* ENOEXEC produces exit status 127 => GOOD */ + } + else if (status == 99) + NOTE("ENOEXEC invokes sh"); + else if (status == 0) + NOTE("ENOEXEC reports no error"); + } + _exit(n); +} + diff --git a/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/runtest.sh b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/runtest.sh new file mode 100755 index 0000000..e744124 --- /dev/null +++ b/tests/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz842280-posix-spawn-invokes-sh-when-it-should-not +# Description: Test for BZ#842280 (posix_spawn() invokes sh when it should not) +# 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="gcc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp reproducer.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc reproducer.c -o repr" + rlPhaseEnd + + rlPhaseStartTest + rlRun "./repr > log 2>&1" 1,2 + rlAssertGrep "GOOD\|BEST" log + rlFileSubmit log + rlAssertNotGrep "ENOEXEC invokes sh" log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/Makefile b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/Makefile new file mode 100644 index 0000000..8402c19 --- /dev/null +++ b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/Makefile @@ -0,0 +1,66 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6 +# Description: Tests if 'getaddrinfo' returns FQDN in ai_canonname. +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6 +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE ns.pl gai-tst.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Tests if 'getaddrinfo' returns FQDN in ai_canonname." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: bind-utils gcc glibc glibc-devel glibc-headers perl-Net-DNS-Nameserver" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 863384" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + @echo "RhtsRequires: library(glibc/gtu)" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/PURPOSE b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/PURPOSE new file mode 100644 index 0000000..32bea69 --- /dev/null +++ b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6 +Description: Tests if 'getaddrinfo' returns FQDN in ai_canonname. +Author: Arjun Shankar diff --git a/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/gai-tst.c b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/gai-tst.c new file mode 100644 index 0000000..8f4c2f7 --- /dev/null +++ b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/gai-tst.c @@ -0,0 +1,63 @@ +#define _BSD_SOURCE +#include +#include +#include +#include +#include +#include + +#define SIZE 500 + +/* Calls getaddrinfo thrice with argv[1] +i.e. once each for AF_UNSPEC, AF_INET and AF_INET6 +*/ + +void +test (char *query, int af, char *af_name) +{ + struct addrinfo *result, *current; + struct addrinfo hints; + int ecode; + + hints.ai_socktype = 0; + hints.ai_protocol = 0; + hints.ai_flags = AI_CANONNAME|AI_ADDRCONFIG; + hints.ai_family = af; + + if (ecode = getaddrinfo (query, NULL, &hints, &result)) + { + printf ("WARN: %s query failed with error: %s\n", af_name, gai_strerror(ecode)); + } + else + { + printf ("INFO: %s results:\n", af_name); + + for (current = result; current != NULL && current->ai_canonname != NULL; current = current->ai_next) + printf ("%s\n", current->ai_canonname); + + freeaddrinfo (result); + } + + return; +} + +int +main (int argc, char **argv) +{ + char *query; + + /* There must be an argument, which we assume is the FQDN. */ + if (argc < 2) + return EXIT_FAILURE; + + /* Copy FQDN, and tokenize it into name. */ + query = argv[1]; + + printf ("query=%s\n", query); + + test (query, AF_UNSPEC, "AF_UNSPEC"); + test (query, AF_INET, "AF_INET"); + test (query, AF_INET6, "AF_INET6"); + + return EXIT_SUCCESS; +} diff --git a/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/main.fmf b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/main.fmf new file mode 100644 index 0000000..cc6041f --- /dev/null +++ b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/main.fmf @@ -0,0 +1,19 @@ +summary: Tests if 'getaddrinfo' returns FQDN in ai_canonname. +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - bind-utils + - gcc + - glibc + - glibc-devel + - glibc-headers + - perl-Net-DNS-Nameserver +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=863384 +extra-summary: /tools/glibc/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6 +extra-task: /tools/glibc/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6 diff --git a/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/ns.pl b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/ns.pl new file mode 100755 index 0000000..c133fb0 --- /dev/null +++ b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/ns.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +# A simple nameserver that responds only to queries for "A" records of +# "mister.edward.hyde". This program is an almost verbatim copy of the +# Net::DNS::Nameserver example at: +# http://search.cpan.org/dist/Net-DNS/lib/Net/DNS/Nameserver.pm#EXAMPLE + +use strict; +use warnings; +use Net::DNS::Nameserver; + +sub reply_handler +{ + my ($qname, $qclass, $qtype, $peerhost, $query, $conn) = @_; + my ($rcode, @ans, @auth, @add); + + print "Received query from $peerhost to " . $conn->{sockhost} . "\n"; + $query->print; + + my $ttl = 0; + my $rdata = ""; + + $rcode = "NOERROR"; + + if ($qtype eq "A") + { + if ($qname eq "foo.red.hat") { $rdata = "127.126.125.124" } + elsif ($qname eq "bar.foo.red.hat") { $rdata = "127.126.125.124" } + elsif ($qname eq "red.hat") { $rdata = "127.126.125.124" } + else { $rcode = "NXDOMAIN" } + } + elsif ($qtype eq "AAAA") + { + if ($qname eq "foo.red.hat") { $rdata = "::1" } + elsif ($qname eq "bar.foo.red.hat") { $rdata = "::1" } + elsif ($qname eq "red.hat") { $rdata = "::1" } + else { $rcode = "NXDOMAIN" } + } + else + { + $rcode = "NXDOMAIN"; + } + + if ($rcode == "NOERROR") + { + my $rr = new Net::DNS::RR("$qname $ttl $qclass $qtype $rdata"); + push @ans, $rr; + } + + # mark the answer as authoritive (by setting the 'aa' flag + return ($rcode, \@ans, \@auth, \@add, {aa => 1}); +} + +my $ns = new Net::DNS::Nameserver( + LocalPort => 53, + ReplyHandler => \&reply_handler, + Verbose => 1 + ) + || die "couldn't create nameserver object\n"; + +$ns->main_loop; diff --git a/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/runtest.sh b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/runtest.sh new file mode 100755 index 0000000..9937992 --- /dev/null +++ b/tests/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6/runtest.sh @@ -0,0 +1,120 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz863384-getaddrinfo-fails-to-return-FQDN-for-AF_INET-and-AF_INET6 +# Description: Tests if 'getaddrinfo' returns FQDN in ai_canonname. +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 + +PACKAGES=(glibc glibc-devel gcc perl-Net-DNS-Nameserver) + +rlJournalStart + rlPhaseStartSetup + #rlRun "rlImport glibc/gtu" + rlFileBackup /etc/hosts + #gtuAddLabController + + # Standard prep: check "Requires", create testdir, copy files + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp gai-tst.c ns.pl $TmpDir" + rlRun "pushd $TmpDir" + + # Compile the query program + rlRun "gcc gai-tst.c -o gai-tst" + rlAssertExists "gai-tst" + + # Start the local NS and make sure it is running + rlRun "./ns.pl &> /dev/null &" + rlRun "NS_PID=$!" + sleep 10 + rlRun "kill -0 $NS_PID" + + if rlIsFedora + then + rlServiceStop systemd-resolved.service + else + # Back up resolver configuration + rlFileBackup "/etc/resolv.conf" + fi + rlPhaseEnd + + function performTest + { + # $1 is query, $2 is FQDN + rlPhaseStartTest $1 + rlRun "./gai-tst $1 > gai-tst.out" + rlLog "Contents of 'gai-tst.out':" + rlLog "$(cat gai-tst.out)" + rlAssertEquals "gai-tst.out should not contain 'ERROR's." "$(cat gai-tst.out | grep '^ERROR:' | wc -l)" 0 + if [[ $(cat gai-tst.out | grep '^WARN:' | wc -l) > 0 ]] + then + rlLogWarning "'gai-tst.out' contains:'" + rlLogWarning "$(cat gai-tst.out | grep '^WARN:')" + fi + rlRun "cat gai-tst.out | grep -v '^WARN:\|^INFO:\|^ERROR:\|^query=' | sort -u > result_fqdn.out" + rlAssertEquals "There must be exactly one unique result for all tests" "$(cat result_fqdn.out | wc -l)" 1 + rlAssertEquals "Result must match FQDN." "$(cat result_fqdn.out)" "$2" + rlPhaseEnd + } + + # Test with 'red.hat' domain + rlPhaseStartSetup resolvConfChangeA + rlRun "echo -e 'domain red.hat\nnameserver 127.0.0.1' > /etc/resolv.conf" + rlPhaseEnd + + performTest "foo" "foo.red.hat" + performTest "bar.foo" "bar.foo.red.hat" + + # Test with 'hat' domain + rlPhaseStartSetup resolvConfChangeA + rlRun "echo -e 'domain hat\nnameserver 127.0.0.1' > /etc/resolv.conf" + rlPhaseEnd + + performTest "foo.red" "foo.red.hat" + performTest "bar.foo.red" "bar.foo.red.hat" + performTest "red" "red.hat" + + rlPhaseStartCleanup + rlFileRestore + if rlIsFedora + then + rlServiceRestore systemd-resolved.service + fi + + # Stop local NS and ensure it is dead + rlRun "kill $NS_PID" + sleep 10 + rlRun "kill -0 $NS_PID" 1-255 + + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz868808-backtrace-for-recursive-functions/Makefile b/tests/Regression/bz868808-backtrace-for-recursive-functions/Makefile new file mode 100644 index 0000000..251da43 --- /dev/null +++ b/tests/Regression/bz868808-backtrace-for-recursive-functions/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz868808-backtrace-for-recursive-functions +# Description: Calls and verifies result of 'backtrace' while performing recursion. +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz868808-backtrace-for-recursive-functions +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE bt-tst.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Calls and verifies result of 'backtrace' while performing recursion." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 868808" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz868808-backtrace-for-recursive-functions/PURPOSE b/tests/Regression/bz868808-backtrace-for-recursive-functions/PURPOSE new file mode 100644 index 0000000..cade416 --- /dev/null +++ b/tests/Regression/bz868808-backtrace-for-recursive-functions/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz868808-backtrace-for-recursive-functions +Description: Calls and verifies result of 'backtrace' while performing recursion. +Author: Arjun Shankar diff --git a/tests/Regression/bz868808-backtrace-for-recursive-functions/bt-tst.c b/tests/Regression/bz868808-backtrace-for-recursive-functions/bt-tst.c new file mode 100644 index 0000000..a32c040 --- /dev/null +++ b/tests/Regression/bz868808-backtrace-for-recursive-functions/bt-tst.c @@ -0,0 +1,59 @@ +/* Originally copied from the example at `man 3 backtrace' as supplied by +the Linux man-pages project. */ + +#include +#include +#include +#include + +#define SIZE 100 + +void +last (void) +{ + int j, nptrs; + void *buffer[SIZE]; + char **strings; + + nptrs = backtrace (buffer, SIZE); + + strings = backtrace_symbols (buffer, nptrs); + if (strings == NULL) + { + perror ("backtrace_symbols"); + exit (EXIT_FAILURE); + } + + for (j = 0; j < nptrs; j++) + printf ("%s\n", strings[j]); + + free (strings); +} + +static void /* "static" means don't export the symbol... */ +penultimate (void) +{ + last (); +} + +void +recursive (int ncalls) +{ + if (ncalls > 1) + recursive (ncalls - 1); + else + penultimate (); +} + +int +main (int argc, char *argv[]) +{ + if (argc != 2) + { + fprintf (stderr, "%s num-calls\n", argv[0]); + exit (EXIT_FAILURE); + } + + recursive (atoi (argv[1])); + exit (EXIT_SUCCESS); +} diff --git a/tests/Regression/bz868808-backtrace-for-recursive-functions/main.fmf b/tests/Regression/bz868808-backtrace-for-recursive-functions/main.fmf new file mode 100644 index 0000000..58916e4 --- /dev/null +++ b/tests/Regression/bz868808-backtrace-for-recursive-functions/main.fmf @@ -0,0 +1,17 @@ +summary: Calls and verifies result of 'backtrace' while performing recursion. +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=868808 +extra-summary: /tools/glibc/Regression/bz868808-backtrace-for-recursive-functions +extra-task: /tools/glibc/Regression/bz868808-backtrace-for-recursive-functions diff --git a/tests/Regression/bz868808-backtrace-for-recursive-functions/runtest.sh b/tests/Regression/bz868808-backtrace-for-recursive-functions/runtest.sh new file mode 100755 index 0000000..cf83c3c --- /dev/null +++ b/tests/Regression/bz868808-backtrace-for-recursive-functions/runtest.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz868808-backtrace-for-recursive-functions +# Description: Calls and verifies result of 'backtrace' while performing recursion. +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 + +PACKAGES=(glibc glibc-devel gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp bt-tst.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -O0 -rdynamic bt-tst.c -o bt-tst" + rlAssertExists "bt-tst" + rlPhaseEnd + + rlPhaseStartTest + rlRun "./bt-tst 10 > bt-tst.out" + + OUTPUT_LC="$(cat bt-tst.out | wc -l)" + rlAssertGreaterOrEqual "At least 13 entries in the backtrace" $OUTPUT_LC 13 + + function checkBackTrace { + BT_STACK_ENTRY="$(cat bt-tst.out | tail -n $(($OUTPUT_LC -$1)) | head -n1)" + if [[ $BT_STACK_ENTRY == *"./bt-tst($2"* ]] + then + rlPass "Expect '$2' @ $1 positions below top-of-stack: \"$BT_STACK_ENTRY\"" + else + rlFail "Expect '$2' @ $1 positions below top-of-stack: \"$BT_STACK_ENTRY\"" + fi + } + + # Check each line of the backtrace, right down to `main': + checkBackTrace 0 last + checkBackTrace 1 ")" + for i in {2..11} + do + checkBackTrace $i recursive + done + checkBackTrace 12 main + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/Makefile b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/Makefile new file mode 100644 index 0000000..3792789 --- /dev/null +++ b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory +# Description: Tests pathconf and fpathconf on a FIFO and directory +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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/glibc/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE fpathconf-t.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Tests pathconf and fpathconf on a FIFO and directory" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 916656" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/PURPOSE b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/PURPOSE new file mode 100644 index 0000000..925ade3 --- /dev/null +++ b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory +Description: Tests pathconf and fpathconf on a FIFO and directory +Author: Arjun Shankar diff --git a/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/fpathconf-t.c b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/fpathconf-t.c new file mode 100644 index 0000000..0cad333 --- /dev/null +++ b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/fpathconf-t.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +int main(void) { + + int fd151, fd152, fd161, fd162; + long p151, p152, p161, p162; + + const char f15[15] = "fpathconf-t.15"; + const char f16[15] = "fpathconf-t.16"; + const char dot[2] = "."; + + fd151 = open(f15, O_RDONLY|O_NONBLOCK); + + p151 = fpathconf(fd151, _PC_PIPE_BUF); + p152 = pathconf(f15, _PC_PIPE_BUF); + + if(p151 != p152) { + printf("test15 FAIL - fpathconf for '%s' (%ld) does not equal pathconf for '%s' (%ld) \n", f15, p151, f15, p152); + } else { + printf("test15 PASS - fpathconf for '%s' (%ld) equals pathconf for '%s' (%ld) \n", f15, p151, f15, p152); + } + + fd161 = open(dot, O_RDONLY); + fd162 = open(f16, O_RDONLY|O_NONBLOCK); + + p161 = fpathconf(fd161, _PC_PIPE_BUF); + p162 = fpathconf(fd162, _PC_PIPE_BUF); + + if(p161 != p162) { + printf("test16 FAIL - fpathconf for '%s' (%ld) does not equal fpathconf for '%s' (%ld) \n", dot, p161, f16, p162); + } else { + printf("test16 PASS - fpathconf for '%s' (%ld) equals fpathconf for '%s' (%ld) \n", dot, p161, f16, p162); + } + + close(fd161); + close(fd162); + + return 0; +} diff --git a/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/main.fmf b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/main.fmf new file mode 100644 index 0000000..0c4fa47 --- /dev/null +++ b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/main.fmf @@ -0,0 +1,17 @@ +summary: Tests pathconf and fpathconf on a FIFO and directory +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=916656 +extra-summary: /tools/glibc/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory +extra-task: /tools/glibc/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory diff --git a/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/runtest.sh b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/runtest.sh new file mode 100755 index 0000000..2ade365 --- /dev/null +++ b/tests/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz916656-fpathconf-for-FIFO-returns-different-value-than-for-directory +# Description: Tests pathconf and fpathconf on a FIFO and directory +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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 + +PACKAGE="glibc" +REQUIRES=(gcc glibc glibc-devel) + +rlJournalStart + rlPhaseStartSetup + for p in ${REQUIRES[@]}; do + rlAssertRpm $p + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp fpathconf-t.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -o fpathconf-t fpathconf-t.c" + rlAssertExists "fpathconf-t" + rlPhaseEnd + + rlPhaseStartTest + rlRun "mkfifo fpathconf-t.15" + rlRun "mkfifo fpathconf-t.16" + rlRun "./fpathconf-t &> fpathconf-t.out" + rlAssertEquals "Test should report PASS twice" "$(cat fpathconf-t.out | grep PASS | wc -l)" "2" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz916986-MAP_HUGETLB_support/Makefile b/tests/Regression/bz916986-MAP_HUGETLB_support/Makefile new file mode 100644 index 0000000..5cdf0e9 --- /dev/null +++ b/tests/Regression/bz916986-MAP_HUGETLB_support/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz916986-MAP_HUGETLB_support +# Description: Verifies that MAP_HUGETLB is defined in sys/mman.h. +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Regression/bz916986-MAP_HUGETLB_support +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE bz916986.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Verifies that MAP_HUGETLB is defined in sys/mman.h." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 916986" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz916986-MAP_HUGETLB_support/PURPOSE b/tests/Regression/bz916986-MAP_HUGETLB_support/PURPOSE new file mode 100644 index 0000000..d8a04c1 --- /dev/null +++ b/tests/Regression/bz916986-MAP_HUGETLB_support/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz916986-MAP_HUGETLB_support +Description: Verifies that MAP_HUGETLB is defined in sys/mman.h. +Author: Arjun Shankar diff --git a/tests/Regression/bz916986-MAP_HUGETLB_support/bz916986.c b/tests/Regression/bz916986-MAP_HUGETLB_support/bz916986.c new file mode 100644 index 0000000..4f3656c --- /dev/null +++ b/tests/Regression/bz916986-MAP_HUGETLB_support/bz916986.c @@ -0,0 +1,7 @@ +#include +#ifndef MAP_HUGETLB +#error MAP_HUGETLB should be defined. +#endif +#ifndef MAP_STACK +#error MAP_STACK should be defined. +#endif diff --git a/tests/Regression/bz916986-MAP_HUGETLB_support/main.fmf b/tests/Regression/bz916986-MAP_HUGETLB_support/main.fmf new file mode 100644 index 0000000..26f01c8 --- /dev/null +++ b/tests/Regression/bz916986-MAP_HUGETLB_support/main.fmf @@ -0,0 +1,17 @@ +summary: Verifies that MAP_HUGETLB is defined in sys/mman.h. +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=916986 +extra-summary: /tools/glibc/Regression/bz916986-MAP_HUGETLB_support +extra-task: /tools/glibc/Regression/bz916986-MAP_HUGETLB_support diff --git a/tests/Regression/bz916986-MAP_HUGETLB_support/runtest.sh b/tests/Regression/bz916986-MAP_HUGETLB_support/runtest.sh new file mode 100755 index 0000000..ed52266 --- /dev/null +++ b/tests/Regression/bz916986-MAP_HUGETLB_support/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz916986-MAP_HUGETLB_support +# Description: Verifies that MAP_HUGETLB is defined in sys/mman.h. +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 + +PACKAGE=glibc +REQUIRES=(gcc glibc glibc-devel) + +rlJournalStart + rlPhaseStartSetup + for p in "${REQUIRES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp bz916986.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -c bz916986.c" + rlAssertExists "bz916986.o" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/Makefile b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/Makefile new file mode 100644 index 0000000..0eee073 --- /dev/null +++ b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace +# Description: Calls getdate function with leading and trailing whitespace +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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/glibc/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE tst-getdate.c tst-getdate.tmpl + +.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Calls getdate function with leading and trailing whitespace" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 947350" >> $(METADATA) + @echo "Releases: -RHELServer5 -RHELClient5 -RHEL6" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/PURPOSE b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/PURPOSE new file mode 100644 index 0000000..550d1b0 --- /dev/null +++ b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace +Description: Calls getdate function with leading and trailing whitespace +Author: Arjun Shankar diff --git a/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/main.fmf b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/main.fmf new file mode 100644 index 0000000..4d90b56 --- /dev/null +++ b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/main.fmf @@ -0,0 +1,17 @@ +summary: Calls getdate function with leading and trailing whitespace +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=947350 +extra-summary: /tools/glibc/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace +extra-task: /tools/glibc/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace diff --git a/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/runtest.sh b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/runtest.sh new file mode 100755 index 0000000..dacdb69 --- /dev/null +++ b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/runtest.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace +# Description: Calls getdate function with leading and trailing whitespace +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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 + +PACKAGE="glibc" +REQUIRES=(gcc glibc glibc-devel) + +rlJournalStart + rlPhaseStartSetup + for p in ${REQUIRES[@]}; do + rlAssertRpm $p + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp tst-getdate* $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -o tst-getdate tst-getdate.c" + rlAssertExists "tst-getdate" + rlPhaseEnd + + rlPhaseStartTest + rlRun "DATEMSK=tst-getdate.tmpl ./tst-getdate 31-12-13" + rlRun "DATEMSK=tst-getdate.tmpl ./tst-getdate ' 31 - 12 - 13 '" + rlRun "DATEMSK=tst-getdate.tmpl ./tst-getdate 31/12/13" + rlRun "DATEMSK=tst-getdate.tmpl ./tst-getdate ' 31/ 12/ 13 '" + rlRun "DATEMSK=tst-getdate.tmpl ./tst-getdate '12 AM'" + rlRun "DATEMSK=tst-getdate.tmpl ./tst-getdate ' 12 AM '" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/tst-getdate.c b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/tst-getdate.c new file mode 100644 index 0000000..145ccb2 --- /dev/null +++ b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/tst-getdate.c @@ -0,0 +1,35 @@ +#define _GNU_SOURCE 500 +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + struct tm *tmp; + int j; + + for (j = 1; j < argc; j++) + { + tmp = getdate (argv[j]); + + if (tmp == NULL) + { + fprintf (stderr, "Call %d failed; getdate_err = %d\n", j, getdate_err); + exit (EXIT_FAILURE); + } + + printf ("Call %d (\"%s\") succeeded:\n", j, argv[j]); + printf (" tm_sec = %d\n", tmp->tm_sec); + printf (" tm_min = %d\n", tmp->tm_min); + printf (" tm_hour = %d\n", tmp->tm_hour); + printf (" tm_mday = %d\n", tmp->tm_mday); + printf (" tm_mon = %d\n", tmp->tm_mon); + printf (" tm_year = %d\n", tmp->tm_year); + printf (" tm_wday = %d\n", tmp->tm_wday); + printf (" tm_yday = %d\n", tmp->tm_yday); + printf (" tm_isdst = %d\n", tmp->tm_isdst); + } + + exit (EXIT_SUCCESS); +} diff --git a/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/tst-getdate.tmpl b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/tst-getdate.tmpl new file mode 100644 index 0000000..9f46a2d --- /dev/null +++ b/tests/Regression/bz947350-getdate-does-not-ignore-trailing-whitespace/tst-getdate.tmpl @@ -0,0 +1,3 @@ + %d - %m - %y + %d / %m / %y +%I %p diff --git a/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/Makefile b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/Makefile new file mode 100644 index 0000000..5618609 --- /dev/null +++ b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/Makefile @@ -0,0 +1,66 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up +# Description: Tests fputs EINTR when writing to a blocking, full stream +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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/glibc/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE bz970854.c ubz15362.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: Arjun Shankar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Tests fputs EINTR when writing to a blocking, full stream" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 979363" >> $(METADATA) + @echo "Releases: -RHELServer5 -RHELClient5 -RHEL6" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/PURPOSE b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/PURPOSE new file mode 100644 index 0000000..d6a78d6 --- /dev/null +++ b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up +Description: Tests fputs EINTR when writing to a blocking, full stream +Author: Arjun Shankar diff --git a/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/bz970854.c b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/bz970854.c new file mode 100644 index 0000000..e28c781 --- /dev/null +++ b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/bz970854.c @@ -0,0 +1,301 @@ +/* This is a reproducer for BZ#970854. + * https://bugzilla.redhat.com/show_bug.cgi?id=970854 + */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* Signal number of caught signal. */ +int caught_sig; +/* Pipe used to simulate the EINTR return. */ +int pfd[2]; +/* General purpose buffer. */ +#define BLK_SIZE 512 +char buf[BLK_SIZE]; +/* Alarm counter. */ +int alrm_flag = 0; + +#define SPEEDFACTOR (3) +#define WAITTIME (5*SPEEDFACTOR) +#define NSIG 32 + +/* Enable or disable debug printf. */ +#define DPRINTF(...) printf(__VA_ARGS__) +// #define DPRINTF(...) do {} while (0) + +/* Signal function to check timeouts. */ +void +alrm (int signal) +{ + ++alrm_flag; +} + +#define NULLSA ((struct sigaction *)0) + +/* Timeout function. */ +#define SET_TIMEOUT(waittime) \ + { \ + unsigned to_unslept, to_alrm, to_time; \ + int to_err, to_flag, to_ret; \ + struct sigaction to_alrm_sa, to_old_sa; \ + to_time = (waittime); \ + to_flag = 0; \ + alrm_flag = 0; \ + to_alrm_sa.sa_handler = alrm; \ + to_alrm_sa.sa_flags = 0; \ + (void) sigemptyset(&to_alrm_sa.sa_mask); \ + to_alrm = alarm(0); \ + to_ret = sigaction(SIGALRM, &to_alrm_sa, &to_old_sa); \ + if (to_ret != 0) \ + DPRINTF("SET_TIMEOUT: sigaction(SIGALRM, ...) failed"); \ + if (to_alrm != 0) { \ + if (to_time < to_alrm) { \ + ++to_flag; \ + to_alrm -= to_time; \ + } else { \ + --to_flag; \ + to_time = to_alrm; \ + to_alrm = 0; \ + (void) sigaction(SIGALRM, &to_old_sa, NULLSA); \ + } \ + } \ + (void) alarm(to_time); + + +#define CLEAR_ALARM \ + to_err = errno; \ + to_unslept = alarm(0); \ + if (to_flag >= 0) \ + (void) sigaction(SIGALRM, &to_old_sa, NULLSA); \ + if (to_flag > 0 || (to_flag < 0 && to_unslept != 0)) \ + (void) alarm(to_alrm + to_unslept); \ + errno = to_err; \ + } + + +void +sig_catch (int signal) +{ + caught_sig = signal; +} + +int +main (void) +{ + int ret; + pid_t child; + struct sigaction act; + int fd, flags; + int written, count; + FILE *fp; + + act.sa_handler = sig_catch; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + + /* Create a pipe for using with a child process that will write to + the pipe via fputs. */ + ret = pipe (pfd); + if (ret != 0) + { + perror ("pipe"); + exit (1); + } + + /* Work with the write side of the pipe. */ + fd = pfd[1]; + + /* Set the pipe into non-blocking mode. + We do this to fill up the pipe without blocking. */ + flags = fcntl (fd, F_GETFL); + if (flags == -1) + { + perror ("fcntl (F_GETFL)"); + exit (1); + } + flags |= O_NONBLOCK; + ret = fcntl (fd, F_SETFL, flags); + if (ret == -1) + { + perror ("fcntl (F_SETFL)"); + exit (1); + } + /* Fill the write side of the pipe. */ + /* Fill BLK_SIZE at a time... */ + do + { + written = write (fd, buf, BLK_SIZE); + if (written == -1) + { + DPRINTF ("write (BLK_SIZE), written = %d, errno = %d\n", written, errno); + } + else + count += written; + } + while (written > 0); + /* Fill the remainder char at a time... */ + do + { + written = write (fd, "z", 1); + if (written == -1) + { + DPRINTF ("write (z), errno = %d\n", errno); + } + else + count += written; + } + while (written > 0); + DPRINTF ("Wrote %d bytes to write side of pipe.\n", count); + /* Set pipe to blocking now. */ + flags = fcntl (fd, F_GETFL); + if (flags == -1) + { + perror ("fcntl (F_GETFL)"); + exit (1); + } + flags &= ~O_NONBLOCK; + ret = fcntl (fd, F_SETFL, flags); + if (ret == -1) + { + perror ("fcntl (F_SETFL)"); + exit (1); + } + /* Get a stream for child fputs. */ + fp = fdopen (fd, "w"); + if (fp == NULL) + { + perror ("fopen"); + exit (1); + } + /* Unbuffer the stream... */ + /* Original uses setbuf (fp, (char *) NULL); */ + ret = setvbuf (fp, (char *) NULL, _IONBF, 0); + if (ret != 0) + { + perror ("setvbuf"); + exit (1); + } + /* Start the alarm counting... */ + SET_TIMEOUT (2 * WAITTIME) + child = fork (); + + + if (child == 0) + { + pid_t selfid __attribute__ ((__unused__)); + int i; + /* In the child. */ + DPRINTF ("child: In the child\n"); + selfid = getpid (); + DPRINTF ("child: Child pid is %d\n", (int) selfid); + + /* Set all signals to SIG_DFL, except for SIGKILL, SIGSTOP, and SIGCHLD. */ + for (i = 1; i < NSIG; i++) + { + int ret; + struct sigaction sig; + if (i == SIGKILL || i == SIGSTOP || i == SIGCHLD) + continue; + ret = sigaction (i, NULLSA, &sig); + if (ret != 0) + { + perror ("sigaction - get signal setting"); + _exit (1); + } + if (sig.sa_handler != SIG_IGN) + { + sig.sa_handler = SIG_DFL; + sig.sa_flags = 0; + ret = sigemptyset (&sig.sa_mask); + if (ret != 0) + { + perror ("sigemptyset - set empty set"); + _exit (1); + } + ret = sigaction (i, &sig, NULLSA); + if (ret != 0) + { + perror ("sigaction - set SIG_DFL"); + _exit (1); + } + } + + } + /* Call alrm when SIGALRM is delivered. */ + struct sigaction new, old; + int saved_errno; + new.sa_handler = alrm; + new.sa_flags = 0; + sigemptyset (&new.sa_mask); + ret = sigaction (SIGALRM, &new, &old); + if (ret != 0) + { + perror ("sigaction - set SIGALRM action"); + _exit (1); + } + /* Deliver an alarm in WAITTIME seconds... */ + alarm (WAITTIME); + /* Try to write to a blocking stream that is full... */ + ret = fputs("test string", fp); + saved_errno = errno; + /* Alarm should trigger. */ + if (ret < 0) + { + DPRINTF ("fputs errno is %d\n", saved_errno); + } + if (saved_errno == EINTR) + printf ("PASS: fputs blocked on a pipe returned EINTR when interrupted by signal.\n"); + else + { + printf ("FAIL: fputs blocked on a pipe returned errno %d instead of EINTR.\n", saved_errno); + _exit (1); + } + + if (alrm_flag > 0) + { + DPRINTF ("child: alrm_flag was %d\n", alrm_flag); + } + _exit (0); + } + else + { + /* In the parent. */ + pid_t wid; + int status, wstatus __attribute__ ((__unused__)); + DPRINTF ("parent: In the parent\n"); + DPRINTF ("parent: Child pid is %d\n", (int) child); + wid = waitpid (child, &status, 0); + if (wid == -1) + { + perror ("waitpid"); + if (alrm_flag > 0) + { + printf ("FAIL: child process timed out.\n"); + } + exit (1); + } + DPRINTF ("child status was %d\n", status); + if (!WIFEXITED(status)) + { + printf ("FAIL: child did not exit normally.\n"); + } + else + { + wstatus = WEXITSTATUS(status); + DPRINTF ("child exit status was: %d\n", wstatus); + } + } + /* ... clear the alarm. We are done the test. */ + CLEAR_ALARM + if (alrm_flag > 0) + printf ("FAIL: test function timed out\n"); + close (pfd[0]); + close (pfd[1]); + fclose (fp); + return 0; +} diff --git a/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/main.fmf b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/main.fmf new file mode 100644 index 0000000..32211fc --- /dev/null +++ b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/main.fmf @@ -0,0 +1,17 @@ +summary: Tests fputs EINTR when writing to a blocking, full stream +description: '' +contact: Arjun Shankar +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - gcc + - glibc + - glibc-devel + - glibc-headers +duration: 15m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=979363 +extra-summary: /tools/glibc/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up +extra-task: /tools/glibc/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up diff --git a/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/runtest.sh b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/runtest.sh new file mode 100755 index 0000000..94468d6 --- /dev/null +++ b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/runtest.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up +# Description: Tests fputs EINTR when writing to a blocking, full stream +# Author: Arjun Shankar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. +# +# 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 + +PACKAGE="glibc" +REQUIRES=(gcc glibc glibc-devel) + +rlJournalStart + rlPhaseStartSetup + for p in ${REQUIRES[@]}; do + rlAssertRpm $p + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp bz970854.c ubz15362.c $TmpDir" + rlRun "pushd $TmpDir" + + # Create an 80 MB regular file consisting of an ext4 FS + rlRun "dd if=/dev/zero of=filesystem bs=1M count=80" + rlAssertExists "filesystem" + rlRun "mkfs.ext4 -F filesystem" + + # Mount it + rlRun "mkdir mountpoint" + rlRun "mount -t ext4 filesystem mountpoint" + rlRun "df -l $TmpDir/mountpoint | grep $TmpDir/mountpoint" + + # Compile test sources + rlRun "gcc -D_POSIX_SOURCE -std=c99 -Wall -pedantic -O0 -g3 -o bz970854 bz970854.c" + rlAssertExists "bz970854" + + rlRun "gcc -Wall -O0 -o ubz15362 ubz15362.c" + rlAssertExists "ubz15362" + rlPhaseEnd + + rlPhaseStartTest + # First Test + rlRun "./bz970854 > bz970854.out" + rlAssertExists "bz970854.out" + rlAssertGrep "child status was 0" "bz970854.out" + rlAssertGrep "child exit status was: 0" "bz970854.out" + rlAssertNotGrep "FAIL" "bz970854.out" + + # Second Test (write to 80 MB FS til it is full, expect no FAILs + rlRun "./ubz15362 mountpoint/foo" + rlRun "./ubz15362 mountpoint/bar" + rlRun "./ubz15362 mountpoint/baz" + rlRun "./ubz15362 mountpoint/zoo" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "umount mountpoint" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/ubz15362.c b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/ubz15362.c new file mode 100644 index 0000000..e9c24bf --- /dev/null +++ b/tests/Regression/bz979363-fputs-should-see-EINTR-and-propagate-it-up/ubz15362.c @@ -0,0 +1,64 @@ +/* A reproducer from https://sourceware.org/bugzilla/show_bug.cgi?id=15362. */ + +#include +#include +#include +#include +#include +#include +#include + +#define CATCH_SIGSEGV 0 +#define FILESIZE (32 * 1024 * 1024) + +static void *buf; + +static void +sigsegv_handler (int signo, siginfo_t * info, void *context) +{ + printf ("Caught SIGSEGV at address %p (buf + %lu)\n", + info->si_addr, (void *) info->si_addr - buf); + abort (); +} + +#define handle_error(msg) error(1, errno, msg) + +int +main (int argc, char *argv[]) +{ + FILE *fp; + size_t bytes_written; + int ret; + struct sigaction sa; + char * filepath; + + if (argc != 2) + handle_error ("Invalid number of arguments\n"); + + filepath = argv[1]; + + buf = mmap (NULL, FILESIZE + 4096, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (buf == MAP_FAILED) + handle_error ("mmap_failed"); + + ret = mprotect (buf + FILESIZE, 4096, PROT_NONE); + if (ret == -1) + handle_error ("mprotect failed"); + + memset (buf, 0, FILESIZE); + + fp = fopen (filepath, "wb"); + if (!fp) + handle_error ("fopen(...) failed"); + + memset (&sa, 0, sizeof (sa)); + sa.sa_sigaction = sigsegv_handler; + sa.sa_flags = SA_SIGINFO; +#if CATCH_SIGSEGV + sigaction (SIGSEGV, &sa, NULL); +#endif + bytes_written = fwrite (buf, 1, FILESIZE, fp); + printf ("fwrite(): bytes_written = %zu (errno: %m)\n", bytes_written); + return 0; +} diff --git a/tests/Regression/double_free_exploit/Makefile b/tests/Regression/double_free_exploit/Makefile new file mode 100644 index 0000000..eb8a3fc --- /dev/null +++ b/tests/Regression/double_free_exploit/Makefile @@ -0,0 +1,62 @@ +# Copyright (c) 2006 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 v.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. +# +# Author: Updated to 2.5 by John Poelstra + +# The toplevel namespace within which the test lives. +TOPLEVEL_NAMESPACE=/tools + +# The name of the package under test: +PACKAGE_NAME=glibc + +# The path of the test below the package: +RELATIVE_PATH=double-free-exploit + +# Version of the Test. Used with make tag. +export TESTVERSION=1.1 + +# The compiled namespace of the test. +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) + +.PHONY: all install download clean + +BUILT_FILES= exploit exploit2 +FILES=$(METADATA) runtest.sh Makefile exploit.c exploit2.c + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + +# Include Common Makefile +include /usr/share/rhts/lib/rhts-make.include + +# Generate the testinfo.desc here: +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Verify that double free exploit attempts get detected/prevented">> $(METADATA) + @echo "TestTime: 3m" >> $(METADATA) + @echo "Bug: 159714" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-devel gcc" >> $(METADATA) + @echo "Type: Tier2" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + rhts-lint $(METADATA) diff --git a/tests/Regression/double_free_exploit/PURPOSE b/tests/Regression/double_free_exploit/PURPOSE new file mode 100644 index 0000000..18c44f6 --- /dev/null +++ b/tests/Regression/double_free_exploit/PURPOSE @@ -0,0 +1 @@ +This tests if attempts to double-free a pointer are prevented by glibc routines. diff --git a/tests/Regression/double_free_exploit/exploit.c b/tests/Regression/double_free_exploit/exploit.c new file mode 100644 index 0000000..dfc0420 --- /dev/null +++ b/tests/Regression/double_free_exploit/exploit.c @@ -0,0 +1,58 @@ +#include +#include +#include + +int main(void) { + unsigned int *chunk; + int i; + unsigned int shellcode[10]; + unsigned int ret_addr_2_change = 9; + + /* Get some space */ + chunk = malloc(0x8); + + /* now setup the chunk to fool chunk_free() + By making prev_size negative it will look + _after_ this chunk in stead of in front of it + */ + chunk[0] = -0x10; /* prev_size */ + chunk[1] = 0x8; /* size */ + chunk[2] = shellcode; /* fd */ + chunk[3] = shellcode; /* bk */ + + /* set fd to the adres of the return address - 3 + the minus 3 is needed because fd[3] will become bk + bk will be set to point to our shellcode. Remember that + bk[2] will be changed to contain fd so that there should be + a jmp or so in the shellcode to skip that value. + */ + chunk[4+2] = (int) (&ret_addr_2_change - 3); + chunk[4+3] = (int) (shellcode); + + /* set shellcode to 0 so that we can see the change */ + memset(shellcode, 0, sizeof(shellcode)); + + i = ret_addr_2_change; + +// printf("ret before call: %x\n", ret_addr_2_change); +// printf("address of ret: %x\n", &ret_addr_2_change); +// printf("address of shellcode: %x\n", shellcode); + /* remember we give mem to free which finds the chunk based on + that */ + free(chunk+2); + +// printf("ret now: %x\n", ret_addr_2_change); + + if (ret_addr_2_change != i) { + printf("FAIL\n"); /* Exploit succeeded */ + exit(1); + } + + for (i = 0 ; i < 10; i++) { + if (shellcode[i] != 0) { + printf("FAIL\n"); /* Exploit succeeded */ + exit(1); + } + } + return 0; +} diff --git a/tests/Regression/double_free_exploit/exploit2.c b/tests/Regression/double_free_exploit/exploit2.c new file mode 100644 index 0000000..b9eb76f --- /dev/null +++ b/tests/Regression/double_free_exploit/exploit2.c @@ -0,0 +1,11 @@ +main() +{ + int *a,*b,*c,*d,*e; + b=malloc(8); + c=malloc(10); /* Essential so we don't coalesce */ + free(b); + free(b); /* this should die */ + d=malloc(8); /* we'll get the old b block */ + e=malloc(8); /* the double free flaw means we get the old b block again! */ + if (d==e) { printf("FAIL: Exploitable double free behaviour\n"); } +} diff --git a/tests/Regression/double_free_exploit/main.fmf b/tests/Regression/double_free_exploit/main.fmf new file mode 100644 index 0000000..af92d0d --- /dev/null +++ b/tests/Regression/double_free_exploit/main.fmf @@ -0,0 +1,17 @@ +summary: Verify that double free exploit attempts get detected/prevented +description: | + This tests if attempts to double-free a pointer are prevented by glibc routines. +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-devel + - gcc +duration: 3m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=159714 +extra-summary: /tools/glibc/double-free-exploit +extra-task: /tools/glibc/double-free-exploit diff --git a/tests/Regression/double_free_exploit/runtest.sh b/tests/Regression/double_free_exploit/runtest.sh new file mode 100755 index 0000000..35580e4 --- /dev/null +++ b/tests/Regression/double_free_exploit/runtest.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# +# Copyright (c) 2018 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="glibc" +TESTPROG1="exploit" +TESTPROG2="exploit2" +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun -l "gcc --version" + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun -c "cp ${TESTPROG1}.c ${TESTPROG2}.c ${TESTTMPDIR}/" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + for T in $TESTPROG1 $TESTPROG2 + do + + rlPhaseStartTest $T + rlRun -c "gcc ${T}.c -o ${T}" + RS=`./${T}` + rlLog "Return code: $?" + if [ "$RS" == 'FAIL' ] + then + Log "$T exploit wasn't prevented: FAIL" + rlFail $T FAIL + else + rlLog "$T exploit was prevented: PASS" + rlPass $T PASS + fi + rlPhaseEnd + done + + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/expf-gives-infinity-where-result-finite/Makefile b/tests/Regression/expf-gives-infinity-where-result-finite/Makefile new file mode 100644 index 0000000..94a9bb5 --- /dev/null +++ b/tests/Regression/expf-gives-infinity-where-result-finite/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/expf-gives-infinity-where-result-finite +# Description: Test for one case, where expf gives an incorrect result +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/expf-gives-infinity-where-result-finite +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE tc1.cpp + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for one case, where expf gives an incorrect result" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "Requires: gcc-c++" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/expf-gives-infinity-where-result-finite/PURPOSE b/tests/Regression/expf-gives-infinity-where-result-finite/PURPOSE new file mode 100644 index 0000000..3b0f14b --- /dev/null +++ b/tests/Regression/expf-gives-infinity-where-result-finite/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/expf-gives-infinity-where-result-finite +Description: Test for one case, where expf gives an incorrect result +Author: Petr Muller diff --git a/tests/Regression/expf-gives-infinity-where-result-finite/main.fmf b/tests/Regression/expf-gives-infinity-where-result-finite/main.fmf new file mode 100644 index 0000000..30c04ab --- /dev/null +++ b/tests/Regression/expf-gives-infinity-where-result-finite/main.fmf @@ -0,0 +1,14 @@ +summary: Test for one case, where expf gives an incorrect result +description: '' +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - gcc + - gcc-c++ +duration: 15m +extra-summary: /tools/glibc/Regression/expf-gives-infinity-where-result-finite +extra-task: /tools/glibc/Regression/expf-gives-infinity-where-result-finite diff --git a/tests/Regression/expf-gives-infinity-where-result-finite/runtest.sh b/tests/Regression/expf-gives-infinity-where-result-finite/runtest.sh new file mode 100755 index 0000000..ac01945 --- /dev/null +++ b/tests/Regression/expf-gives-infinity-where-result-finite/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/expf-gives-infinity-where-result-finite +# Description: Test for one case, where expf gives an incorrect result +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart +rlPhaseStartSetup Setup + rlAssertRpm $PACKAGE + rlRun "g++ tc1.cpp -o testcase" +rlPhaseEnd + +rlPhaseStartTest Testing + rlRun "./testcase > output 2>&1" + while read line; do + rlLog "$line" + done < output + + unset IPS +rlPhaseEnd + +rlPhaseStartCleanup Cleanup + rlRun "rm -f output testcase" +rlPhaseEnd +rlJournalEnd diff --git a/tests/Regression/expf-gives-infinity-where-result-finite/tc1.cpp b/tests/Regression/expf-gives-infinity-where-result-finite/tc1.cpp new file mode 100644 index 0000000..cbd1baf --- /dev/null +++ b/tests/Regression/expf-gives-infinity-where-result-finite/tc1.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +int main() +{ + float x = 88.722f; + float d_exp_x = float(std::exp(double(x))); + float f_exp_x = std::exp(x); + std::cout << std::setprecision(60); + std::cout << " x is " << x << std::endl; + std::cout << " expf(x) is " << f_exp_x << std::endl; + std::cout << " exp(x) is " << d_exp_x << std::endl; + return (( f_exp_x == d_exp_x ) ? 0 : 1); +} diff --git a/tests/Regression/fallocate_156289/Makefile b/tests/Regression/fallocate_156289/Makefile new file mode 100644 index 0000000..8afe24a --- /dev/null +++ b/tests/Regression/fallocate_156289/Makefile @@ -0,0 +1,70 @@ +# Copyright (c) 2006 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 v.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. +# +# Author: David Malcolm + +# The toplevel namespace within which the test lives. +TOPLEVEL_NAMESPACE=/tools + +# The name of the package under test: +PACKAGE_NAME=glibc + +# The path of the test below the package: +RELATIVE_PATH=fallocate_156289 + +# Version of the Test. Used with make tag. +export TESTVERSION=1.0 + +# The compiled namespace of the test. +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) + +.PHONY: all install download clean + +BUILT_FILES=fallocate +FILES=$(METADATA) runtest.sh Makefile fallocate.c++ + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + +# You may need to add other taregts e.g. to build executables from source code +# Add them here: +fallocate: + g++ fallocate.c++ -o fallocate + +# Include Common Makefile +include /usr/share/rhts/lib/rhts-make.include + +# Generate the testinfo.desc here: +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: David Malcolm " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "License: Unknown" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Ensure fallocate() extends files by the correct amount">> $(METADATA) + @echo "TestTime: 3m" >> $(METADATA) + @echo "Bug: 156289" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: gcc-c++" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "Type: Standardscompliance" >> $(METADATA) + @echo "Type: Tier2" >> $(METADATA) + rhts-lint $(METADATA) diff --git a/tests/Regression/fallocate_156289/PURPOSE b/tests/Regression/fallocate_156289/PURPOSE new file mode 100644 index 0000000..2eff71e --- /dev/null +++ b/tests/Regression/fallocate_156289/PURPOSE @@ -0,0 +1 @@ +Ensure fallocate() extends files by the correct amount. fallocate() is wrapped in fallocate.c++ source code. diff --git a/tests/Regression/fallocate_156289/fallocate.c++ b/tests/Regression/fallocate_156289/fallocate.c++ new file mode 100644 index 0000000..ddfabbd --- /dev/null +++ b/tests/Regression/fallocate_156289/fallocate.c++ @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +int main(int argc, char **argv) +{ + ::signal(SIGXFSZ, SIG_IGN); + + if (argc!=3) + { + puts("usage: posixFallocateTester "); + return 1; + } + + const size_t N = ::atoi(argv[2]); + + + int fd = open(argv[1], O_RDWR| O_CREAT |O_TRUNC, 0666 ); + + if (fd < 0) + { + perror("open failed"); + exit(1); + } + + + if (::posix_fallocate(fd, 0, N) != 0) + { + perror("posix_fallocate failed"); + exit(1); + } + +} \ No newline at end of file diff --git a/tests/Regression/fallocate_156289/main.fmf b/tests/Regression/fallocate_156289/main.fmf new file mode 100644 index 0000000..1812348 --- /dev/null +++ b/tests/Regression/fallocate_156289/main.fmf @@ -0,0 +1,16 @@ +summary: Ensure fallocate() extends files by the correct amount +description: | + Ensure fallocate() extends files by the correct amount. fallocate() is wrapped in fallocate.c++ source code. +contact: David Malcolm +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc-c++ +duration: 3m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=156289 +extra-summary: /tools/glibc/fallocate_156289 +extra-task: /tools/glibc/fallocate_156289 diff --git a/tests/Regression/fallocate_156289/runtest.sh b/tests/Regression/fallocate_156289/runtest.sh new file mode 100755 index 0000000..359068e --- /dev/null +++ b/tests/Regression/fallocate_156289/runtest.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# +# Copyright (c) 2018 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 + +TESTPROG="fallocate" + +PACKAGE="glibc" +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun -l "gcc --version" + rlRun "TESTTMPDIR=$(mktemp -d)" + rlRun -c "cp ${TESTPROG}.c++ ${TESTTMPDIR}/" + rlRun "pushd $TESTTMPDIR" + rlPhaseEnd + + rlPhaseStartTest + TESTFILE=`pwd`/foo + rlRun "touch $TESTFILE" + rlRun -c "g++ ${TESTPROG}.c++ -o ${TESTPROG}" + rlRun -c "./${TESTPROG} $TESTFILE 10000" + size=`stat -c %s $TESTFILE` + rlLog "Checking size of $TESTFILE (should be 1000): %size" + + if [ "$size" -ne "10000" ] + then + rlFail "Size differs: FAIL" + else + rlPass "Size is 1000: PASS" + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TESTTMPDIR" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + diff --git a/tests/Regression/setvbuf-to-full-not-working/Makefile b/tests/Regression/setvbuf-to-full-not-working/Makefile new file mode 100644 index 0000000..06f1df1 --- /dev/null +++ b/tests/Regression/setvbuf-to-full-not-working/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Regression/setvbuf-to-full-not-working +# Description: When a file was first open as NON BUFFERED, and then we change it into FULL BUFFERED, this will take no effect (PR6719) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Regression/setvbuf-to-full-not-working +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE try.exp testcase.c + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: When a file was first open as NON BUFFERED, and then we change it into FULL BUFFERED, this will take no effect (PR6719)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc expect tcl" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/setvbuf-to-full-not-working/PURPOSE b/tests/Regression/setvbuf-to-full-not-working/PURPOSE new file mode 100644 index 0000000..3a0a38c --- /dev/null +++ b/tests/Regression/setvbuf-to-full-not-working/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Regression/setvbuf-to-full-not-working +Description: When a file was first open as NON BUFFERED, and then we change it into FULL BUFFERED, this will take no effect (PR6719) +Author: Petr Muller diff --git a/tests/Regression/setvbuf-to-full-not-working/main.fmf b/tests/Regression/setvbuf-to-full-not-working/main.fmf new file mode 100644 index 0000000..f082804 --- /dev/null +++ b/tests/Regression/setvbuf-to-full-not-working/main.fmf @@ -0,0 +1,16 @@ +summary: When a file was first open as NON BUFFERED, and then we change it into FULL + BUFFERED, this will take no effect (PR6719) +description: '' +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: shell +recommend: + - glibc + - expect + - tcl + - gcc +duration: 30m +extra-summary: /tools/glibc/Regression/setvbuf-to-full-not-working +extra-task: /tools/glibc/Regression/setvbuf-to-full-not-working diff --git a/tests/Regression/setvbuf-to-full-not-working/runtest.sh b/tests/Regression/setvbuf-to-full-not-working/runtest.sh new file mode 100755 index 0000000..4d31e61 --- /dev/null +++ b/tests/Regression/setvbuf-to-full-not-working/runtest.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Regression/setvbuf-to-full-not-working +# Description: When a file was first open as NON BUFFERED, and then we change it into FULL BUFFERED, this will take no effect (PR6719) +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +rpm -Uvh http://nest.test.redhat.com/mnt/qa/scratch/pmuller/rhtslib/rhtslib.rpm +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart +rlPhaseStartSetup Setup + rlAssertRpm $PACKAGE + rlRun "gcc testcase.c -o testcase" +rlPhaseEnd + +rlPhaseStartTest Testing + rlRun "./try.exp" 0 "Running the tescase" +rlPhaseEnd + +rlPhaseStartCleanup Cleanup + rlRun "rm -f testcase" +rlPhaseEnd + +rlJournalEnd diff --git a/tests/Regression/setvbuf-to-full-not-working/testcase.c b/tests/Regression/setvbuf-to-full-not-working/testcase.c new file mode 100644 index 0000000..4bc7d9f --- /dev/null +++ b/tests/Regression/setvbuf-to-full-not-working/testcase.c @@ -0,0 +1,16 @@ +#include +#include + +int main(void) +{ + setvbuf(stderr, NULL, _IOFBF, BUFSIZ); + setvbuf(stdout, NULL, _IONBF, 0); + + fprintf(stderr, "stderr"); + fprintf(stdout, "stdout"); + sleep(1); + printf("\n"); + + + return 0; +} diff --git a/tests/Regression/setvbuf-to-full-not-working/try.exp b/tests/Regression/setvbuf-to-full-not-working/try.exp new file mode 100755 index 0000000..ed5c619 --- /dev/null +++ b/tests/Regression/setvbuf-to-full-not-working/try.exp @@ -0,0 +1,7 @@ +#!/usr/bin/expect + +set timeout -1 +spawn ./testcase +expect "stdout" { expect "stderr" { exit 0 } } +exit 1 + diff --git a/tests/Sanity/basic-linking-sanity/Makefile b/tests/Sanity/basic-linking-sanity/Makefile new file mode 100644 index 0000000..a116188 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Sanity/basic-linking-sanity +# Description: Test contains few testcases linking to various glibc libraries. Testing if testcases can be successfuly linked and run +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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/glibc/Sanity/basic-linking-sanity +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE *.c *.golden + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test contains few testcases linking to various glibc libraries. Testing if testcases can be successfuly linked and run" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/basic-linking-sanity/PURPOSE b/tests/Sanity/basic-linking-sanity/PURPOSE new file mode 100644 index 0000000..9f0038b --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/glibc/Sanity/basic-linking-sanity +Description: Test contains few testcases linking to various glibc libraries. Testing if testcases can be successfuly linked and run +Author: Petr Muller diff --git a/tests/Sanity/basic-linking-sanity/lc.c b/tests/Sanity/basic-linking-sanity/lc.c new file mode 100644 index 0000000..2b4f286 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lc.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int main(){ + char one[] = "Whatever!"; + char *two; + FILE *fp = fopen("lc.out", "w"); + + fprintf(fp, "Printf: %d\n", 10); + fprintf(fp, "Whatever: %s, length %d\n", one, strlen(one)); + + two = malloc(sizeof(char) * 20); + memcpy(two, one, 3); + two[3] = '\0'; + fprintf(fp, "Two: %s, length %d\n", two, strlen(two)); + + close(fp); + free(two); + return 0; +} diff --git a/tests/Sanity/basic-linking-sanity/lc.golden b/tests/Sanity/basic-linking-sanity/lc.golden new file mode 100644 index 0000000..a3116eb --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lc.golden @@ -0,0 +1,3 @@ +Printf: 10 +Whatever: Whatever!, length 9 +Two: Wha, length 3 diff --git a/tests/Sanity/basic-linking-sanity/lm.c b/tests/Sanity/basic-linking-sanity/lm.c new file mode 100644 index 0000000..72612b9 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lm.c @@ -0,0 +1,13 @@ +#include +#include + +int main(){ + FILE *fp = fopen("lm.out", "w"); + double a = pow(10, 2); + fprintf(fp, "POW: %0.2f\n", a); + fprintf(fp, "SIN: %0.2f\n", 1.0); + + + close(fp); + return 0; +} diff --git a/tests/Sanity/basic-linking-sanity/lm.golden b/tests/Sanity/basic-linking-sanity/lm.golden new file mode 100644 index 0000000..ddfa1ca --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lm.golden @@ -0,0 +1,2 @@ +POW: 100.00 +SIN: 1.00 diff --git a/tests/Sanity/basic-linking-sanity/lpthread.c b/tests/Sanity/basic-linking-sanity/lpthread.c new file mode 100644 index 0000000..65aca15 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lpthread.c @@ -0,0 +1,46 @@ +#include +#include + +FILE *fp; +pthread_mutex_t mutech = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +int counter = 0; + +void *one(void *arg){ + pthread_mutex_lock(&mutech); + while (counter == 0) + pthread_cond_wait(&cond, &mutech); + + counter = 2; + fprintf(fp, "Thread 1 run\n"); + + pthread_mutex_unlock(&mutech); + pthread_cond_signal(&cond); +} + +void *two(void *arg){ + pthread_mutex_lock(&mutech); + while(counter == 1) + pthread_cond_wait(&cond, &mutech); + + counter = 1; + fprintf(fp, "Thread 2 run\n"); + + pthread_mutex_unlock(&mutech); + pthread_cond_signal(&cond); +} + + +int main(){ + fp = fopen("lpthread.out", "w"); + pthread_t on; + pthread_t tw; + pthread_create(&on, NULL, one, NULL); + pthread_create(&tw, NULL, two, NULL); + + pthread_join(tw, NULL); + pthread_join(on, NULL); + + close(fp); + return 0; +} diff --git a/tests/Sanity/basic-linking-sanity/lpthread.golden b/tests/Sanity/basic-linking-sanity/lpthread.golden new file mode 100644 index 0000000..e150192 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lpthread.golden @@ -0,0 +1,2 @@ +Thread 2 run +Thread 1 run diff --git a/tests/Sanity/basic-linking-sanity/lrt.c b/tests/Sanity/basic-linking-sanity/lrt.c new file mode 100644 index 0000000..2a31e0d --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lrt.c @@ -0,0 +1,21 @@ +#include +#include + +int main(){ + FILE *fp = fopen("lrt.out", "w"); + + int opn = shm_open("/stuffz0r", O_RDWR|O_CREAT, 0777); + if ( opn == -1 ) + fprintf(fp, "shm_open failed\n"); + else + fprintf(fp, "shm_open successful\n"); + + int unl = shm_unlink("/stuffz0r"); + if ( unl == -1 ) + fprintf(fp, "shm_unlink failed\n"); + else + fprintf(fp, "shm_unlink successful\n"); + + close(fp); + return 0; +} diff --git a/tests/Sanity/basic-linking-sanity/lrt.golden b/tests/Sanity/basic-linking-sanity/lrt.golden new file mode 100644 index 0000000..f5ff068 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/lrt.golden @@ -0,0 +1,2 @@ +shm_open successful +shm_unlink successful diff --git a/tests/Sanity/basic-linking-sanity/main.fmf b/tests/Sanity/basic-linking-sanity/main.fmf new file mode 100644 index 0000000..743943a --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/main.fmf @@ -0,0 +1,13 @@ +summary: Test contains few testcases linking to various glibc libraries. Testing if + testcases can be successfuly linked and run +description: '' +contact: Petr Muller +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc +duration: 30m +extra-summary: /tools/glibc/Sanity/basic-linking-sanity +extra-task: /tools/glibc/Sanity/basic-linking-sanity diff --git a/tests/Sanity/basic-linking-sanity/runtest.sh b/tests/Sanity/basic-linking-sanity/runtest.sh new file mode 100755 index 0000000..9831078 --- /dev/null +++ b/tests/Sanity/basic-linking-sanity/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Sanity/basic-linking-sanity +# Description: Test contains few testcases linking to various glibc libraries. Testing if testcases can be successfuly linked and run +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 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 rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="glibc" + +rlJournalStart + rlPhaseStartTest "Compiling" + rlRun "gcc lc.c -lc -o lc -fno-builtin" 0 "Testing for -lc linkage" + rlRun "gcc lm.c -lm -o lm -fno-builtin" 0 "Testing for -lm linkage" + rlRun "gcc lrt.c -lrt -o lrt -fno-builtin" 0 "Testing for -lrt linkage" + rlRun "gcc lpthread.c -lpthread -o lpthread -fno-builtin" 0 "Testing for -lpthread linkage" + rlPhaseEnd + + rlPhaseStartTest + rlRun "./lc" 0 "Running lc testcase" + rlRun "./lm" 0 "Running lm testcase" + rlRun "./lrt" 0 "Running lrt testcase" + rlRun "./lpthread" 0 "Running lpthread testcase" + + rlAssertNotDiffer "lc.out" "lc.golden" + rlAssertNotDiffer "lm.out" "lm.golden" + rlAssertNotDiffer "lrt.out" "lrt.golden" + rlAssertNotDiffer "lpthread.out" "lpthread.golden" + rlPhaseEnd + + rlPhaseStartCleanup + rlBundleLogs "outputs" *.out + rlRun "rm lc lc.out lm lm.out lrt lrt.out lpthread lpthread.out" + rlPhaseEnd +rlJournalEnd diff --git a/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/Makefile b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/Makefile new file mode 100644 index 0000000..011936c --- /dev/null +++ b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/glibc/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits +# Description: Test for bz531160 (ldd Vulnerable to Social Engineering Exploits) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE hello.c interp.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: Test for bz531160 (ldd Vulnerable to Social Engineering Exploits)" >> $(METADATA) + @echo "Type: Standardscompliance" >> $(METADATA) + @echo "TestTime: 60m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-static glibc-common glibc-devel gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 531160" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/PURPOSE b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/PURPOSE new file mode 100644 index 0000000..bb7a657 --- /dev/null +++ b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits +Description: Test for bz531160 (ldd Vulnerable to Social Engineering Exploits) +Author: Miroslav Franc +Bug summary: ldd Vulnerable to Social Engineering Exploits +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=531160 diff --git a/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/hello.c b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/hello.c new file mode 100644 index 0000000..c20ca2e --- /dev/null +++ b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/hello.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + puts("hello, world"); + return 0; +} diff --git a/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/interp.c b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/interp.c new file mode 100644 index 0000000..965d3d1 --- /dev/null +++ b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/interp.c @@ -0,0 +1,7 @@ +#define MESG "you are not suppposed to see this\n" + +int main() +{ + write(1, MESG, sizeof(MESG) - 1); + return 0; +} diff --git a/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/main.fmf b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/main.fmf new file mode 100644 index 0000000..0000dcb --- /dev/null +++ b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/main.fmf @@ -0,0 +1,20 @@ +summary: Test for bz531160 (ldd Vulnerable to Social Engineering Exploits) +description: | + Bug summary: ldd Vulnerable to Social Engineering Exploits + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=531160 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-static + - glibc-common + - glibc-devel + - gcc +duration: 60m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=531160 +extra-summary: /tools/glibc/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits +extra-task: /tools/glibc/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits diff --git a/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/runtest.sh b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/runtest.sh new file mode 100755 index 0000000..91a00d5 --- /dev/null +++ b/tests/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Standardscompliance/bz531160-ldd-Vulnerable-to-Social-Engineering-Exploits +# Description: Test for bz531160 (ldd Vulnerable to Social Engineering Exploits) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc glibc-common glibc-devel gcc) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp hello.c interp.c $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -static -o interp interp.c" + rlAssertExists "interp" + rlRun "gcc -o hello hello.c -Wl,--dynamic-linker,./interp" + rlAssertExists "hello" + rlPhaseEnd + + rlPhaseStartTest + rlRun "ldd ./hello > log 2>&1" + rlAssertNotGrep "you are not suppposed to see this" log + rlLog "$( +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/glibc/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE cursym.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: Test for bz639000 (Wrong Ukrainian currency symbol)" >> $(METADATA) + @echo "Type: Standardscompliance" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc gcc glibc-langpack-uk" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 639000" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/PURPOSE b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/PURPOSE new file mode 100644 index 0000000..3d7835a --- /dev/null +++ b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol +Description: Test for bz639000 (Wrong Ukrainian currency symbol) +Author: Miroslav Franc +Bug summary: Wrong Ukrainian currency symbol +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=639000 diff --git a/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/cursym.c b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/cursym.c new file mode 100644 index 0000000..094e50d --- /dev/null +++ b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/cursym.c @@ -0,0 +1,15 @@ +/* taken from bz#639000 */ + +#include +#include + +int main() +{ + struct lconv *lv; + + setlocale (LC_ALL, ""); + lv = localeconv(); + fprintf (stdout, "Currency symbol for locale: %s\n", lv->currency_symbol); + fprintf (stdout, "Intl currency sym for locale: %s\n", lv->int_curr_symbol); + return 0; +} diff --git a/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/main.fmf b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/main.fmf new file mode 100644 index 0000000..8a475c4 --- /dev/null +++ b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/main.fmf @@ -0,0 +1,18 @@ +summary: Test for bz639000 (Wrong Ukrainian currency symbol) +description: | + Bug summary: Wrong Ukrainian currency symbol + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=639000 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - gcc + - glibc-langpack-uk +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=639000 +extra-summary: /tools/glibc/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol +extra-task: /tools/glibc/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol diff --git a/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/runtest.sh b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/runtest.sh new file mode 100755 index 0000000..fc01c23 --- /dev/null +++ b/tests/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Standardscompliance/bz639000-Wrong-Ukrainian-currency-symbol +# Description: Test for bz639000 (Wrong Ukrainian currency symbol) +# 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 || exit 1 + +PACKAGE="gcc" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp cursym.c $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "gcc -o cursym cursym.c" + rlAssertExists "./cursym" + rlRun "LC_ALL=uk_UA.UTF-8 ./cursym > log" + rlAssertGrep "грн" log + rlAssertGrep "UAH" log + rlLog "$( +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/glibc/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE symbol.txt + +.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 bz692838 ([indic] update locales with currency symbol to)" >> $(METADATA) + @echo "Type: Standardscompliance" >> $(METADATA) + @echo "TestTime: 6m" >> $(METADATA) + @echo "RunFor: glibc" >> $(METADATA) + @echo "Requires: glibc glibc-common sed" >> $(METADATA) + @echo "Requires: glibc-langpack-ar glibc-langpack-as glibc-langpack-bn glibc-langpack-en glibc-langpack-gu " >> $(METADATA) + @echo "Requires: glibc-langpack-hi glibc-langpack-kn glibc-langpack-kok glibc-langpack-ks glibc-langpack-ml" >> $(METADATA) + @echo "Requires: glibc-langpack-mr glibc-langpack-or glibc-langpack-pa glibc-langpack-sa glibc-langpack-sd glibc-langpack-ta glibc-langpack-te" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 692838" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/PURPOSE b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/PURPOSE new file mode 100644 index 0000000..00e692c --- /dev/null +++ b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/glibc/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to +Description: Test for bz692838 ([indic] update locales with currency symbol to) +Author: Miroslav Franc +Bug summary: [indic] update locales with currency symbol to U20B9 +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=692838 diff --git a/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/main.fmf b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/main.fmf new file mode 100644 index 0000000..63aae5d --- /dev/null +++ b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/main.fmf @@ -0,0 +1,35 @@ +summary: Test for bz692838 ([indic] update locales with currency symbol to) +description: | + Bug summary: [indic] update locales with currency symbol to U20B9 + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=692838 +contact: Miroslav Franc +component: + - glibc +test: ./runtest.sh +framework: beakerlib +recommend: + - glibc + - glibc-common + - sed + - glibc-langpack-ar + - glibc-langpack-as + - glibc-langpack-bn + - glibc-langpack-en + - glibc-langpack-gu + - glibc-langpack-hi + - glibc-langpack-kn + - glibc-langpack-kok + - glibc-langpack-ks + - glibc-langpack-ml + - glibc-langpack-mr + - glibc-langpack-or + - glibc-langpack-pa + - glibc-langpack-sa + - glibc-langpack-sd + - glibc-langpack-ta + - glibc-langpack-te +duration: 6m +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=692838 +extra-summary: /tools/glibc/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to +extra-task: /tools/glibc/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to diff --git a/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/runtest.sh b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/runtest.sh new file mode 100755 index 0000000..64a6450 --- /dev/null +++ b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/glibc/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to +# Description: Test for bz692838 ([indic] update locales with currency symbol to) +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 + +PACKAGES=(glibc glibc-common sed) +LOCALES=(ar_IN as_IN bn_IN en_IN gu_IN hi_IN kn_IN kok_IN ks_IN ml_IN mr_IN or_IN pa_IN sa_IN sd_IN ta_IN te_IN) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp symbol.txt $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + for l in "${LOCALES[@]}"; do + rlRun "LC_MONETARY=$l locale -c LC_MONETARY | sed -n 3p > $l" + rlAssertNotDiffer "$l" symbol.txt + done; unset l + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/symbol.txt b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/symbol.txt new file mode 100644 index 0000000..2697415 --- /dev/null +++ b/tests/Standardscompliance/bz692838-indic-update-locales-with-currency-symbol-to/symbol.txt @@ -0,0 +1 @@ +₹