Compare commits

...

No commits in common. "c8" and "c9s" have entirely different histories.
c8 ... c9s

21 changed files with 336 additions and 357 deletions

7
.gitignore vendored
View File

@ -1 +1,6 @@
SOURCES/libffi-3.1.tar.gz
libffi-3.0.9.tar.gz
/libffi-3.0.10.tar.gz
/libffi-3.0.11.tar.gz
/libffi-3.0.13.tar.gz
/libffi-3.1.tar.gz
/libffi-3.4.2.tar.gz

View File

@ -1 +1 @@
cb373ef2115ec7c57913b84ca72eee14b10ccdc3 SOURCES/libffi-3.1.tar.gz
460882cfdb52a2bd13fc08edc540b242ae421033 libffi-3.4.2.tar.gz

View File

@ -1,11 +0,0 @@
--- a/src/aarch64/sysv.S
+++ b/src/aarch64/sysv.S
@@ -396,3 +396,8 @@
#ifdef __ELF__
.size CNAME(ffi_closure_SYSV), .-CNAME(ffi_closure_SYSV)
#endif
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",%progbits
+#endif
+

View File

@ -1,79 +0,0 @@
From 8daeed9570af72eb135c8ded460d2888f05b2e68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <mic@digikod.net>
Date: Sun, 11 May 2014 22:54:58 +0200
Subject: [PATCH 626/627] closures: Create temporary file with O_TMPFILE and
O_CLOEXEC when available
The open_temp_exec_file_dir function can create a temporary file without
file system accessible link. If the O_TMPFILE flag is not defined (old
Linux kernel or libc) the behavior is unchanged.
The open_temp_exec_file_name function now need a new argument "flags"
(like O_CLOEXEC) used for temporary file creation.
The O_TMPFILE flag allow temporary file creation without race condition.
This feature/fix prevent another process to access the (future)
executable file from the file system.
The O_CLOEXEC flag automatically close the temporary file for any
execve. This avoid transmitting (executable) file descriptor to a child
process.
---
src/closures.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2019-06-14 14:24:01.510844835 -0400
+++ b/src/closures.c 2019-06-14 14:26:48.248924350 -0400
@@ -265,9 +265,9 @@ static size_t execsize = 0;
/* Open a temporary file name, and immediately unlink it. */
static int
-open_temp_exec_file_name (char *name)
+open_temp_exec_file_name (char *name, int flags)
{
- int fd = mkstemp (name);
+ int fd = mkostemp (name, flags);
if (fd != -1)
unlink (name);
@@ -280,8 +280,28 @@ static int
open_temp_exec_file_dir (const char *dir)
{
static const char suffix[] = "/ffiXXXXXX";
- size_t lendir = strlen (dir);
- char *tempname = __builtin_alloca (lendir + sizeof (suffix));
+ size_t lendir;
+ int flags, fd;
+ char *tempname;
+
+#ifdef O_CLOEXEC
+ flags = O_CLOEXEC;
+#else
+ flags = 0;
+#endif
+
+#ifdef O_TMPFILE
+ fd = open (dir, flags | O_RDWR | O_EXCL | O_TMPFILE, 0700);
+ /* If the running system does not support the O_TMPFILE flag then retry without it. */
+ if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP)) {
+ return fd;
+ } else {
+ errno = 0;
+ }
+#endif
+
+ lendir = strlen (dir);
+ tempname = __builtin_alloca (lendir + sizeof (suffix));
if (!tempname)
return -1;
@@ -289,7 +309,7 @@ open_temp_exec_file_dir (const char *dir
memcpy (tempname, dir, lendir);
memcpy (tempname + lendir, suffix, sizeof (suffix));
- return open_temp_exec_file_name (tempname);
+ return open_temp_exec_file_name (tempname, flags);
}
/* Open a temporary file in the directory in the named environment

View File

@ -1,31 +0,0 @@
From 978c9540154d320525488db1b7049277122f736d Mon Sep 17 00:00:00 2001
From: Samuli Suominen <ssuominen@gentoo.org>
Date: Sat, 31 May 2014 08:53:10 -0400
Subject: [PATCH] Add missing GNU stack markings in win32.S
---
src/x86/win32.S | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/x86/win32.S b/src/x86/win32.S
index daf0e79..e42baf2 100644
--- a/src/x86/win32.S
+++ b/src/x86/win32.S
@@ -1,5 +1,6 @@
/* -----------------------------------------------------------------------
- win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
+ win32.S - Copyright (c) 2014 Anthony Green
+ Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
Copyright (c) 2001 John Beniton
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2009 Daniel Witte
@@ -1304,3 +1305,6 @@ L_ffi_closure_SYSV_inner$stub:
#endif /* !_MSC_VER */
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
--
1.9.3

View File

@ -1,17 +0,0 @@
diff -up libffi-3.1/libffi.pc.in.fixpath libffi-3.1/libffi.pc.in
--- libffi-3.1/libffi.pc.in.fixpath 2014-04-25 19:45:13.000000000 +0200
+++ libffi-3.1/libffi.pc.in 2014-06-12 12:06:06.000000000 +0200
@@ -1,11 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
-toolexeclibdir=@toolexeclibdir@
-includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
+includedir=@includedir@
Name: @PACKAGE_NAME@
Description: Library supporting Foreign Function Interfaces
Version: @PACKAGE_VERSION@
-Libs: -L${toolexeclibdir} -lffi
+Libs: -L${libdir} -lffi
Cflags: -I${includedir}

View File

@ -1,17 +0,0 @@
Most temp file directories need to be hardened against execution, but
libffi needs execute privileges. Add a libffi-specific temp directory
that can be set up by sysadmins as needed with suitable permissions.
This both ensures that libffi will have a valid temp directory to use
as well as preventing attempts to access other directories.
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2014-05-11 09:54:19.000000000 -0400
+++ b/src/closures.c 2020-04-29 20:50:00.454853909 -0400
@@ -362,6 +362,7 @@ static struct
const char *arg;
int repeat;
} open_temp_exec_file_opts[] = {
+ { open_temp_exec_file_env, "LIBFFI_TMPDIR", 0 },
{ open_temp_exec_file_env, "TMPDIR", 0 },
{ open_temp_exec_file_dir, "/tmp", 0 },
{ open_temp_exec_file_dir, "/var/tmp", 0 },

View File

@ -1,120 +0,0 @@
From 5c63b463b87d3c06102a4a7f05f395929d9ea79b Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@delorie.com>
Date: Wed, 2 Dec 2020 16:14:27 -0500
Subject: Use memfd_create() (#604)
memfd_create creates a file in a memory-only filesystem that may
bypass strict security protocols in filesystem-based temporary
files.
diff -rup a/configure.ac b/configure.ac
--- a/configure.ac 2014-05-11 09:57:49.000000000 -0400
+++ b/configure.ac 2021-11-03 17:41:31.935391831 -0400
@@ -63,6 +63,9 @@ EOF
AM_MAINTAINER_MODE
+AC_CHECK_HEADERS(sys/memfd.h)
+AC_CHECK_FUNCS([memfd_create])
+
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_FUNCS(mmap)
AC_FUNC_MMAP_BLACKLIST
diff -rup a/configure b/configure
--- a/configure 2014-05-19 09:44:03.000000000 -0400
+++ b/configure 2021-11-18 17:29:45.484951520 -0500
@@ -16976,6 +16976,30 @@ fi
+for ac_header in sys/memfd.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/memfd.h" "ac_cv_header_sys_memfd_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_memfd_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_MEMFD_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_func in memfd_create
+do :
+ ac_fn_c_check_func "$LINENO" "memfd_create" "ac_cv_func_memfd_create"
+if test "x$ac_cv_func_memfd_create" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMFD_CREATE 1
+_ACEOF
+
+fi
+done
+
+
for ac_header in sys/mman.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
diff -rup a/fficonfig.h.in b/fficonfig.h.in
--- a/fficonfig.h.in 2014-05-19 09:44:04.000000000 -0400
+++ b/fficonfig.h.in 2021-11-18 17:45:39.000000000 -0500
@@ -79,6 +79,9 @@
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
+/* Define to 1 if you have the `memfd_create' function. */
+#undef HAVE_MEMFD_CREATE
+
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
@@ -109,6 +112,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the <sys/memfd.h> header file. */
+#undef HAVE_SYS_MEMFD_H
+
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2021-11-03 17:37:37.841416436 -0400
+++ b/src/closures.c 2021-11-03 17:43:19.027498783 -0400
@@ -117,6 +117,9 @@
#endif /* HAVE_MNTENT */
#include <sys/param.h>
#include <pthread.h>
+#ifdef HAVE_SYS_MEMFD_H
+#include <sys/memfd.h>
+#endif
/* We don't want sys/mman.h to be included after we redefine mmap and
dlmunmap. */
@@ -263,6 +266,17 @@ static int execfd = -1;
/* The amount of space already allocated from the temporary file. */
static size_t execsize = 0;
+#ifdef HAVE_MEMFD_CREATE
+/* Open a temporary file name, and immediately unlink it. */
+static int
+open_temp_exec_file_memfd (const char *name)
+{
+ int fd;
+ fd = memfd_create (name, MFD_CLOEXEC);
+ return fd;
+}
+#endif
+
/* Open a temporary file name, and immediately unlink it. */
static int
open_temp_exec_file_name (char *name, int flags)
@@ -382,6 +396,9 @@ static struct
const char *arg;
int repeat;
} open_temp_exec_file_opts[] = {
+#ifdef HAVE_MEMFD_CREATE
+ { open_temp_exec_file_memfd, "libffi", 0 },
+#endif
{ open_temp_exec_file_env, "LIBFFI_TMPDIR", 0 },
{ open_temp_exec_file_env, "TMPDIR", 0 },
{ open_temp_exec_file_dir, "/tmp", 0 },

View File

@ -1,11 +0,0 @@
--- libffi-3.1/src/aarch64/ffi.c.orig 2014-04-25 18:45:13.000000000 +0100
+++ libffi-3.1/src/aarch64/ffi.c 2015-01-15 02:36:56.314906455 +0000
@@ -728,7 +728,7 @@
state.ngrn = N_X_ARG_REG;
memcpy (allocate_to_stack (&state, stack, ty->alignment,
- ty->size), ecif->avalue + i, ty->size);
+ ty->size), ecif->avalue[i], ty->size);
}
break;

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}

View File

@ -1,7 +1,7 @@
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2022-11-16 15:27:45.632725415 -0500
+++ b/src/closures.c 2022-11-18 13:56:17.948172306 -0500
@@ -140,6 +140,9 @@ selinux_enabled_check (void)
--- a/src/closures.c 2021-06-27 14:03:12.000000000 -0400
+++ b/src/closures.c 2023-04-06 23:37:18.742954529 -0400
@@ -432,6 +432,9 @@ selinux_enabled_check (void)
char *buf = NULL;
size_t len = 0;

View File

@ -1,24 +1,25 @@
%global multilib_arches %{ix86} ppc ppc64 ppc64p7 s390 s390x x86_64
%bcond_with bootstrap
%global multilib_arches %{ix86} x86_64
Name: libffi
Version: 3.1
Release: 24%{?dist}
Version: 3.4.2
Release: 8%{?dist}
Summary: A portable foreign function interface library
Group: System Environment/Libraries
License: MIT
URL: http://sourceware.org/libffi
Source0: ftp://sourceware.org/pub/libffi/libffi-%{version}.tar.gz
Source0: https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz
Source1: ffi-multilib.h
Source2: ffitarget-multilib.h
Patch0: libffi-3.1-fix-include-path.patch
Patch1: libffi-3.1-fix-exec-stack.patch
Patch2: libffi-aarch64-rhbz1174037.patch
Patch3: libffi-3.1-aarch64-fix-exec-stack.patch
Patch5: libffi-3.1-closures-Create-temporary-file-with-O_TMPFILE-and-O_.patch
Patch6: libffi-3.1-libffi_tmpdir.patch
Patch7: libffi-3.1-memfd.patch
Patch8: libffi-3.1-rh2014228.patch
Patch1: libffi-3.4.2-rh2152228.patch
BuildRequires: make
BuildRequires: gcc
%if %{without bootstrap}
BuildRequires: gcc-c++
BuildRequires: dejagnu
%endif
%description
Compilers for high level languages generate code that follow certain
@ -47,40 +48,36 @@ layer of a fully featured foreign function interface. A layer must
exist above `libffi' that handles type conversions for values passed
between the two languages.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%prep
%setup -q
%patch0 -p1 -b .fixpath
%patch1 -p1 -b .execstack
%patch2 -p1 -b .aarch64
%patch3 -p1 -b .aarch64execstack
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch1 -p1
%build
export CFLAGS="%{build_cflags} -Wa,--generate-missing-build-notes=yes"
%configure --disable-static
make %{?_smp_mflags}
# For now we disable the static templates to avoid ghc and
# gobject-introspection failures:
# https://gitlab.haskell.org/ghc/ghc/-/issues/20051
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/283
# We need to get these fixes into Fedora before we can reeanble them.
%configure --disable-static --disable-exec-static-tramp
%make_build
%check
%if %{without bootstrap}
%make_build check
%endif
%install
make install DESTDIR=$RPM_BUILD_ROOT
%make_install
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
@ -96,65 +93,94 @@ mkdir -p $RPM_BUILD_ROOT%{_includedir}
# can have both a 32- and 64-bit version of the library, and they each need
# their own correct-but-different versions of the headers to be usable.
for i in ffi ffitarget; do
mv $RPM_BUILD_ROOT%{_libdir}/libffi-%{version}/include/$i.h $RPM_BUILD_ROOT%{_includedir}/$i-${basearch}.h
mv $RPM_BUILD_ROOT%{_includedir}/$i.h $RPM_BUILD_ROOT%{_includedir}/$i-${basearch}.h
done
install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_includedir}/ffi.h
install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_includedir}/ffitarget.h
%else
mv $RPM_BUILD_ROOT%{_libdir}/libffi-%{version}/include/{ffi,ffitarget}.h $RPM_BUILD_ROOT%{_includedir}
%endif
rm -rf $RPM_BUILD_ROOT%{_libdir}/libffi-%{version}
%ldconfig_scriptlets
%post devel
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/libffi.info.gz || :
%preun devel
if [ $1 = 0 ] ;then
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/libffi.info.gz || :
fi
%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc README
%{_libdir}/*.so.*
%doc README.md
%{_libdir}/libffi.so.8
%{_libdir}/libffi.so.8.1.0
%files devel
%{_libdir}/pkgconfig/*.pc
%{_includedir}/ffi*.h
%{_libdir}/*.so
%{_mandir}/man3/*.gz
%{_infodir}/libffi.info.gz
%{_infodir}/libffi.info.*
%changelog
* Wed Nov 16 2022 DJ Delorie <dj@redhat.com> - 3.1-24
* Fri Apr 07 2023 DJ Delorie <dj@redhat.com> - 3.4.2-8
- Use /etc/sysconfig/libffi-force-shared-memory-check-first to
override selinux permissions check for shared memory access (#2014228)
override selinux permissions check for shared memory access (#2152228)
* Fri Nov 19 2021 DJ Delorie <dj@redhat.com> - 3.1-23
- Use memfd_create() to allocate closures (#1875340)
* Thu Aug 26 2021 Carlos O'Donell <codonell@redhat.com> - 3.4.2-7
- Remove compat-libffi3.1 subpackage to complete SONAME transition.
Related: rhbz#1891914
* Wed May 6 2020 DJ Delorie <dj@redhat.com> - 3.1-22
- Add $LIBFFI_TMPDIR environment variable support (#1723951)
* Wed Aug 18 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-6
- Rebuilt for libffi 3.4.2 SONAME transition. Related: rhbz#1891914
* Thu Aug 1 2019 DJ Delorie <dj@redhat.com> - 3.1-21
- Revert 1652930 until 1721569 can be fixed (#1652930)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 3.4.2-5
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Jun 14 2019 DJ Delorie <dj@redhat.com> - 3.1-20
- closures: Create temporary file with O_TMPFILE and O_CLOEXEC (#1720600)
* Thu Jul 29 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-4
- Drop pkgconf support for compat-libffi3.1.
* Fri Jun 14 2019 Florian Weimer <fweimer@redhat.com> - 3.1-19
- aarch64: Flush code alias mapping after creating closure (#1652930)
* Tue Jul 27 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-3
- Add temporary compat-libffi3.1 for library transition.
* Tue Nov 27 2018 Severin Gehwolf <sgehwolf@redhat.com> - 3.1-18
- Compile with -Wa,--generate-missing-build-notes=yes
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Aug 10 2018 Severin Gehwolf <sgehwolf@redhat.com> - 3.1-17
- Fix declared license: BSD => MIT.
* Mon Jun 28 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-1
- Rebase to libffi 3.4.2.
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.1-29
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-28
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Dec 02 2020 Carlos O'Donell <carlos@redhat.com> - 3.1-27
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-26
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Apr 30 2020 DJ Delorie <idj@redhat.com> - 3.1-25
- Add $LIBFFI_TMPDIR environment variable support (#1667620)
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-23
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Jul 9 2019 Florian Weimer <fweimer@redhat.com> - 3.1-22
- Run test suite during build (#1727088)
* Wed Jun 19 2019 Anthony Green <green@redhat.com> - 3.1-21
- Fix license tag
* Wed Apr 24 2019 Björn Esser <besser82@fedoraproject.org> - 3.1-20
- Remove hardcoded gzip suffix from GNU info pages
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sun Jul 22 2018 Peter Robinson <pbrobinson@fedoraproject.org> 3.1-28
- Fix FTBFS
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (libffi-3.4.2.tar.gz) = 31bad35251bf5c0adb998c88ff065085ca6105cf22071b9bd4b5d5d69db4fadf16cadeec9baca944c4bb97b619b035bb8279de8794b922531fddeb0779eb7fb1

17
tests/tests.yml Normal file
View File

@ -0,0 +1,17 @@
---
# This first play always runs on the local staging system
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- testsuite
required_packages:
- libffi
- libffi-devel
- gcc
- dejagnu
- rpm-build
- gcc-c++
- strace

63
tests/testsuite/Makefile Normal file
View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/libffi/Sanity/testsuite
# Description: Runs upstream testsuite
# Author: Michal Nowak <mnowak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/tools/libffi/Sanity/testsuite
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE dynamic_linking.patch dynamic_linking-dg.patch
.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: Michal Nowak <mnowak@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Runs upstream testsuite" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 19m" >> $(METADATA)
@echo "RunFor: libffi" >> $(METADATA)
@echo "Requires: libffi libffi-devel gcc dejagnu rpm-build gcc-c++ texinfo strace" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv3" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4 -RHEL5" >> $(METADATA)
rhts-lint $(METADATA)

3
tests/testsuite/PURPOSE Normal file
View File

@ -0,0 +1,3 @@
PURPOSE of /tools/libffi/Sanity/testsuite
Description: Runs upstream testsuite
Author: Michal Nowak <mnowak@redhat.com>

View File

@ -0,0 +1,29 @@
--- testsuite/lib/libffi-dg.exp 2008-02-14 19:45:33.000000000 -0500
+++ testsuite/lib/libffi-dg.exp 2015-02-13 13:32:08.422053435 -0500
@@ -110,7 +110,7 @@
}
verbose "gccdir $gccdir"
- set ld_library_path "."
+ set ld_library_path ""
append ld_library_path ":${gccdir}"
set compiler "${gccdir}/xgcc"
@@ -127,16 +127,13 @@
}
}
}
- # add the library path for libffi.
- append ld_library_path ":${blddirffi}/.libs"
-
verbose "ld_library_path: $ld_library_path"
# Point to the Libffi headers in libffi.
set libffi_include "${blddirffi}/include"
verbose "libffi_include $libffi_include"
- set libffi_dir "${blddirffi}/.libs"
+ set libffi_dir "/usr/LIBRARY_DIR"
verbose "libffi_dir $libffi_dir"
if { $libffi_dir != "" } {
set libffi_dir [file dirname ${libffi_dir}]

View File

@ -0,0 +1,29 @@
--- testsuite/lib/libffi.exp 2013-03-16 07:19:39.000000000 -0400
+++ testsuite/lib/libffi.exp 2014-10-22 11:10:42.449143642 -0400
@@ -118,7 +118,7 @@
}
verbose "gccdir $gccdir"
- set ld_library_path "."
+ set ld_library_path ""
append ld_library_path ":${gccdir}"
set compiler "${gccdir}/xgcc"
@@ -142,16 +142,13 @@
}
- # add the library path for libffi.
- append ld_library_path ":${blddirffi}/.libs"
-
verbose "ld_library_path: $ld_library_path"
# Point to the Libffi headers in libffi.
set libffi_include "${blddirffi}/include"
verbose "libffi_include $libffi_include"
- set libffi_dir "${blddirffi}/.libs"
+ set libffi_dir "/usr/LIBRARY_DIR"
verbose "libffi_dir $libffi_dir"
if { $libffi_dir != "" } {
set libffi_dir [file dirname ${libffi_dir}]

86
tests/testsuite/runtest.sh Executable file
View File

@ -0,0 +1,86 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/libffi/Sanity/testsuite
# Description: Runs upstream testsuite
# Author: Michal Nowak <mnowak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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 3 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 rhts environment
. /usr/lib/beakerlib/beakerlib.sh
PACKAGES=(libffi libffi-devel gcc dejagnu rpm-build gcc-c++)
rlJournalStart
rlPhaseStartSetup
for p in "${PACKAGES[@]}"; do
if ! rlCheckRpm "$p"; then
rlRun "yum -y install $p"
rlAssertRpm "$p"
fi
done;
rlRun "TmpDir=`mktemp -d`" 0 "Creating tmp directory"
rlRun "cp *.patch $TmpDir/"
rlRun "pushd $TmpDir"
rlFetchSrcForInstalled libffi
rlRun "rpm -ivh libffi*.src.rpm"
rlRun "popd"
rlRun "specfile=$(rpm --eval='%_specdir')/libffi.spec"
rlRun "rpmbuild -bp $specfile"
rlRun "builddir=$(rpm --eval='%_builddir')"
rlRun "pushd $builddir/libffi-*/"
rlRun "./configure"
rlRUn "make"
rlPhaseEnd
rlPhaseStartTest "Run testsuite"
# patching the testsuite to test the installed libraries instead of the built ones
if [ -e /usr/lib64/libffi.so ]; then
export LD_LIBRARY_PATH=/usr/lib64
perl -i -pe 's/LIBRARY_DIR/lib64/' $TmpDir/dynamic_linking.patch
perl -i -pe 's/LIBRARY_DIR/lib64/' $TmpDir/dynamic_linking-dg.patch
else
export LD_LIBRARY_PATH=/usr/lib
perl -i -pe 's/LIBRARY_DIR/lib/' $TmpDir/dynamic_linking.patch
perl -i -pe 's/LIBRARY_DIR/lib/' $TmpDir/dynamic_linking-dg.patch
fi
test -e testsuite/lib/libffi.exp && rlRun "patch testsuite/lib/libffi.exp < $TmpDir/dynamic_linking.patch"
test -e testsuite/lib/libffi-dg.exp && rlRun "patch testsuite/lib/libffi-dg.exp < $TmpDir/dynamic_linking-dg.patch"
rlLog "Checking whether we test really the installed libraries."
strace -F -e open,openat,stat -o strace.log -- make check
LIBFFI_SO_CALLS=`cat strace.log | grep libffi.so | grep -v ENOENT | grep -v 'usr/lib' | grep -v '\"\/lib' | grep -v 'unfinished' | wc -l`
rlAssertGreater "The just built libraries should not be used, everything should be taken from /usr" 5 $LIBFFI_SO_CALLS
rlRun "cat strace.log | grep libffi.so | grep usr"
rlRun "cat strace.log | grep libffi.so | grep rpmbuild" 1
rlRun "make check" 0 "RUNNING THE TESTSUITE"
rlRun "popd"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "ls -al $TmpDir"
rlBundleLogs logs $(find . -name 'libffi.sum') $(find . -name 'libffi.log')
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd