Compare commits
No commits in common. "c8" and "c9s" have entirely different histories.
12
.gitignore
vendored
@ -1 +1,11 @@
|
|||||||
SOURCES/exempi-2.4.5.tar.bz2
|
exempi-2.1.1.tar.gz
|
||||||
|
/exempi-2.2.0.tar.bz2
|
||||||
|
/exempi-2.2.1.tar.bz2
|
||||||
|
/exempi-2.3.0.tar.bz2
|
||||||
|
/exempi-2.4.0.tar.bz2
|
||||||
|
/exempi-2.4.1.tar.bz2
|
||||||
|
/exempi-2.4.2.tar.bz2
|
||||||
|
/exempi-2.4.4.tar.bz2
|
||||||
|
/exempi-2.4.5.tar.bz2
|
||||||
|
/exempi-2.5.1.tar.bz2
|
||||||
|
/exempi-e23c21380f467f1f1c9dc397e0a08405fb4afa7a.tar.bz2
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
From 4f583ff12989f7cea1f81bd2751c321030f1bdbf Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Hubert=20Figui=C3=A8re?= <hub@figuiere.net>
|
|
||||||
Date: Sun, 28 Jul 2019 10:15:19 -0400
|
|
||||||
Subject: [PATCH] (CVE-2020-18651) Issue #13 - Fix a buffer a overflow in ID3
|
|
||||||
support
|
|
||||||
|
|
||||||
https://gitlab.freedesktop.org/libopenraw/exempi/issues/13
|
|
||||||
(cherry picked from commit fdd4765a699f9700850098b43b9798b933acb32f)
|
|
||||||
---
|
|
||||||
XMPFiles/source/FormatSupport/ID3_Support.cpp | 8 ++++++++
|
|
||||||
1 file changed, 8 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/XMPFiles/source/FormatSupport/ID3_Support.cpp b/XMPFiles/source/FormatSupport/ID3_Support.cpp
|
|
||||||
index dd19c16..4619079 100644
|
|
||||||
--- a/XMPFiles/source/FormatSupport/ID3_Support.cpp
|
|
||||||
+++ b/XMPFiles/source/FormatSupport/ID3_Support.cpp
|
|
||||||
@@ -669,6 +669,10 @@ bool ID3v2Frame::getFrameValue ( XMP_Uns8 majorVersion, XMP_Uns32 logicalID, std
|
|
||||||
std::string tmp ( this->content, this->contentSize );
|
|
||||||
bool bigEndian = true; // assume for now (if no BOM follows)
|
|
||||||
|
|
||||||
+ if (pos + 2 > this->contentSize) {
|
|
||||||
+ // No enough for the string
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
if ( GetUns16BE ( &this->content[pos] ) == 0xFEFF ) {
|
|
||||||
pos += 2;
|
|
||||||
bigEndian = true;
|
|
||||||
@@ -686,6 +690,10 @@ bool ID3v2Frame::getFrameValue ( XMP_Uns8 majorVersion, XMP_Uns32 logicalID, std
|
|
||||||
{
|
|
||||||
if ( commMode && (! advancePastCOMMDescriptor ( pos )) ) return false; // not a frame of interest!
|
|
||||||
|
|
||||||
+ if (pos + 4 > this->contentSize) {
|
|
||||||
+ // No enough for the string
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
if ( (GetUns32BE ( &this->content[pos]) & 0xFFFFFF00 ) == 0xEFBBBF00 ) {
|
|
||||||
pos += 3; // swallow any BOM, just in case
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.41.0
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
From a3b1e52e5a5836fe1fd07013a2a098518b1801de Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Hubert=20Figui=C3=A8re?= <hub@figuiere.net>
|
|
||||||
Date: Sat, 27 Jul 2019 20:42:51 -0400
|
|
||||||
Subject: [PATCH] (CVE-20220-18652) Bug #12 - Invalid WebP cause memory
|
|
||||||
overflow.
|
|
||||||
|
|
||||||
https://gitlab.freedesktop.org/libopenraw/exempi/issues/12
|
|
||||||
(cherry picked from commit acee2894ceb91616543927c2a6e45050c60f98f7)
|
|
||||||
---
|
|
||||||
XMPFiles/source/FormatSupport/WEBP_Support.cpp | 10 ++++++++--
|
|
||||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/XMPFiles/source/FormatSupport/WEBP_Support.cpp b/XMPFiles/source/FormatSupport/WEBP_Support.cpp
|
|
||||||
index ffaf220..0d4b81d 100644
|
|
||||||
--- a/XMPFiles/source/FormatSupport/WEBP_Support.cpp
|
|
||||||
+++ b/XMPFiles/source/FormatSupport/WEBP_Support.cpp
|
|
||||||
@@ -120,10 +120,16 @@ VP8XChunk::VP8XChunk(Container* parent)
|
|
||||||
this->data.assign(this->size, 0);
|
|
||||||
XMP_Uns8* bitstream =
|
|
||||||
(XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data();
|
|
||||||
+ XMP_Uns32 width = 0;
|
|
||||||
+ XMP_Uns32 height = 0;
|
|
||||||
// See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247
|
|
||||||
// bitstream could be NULL.
|
|
||||||
- XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0;
|
|
||||||
- XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0;
|
|
||||||
+ // See bug https://gitlab.freedesktop.org/libopenraw/exempi/issues/12
|
|
||||||
+ // image chunk data could be too short (must be 10)
|
|
||||||
+ if (parent->chunks[WEBP_CHUNK_IMAGE][0]->data.size() >= 10 && bitstream) {
|
|
||||||
+ width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff;
|
|
||||||
+ height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff;
|
|
||||||
+ }
|
|
||||||
this->width(width);
|
|
||||||
this->height(height);
|
|
||||||
parent->vp8x = this;
|
|
||||||
--
|
|
||||||
2.41.0
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
From 487f4136013d9fa3351b863e5f861463a1cbddcf Mon Sep 17 00:00:00 2001
|
|
||||||
From: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
|
|
||||||
Date: Sat, 18 Aug 2018 13:54:55 +0000
|
|
||||||
Subject: [PATCH] Issue #9 - Fix null-pointer-dereference (CVE-2018-12648)
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
The WEBP::GetLE32 function in
|
|
||||||
XMPFiles/source/FormatSupport/WEBP_Support.hpp in Exempi 2.4.5 has a
|
|
||||||
NULL pointer dereference.
|
|
||||||
|
|
||||||
https://bugs.freedesktop.org/show_bug.cgi?id=106981
|
|
||||||
https://gitlab.freedesktop.org/libopenraw/exempi/issues/9
|
|
||||||
|
|
||||||
Signed-off-by: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
|
|
||||||
Signed-off-by: Hubert Figuière <hub@figuiere.net>
|
|
||||||
---
|
|
||||||
XMPFiles/source/FormatSupport/WEBP_Support.cpp | 8 +++++---
|
|
||||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/XMPFiles/source/FormatSupport/WEBP_Support.cpp b/XMPFiles/source/FormatSupport/WEBP_Support.cpp
|
|
||||||
index ffaf220..4fe705b 100644
|
|
||||||
--- a/XMPFiles/source/FormatSupport/WEBP_Support.cpp
|
|
||||||
+++ b/XMPFiles/source/FormatSupport/WEBP_Support.cpp
|
|
||||||
@@ -160,9 +160,11 @@ bool VP8XChunk::xmp()
|
|
||||||
}
|
|
||||||
void VP8XChunk::xmp(bool hasXMP)
|
|
||||||
{
|
|
||||||
- XMP_Uns32 flags = GetLE32(&this->data[0]);
|
|
||||||
- flags ^= (-hasXMP ^ flags) & (1 << XMP_FLAG_BIT);
|
|
||||||
- PutLE32(&this->data[0], flags);
|
|
||||||
+ if (&this->data[0] != NULL) {
|
|
||||||
+ XMP_Uns32 flags = GetLE32(&this->data[0]);
|
|
||||||
+ flags ^= (-hasXMP ^ flags) & (1 << XMP_FLAG_BIT);
|
|
||||||
+ PutLE32(&this->data[0], flags);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
Container::Container(WEBP_MetaHandler* handler) : Chunk(NULL, handler)
|
|
||||||
--
|
|
||||||
2.17.1
|
|
||||||
|
|
27
exempi-e23c213-typeinfos.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From d45c06270576493e1537080fa43c1af667c4337a Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
|
||||||
|
Date: Tue, 12 Oct 2021 14:15:17 +0200
|
||||||
|
Subject: [PATCH] Avoid multiple definitions of typeinfos
|
||||||
|
|
||||||
|
---
|
||||||
|
XMPFiles/source/XMPFiles_Impl.cpp | 4 +++-
|
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/XMPFiles/source/XMPFiles_Impl.cpp b/XMPFiles/source/XMPFiles_Impl.cpp
|
||||||
|
index 2f918ac..ff45040 100644
|
||||||
|
--- a/XMPFiles/source/XMPFiles_Impl.cpp
|
||||||
|
+++ b/XMPFiles/source/XMPFiles_Impl.cpp
|
||||||
|
@@ -47,7 +47,9 @@ using namespace std;
|
||||||
|
/// This file ...
|
||||||
|
///
|
||||||
|
// =================================================================================================
|
||||||
|
-#include "public/include/XMP.incl_cpp"
|
||||||
|
+#if ! XMP_StaticBuild
|
||||||
|
+ #include "public/include/XMP.incl_cpp"
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#if XMP_WinBuild
|
||||||
|
#pragma warning ( disable : 4290 ) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
@ -1,18 +1,20 @@
|
|||||||
|
%global commit e23c21380f467f1f1c9dc397e0a08405fb4afa7a
|
||||||
|
%global shortcommit %%(c=%{commit}; echo ${c:0:7})
|
||||||
|
%global date 20211007
|
||||||
|
|
||||||
Summary: Library for easy parsing of XMP metadata
|
Summary: Library for easy parsing of XMP metadata
|
||||||
Name: exempi
|
Name: exempi
|
||||||
Version: 2.4.5
|
Version: 2.6.0
|
||||||
Release: 4%{?dist}
|
Release: 0.2.%{date}git%{shortcommit}%{?dist}
|
||||||
License: BSD
|
License: BSD
|
||||||
Group: System Environment/Libraries
|
|
||||||
URL: http://libopenraw.freedesktop.org/wiki/Exempi
|
URL: http://libopenraw.freedesktop.org/wiki/Exempi
|
||||||
Source0: http://libopenraw.freedesktop.org/download/%{name}-%{version}.tar.bz2
|
Source0: https://gitlab.freedesktop.org/libopenraw/%{name}/-/archive/%{commit}/%{name}-%{commit}.tar.bz2
|
||||||
Patch0: CVE-2018-12648.patch
|
Patch0: exempi-e23c213-typeinfos.patch
|
||||||
Patch0001: 0001-CVE-2020-18651-Issue-13-Fix-a-buffer-a-overflow-in-I.patch
|
|
||||||
Patch0002: 0002-CVE-20220-18652-Bug-12-Invalid-WebP-cause-memory-ove.patch
|
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
BuildRequires: boost-devel expat-devel zlib-devel pkgconfig
|
BuildRequires: boost-devel expat-devel zlib-devel pkgconfig
|
||||||
# Work around for aarch64 support (https://bugzilla.redhat.com/show_bug.cgi?id=925327)
|
# Work around for aarch64 support (https://bugzilla.redhat.com/show_bug.cgi?id=925327)
|
||||||
BuildRequires: autoconf automake libtool
|
BuildRequires: autoconf automake libtool
|
||||||
|
BuildRequires: make
|
||||||
Provides: bundled(md5-polstra)
|
Provides: bundled(md5-polstra)
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -22,7 +24,6 @@ It includes XMPCore and XMPFiles.
|
|||||||
|
|
||||||
%package devel
|
%package devel
|
||||||
Summary: Headers for developing programs that will use %{name}
|
Summary: Headers for developing programs that will use %{name}
|
||||||
Group: Development/Libraries
|
|
||||||
Requires: %{name} = %{version}-%{release}
|
Requires: %{name} = %{version}-%{release}
|
||||||
Requires: pkgconfig
|
Requires: pkgconfig
|
||||||
|
|
||||||
@ -31,14 +32,11 @@ This package contains the libraries and header files needed for
|
|||||||
developing with exempi.
|
developing with exempi.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%autosetup -p1 -n %{name}-%{commit}
|
||||||
%patch0 -p1
|
|
||||||
%patch1 -p1
|
|
||||||
%patch2 -p1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
libtoolize -vi
|
libtoolize -vi
|
||||||
./autogen.sh
|
NOCONFIGURE=1 ./autogen.sh
|
||||||
# BanEntityUsage needed for #888765
|
# BanEntityUsage needed for #888765
|
||||||
%configure CPPFLAGS="-I%{_includedir} -fno-strict-aliasing -DBanAllEntityUsage=1"
|
%configure CPPFLAGS="-I%{_includedir} -fno-strict-aliasing -DBanAllEntityUsage=1"
|
||||||
|
|
||||||
@ -46,44 +44,88 @@ libtoolize -vi
|
|||||||
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
|
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
|
||||||
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
|
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
|
||||||
|
|
||||||
make %{?_smp_mflags} V=1
|
%make_build
|
||||||
|
|
||||||
%check
|
%check
|
||||||
|
%ifarch s390x
|
||||||
|
# testcore test fails on big endian arches since exempi 2.5.2:
|
||||||
|
# https://gitlab.freedesktop.org/libopenraw/exempi/-/issues/23
|
||||||
|
make check || [ "$(grep '^FAIL:' exempi/test-suite.log)" = "FAIL: tests/testcore" ]
|
||||||
|
%else
|
||||||
make check
|
make check
|
||||||
|
%endif
|
||||||
|
|
||||||
%install
|
%install
|
||||||
make DESTDIR=%{buildroot} install
|
%make_install
|
||||||
|
|
||||||
rm -rf %{buildroot}%{_libdir}/*.la
|
rm -rf %{buildroot}%{_libdir}/*.la
|
||||||
rm -rf %{buildroot}%{_libdir}/*.a
|
rm -rf %{buildroot}%{_libdir}/*.a
|
||||||
|
|
||||||
%post -p /sbin/ldconfig
|
|
||||||
|
|
||||||
%postun -p /sbin/ldconfig
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%doc AUTHORS ChangeLog COPYING README
|
%doc AUTHORS ChangeLog COPYING README
|
||||||
%{_bindir}/exempi
|
%{_bindir}/exempi
|
||||||
%{_libdir}/*.so.*
|
%{_libdir}/libexempi.so.8*
|
||||||
%{_mandir}/man1/exempi.1*
|
%{_mandir}/man1/exempi.1*
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
%{_includedir}/exempi-2.0/
|
%{_includedir}/exempi-2.0/
|
||||||
%{_libdir}/*.so
|
%{_libdir}/libexempi.so
|
||||||
%{_libdir}/pkgconfig/*.pc
|
%{_libdir}/pkgconfig/*.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Jan 08 2024 Matej Mužila <mmuzila@redhat.com> - 2.4.5-4
|
* Wed Nov 03 2021 Nikola Forró <nforro@redhat.com> - 2.6.0-0.2.20211007gite23c213
|
||||||
- Fix CVE-2020-18652
|
- Add modified upstream test suite as a gating test
|
||||||
- Resolves: RHEL-5416
|
Related #1989405
|
||||||
|
|
||||||
* Mon Jan 08 2024 Matej Mužila <mmuzila@redhat.com> - 2.4.5-3
|
* Wed Oct 20 2021 Nikola Forró <nforro@redhat.com> - 2.6.0-0.1.20211007gite23c213
|
||||||
- Fix CVE-2020-18651
|
- Update to (unreleased) version 2.6.0 to resolve licensing issues
|
||||||
- Resolves: RHEL-5415
|
Resolves #1989405
|
||||||
|
|
||||||
* Wed Sep 26 2018 Nikola Forró <nforro@redhat.com> - 2.4.5-2
|
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.5.1-8
|
||||||
|
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||||
|
Related: rhbz#1991688
|
||||||
|
|
||||||
|
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 2.5.1-7
|
||||||
|
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
||||||
|
|
||||||
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.1-6
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jul 28 2020 Jeff Law <law@redhat.com> - 2.5.1-5
|
||||||
|
- Force C++14 as this code is not C++17 ready
|
||||||
|
|
||||||
|
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.1-4
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jul 14 2020 Tom Stellard <tstellar@redhat.com> - 2.5.1-3
|
||||||
|
- Use make macros
|
||||||
|
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
|
||||||
|
|
||||||
|
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.1-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Aug 30 2019 Nikola Forró <nforro@redhat.com> - 2.5.1-1
|
||||||
|
- Update to version 2.5.1
|
||||||
|
Resolves #1747391
|
||||||
|
|
||||||
|
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.5-7
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.5-6
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Oct 9 2018 Owen Taylor <otaylor@redhat.com> - 2.4.5-5
|
||||||
|
- Set NOCONFIGURE when running autogen.sh to avoid running configure twice
|
||||||
|
|
||||||
|
* Wed Sep 26 2018 Nikola Forró <nforro@redhat.com> - 2.4.5-4
|
||||||
- Fix CVE-2018-12648
|
- Fix CVE-2018-12648
|
||||||
Resolves #1594644
|
Resolves #1594643
|
||||||
|
|
||||||
|
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.5-3
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jun 28 2018 Nikola Forró <nforro@redhat.com> - 2.4.5-2
|
||||||
|
- Remove ldconfig from scriptlets
|
||||||
|
|
||||||
* Tue Mar 13 2018 Nikola Forró <nforro@redhat.com> - 2.4.5-1
|
* Tue Mar 13 2018 Nikola Forró <nforro@redhat.com> - 2.4.5-1
|
||||||
- Update to version 2.4.5
|
- Update to version 2.4.5
|
6
gating.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
--- !Policy
|
||||||
|
product_versions:
|
||||||
|
- rhel-9
|
||||||
|
decision_context: osci_compose_gate
|
||||||
|
rules:
|
||||||
|
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
1
sources
Normal file
@ -0,0 +1 @@
|
|||||||
|
SHA512 (exempi-e23c21380f467f1f1c9dc397e0a08405fb4afa7a.tar.bz2) = ad7142712c99bec02e1f119293e095b68db99d303f5c21d47b8658cf43b84f2aa48b78dd49565eb80dc1888e8c1bcfb376686ef690f2a052c415180fa1af13d4
|
4
tests/exempi/Makefile.am
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
SUBDIRS = exempi
|
||||||
|
DIST_SUBDIRS = exempi
|
7
tests/exempi/README
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
exempi test suite modified to run against installed exempi
|
||||||
|
|
||||||
|
All files except the following are taken unmodified from upstream tarball:
|
||||||
|
|
||||||
|
configure.ac
|
||||||
|
Makefile.am
|
||||||
|
exempi/Makefile.am
|
41
tests/exempi/configure.ac
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
AC_PREREQ(2.50)
|
||||||
|
AC_INIT(exempi-tests,0.1)
|
||||||
|
AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
|
||||||
|
AM_MAINTAINER_MODE
|
||||||
|
m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
|
||||||
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
|
EXEMPI_MAJOR_VERSION=2.0
|
||||||
|
AC_SUBST(EXEMPI_MAJOR_VERSION)
|
||||||
|
|
||||||
|
EXEMPI_INCLUDE_BASE=exempi-$EXEMPI_MAJOR_VERSION
|
||||||
|
AC_SUBST(EXEMPI_INCLUDE_BASE)
|
||||||
|
|
||||||
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_CXX
|
||||||
|
AC_PROG_LIBTOOL
|
||||||
|
AX_CXX_COMPILE_STDCXX_11(noext,mandatory)
|
||||||
|
|
||||||
|
AC_C_BIGENDIAN
|
||||||
|
AC_DEFINE(CHECKED_ENDIANNESS)
|
||||||
|
|
||||||
|
ENABLE_UNITTEST=yes
|
||||||
|
BOOST_REQUIRE([1.48.0])
|
||||||
|
BOOST_TEST([mt-s])
|
||||||
|
|
||||||
|
AC_DEFINE(UNIX_ENV, [1])
|
||||||
|
|
||||||
|
AM_CONDITIONAL(WITH_UNIT_TEST, test x$ENABLE_UNITTEST = xyes)
|
||||||
|
|
||||||
|
VALGRIND=
|
||||||
|
AC_SUBST(VALGRIND)
|
||||||
|
|
||||||
|
AC_LANG_CPLUSPLUS
|
||||||
|
AC_LANG_COMPILER_REQUIRE
|
||||||
|
|
||||||
|
AC_OUTPUT([
|
||||||
|
Makefile
|
||||||
|
exempi/Makefile
|
||||||
|
])
|
99
tests/exempi/exempi/Makefile.am
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
AUTOMAKE_OPTIONS = parallel-tests
|
||||||
|
TEST_EXTENSIONS = .sh
|
||||||
|
|
||||||
|
if WITH_UNIT_TEST
|
||||||
|
check_PROGRAMS = testexempicore testserialise \
|
||||||
|
testwritenewprop \
|
||||||
|
testtiffleak testxmpfiles testxmpfileswrite \
|
||||||
|
testparse testiterator testinit testfdo18635\
|
||||||
|
testfdo83313 testcpp testwebp \
|
||||||
|
testxmpformat \
|
||||||
|
$(NULL)
|
||||||
|
TESTS = testinit testexempicore testserialise \
|
||||||
|
testwritenewprop \
|
||||||
|
testtiffleak testxmpfiles testxmpfileswrite \
|
||||||
|
testparse testiterator testfdo18635 testfdo83313 testcpp testwebp \
|
||||||
|
testxmpformat \
|
||||||
|
$(NULL)
|
||||||
|
TESTS_ENVIRONMENT = TEST_DIR=$(srcdir)/tests BOOST_TEST_CATCH_SYSTEM_ERRORS=no VALGRIND="$(VALGRIND)"
|
||||||
|
LOG_COMPILER = $(VALGRIND)
|
||||||
|
endif
|
||||||
|
|
||||||
|
check_DATA = tests/test1.xmp tests/fdo18635.jpg tests/fdo83313.jpg
|
||||||
|
|
||||||
|
noinst_HEADERS = tests/utils.h
|
||||||
|
|
||||||
|
EXTRA_DIST = $(check_DATA) $(check_SCRIPTS)
|
||||||
|
CLEANFILES = test.jpg test.webp
|
||||||
|
|
||||||
|
AM_CXXFLAGS = @BOOST_CPPFLAGS@
|
||||||
|
|
||||||
|
testinit_SOURCES = tests/testinit.cpp tests/utils.cpp
|
||||||
|
testinit_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testinit_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testinit_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testexempicore_SOURCES = tests/test-exempi-core.cpp tests/utils.cpp
|
||||||
|
testexempicore_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testexempicore_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testexempicore_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testserialise_SOURCES = tests/test-serialise.cpp tests/utils.cpp
|
||||||
|
testserialise_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testserialise_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testserialise_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testwritenewprop_SOURCES = tests/test-write-new-prop.cpp tests/utils.cpp
|
||||||
|
testwritenewprop_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testwritenewprop_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testwritenewprop_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testtiffleak_SOURCES = tests/test-tiff-leak.cpp tests/utils.cpp
|
||||||
|
testtiffleak_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testtiffleak_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testtiffleak_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testxmpfiles_SOURCES = tests/test-xmpfiles.cpp tests/utils.cpp
|
||||||
|
testxmpfiles_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testxmpfiles_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testxmpfiles_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testxmpfileswrite_SOURCES = tests/test-xmpfiles-write.cpp tests/utils.cpp
|
||||||
|
testxmpfileswrite_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testxmpfileswrite_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testxmpfileswrite_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testparse_SOURCES = tests/testparse.cpp tests/utils.cpp
|
||||||
|
testparse_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testparse_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testparse_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testiterator_SOURCES = tests/test-iterator.cpp tests/utils.cpp
|
||||||
|
testiterator_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testiterator_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testiterator_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testfdo18635_SOURCES = tests/test-bgo.cpp tests/utils.cpp
|
||||||
|
testfdo18635_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testfdo18635_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testfdo18635_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testfdo83313_SOURCES = tests/test-fdo83313.cpp tests/utils.cpp
|
||||||
|
testfdo83313_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testfdo83313_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testfdo83313_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testcpp_SOURCES = tests/testcpp.cpp tests/utils.cpp
|
||||||
|
testcpp_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testcpp_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testcpp_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testwebp_SOURCES = tests/test-webp.cpp tests/utils.cpp
|
||||||
|
testwebp_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testwebp_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testwebp_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
||||||
|
|
||||||
|
testxmpformat_SOURCES = tests/test-xmpformat.cpp
|
||||||
|
testxmpformat_LDADD = -lexempi @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
|
||||||
|
testxmpformat_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
|
||||||
|
testxmpformat_CPPFLAGS = -I$(includedir)/@EXEMPI_INCLUDE_BASE@ -I$(includedir)/@EXEMPI_INCLUDE_BASE@/exempi
|
BIN
tests/exempi/exempi/tests/fdo18635.jpg
Normal file
After Width: | Height: | Size: 212 KiB |
BIN
tests/exempi/exempi/tests/fdo83313.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
74
tests/exempi/exempi/tests/test-bgo.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-bgo.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
int test_main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "fdo18635.jpg");
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpFilePtr xf = xmp_files_open_new(g_testfile.c_str(), XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(xf != NULL);
|
||||||
|
if (xf == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_files_get_new_xmp(xf);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_free(xf));
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
235
tests/exempi/exempi/tests/test-exempi-core.cpp
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-exempi-core.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2013 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_exempi()
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "test1.xmp");
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
FILE *f = fopen(g_testfile.c_str(), "rb");
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
buffer = (char *)malloc(len + 1);
|
||||||
|
size_t rlen = fread(buffer, 1, len, f);
|
||||||
|
|
||||||
|
BOOST_CHECK(rlen == len);
|
||||||
|
BOOST_CHECK(len != 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
// See https://bugs.freedesktop.org/show_bug.cgi?id=53983
|
||||||
|
// It is recognized as unknown.
|
||||||
|
BOOST_CHECK(xmp_files_check_file_format(g_testfile.c_str()) == XMP_FT_UNKNOWN);
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_parse(xmp, buffer, len));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
XmpStringPtr the_prop = xmp_string_new();
|
||||||
|
BOOST_CHECK(xmp_string_len(the_prop) == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_has_property(xmp, NS_TIFF, "Make"));
|
||||||
|
BOOST_CHECK(!xmp_has_property(xmp, NS_TIFF, "Foo"));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_get_property(xmp, NS_TIFF, "Make", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("Canon", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
BOOST_CHECK(xmp_string_len(the_prop) == 5);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_set_property(xmp, NS_TIFF, "Make", "Leica", 0));
|
||||||
|
BOOST_CHECK(xmp_get_property(xmp, NS_TIFF, "Make", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("Leica", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
BOOST_CHECK(xmp_string_len(the_prop) == 5);
|
||||||
|
|
||||||
|
uint32_t bits;
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property(xmp, NS_DC, "rights[1]/?xml:lang", the_prop, &bits));
|
||||||
|
BOOST_CHECK(bits == 0x20);
|
||||||
|
BOOST_CHECK(XMP_IS_PROP_QUALIFIER(bits));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_get_property(xmp, NS_DC, "rights[1]", the_prop, &bits));
|
||||||
|
BOOST_CHECK(bits == 0x50);
|
||||||
|
BOOST_CHECK(XMP_HAS_PROP_QUALIFIERS(bits));
|
||||||
|
|
||||||
|
XmpStringPtr the_lang = xmp_string_new();
|
||||||
|
BOOST_CHECK(xmp_get_localized_text(xmp, NS_DC, "rights", NULL, "x-default",
|
||||||
|
the_lang, the_prop, &bits));
|
||||||
|
BOOST_CHECK(strcmp("x-default", xmp_string_cstr(the_lang)) == 0);
|
||||||
|
BOOST_CHECK(strcmp("2006, Hubert Figuiere", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
// This will modify the default property.
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_set_localized_text(xmp, NS_DC, "rights", "en", "en-CA", "Foo Bar", 0));
|
||||||
|
// Ask for the en_US alternative.
|
||||||
|
BOOST_CHECK(xmp_get_localized_text(xmp, NS_DC, "rights", "en", "en-US",
|
||||||
|
the_lang, the_prop, &bits));
|
||||||
|
// And we only got the "en-CA" as the only "en"
|
||||||
|
BOOST_CHECK(strcmp("en-US", xmp_string_cstr(the_lang)) != 0);
|
||||||
|
BOOST_CHECK(strcmp("en-CA", xmp_string_cstr(the_lang)) == 0);
|
||||||
|
// Check its value
|
||||||
|
BOOST_CHECK(strcmp("Foo Bar", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
// The default property is supposed to have been changed too.
|
||||||
|
BOOST_CHECK(xmp_get_localized_text(xmp, NS_DC, "rights", NULL, "x-default",
|
||||||
|
the_lang, the_prop, &bits));
|
||||||
|
BOOST_CHECK(strcmp("Foo Bar", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
// This should also remove the property x-default. (SDK 5.2.2)
|
||||||
|
BOOST_CHECK(xmp_delete_localized_text(xmp, NS_DC, "rights", "en", "en-CA"));
|
||||||
|
|
||||||
|
BOOST_CHECK(!xmp_has_property(xmp, NS_DC, "rights[1]"));
|
||||||
|
BOOST_CHECK(!xmp_has_property(xmp, NS_DC, "rights[2]"));
|
||||||
|
|
||||||
|
xmp_string_free(the_lang);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_set_array_item(xmp, NS_DC, "creator", 2, "foo", 0));
|
||||||
|
BOOST_CHECK(xmp_get_array_item(xmp, NS_DC, "creator", 2, the_prop, &bits));
|
||||||
|
BOOST_CHECK(XMP_IS_PROP_SIMPLE(bits));
|
||||||
|
BOOST_CHECK(strcmp("foo", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
BOOST_CHECK(xmp_append_array_item(xmp, NS_DC, "creator", 0, "bar", 0));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_get_array_item(xmp, NS_DC, "creator", 3, the_prop, &bits));
|
||||||
|
BOOST_CHECK(XMP_IS_PROP_SIMPLE(bits));
|
||||||
|
BOOST_CHECK(strcmp("bar", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_delete_property(xmp, NS_DC, "creator[3]"));
|
||||||
|
BOOST_CHECK(!xmp_has_property(xmp, NS_DC, "creator[3]"));
|
||||||
|
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property(xmp, NS_EXIF, "DateTimeOriginal", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("2006-12-07T23:20:43-05:00", xmp_string_cstr(the_prop)) ==
|
||||||
|
0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_get_property(xmp, NS_XAP, "Rating", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("3", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
xmp_string_free(the_prop);
|
||||||
|
|
||||||
|
// testing date time get
|
||||||
|
XmpDateTime the_dt;
|
||||||
|
bool ret;
|
||||||
|
BOOST_CHECK(ret = xmp_get_property_date(xmp, NS_EXIF, "DateTimeOriginal",
|
||||||
|
&the_dt, NULL));
|
||||||
|
BOOST_CHECK(the_dt.year == 2006);
|
||||||
|
BOOST_CHECK(the_dt.minute == 20);
|
||||||
|
BOOST_CHECK(the_dt.tzSign == XMP_TZ_WEST);
|
||||||
|
|
||||||
|
// testing compare
|
||||||
|
XmpDateTime the_other_dt;
|
||||||
|
BOOST_CHECK(ret = xmp_get_property_date(xmp, NS_EXIF, "DateTimeOriginal",
|
||||||
|
&the_other_dt, NULL));
|
||||||
|
BOOST_CHECK(xmp_datetime_compare(&the_dt, &the_other_dt) == 0);
|
||||||
|
the_other_dt.year++;
|
||||||
|
BOOST_CHECK(xmp_datetime_compare(&the_dt, &the_other_dt) < 0);
|
||||||
|
BOOST_CHECK(xmp_datetime_compare(&the_other_dt, &the_dt) > 0);
|
||||||
|
// NULL checks - this is Exempi API
|
||||||
|
BOOST_CHECK(xmp_datetime_compare(NULL, NULL) == 0);
|
||||||
|
BOOST_CHECK(xmp_datetime_compare(NULL, &the_other_dt) < 0);
|
||||||
|
BOOST_CHECK(xmp_datetime_compare(&the_other_dt, NULL) > 0);
|
||||||
|
|
||||||
|
// testing float get set
|
||||||
|
double float_value = 0.0;
|
||||||
|
BOOST_CHECK(xmp_get_property_float(xmp, NS_CAMERA_RAW_SETTINGS,
|
||||||
|
"SharpenRadius", &float_value, NULL));
|
||||||
|
BOOST_CHECK(float_value == 1.0);
|
||||||
|
BOOST_CHECK(xmp_set_property_float(xmp, NS_CAMERA_RAW_SETTINGS,
|
||||||
|
"SharpenRadius", 2.5, 0));
|
||||||
|
BOOST_CHECK(xmp_get_property_float(xmp, NS_CAMERA_RAW_SETTINGS,
|
||||||
|
"SharpenRadius", &float_value, NULL));
|
||||||
|
BOOST_CHECK(float_value == 2.5);
|
||||||
|
|
||||||
|
// testing bool get set
|
||||||
|
bool bool_value = true;
|
||||||
|
BOOST_CHECK(xmp_get_property_bool(xmp, NS_CAMERA_RAW_SETTINGS,
|
||||||
|
"AlreadyApplied", &bool_value, NULL));
|
||||||
|
BOOST_CHECK(!bool_value);
|
||||||
|
BOOST_CHECK(xmp_set_property_bool(xmp, NS_CAMERA_RAW_SETTINGS,
|
||||||
|
"AlreadyApplied", true, 0));
|
||||||
|
BOOST_CHECK(xmp_get_property_bool(xmp, NS_CAMERA_RAW_SETTINGS,
|
||||||
|
"AlreadyApplied", &bool_value, NULL));
|
||||||
|
BOOST_CHECK(bool_value);
|
||||||
|
|
||||||
|
// testing int get set
|
||||||
|
int32_t value = 0;
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property_int32(xmp, NS_EXIF, "MeteringMode", &value, NULL));
|
||||||
|
BOOST_CHECK(value == 5);
|
||||||
|
BOOST_CHECK(xmp_set_property_int32(xmp, NS_EXIF, "MeteringMode", 10, 0));
|
||||||
|
int64_t valuelarge = 0;
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property_int64(xmp, NS_EXIF, "MeteringMode", &valuelarge, NULL));
|
||||||
|
BOOST_CHECK(valuelarge == 10);
|
||||||
|
BOOST_CHECK(xmp_set_property_int64(xmp, NS_EXIF, "MeteringMode", 32, 0));
|
||||||
|
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property_int32(xmp, NS_EXIF, "MeteringMode", &value, NULL));
|
||||||
|
BOOST_CHECK(value == 32);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
74
tests/exempi/exempi/tests/test-fdo83313.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-bgo.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
int test_main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "fdo83313.jpg");
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpFilePtr xf = xmp_files_open_new(g_testfile.c_str(), XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(xf != NULL);
|
||||||
|
if (xf == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_files_get_new_xmp(xf);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_free(xf));
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
174
tests/exempi/exempi/tests/test-iterator.cpp
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test3.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2017 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_exempi_iterate()
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "test1.xmp");
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
FILE *f = fopen(g_testfile.c_str(), "rb");
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
buffer = (char *)malloc(len + 1);
|
||||||
|
size_t rlen = fread(buffer, 1, len, f);
|
||||||
|
|
||||||
|
BOOST_CHECK(rlen == len);
|
||||||
|
BOOST_CHECK(len != 0);
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_parse(xmp, buffer, len));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
XmpStringPtr the_schema = xmp_string_new();
|
||||||
|
XmpStringPtr the_path = xmp_string_new();
|
||||||
|
XmpStringPtr the_prop = xmp_string_new();
|
||||||
|
uint32_t options;
|
||||||
|
|
||||||
|
typedef std::array<std::string, 3> tuple3;
|
||||||
|
|
||||||
|
{
|
||||||
|
// leafnodes iteration
|
||||||
|
XmpIteratorPtr iter =
|
||||||
|
xmp_iterator_new(xmp, NS_DC, NULL, XMP_ITER_JUSTLEAFNODES);
|
||||||
|
|
||||||
|
BOOST_CHECK(iter);
|
||||||
|
std::vector<tuple3> props;
|
||||||
|
|
||||||
|
while (xmp_iterator_next(iter, the_schema, the_path, the_prop, &options)) {
|
||||||
|
props.push_back(tuple3 {{
|
||||||
|
xmp_string_cstr(the_schema),
|
||||||
|
xmp_string_cstr(the_path),
|
||||||
|
xmp_string_cstr(the_prop)
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(props.size() == 7);
|
||||||
|
for (auto prop_tuple : props) {
|
||||||
|
BOOST_CHECK(prop_tuple[0] == NS_DC);
|
||||||
|
}
|
||||||
|
BOOST_CHECK(props[0][2] == "unknown");
|
||||||
|
BOOST_CHECK(props[3][1] == "dc:subject[1]");
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_iterator_free(iter));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// leafname iteration
|
||||||
|
XmpIteratorPtr iter =
|
||||||
|
xmp_iterator_new(xmp, NS_DC, "rights", XMP_ITER_JUSTLEAFNAME);
|
||||||
|
|
||||||
|
BOOST_CHECK(iter);
|
||||||
|
std::vector<tuple3> props;
|
||||||
|
|
||||||
|
while (xmp_iterator_next(iter, the_schema, the_path, the_prop, &options)) {
|
||||||
|
props.push_back(tuple3 {{
|
||||||
|
xmp_string_cstr(the_schema),
|
||||||
|
xmp_string_cstr(the_path),
|
||||||
|
xmp_string_cstr(the_prop)
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(props.size() == 3);
|
||||||
|
|
||||||
|
BOOST_CHECK(props[0] == (tuple3{{NS_DC, "dc:rights", ""}}));
|
||||||
|
BOOST_CHECK(props[1] == (tuple3{{"", "[1]", "2006, Hubert Figuiere"}}));
|
||||||
|
BOOST_CHECK(props[2] == (tuple3{{NS_XML, "xml:lang", "x-default"}}));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_iterator_free(iter));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Iterator with property but no NS is invalid.
|
||||||
|
XmpIteratorPtr iter =
|
||||||
|
xmp_iterator_new(xmp, NULL, "rights", XMP_ITER_JUSTLEAFNODES);
|
||||||
|
|
||||||
|
// Invalid iterator
|
||||||
|
BOOST_CHECK(!iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Iterating namespaces is invalid.
|
||||||
|
XmpIteratorPtr iter =
|
||||||
|
xmp_iterator_new(xmp, NULL, NULL, XMP_ITER_NAMESPACES);
|
||||||
|
|
||||||
|
// Invalid iterator
|
||||||
|
BOOST_CHECK(!iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmp_string_free(the_prop);
|
||||||
|
xmp_string_free(the_path);
|
||||||
|
xmp_string_free(the_schema);
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
fclose(f);
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
102
tests/exempi/exempi/tests/test-serialise.cpp
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-serialise.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_serialize()
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "test1.xmp");
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
char *buffer;
|
||||||
|
FILE *f = fopen(g_testfile.c_str(), "rb");
|
||||||
|
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
buffer = (char *)malloc(len + 1);
|
||||||
|
size_t rlen = fread(buffer, 1, len, f);
|
||||||
|
|
||||||
|
BOOST_CHECK(rlen == len);
|
||||||
|
BOOST_CHECK(len != 0);
|
||||||
|
buffer[rlen] = 0;
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_parse(xmp, buffer, len));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
std::string b1(buffer);
|
||||||
|
std::string b2;
|
||||||
|
XmpStringPtr output = xmp_string_new();
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_serialize_and_format(
|
||||||
|
xmp, output, XMP_SERIAL_OMITPACKETWRAPPER, 0, "\n", " ", 0));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
b2 = xmp_string_cstr(output);
|
||||||
|
// find a way to compare that.
|
||||||
|
// BOOST_CHECK_EQUAL(b1, b2);
|
||||||
|
|
||||||
|
xmp_string_free(output);
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
86
tests/exempi/exempi/tests/test-tiff-leak.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-tiff-leak.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008,2010 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
|
||||||
|
/** See http://www.adobeforums.com/webx/.3bc42b73 for the orignal
|
||||||
|
* test case */
|
||||||
|
// void test_tiff_leak()
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "../../samples/testfiles/BlueSquare.jpg");
|
||||||
|
|
||||||
|
std::string orig_tiff_file =
|
||||||
|
g_src_testdir + "../../samples/testfiles/BlueSquare.tif";
|
||||||
|
BOOST_CHECK(copy_file(orig_tiff_file, "test.tif"));
|
||||||
|
BOOST_CHECK(chmod("test.tif", S_IRUSR | S_IWUSR) == 0);
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpFilePtr f = xmp_files_open_new("test.tif", XMP_OPEN_FORUPDATE);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmpPtr xmp;
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp = xmp_files_get_new_xmp(f));
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
xmp_set_localized_text(xmp, NS_DC, "description", "en", "en-US", "foo", 0);
|
||||||
|
BOOST_CHECK(xmp_files_put_xmp(f, xmp));
|
||||||
|
BOOST_CHECK(xmp_files_close(f, XMP_CLOSE_NOOPTION));
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(unlink("test.tif") == 0);
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
119
tests/exempi/exempi/tests/test-webp.cpp
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-webp.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2016 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "../../samples/testfiles/BlueSquare.webp");
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_check_file_format(g_testfile.c_str()) == XMP_FT_WEBP);
|
||||||
|
XmpFilePtr f = xmp_files_open_new(g_testfile.c_str(), XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_files_get_new_xmp(f);
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
BOOST_CHECK(copy_file(g_testfile, "test.webp"));
|
||||||
|
BOOST_CHECK(chmod("test.webp", S_IRUSR | S_IWUSR) == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_check_file_format("test.webp") == XMP_FT_WEBP);
|
||||||
|
|
||||||
|
f = xmp_files_open_new("test.webp", XMP_OPEN_FORUPDATE);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_set_property(xmp, NS_PHOTOSHOP, "ICCProfile", "foo", 0));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_can_put_xmp(f, xmp));
|
||||||
|
BOOST_CHECK(xmp_files_put_xmp(f, xmp));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_close(f, XMP_CLOSE_SAFEUPDATE));
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
f = xmp_files_open_new("test.webp", XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
xmp = xmp_files_get_new_xmp(f);
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
XmpStringPtr the_prop = xmp_string_new();
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property(xmp, NS_PHOTOSHOP, "ICCProfile", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("foo", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
xmp_string_free(the_prop);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_close(f, XMP_CLOSE_NOOPTION));
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
150
tests/exempi/exempi/tests/test-write-new-prop.cpp
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test1.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_write_new_property()
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "test1.xmp");
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
FILE *f = fopen(g_testfile.c_str(), "rb");
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
buffer = (char *)malloc(len + 1);
|
||||||
|
size_t rlen = fread(buffer, 1, len, f);
|
||||||
|
|
||||||
|
BOOST_CHECK(rlen == len);
|
||||||
|
BOOST_CHECK(len != 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_parse(xmp, buffer, len));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
XmpStringPtr reg_prefix = xmp_string_new();
|
||||||
|
BOOST_CHECK(xmp_register_namespace(NS_CC, "cc", reg_prefix));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
BOOST_CHECK(strcmp("cc:", xmp_string_cstr(reg_prefix)) == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_prefix_namespace_uri("cc", reg_prefix));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
BOOST_CHECK(strcmp(NS_CC, xmp_string_cstr(reg_prefix)) == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_namespace_prefix(NS_CC, reg_prefix));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
BOOST_CHECK(strcmp("cc:", xmp_string_cstr(reg_prefix)) == 0);
|
||||||
|
|
||||||
|
xmp_string_free(reg_prefix);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_set_property(xmp, NS_CC, "License", "Foo", 0));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
XmpStringPtr the_prop = xmp_string_new();
|
||||||
|
BOOST_CHECK(xmp_get_property(xmp, NS_CC, "License", the_prop, NULL));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
BOOST_CHECK(strcmp("Foo", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
XmpDateTime the_dt;
|
||||||
|
the_dt.year = 2005;
|
||||||
|
the_dt.month = 12;
|
||||||
|
the_dt.day = 25;
|
||||||
|
the_dt.hour = 12;
|
||||||
|
the_dt.minute = 42;
|
||||||
|
the_dt.second = 42;
|
||||||
|
the_dt.tzSign = XMP_TZ_UTC;
|
||||||
|
the_dt.tzHour = 0;
|
||||||
|
the_dt.tzMinute = 0;
|
||||||
|
the_dt.nanoSecond = 0;
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_set_property_date(xmp, NS_EXIF, "DateTimeOriginal", &the_dt, 0));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property(xmp, NS_EXIF, "DateTimeOriginal", the_prop, NULL));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
BOOST_CHECK(strcmp("2005-12-25T12:42:42", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
XmpDateTime the_dt2;
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property_date(xmp, NS_EXIF, "DateTimeOriginal", &the_dt2, NULL));
|
||||||
|
BOOST_CHECK(xmp_get_error() == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(the_dt2.year == 2005);
|
||||||
|
BOOST_CHECK(the_dt2.minute == 42);
|
||||||
|
BOOST_CHECK(the_dt2.tzSign == XMP_TZ_UTC);
|
||||||
|
|
||||||
|
xmp_string_free(the_prop);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
120
tests/exempi/exempi/tests/test-xmpfiles-write.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-xmpfile-write.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008,2010 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_xmpfiles_write()
|
||||||
|
int test_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "../../samples/testfiles/BlueSquare.jpg");
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_check_file_format(g_testfile.c_str()) == XMP_FT_JPEG);
|
||||||
|
XmpFilePtr f = xmp_files_open_new(g_testfile.c_str(), XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_files_get_new_xmp(f);
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
BOOST_CHECK(copy_file(g_testfile, "test.jpg"));
|
||||||
|
BOOST_CHECK(chmod("test.jpg", S_IRUSR | S_IWUSR) == 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_check_file_format("test.jpg") == XMP_FT_JPEG);
|
||||||
|
|
||||||
|
f = xmp_files_open_new("test.jpg", XMP_OPEN_FORUPDATE);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_set_property(xmp, NS_PHOTOSHOP, "ICCProfile", "foo", 0));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_can_put_xmp(f, xmp));
|
||||||
|
BOOST_CHECK(xmp_files_put_xmp(f, xmp));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_close(f, XMP_CLOSE_SAFEUPDATE));
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
f = xmp_files_open_new("test.jpg", XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
xmp = xmp_files_get_new_xmp(f);
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
XmpStringPtr the_prop = xmp_string_new();
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property(xmp, NS_PHOTOSHOP, "ICCProfile", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("foo", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
xmp_string_free(the_prop);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
BOOST_CHECK(xmp_files_close(f, XMP_CLOSE_NOOPTION));
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
// unlink("test.jpg");
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
129
tests/exempi/exempi/tests/test-xmpfiles.cpp
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-xmpfiles.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2016 Hubert Figuière
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_xmpfiles()
|
||||||
|
int test_main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "../../samples/testfiles/BlueSquare.jpg");
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpFilePtr f = xmp_files_open_new(g_testfile.c_str(), XMP_OPEN_READ);
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_check_file_format(g_testfile.c_str()) == XMP_FT_JPEG);
|
||||||
|
|
||||||
|
XmpStringPtr file_path = xmp_string_new();
|
||||||
|
XmpOpenFileOptions options;
|
||||||
|
XmpFileType file_format;
|
||||||
|
XmpFileFormatOptions handler_flags;
|
||||||
|
BOOST_CHECK(xmp_files_get_file_info(f, file_path, &options, &file_format,
|
||||||
|
&handler_flags));
|
||||||
|
BOOST_CHECK(options == XMP_OPEN_READ);
|
||||||
|
BOOST_CHECK(file_format == XMP_FT_JPEG);
|
||||||
|
// the value check might break at each SDK update. You have been warned.
|
||||||
|
BOOST_CHECK(handler_flags == 0x27f);
|
||||||
|
BOOST_CHECK(g_testfile == xmp_string_cstr(file_path));
|
||||||
|
xmp_string_free(file_path);
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_get_xmp(f, xmp));
|
||||||
|
|
||||||
|
{
|
||||||
|
XmpStringPtr thestring = xmp_string_new();
|
||||||
|
XmpPacketInfo packet_info;
|
||||||
|
BOOST_CHECK(xmp_files_get_xmp_xmpstring(f, thestring, &packet_info));
|
||||||
|
BOOST_CHECK(packet_info.offset == 2189);
|
||||||
|
BOOST_CHECK(packet_info.length == 4782);
|
||||||
|
BOOST_CHECK(packet_info.padSize == 2049);
|
||||||
|
BOOST_CHECK(packet_info.hasWrapper);
|
||||||
|
|
||||||
|
const char *xmp_str = xmp_string_cstr(thestring);
|
||||||
|
BOOST_CHECK(xmp_str);
|
||||||
|
xmp_string_free(thestring);
|
||||||
|
}
|
||||||
|
|
||||||
|
XmpStringPtr the_prop = xmp_string_new();
|
||||||
|
|
||||||
|
BOOST_CHECK(
|
||||||
|
xmp_get_property(xmp, NS_PHOTOSHOP, "ICCProfile", the_prop, NULL));
|
||||||
|
BOOST_CHECK(strcmp("sRGB IEC61966-2.1", xmp_string_cstr(the_prop)) == 0);
|
||||||
|
|
||||||
|
xmp_string_free(the_prop);
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_files_free(f));
|
||||||
|
|
||||||
|
XmpFileFormatOptions formatOptions;
|
||||||
|
|
||||||
|
// the value check might break at each SDK update. You have been warned.
|
||||||
|
BOOST_CHECK(xmp_files_get_format_info(XMP_FT_JPEG, &formatOptions));
|
||||||
|
BOOST_CHECK(formatOptions == 0x27f);
|
||||||
|
BOOST_CHECK(xmp_files_get_format_info(XMP_FT_GIF, &formatOptions));
|
||||||
|
BOOST_CHECK(formatOptions == 0x46b);
|
||||||
|
BOOST_CHECK(xmp_files_get_format_info(XMP_FT_PNG, &formatOptions));
|
||||||
|
BOOST_CHECK(formatOptions == 0x46b);
|
||||||
|
// PDF doesn't have a smart handler.
|
||||||
|
BOOST_CHECK(!xmp_files_get_format_info(XMP_FT_PDF, &formatOptions));
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
98
tests/exempi/exempi/tests/test-xmpformat.cpp
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test-xmpformat.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Hubert Figuière
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
const std::map<const char*, XmpFileType> TEST_CASES = {
|
||||||
|
{ "avi", XMP_FT_AVI },
|
||||||
|
{ "eps", XMP_FT_EPS },
|
||||||
|
{ "gif", XMP_FT_GIF },
|
||||||
|
{ "indd", XMP_FT_INDESIGN },
|
||||||
|
{ "jpg", XMP_FT_JPEG },
|
||||||
|
{ "mov", XMP_FT_MOV },
|
||||||
|
{ "mp3", XMP_FT_MP3 },
|
||||||
|
{ "png", XMP_FT_PNG },
|
||||||
|
{ "psd", XMP_FT_PHOTOSHOP },
|
||||||
|
{ "tif", XMP_FT_TIFF },
|
||||||
|
{ "webp", XMP_FT_WEBP },
|
||||||
|
{ "wav", XMP_FT_WAV }
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::map<const char*, XmpFileType> FAILING_CASES = {
|
||||||
|
// This is a GIF87a. Not supported.
|
||||||
|
{ "gif", XMP_FT_UNKNOWN }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test that the sample files match the file type.
|
||||||
|
//
|
||||||
|
// This test would have caught:
|
||||||
|
// https://gitlab.freedesktop.org/libopenraw/exempi/-/issues/20
|
||||||
|
//
|
||||||
|
int test_main(int , char *[])
|
||||||
|
{
|
||||||
|
const char* srcdir = getenv("srcdir");
|
||||||
|
if (!srcdir) {
|
||||||
|
srcdir = ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
for (auto testcase : TEST_CASES) {
|
||||||
|
std::string imagepath(srcdir);
|
||||||
|
imagepath += "/../samples/testfiles/BlueSquare.";
|
||||||
|
imagepath += testcase.first;
|
||||||
|
|
||||||
|
printf("%s\n", imagepath.c_str());
|
||||||
|
auto xft = xmp_files_check_file_format(imagepath.c_str());
|
||||||
|
BOOST_CHECK(xft == testcase.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto testcase : FAILING_CASES) {
|
||||||
|
std::string imagepath(srcdir);
|
||||||
|
imagepath += "/../samples/testfiles/BlueSquare-FAIL.";
|
||||||
|
imagepath += testcase.first;
|
||||||
|
|
||||||
|
printf("%s\n", imagepath.c_str());
|
||||||
|
auto xft = xmp_files_check_file_format(imagepath.c_str());
|
||||||
|
BOOST_CHECK(xft == testcase.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
255
tests/exempi/exempi/tests/test1.xmp
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Public XMP Toolkit Core 3.5">
|
||||||
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:tiff="http://ns.adobe.com/tiff/1.0/">
|
||||||
|
<tiff:Make>Canon</tiff:Make>
|
||||||
|
<tiff:Model>Canon EOS 20D</tiff:Model>
|
||||||
|
<tiff:Orientation>1</tiff:Orientation>
|
||||||
|
<tiff:ImageWidth>3504</tiff:ImageWidth>
|
||||||
|
<tiff:ImageLength>2336</tiff:ImageLength>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:exif="http://ns.adobe.com/exif/1.0/">
|
||||||
|
<exif:ExifVersion>0221</exif:ExifVersion>
|
||||||
|
<exif:ExposureTime>15/1</exif:ExposureTime>
|
||||||
|
<exif:ShutterSpeedValue>-3906891/1000000</exif:ShutterSpeedValue>
|
||||||
|
<exif:FNumber>8/1</exif:FNumber>
|
||||||
|
<exif:ApertureValue>6/1</exif:ApertureValue>
|
||||||
|
<exif:ExposureProgram>1</exif:ExposureProgram>
|
||||||
|
<exif:DateTimeOriginal>2006-12-07T23:20:43-05:00</exif:DateTimeOriginal>
|
||||||
|
<exif:DateTimeDigitized>2006-12-07T23:20:43-05:00</exif:DateTimeDigitized>
|
||||||
|
<exif:ExposureBiasValue>0/2</exif:ExposureBiasValue>
|
||||||
|
<exif:MaxApertureValue>3625/1000</exif:MaxApertureValue>
|
||||||
|
<exif:MeteringMode>5</exif:MeteringMode>
|
||||||
|
<exif:FocalLength>32/1</exif:FocalLength>
|
||||||
|
<exif:CustomRendered>0</exif:CustomRendered>
|
||||||
|
<exif:ExposureMode>1</exif:ExposureMode>
|
||||||
|
<exif:WhiteBalance>0</exif:WhiteBalance>
|
||||||
|
<exif:SceneCaptureType>0</exif:SceneCaptureType>
|
||||||
|
<exif:FocalPlaneXResolution>3504000/885</exif:FocalPlaneXResolution>
|
||||||
|
<exif:FocalPlaneYResolution>2336000/590</exif:FocalPlaneYResolution>
|
||||||
|
<exif:FocalPlaneResolutionUnit>2</exif:FocalPlaneResolutionUnit>
|
||||||
|
<exif:ISOSpeedRatings>
|
||||||
|
<rdf:Seq>
|
||||||
|
<rdf:li>100</rdf:li>
|
||||||
|
</rdf:Seq>
|
||||||
|
</exif:ISOSpeedRatings>
|
||||||
|
<exif:Flash rdf:parseType="Resource">
|
||||||
|
<exif:Fired>False</exif:Fired>
|
||||||
|
<exif:Return>0</exif:Return>
|
||||||
|
<exif:Mode>2</exif:Mode>
|
||||||
|
<exif:Function>False</exif:Function>
|
||||||
|
<exif:RedEyeMode>False</exif:RedEyeMode>
|
||||||
|
</exif:Flash>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:xap="http://ns.adobe.com/xap/1.0/">
|
||||||
|
<xap:ModifyDate>2006-12-07T23:20:43-05:00</xap:ModifyDate>
|
||||||
|
<xap:Rating>3</xap:Rating>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
|
<dc:creator>
|
||||||
|
<rdf:Seq>
|
||||||
|
<rdf:li>unknown</rdf:li>
|
||||||
|
</rdf:Seq>
|
||||||
|
</dc:creator>
|
||||||
|
<dc:rights>
|
||||||
|
<rdf:Alt>
|
||||||
|
<rdf:li xml:lang="x-default">2006, Hubert Figuiere</rdf:li>
|
||||||
|
</rdf:Alt>
|
||||||
|
</dc:rights>
|
||||||
|
<dc:subject>
|
||||||
|
<rdf:Bag>
|
||||||
|
<rdf:li>night</rdf:li>
|
||||||
|
<rdf:li>ontario</rdf:li>
|
||||||
|
<rdf:li>ottawa</rdf:li>
|
||||||
|
<rdf:li>parliament of canada</rdf:li>
|
||||||
|
</rdf:Bag>
|
||||||
|
</dc:subject>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:aux="http://ns.adobe.com/exif/1.0/aux/">
|
||||||
|
<aux:SerialNumber>420103070</aux:SerialNumber>
|
||||||
|
<aux:LensInfo>24/1 85/1 0/0 0/0</aux:LensInfo>
|
||||||
|
<aux:Lens>24.0-85.0 mm</aux:Lens>
|
||||||
|
<aux:ImageNumber>176</aux:ImageNumber>
|
||||||
|
<aux:FlashCompensation>-2/1</aux:FlashCompensation>
|
||||||
|
<aux:OwnerName>unknown</aux:OwnerName>
|
||||||
|
<aux:Firmware>1.1.0</aux:Firmware>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/">
|
||||||
|
<crs:AlreadyApplied>False</crs:AlreadyApplied>
|
||||||
|
<crs:WhiteBalance>As Shot</crs:WhiteBalance>
|
||||||
|
<crs:Exposure>0.00</crs:Exposure>
|
||||||
|
<crs:Shadows>5</crs:Shadows>
|
||||||
|
<crs:Brightness>+50</crs:Brightness>
|
||||||
|
<crs:Contrast>+25</crs:Contrast>
|
||||||
|
<crs:Saturation>0</crs:Saturation>
|
||||||
|
<crs:Sharpness>25</crs:Sharpness>
|
||||||
|
<crs:LuminanceSmoothing>0</crs:LuminanceSmoothing>
|
||||||
|
<crs:ColorNoiseReduction>25</crs:ColorNoiseReduction>
|
||||||
|
<crs:ChromaticAberrationR>0</crs:ChromaticAberrationR>
|
||||||
|
<crs:ChromaticAberrationB>0</crs:ChromaticAberrationB>
|
||||||
|
<crs:VignetteAmount>0</crs:VignetteAmount>
|
||||||
|
<crs:ShadowTint>0</crs:ShadowTint>
|
||||||
|
<crs:RedHue>0</crs:RedHue>
|
||||||
|
<crs:RedSaturation>0</crs:RedSaturation>
|
||||||
|
<crs:GreenHue>0</crs:GreenHue>
|
||||||
|
<crs:GreenSaturation>0</crs:GreenSaturation>
|
||||||
|
<crs:BlueHue>0</crs:BlueHue>
|
||||||
|
<crs:BlueSaturation>0</crs:BlueSaturation>
|
||||||
|
<crs:FillLight>0</crs:FillLight>
|
||||||
|
<crs:Vibrance>0</crs:Vibrance>
|
||||||
|
<crs:HighlightRecovery>0</crs:HighlightRecovery>
|
||||||
|
<crs:Clarity>0</crs:Clarity>
|
||||||
|
<crs:Defringe>0</crs:Defringe>
|
||||||
|
<crs:HueAdjustmentRed>0</crs:HueAdjustmentRed>
|
||||||
|
<crs:HueAdjustmentOrange>0</crs:HueAdjustmentOrange>
|
||||||
|
<crs:HueAdjustmentYellow>0</crs:HueAdjustmentYellow>
|
||||||
|
<crs:HueAdjustmentGreen>0</crs:HueAdjustmentGreen>
|
||||||
|
<crs:HueAdjustmentAqua>0</crs:HueAdjustmentAqua>
|
||||||
|
<crs:HueAdjustmentBlue>0</crs:HueAdjustmentBlue>
|
||||||
|
<crs:HueAdjustmentPurple>0</crs:HueAdjustmentPurple>
|
||||||
|
<crs:HueAdjustmentMagenta>0</crs:HueAdjustmentMagenta>
|
||||||
|
<crs:SaturationAdjustmentRed>0</crs:SaturationAdjustmentRed>
|
||||||
|
<crs:SaturationAdjustmentOrange>0</crs:SaturationAdjustmentOrange>
|
||||||
|
<crs:SaturationAdjustmentYellow>0</crs:SaturationAdjustmentYellow>
|
||||||
|
<crs:SaturationAdjustmentGreen>0</crs:SaturationAdjustmentGreen>
|
||||||
|
<crs:SaturationAdjustmentAqua>0</crs:SaturationAdjustmentAqua>
|
||||||
|
<crs:SaturationAdjustmentBlue>0</crs:SaturationAdjustmentBlue>
|
||||||
|
<crs:SaturationAdjustmentPurple>0</crs:SaturationAdjustmentPurple>
|
||||||
|
<crs:SaturationAdjustmentMagenta>0</crs:SaturationAdjustmentMagenta>
|
||||||
|
<crs:LuminanceAdjustmentRed>0</crs:LuminanceAdjustmentRed>
|
||||||
|
<crs:LuminanceAdjustmentOrange>0</crs:LuminanceAdjustmentOrange>
|
||||||
|
<crs:LuminanceAdjustmentYellow>0</crs:LuminanceAdjustmentYellow>
|
||||||
|
<crs:LuminanceAdjustmentGreen>0</crs:LuminanceAdjustmentGreen>
|
||||||
|
<crs:LuminanceAdjustmentAqua>0</crs:LuminanceAdjustmentAqua>
|
||||||
|
<crs:LuminanceAdjustmentBlue>0</crs:LuminanceAdjustmentBlue>
|
||||||
|
<crs:LuminanceAdjustmentPurple>0</crs:LuminanceAdjustmentPurple>
|
||||||
|
<crs:LuminanceAdjustmentMagenta>0</crs:LuminanceAdjustmentMagenta>
|
||||||
|
<crs:SplitToningShadowHue>0</crs:SplitToningShadowHue>
|
||||||
|
<crs:SplitToningShadowSaturation>0</crs:SplitToningShadowSaturation>
|
||||||
|
<crs:SplitToningHighlightHue>0</crs:SplitToningHighlightHue>
|
||||||
|
<crs:SplitToningHighlightSaturation>0</crs:SplitToningHighlightSaturation>
|
||||||
|
<crs:SplitToningBalance>0</crs:SplitToningBalance>
|
||||||
|
<crs:ParametricShadows>0</crs:ParametricShadows>
|
||||||
|
<crs:ParametricDarks>0</crs:ParametricDarks>
|
||||||
|
<crs:ParametricLights>0</crs:ParametricLights>
|
||||||
|
<crs:ParametricHighlights>0</crs:ParametricHighlights>
|
||||||
|
<crs:ParametricShadowSplit>25</crs:ParametricShadowSplit>
|
||||||
|
<crs:ParametricMidtoneSplit>50</crs:ParametricMidtoneSplit>
|
||||||
|
<crs:ParametricHighlightSplit>75</crs:ParametricHighlightSplit>
|
||||||
|
<crs:SharpenRadius>+1.0</crs:SharpenRadius>
|
||||||
|
<crs:SharpenDetail>25</crs:SharpenDetail>
|
||||||
|
<crs:SharpenEdgeMasking>0</crs:SharpenEdgeMasking>
|
||||||
|
<crs:ConvertToGrayscale>False</crs:ConvertToGrayscale>
|
||||||
|
<crs:ToneCurveName>Medium Contrast</crs:ToneCurveName>
|
||||||
|
<crs:ToneCurve>
|
||||||
|
<rdf:Seq>
|
||||||
|
<rdf:li>0, 0</rdf:li>
|
||||||
|
<rdf:li>32, 22</rdf:li>
|
||||||
|
<rdf:li>64, 56</rdf:li>
|
||||||
|
<rdf:li>128, 128</rdf:li>
|
||||||
|
<rdf:li>192, 196</rdf:li>
|
||||||
|
<rdf:li>255, 255</rdf:li>
|
||||||
|
</rdf:Seq>
|
||||||
|
</crs:ToneCurve>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:crx="http://ns.adobe.com/lightroom-settings-experimental/1.0/">
|
||||||
|
<crx:ConvertToGrayscale>false</crx:ConvertToGrayscale>
|
||||||
|
<crx:SplitToningHighlightHue>0</crx:SplitToningHighlightHue>
|
||||||
|
<crx:Sharpness>25</crx:Sharpness>
|
||||||
|
<crx:CropBottom>1</crx:CropBottom>
|
||||||
|
<crx:GreenSaturation>0</crx:GreenSaturation>
|
||||||
|
<crx:Exposure>0</crx:Exposure>
|
||||||
|
<crx:LuminanceAdjustmentGreens>0</crx:LuminanceAdjustmentGreens>
|
||||||
|
<crx:SplitToningShadowHue>0</crx:SplitToningShadowHue>
|
||||||
|
<crx:BlueHue>0</crx:BlueHue>
|
||||||
|
<crx:GreenHue>0</crx:GreenHue>
|
||||||
|
<crx:FillLight>0</crx:FillLight>
|
||||||
|
<crx:HueAdjustmentCyans>0</crx:HueAdjustmentCyans>
|
||||||
|
<crx:SaturationAdjustmentGreens>0</crx:SaturationAdjustmentGreens>
|
||||||
|
<crx:Saturation>0</crx:Saturation>
|
||||||
|
<crx:SaturationAdjustmentBlues>0</crx:SaturationAdjustmentBlues>
|
||||||
|
<crx:VignetteMidpoint>50</crx:VignetteMidpoint>
|
||||||
|
<crx:ToneHighlightSplit>75</crx:ToneHighlightSplit>
|
||||||
|
<crx:ToneShadowSplit>25</crx:ToneShadowSplit>
|
||||||
|
<crx:Contrast>25</crx:Contrast>
|
||||||
|
<crx:WhiteBalance>As Shot</crx:WhiteBalance>
|
||||||
|
<crx:HueAdjustmentMagentas>0</crx:HueAdjustmentMagentas>
|
||||||
|
<crx:HighlightRecovery>0</crx:HighlightRecovery>
|
||||||
|
<crx:SaturationAdjustmentCyans>0</crx:SaturationAdjustmentCyans>
|
||||||
|
<crx:GrayMixerYellows>100</crx:GrayMixerYellows>
|
||||||
|
<crx:HueAdjustmentGreens>0</crx:HueAdjustmentGreens>
|
||||||
|
<crx:ToneShadows>0</crx:ToneShadows>
|
||||||
|
<crx:GrayMixerGreens>71</crx:GrayMixerGreens>
|
||||||
|
<crx:GrayMixerBlues>0</crx:GrayMixerBlues>
|
||||||
|
<crx:ColorNoiseReduction>25</crx:ColorNoiseReduction>
|
||||||
|
<crx:ShadowTint>0</crx:ShadowTint>
|
||||||
|
<crx:Shadows>5</crx:Shadows>
|
||||||
|
<crx:RedHue>0</crx:RedHue>
|
||||||
|
<crx:Brightness>50</crx:Brightness>
|
||||||
|
<crx:BlueSaturation>0</crx:BlueSaturation>
|
||||||
|
<crx:CropTop>0</crx:CropTop>
|
||||||
|
<crx:SaturationAdjustmentMagentas>0</crx:SaturationAdjustmentMagentas>
|
||||||
|
<crx:GrayMixerReds>29</crx:GrayMixerReds>
|
||||||
|
<crx:AutoBrightness>false</crx:AutoBrightness>
|
||||||
|
<crx:AutoTonality>false</crx:AutoTonality>
|
||||||
|
<crx:AutoExposure>false</crx:AutoExposure>
|
||||||
|
<crx:RedSaturation>0</crx:RedSaturation>
|
||||||
|
<crx:LuminanceAdjustmentMagentas>0</crx:LuminanceAdjustmentMagentas>
|
||||||
|
<crx:LuminanceAdjustmentBlues>0</crx:LuminanceAdjustmentBlues>
|
||||||
|
<crx:HueAdjustmentBlues>0</crx:HueAdjustmentBlues>
|
||||||
|
<crx:SaturationAdjustmentReds>0</crx:SaturationAdjustmentReds>
|
||||||
|
<crx:LuminanceAdjustmentYellows>0</crx:LuminanceAdjustmentYellows>
|
||||||
|
<crx:SplitToningShadowSaturation>0</crx:SplitToningShadowSaturation>
|
||||||
|
<crx:ChromaticAberrationR>0</crx:ChromaticAberrationR>
|
||||||
|
<crx:LuminanceAdjustmentCyans>0</crx:LuminanceAdjustmentCyans>
|
||||||
|
<crx:CropAngle>0</crx:CropAngle>
|
||||||
|
<crx:ChromaticAberrationB>0</crx:ChromaticAberrationB>
|
||||||
|
<crx:AutoShadows>false</crx:AutoShadows>
|
||||||
|
<crx:CropRight>1</crx:CropRight>
|
||||||
|
<crx:ToneLights>0</crx:ToneLights>
|
||||||
|
<crx:HueAdjustmentReds>0</crx:HueAdjustmentReds>
|
||||||
|
<crx:Vibrance>0</crx:Vibrance>
|
||||||
|
<crx:ToneDarks>0</crx:ToneDarks>
|
||||||
|
<crx:GrayMixerMagentas>29</crx:GrayMixerMagentas>
|
||||||
|
<crx:LuminanceSmoothing>0</crx:LuminanceSmoothing>
|
||||||
|
<crx:SplitToningHighlightSaturation>0</crx:SplitToningHighlightSaturation>
|
||||||
|
<crx:HueAdjustmentYellows>0</crx:HueAdjustmentYellows>
|
||||||
|
<crx:GrayMixerCyans>71</crx:GrayMixerCyans>
|
||||||
|
<crx:ToneMidtoneSplit>50</crx:ToneMidtoneSplit>
|
||||||
|
<crx:VignetteAmount>0</crx:VignetteAmount>
|
||||||
|
<crx:AutoContrast>false</crx:AutoContrast>
|
||||||
|
<crx:CropLeft>0</crx:CropLeft>
|
||||||
|
<crx:ToneHighlights>0</crx:ToneHighlights>
|
||||||
|
<crx:AutoGrayscaleWeights>true</crx:AutoGrayscaleWeights>
|
||||||
|
<crx:SaturationAdjustmentYellows>0</crx:SaturationAdjustmentYellows>
|
||||||
|
<crx:LuminanceAdjustmentReds>0</crx:LuminanceAdjustmentReds>
|
||||||
|
<crx:Tint>1</crx:Tint>
|
||||||
|
<crx:Temperature>4350</crx:Temperature>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:lr="http://ns.adobe.com/lightroom/1.0/">
|
||||||
|
<lr:hierarchicalKeywords>aGllcmFyY2hpY2FsS2V5d29yZHMgPSB7Cgl7CgkJZmxhdCA9IHsKCQkJIm5pZ2h0IiwKCQl9LAoJCXBhdGggPSB7CgkJCSJuaWdodCIsCgkJfSwKCQlwcmltYXJ5ID0gIm5pZ2h0IiwKCQl1dWlkID0gIkU1RDEwQTFELTU3QUYtMTFEQi04RTMzLTAwMEQ5MzVDODY5QSIsCgl9LAoJewoJCWZsYXQgPSB7CgkJCSJvbnRhcmlvIiwKCQkJIm90dGF3YSIsCgkJfSwKCQlwYXRoID0gewoJCQkib250YXJpbyIsCgkJCSJvdHRhd2EiLAoJCX0sCgkJcHJpbWFyeSA9ICJvdHRhd2EiLAoJCXV1aWQgPSAiQjgzMTc4RkItNTdBRi0xMURCLThFMzMtMDAwRDkzNUM4NjlBIiwKCX0sCgl7CgkJZmxhdCA9IHsKCQkJInBhcmxpYW1lbnQgb2YgY2FuYWRhIiwKCQkJIm9udGFyaW8iLAoJCQkib3R0YXdhIiwKCQl9LAoJCXBhdGggPSB7CgkJCSJvbnRhcmlvIiwKCQkJIm90dGF3YSIsCgkJCSJwYXJsaWFtZW50IG9mIGNhbmFkYSIsCgkJfSwKCQlwcmltYXJ5ID0gInBhcmxpYW1lbnQgb2YgY2FuYWRhIiwKCQl1dWlkID0gIkU1RDMzMEZDLTU3QUYtMTFEQi04RTMzLTAwMEQ5MzVDODY5QSIsCgl9LAp9Cg==</lr:hierarchicalKeywords>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:xmpTPg="http://ns.adobe.com/xap/1.0/t/pg/">
|
||||||
|
<xmpTPg:MaxPageSize>
|
||||||
|
<rdf:Description
|
||||||
|
xmlns:stDim="http:ns.adobe.com/xap/1.0/sType/Dimensions#">
|
||||||
|
<stDim:w>4</stDim:w>
|
||||||
|
<stDim:h>3</stDim:h>
|
||||||
|
<stDim:unit>inches</stDim:unit>
|
||||||
|
</rdf:Description>
|
||||||
|
</xmpTPg:MaxPageSize>
|
||||||
|
</rdf:Description>
|
||||||
|
<rdf:Description rdf:about=""
|
||||||
|
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
|
||||||
|
<Iptc4xmpCore:Location>Parliament Hill, Ottawa, Ontario, Canada</Iptc4xmpCore:Location>
|
||||||
|
</rdf:Description>
|
||||||
|
</rdf:RDF>
|
||||||
|
</x:xmpmeta>
|
69
tests/exempi/exempi/tests/testcpp.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* exempi - testcpp.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp++.hpp"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
int test_main(int /*argc*/, char* /*argv*/ [])
|
||||||
|
{
|
||||||
|
// this test is totally useless without leak checking.
|
||||||
|
// but for compiling.
|
||||||
|
{
|
||||||
|
xmp::ScopedPtr<XmpStringPtr> ptr(xmp_string_new());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
xmp::ScopedPtr<XmpFilePtr> ptr(xmp_files_new());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
xmp::ScopedPtr<XmpPtr> ptr(xmp_new_empty());
|
||||||
|
{
|
||||||
|
xmp::ScopedPtr<XmpIteratorPtr> iterptr(
|
||||||
|
xmp_iterator_new(ptr, NS_EXIF, NULL, XMP_ITER_JUSTLEAFNODES));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
96
tests/exempi/exempi/tests/testinit.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* exempi - testinit.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
|
||||||
|
// void test_exempi_init()
|
||||||
|
int test_main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
prepare_test(argc, argv, "test1.xmp");
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
char* buffer;
|
||||||
|
|
||||||
|
FILE* f = fopen(g_testfile.c_str(), "rb");
|
||||||
|
|
||||||
|
BOOST_CHECK(f != NULL);
|
||||||
|
if (f == NULL) {
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
buffer = (char*)malloc(len + 1);
|
||||||
|
size_t rlen = fread(buffer, 1, len, f);
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
BOOST_CHECK(rlen == len);
|
||||||
|
BOOST_CHECK(len != 0);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
BOOST_CHECK(xmp_parse(xmp, buffer, len));
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
xmp = xmp_new_empty();
|
||||||
|
BOOST_CHECK(xmp_parse(xmp, buffer, len));
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
77
tests/exempi/exempi/tests/testparse.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* exempi - test3.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2017 Hubert Figuiere
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <boost/test/minimal.hpp>
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xmp.h"
|
||||||
|
#include "xmpconsts.h"
|
||||||
|
|
||||||
|
using boost::unit_test::test_suite;
|
||||||
|
|
||||||
|
// void test_exempi_iterate()
|
||||||
|
int test_main(int, char *[])
|
||||||
|
{
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
buffer = strdup("This is not even XML");
|
||||||
|
size_t len = strlen(buffer);
|
||||||
|
|
||||||
|
BOOST_CHECK(len != 0);
|
||||||
|
BOOST_CHECK(xmp_init());
|
||||||
|
|
||||||
|
XmpPtr xmp = xmp_new_empty();
|
||||||
|
|
||||||
|
BOOST_CHECK(!xmp_parse(xmp, buffer, len));
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp != NULL);
|
||||||
|
|
||||||
|
BOOST_CHECK(xmp_free(xmp));
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
xmp_terminate();
|
||||||
|
|
||||||
|
BOOST_CHECK(!g_lt->check_leaks());
|
||||||
|
BOOST_CHECK(!g_lt->check_errors());
|
||||||
|
return 0;
|
||||||
|
}
|
119
tests/exempi/exempi/tests/utils.cpp
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* exempi - utils.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2016 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
std::string g_testfile;
|
||||||
|
std::string g_src_testdir;
|
||||||
|
std::unique_ptr<LeakTracker> g_lt(new LeakTracker) ;
|
||||||
|
|
||||||
|
void prepare_test(int argc, char *argv[], const char *filename)
|
||||||
|
{
|
||||||
|
if (argc == 1) {
|
||||||
|
// no argument, lets run like we are in "check"
|
||||||
|
const char *srcdir = getenv("TEST_DIR");
|
||||||
|
|
||||||
|
BOOST_ASSERT(srcdir != NULL);
|
||||||
|
g_src_testdir = std::string(srcdir) + "/";
|
||||||
|
g_testfile = g_src_testdir + filename;
|
||||||
|
} else {
|
||||||
|
g_src_testdir = "./";
|
||||||
|
g_testfile = argv[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool copy_file(const std::string &source, const std::string &dest)
|
||||||
|
{
|
||||||
|
std::string command = "cp ";
|
||||||
|
command += source + " " + dest;
|
||||||
|
return (system(command.c_str()) >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
||||||
|
#include <valgrind/memcheck.h>
|
||||||
|
#include <valgrind/valgrind.h>
|
||||||
|
#define CC_EXTENSION __extension__
|
||||||
|
#else
|
||||||
|
#define VALGRIND_COUNT_ERRORS 0
|
||||||
|
#define VALGRIND_DO_LEAK_CHECK
|
||||||
|
#define VALGRIND_COUNT_LEAKS(a, b, c, d) (a = b = c = d = 0)
|
||||||
|
#define CC_EXTENSION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LeakTracker::LeakTracker()
|
||||||
|
: m_leaks(0), m_dubious(0), m_reachable(0), m_suppressed(0), m_errors(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LeakTracker::~LeakTracker()
|
||||||
|
{
|
||||||
|
printf("LeakTracker: leaked = %d, errors = %d\n", m_leaks, m_errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LeakTracker::check_leaks()
|
||||||
|
{
|
||||||
|
int leaked = 0;
|
||||||
|
int dubious = 0;
|
||||||
|
int reachable = 0;
|
||||||
|
int suppressed = 0;
|
||||||
|
|
||||||
|
VALGRIND_DO_LEAK_CHECK;
|
||||||
|
VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed);
|
||||||
|
printf("memleaks: sure:%d dubious:%d reachable:%d suppress:%d\n", leaked,
|
||||||
|
dubious, reachable, suppressed);
|
||||||
|
bool has_leaks = (m_leaks != leaked);
|
||||||
|
|
||||||
|
m_leaks = leaked;
|
||||||
|
m_dubious = dubious;
|
||||||
|
m_reachable = reachable;
|
||||||
|
m_suppressed = suppressed;
|
||||||
|
|
||||||
|
return has_leaks;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LeakTracker::check_errors()
|
||||||
|
{
|
||||||
|
int errors = (int)(CC_EXTENSION VALGRIND_COUNT_ERRORS);
|
||||||
|
bool has_new_errors = (m_errors != errors);
|
||||||
|
m_errors = errors;
|
||||||
|
return has_new_errors;
|
||||||
|
}
|
69
tests/exempi/exempi/tests/utils.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* exempi - utils.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2010 Hubert Figuiere
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1 Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2 Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3 Neither the name of the Authors, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software wit hout specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TEST_UTILS_H__
|
||||||
|
#define __TEST_UTILS_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
extern std::string g_testfile;
|
||||||
|
extern std::string g_src_testdir;
|
||||||
|
|
||||||
|
void prepare_test(int argc, char* argv[], const char* filename);
|
||||||
|
|
||||||
|
bool copy_file(const std::string& source, const std::string& dest);
|
||||||
|
|
||||||
|
class LeakTracker {
|
||||||
|
public:
|
||||||
|
LeakTracker();
|
||||||
|
~LeakTracker();
|
||||||
|
/** return false if there is NO leak. Will print on stdout */
|
||||||
|
int check_leaks();
|
||||||
|
int check_errors();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_leaks;
|
||||||
|
int m_dubious;
|
||||||
|
int m_reachable;
|
||||||
|
int m_suppressed;
|
||||||
|
int m_errors;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern std::unique_ptr<LeakTracker> g_lt;
|
||||||
|
|
||||||
|
#endif
|
67
tests/exempi/m4/ax_append_compile_flags.m4
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
|
||||||
|
# flag. If it does, the flag is added FLAGS-VARIABLE
|
||||||
|
#
|
||||||
|
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
|
||||||
|
# CFLAGS) is used. During the check the flag is always added to the
|
||||||
|
# current language's flags.
|
||||||
|
#
|
||||||
|
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||||
|
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||||
|
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||||
|
# force the compiler to issue an error when a bad flag is given.
|
||||||
|
#
|
||||||
|
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
||||||
|
#
|
||||||
|
# NOTE: This macro depends on the AX_APPEND_FLAG and
|
||||||
|
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
|
||||||
|
# AX_APPEND_LINK_FLAGS.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||||
|
# modified version of the Autoconf Macro, you may extend this special
|
||||||
|
# exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
#serial 5
|
||||||
|
|
||||||
|
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
|
||||||
|
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
|
||||||
|
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
|
||||||
|
for flag in $1; do
|
||||||
|
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
|
||||||
|
done
|
||||||
|
])dnl AX_APPEND_COMPILE_FLAGS
|
71
tests/exempi/m4/ax_append_flag.m4
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
|
||||||
|
# added in between.
|
||||||
|
#
|
||||||
|
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
|
||||||
|
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
|
||||||
|
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
|
||||||
|
# FLAG.
|
||||||
|
#
|
||||||
|
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||||
|
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||||
|
# modified version of the Autoconf Macro, you may extend this special
|
||||||
|
# exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
#serial 6
|
||||||
|
|
||||||
|
AC_DEFUN([AX_APPEND_FLAG],
|
||||||
|
[dnl
|
||||||
|
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
|
||||||
|
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
|
||||||
|
AS_VAR_SET_IF(FLAGS,[
|
||||||
|
AS_CASE([" AS_VAR_GET(FLAGS) "],
|
||||||
|
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
|
||||||
|
[
|
||||||
|
AS_VAR_APPEND(FLAGS,[" $1"])
|
||||||
|
AC_RUN_LOG([: FLAGS="$FLAGS"])
|
||||||
|
])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AS_VAR_SET(FLAGS,[$1])
|
||||||
|
AC_RUN_LOG([: FLAGS="$FLAGS"])
|
||||||
|
])
|
||||||
|
AS_VAR_POPDEF([FLAGS])dnl
|
||||||
|
])dnl AX_APPEND_FLAG
|
230
tests/exempi/m4/ax_cflags_gcc_option.m4
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
##### http://autoconf-archive.cryp.to/ax_cflags_gcc_option.html
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
|
||||||
|
# "checking CFLAGS for gcc -fvomit-frame ... yes" and adds the
|
||||||
|
# optionflag to CFLAGS if it is understood. You can override the
|
||||||
|
# shellvar-default of CFLAGS of course. The order of arguments stems
|
||||||
|
# from the explicit macros like AX_CFLAGS_WARN_ALL.
|
||||||
|
#
|
||||||
|
# The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add
|
||||||
|
# to CXXFLAGS - and it uses the autoconf setup for C++ instead of C
|
||||||
|
# (since it is possible to use different compilers for C and C++).
|
||||||
|
#
|
||||||
|
# The macro is a lot simpler than any special AX_CFLAGS_* macro (or
|
||||||
|
# ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
|
||||||
|
# However, if you use this macro in a few places, it would be great
|
||||||
|
# if you would make up a new function-macro and submit it to the
|
||||||
|
# ac-archive.
|
||||||
|
#
|
||||||
|
# - $1 option-to-check-for : required ("-option" as non-value)
|
||||||
|
# - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case)
|
||||||
|
# - $3 action-if-found : add value to shellvariable
|
||||||
|
# - $4 action-if-not-found : nothing
|
||||||
|
#
|
||||||
|
# note: in earlier versions, $1-$2 were swapped. We try to detect the
|
||||||
|
# situation and accept a $2=~/-/ as being the old
|
||||||
|
# option-to-check-for.
|
||||||
|
#
|
||||||
|
# also: there are other variants that emerged from the original macro
|
||||||
|
# variant which did just test an option to be possibly added.
|
||||||
|
# However, some compilers accept an option silently, or possibly for
|
||||||
|
# just another option that was not intended. Therefore, we have to do
|
||||||
|
# a generic test for a compiler family. For gcc we check "-pedantic"
|
||||||
|
# being accepted which is also understood by compilers who just want
|
||||||
|
# to be compatible with gcc even when not being made from gcc
|
||||||
|
# sources.
|
||||||
|
#
|
||||||
|
# see also:
|
||||||
|
#
|
||||||
|
# AX_CFLAGS_SUN_OPTION AX_CFLAGS_HPUX_OPTION
|
||||||
|
# AX_CFLAGS_AIX_OPTION AX_CFLAGS_IRIX_OPTION
|
||||||
|
#
|
||||||
|
# LAST MODIFICATION
|
||||||
|
#
|
||||||
|
# 2006-12-12
|
||||||
|
#
|
||||||
|
# COPYLEFT
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006 Guido U. Draheim <guidod@gmx.de>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright
|
||||||
|
# owner gives unlimited permission to copy, distribute and modify the
|
||||||
|
# configure scripts that are the output of Autoconf when processing
|
||||||
|
# the Macro. You need not follow the terms of the GNU General Public
|
||||||
|
# License when using or distributing such scripts, even though
|
||||||
|
# portions of the text of the Macro appear in them. The GNU General
|
||||||
|
# Public License (GPL) does govern all other use of the material that
|
||||||
|
# constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the
|
||||||
|
# Autoconf Macro released by the Autoconf Macro Archive. When you
|
||||||
|
# make and distribute a modified version of the Autoconf Macro, you
|
||||||
|
# may extend this special exception to the GPL to apply to your
|
||||||
|
# modified version as well.
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
|
||||||
|
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||||
|
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
|
||||||
|
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
|
||||||
|
VAR,[VAR="no, unknown"
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_C
|
||||||
|
ac_save_[]FLAGS="$[]FLAGS"
|
||||||
|
for ac_arg dnl
|
||||||
|
in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC
|
||||||
|
"-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC
|
||||||
|
#
|
||||||
|
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||||
|
AC_TRY_COMPILE([],[return 0;],
|
||||||
|
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||||
|
done
|
||||||
|
FLAGS="$ac_save_[]FLAGS"
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])
|
||||||
|
case ".$VAR" in
|
||||||
|
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||||
|
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||||
|
*) m4_ifvaln($3,$3,[
|
||||||
|
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||||
|
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||||
|
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||||
|
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||||
|
fi ]) ;;
|
||||||
|
esac
|
||||||
|
AS_VAR_POPDEF([VAR])dnl
|
||||||
|
AS_VAR_POPDEF([FLAGS])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl the only difference - the LANG selection... and the default FLAGS
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
|
||||||
|
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||||
|
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
|
||||||
|
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
|
||||||
|
VAR,[VAR="no, unknown"
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_CPLUSPLUS
|
||||||
|
ac_save_[]FLAGS="$[]FLAGS"
|
||||||
|
for ac_arg dnl
|
||||||
|
in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC
|
||||||
|
"-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC
|
||||||
|
#
|
||||||
|
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||||
|
AC_TRY_COMPILE([],[return 0;],
|
||||||
|
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||||
|
done
|
||||||
|
FLAGS="$ac_save_[]FLAGS"
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])
|
||||||
|
case ".$VAR" in
|
||||||
|
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||||
|
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||||
|
*) m4_ifvaln($3,$3,[
|
||||||
|
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||||
|
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
|
||||||
|
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
|
||||||
|
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
|
||||||
|
fi ]) ;;
|
||||||
|
esac
|
||||||
|
AS_VAR_POPDEF([VAR])dnl
|
||||||
|
AS_VAR_POPDEF([FLAGS])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
|
||||||
|
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
|
||||||
|
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
|
||||||
|
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
|
||||||
|
VAR,[VAR="no, unknown"
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_C
|
||||||
|
ac_save_[]FLAGS="$[]FLAGS"
|
||||||
|
for ac_arg dnl
|
||||||
|
in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
|
||||||
|
"-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
|
||||||
|
#
|
||||||
|
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||||
|
AC_TRY_COMPILE([],[return 0;],
|
||||||
|
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||||
|
done
|
||||||
|
FLAGS="$ac_save_[]FLAGS"
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])
|
||||||
|
case ".$VAR" in
|
||||||
|
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||||
|
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||||
|
*) m4_ifvaln($3,$3,[
|
||||||
|
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||||
|
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
||||||
|
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
||||||
|
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
||||||
|
fi ]) ;;
|
||||||
|
esac
|
||||||
|
AS_VAR_POPDEF([VAR])dnl
|
||||||
|
AS_VAR_POPDEF([FLAGS])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl the only difference - the LANG selection... and the default FLAGS
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
|
||||||
|
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
|
||||||
|
AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
|
||||||
|
AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
|
||||||
|
VAR,[VAR="no, unknown"
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_CPLUSPLUS
|
||||||
|
ac_save_[]FLAGS="$[]FLAGS"
|
||||||
|
for ac_arg dnl
|
||||||
|
in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
|
||||||
|
"-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
|
||||||
|
#
|
||||||
|
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
|
||||||
|
AC_TRY_COMPILE([],[return 0;],
|
||||||
|
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
|
||||||
|
done
|
||||||
|
FLAGS="$ac_save_[]FLAGS"
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])
|
||||||
|
case ".$VAR" in
|
||||||
|
.ok|.ok,*) m4_ifvaln($3,$3) ;;
|
||||||
|
.|.no|.no,*) m4_ifvaln($4,$4) ;;
|
||||||
|
*) m4_ifvaln($3,$3,[
|
||||||
|
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
|
||||||
|
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
|
||||||
|
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
|
||||||
|
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
|
||||||
|
fi ]) ;;
|
||||||
|
esac
|
||||||
|
AS_VAR_POPDEF([VAR])dnl
|
||||||
|
AS_VAR_POPDEF([FLAGS])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
|
||||||
|
[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
|
||||||
|
[AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])
|
74
tests/exempi/m4/ax_check_compile_flag.m4
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check whether the given FLAG works with the current language's compiler
|
||||||
|
# or gives an error. (Warnings, however, are ignored)
|
||||||
|
#
|
||||||
|
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||||
|
# success/failure.
|
||||||
|
#
|
||||||
|
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||||
|
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||||
|
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||||
|
# force the compiler to issue an error when a bad flag is given.
|
||||||
|
#
|
||||||
|
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
||||||
|
#
|
||||||
|
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
|
||||||
|
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||||
|
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||||
|
# modified version of the Autoconf Macro, you may extend this special
|
||||||
|
# exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
#serial 4
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
||||||
|
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
||||||
|
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||||
|
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||||
|
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
|
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||||
|
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
|
||||||
|
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||||
|
[AS_VAR_SET(CACHEVAR,[no])])
|
||||||
|
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||||
|
AS_VAR_IF(CACHEVAR,yes,
|
||||||
|
[m4_default([$2], :)],
|
||||||
|
[m4_default([$3], :)])
|
||||||
|
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||||
|
])dnl AX_CHECK_COMPILE_FLAGS
|
982
tests/exempi/m4/ax_cxx_compile_stdcxx.m4
Normal file
@ -0,0 +1,982 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check for baseline language coverage in the compiler for the specified
|
||||||
|
# version of the C++ standard. If necessary, add switches to CXX and
|
||||||
|
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
|
||||||
|
# or '14' (for the C++14 standard).
|
||||||
|
#
|
||||||
|
# The second argument, if specified, indicates whether you insist on an
|
||||||
|
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
|
||||||
|
# -std=c++11). If neither is specified, you get whatever works, with
|
||||||
|
# preference for an extended mode.
|
||||||
|
#
|
||||||
|
# The third argument, if specified 'mandatory' or if left unspecified,
|
||||||
|
# indicates that baseline support for the specified C++ standard is
|
||||||
|
# required and that the macro should error out if no mode with that
|
||||||
|
# support is found. If specified 'optional', then configuration proceeds
|
||||||
|
# regardless, after defining HAVE_CXX${VERSION} if and only if a
|
||||||
|
# supporting mode is found.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||||
|
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||||
|
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
|
||||||
|
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
|
||||||
|
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
|
||||||
|
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
#serial 6
|
||||||
|
|
||||||
|
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
||||||
|
dnl (serial version number 13).
|
||||||
|
|
||||||
|
AX_REQUIRE_DEFINED([AC_MSG_WARN])
|
||||||
|
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
|
||||||
|
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
|
||||||
|
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
|
||||||
|
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
|
||||||
|
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
|
||||||
|
m4_if([$2], [], [],
|
||||||
|
[$2], [ext], [],
|
||||||
|
[$2], [noext], [],
|
||||||
|
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
|
||||||
|
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
|
||||||
|
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
|
||||||
|
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
|
||||||
|
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
|
||||||
|
AC_LANG_PUSH([C++])dnl
|
||||||
|
ac_success=no
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
|
||||||
|
ax_cv_cxx_compile_cxx$1,
|
||||||
|
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||||
|
[ax_cv_cxx_compile_cxx$1=yes],
|
||||||
|
[ax_cv_cxx_compile_cxx$1=no])])
|
||||||
|
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
|
||||||
|
ac_success=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
m4_if([$2], [noext], [], [dnl
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
for alternative in ${ax_cxx_compile_alternatives}; do
|
||||||
|
switch="-std=gnu++${alternative}"
|
||||||
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
|
||||||
|
$cachevar,
|
||||||
|
[ac_save_CXX="$CXX"
|
||||||
|
CXX="$CXX $switch"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||||
|
[eval $cachevar=yes],
|
||||||
|
[eval $cachevar=no])
|
||||||
|
CXX="$ac_save_CXX"])
|
||||||
|
if eval test x\$$cachevar = xyes; then
|
||||||
|
CXX="$CXX $switch"
|
||||||
|
if test -n "$CXXCPP" ; then
|
||||||
|
CXXCPP="$CXXCPP $switch"
|
||||||
|
fi
|
||||||
|
ac_success=yes
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi])
|
||||||
|
|
||||||
|
m4_if([$2], [ext], [], [dnl
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
dnl HP's aCC needs +std=c++11 according to:
|
||||||
|
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
|
||||||
|
dnl Cray's crayCC needs "-h std=c++11"
|
||||||
|
for alternative in ${ax_cxx_compile_alternatives}; do
|
||||||
|
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
|
||||||
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
|
||||||
|
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
|
||||||
|
$cachevar,
|
||||||
|
[ac_save_CXX="$CXX"
|
||||||
|
CXX="$CXX $switch"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||||
|
[eval $cachevar=yes],
|
||||||
|
[eval $cachevar=no])
|
||||||
|
CXX="$ac_save_CXX"])
|
||||||
|
if eval test x\$$cachevar = xyes; then
|
||||||
|
CXX="$CXX $switch"
|
||||||
|
if test -n "$CXXCPP" ; then
|
||||||
|
CXXCPP="$CXXCPP $switch"
|
||||||
|
fi
|
||||||
|
ac_success=yes
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if test x$ac_success = xyes; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi])
|
||||||
|
AC_LANG_POP([C++])
|
||||||
|
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test x$ac_success = xno; then
|
||||||
|
HAVE_CXX$1=0
|
||||||
|
AC_MSG_NOTICE([No compiler with C++$1 support was found])
|
||||||
|
else
|
||||||
|
HAVE_CXX$1=1
|
||||||
|
AC_DEFINE(HAVE_CXX$1,1,
|
||||||
|
[define if the compiler supports basic C++$1 syntax])
|
||||||
|
fi
|
||||||
|
AC_SUBST(HAVE_CXX$1)
|
||||||
|
m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Test body for checking C++11 support
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
|
||||||
|
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
dnl Test body for checking C++14 support
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
|
||||||
|
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||||
|
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
|
||||||
|
)
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
|
||||||
|
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||||
|
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
|
||||||
|
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
|
||||||
|
)
|
||||||
|
|
||||||
|
dnl Tests for new features in C++11
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
|
||||||
|
|
||||||
|
// If the compiler admits that it is not ready for C++11, why torture it?
|
||||||
|
// Hopefully, this will speed up the test.
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
|
#elif __cplusplus < 201103L
|
||||||
|
|
||||||
|
#error "This is not a C++11 compiler"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace cxx11
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace test_static_assert
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct check
|
||||||
|
{
|
||||||
|
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_final_override
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Base
|
||||||
|
{
|
||||||
|
virtual void f() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Derived : public Base
|
||||||
|
{
|
||||||
|
virtual void f() override {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_double_right_angle_brackets
|
||||||
|
{
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
struct check {};
|
||||||
|
|
||||||
|
typedef check<void> single_type;
|
||||||
|
typedef check<check<void>> double_type;
|
||||||
|
typedef check<check<check<void>>> triple_type;
|
||||||
|
typedef check<check<check<check<void>>>> quadruple_type;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_decltype
|
||||||
|
{
|
||||||
|
|
||||||
|
int
|
||||||
|
f()
|
||||||
|
{
|
||||||
|
int a = 1;
|
||||||
|
decltype(a) b = 2;
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_type_deduction
|
||||||
|
{
|
||||||
|
|
||||||
|
template < typename T1, typename T2 >
|
||||||
|
struct is_same
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
struct is_same<T, T>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T1, typename T2 >
|
||||||
|
auto
|
||||||
|
add(T1 a1, T2 a2) -> decltype(a1 + a2)
|
||||||
|
{
|
||||||
|
return a1 + a2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test(const int c, volatile int v)
|
||||||
|
{
|
||||||
|
static_assert(is_same<int, decltype(0)>::value == true, "");
|
||||||
|
static_assert(is_same<int, decltype(c)>::value == false, "");
|
||||||
|
static_assert(is_same<int, decltype(v)>::value == false, "");
|
||||||
|
auto ac = c;
|
||||||
|
auto av = v;
|
||||||
|
auto sumi = ac + av + 'x';
|
||||||
|
auto sumf = ac + av + 1.0;
|
||||||
|
static_assert(is_same<int, decltype(ac)>::value == true, "");
|
||||||
|
static_assert(is_same<int, decltype(av)>::value == true, "");
|
||||||
|
static_assert(is_same<int, decltype(sumi)>::value == true, "");
|
||||||
|
static_assert(is_same<int, decltype(sumf)>::value == false, "");
|
||||||
|
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
|
||||||
|
return (sumf > 0.0) ? sumi : add(c, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_noexcept
|
||||||
|
{
|
||||||
|
|
||||||
|
int f() { return 0; }
|
||||||
|
int g() noexcept { return 0; }
|
||||||
|
|
||||||
|
static_assert(noexcept(f()) == false, "");
|
||||||
|
static_assert(noexcept(g()) == true, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_constexpr
|
||||||
|
{
|
||||||
|
|
||||||
|
template < typename CharT >
|
||||||
|
unsigned long constexpr
|
||||||
|
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
|
||||||
|
{
|
||||||
|
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename CharT >
|
||||||
|
unsigned long constexpr
|
||||||
|
strlen_c(const CharT *const s) noexcept
|
||||||
|
{
|
||||||
|
return strlen_c_r(s, 0UL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static_assert(strlen_c("") == 0UL, "");
|
||||||
|
static_assert(strlen_c("1") == 1UL, "");
|
||||||
|
static_assert(strlen_c("example") == 7UL, "");
|
||||||
|
static_assert(strlen_c("another\0example") == 7UL, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_rvalue_references
|
||||||
|
{
|
||||||
|
|
||||||
|
template < int N >
|
||||||
|
struct answer
|
||||||
|
{
|
||||||
|
static constexpr int value = N;
|
||||||
|
};
|
||||||
|
|
||||||
|
answer<1> f(int&) { return answer<1>(); }
|
||||||
|
answer<2> f(const int&) { return answer<2>(); }
|
||||||
|
answer<3> f(int&&) { return answer<3>(); }
|
||||||
|
|
||||||
|
void
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
const int c = 0;
|
||||||
|
static_assert(decltype(f(i))::value == 1, "");
|
||||||
|
static_assert(decltype(f(c))::value == 2, "");
|
||||||
|
static_assert(decltype(f(0))::value == 3, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_uniform_initialization
|
||||||
|
{
|
||||||
|
|
||||||
|
struct test
|
||||||
|
{
|
||||||
|
static const int zero {};
|
||||||
|
static const int one {1};
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(test::zero == 0, "");
|
||||||
|
static_assert(test::one == 1, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_lambdas
|
||||||
|
{
|
||||||
|
|
||||||
|
void
|
||||||
|
test1()
|
||||||
|
{
|
||||||
|
auto lambda1 = [](){};
|
||||||
|
auto lambda2 = lambda1;
|
||||||
|
lambda1();
|
||||||
|
lambda2();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test2()
|
||||||
|
{
|
||||||
|
auto a = [](int i, int j){ return i + j; }(1, 2);
|
||||||
|
auto b = []() -> int { return '0'; }();
|
||||||
|
auto c = [=](){ return a + b; }();
|
||||||
|
auto d = [&](){ return c; }();
|
||||||
|
auto e = [a, &b](int x) mutable {
|
||||||
|
const auto identity = [](int y){ return y; };
|
||||||
|
for (auto i = 0; i < a; ++i)
|
||||||
|
a += b--;
|
||||||
|
return x + identity(a + b);
|
||||||
|
}(0);
|
||||||
|
return a + b + c + d + e;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test3()
|
||||||
|
{
|
||||||
|
const auto nullary = [](){ return 0; };
|
||||||
|
const auto unary = [](int x){ return x; };
|
||||||
|
using nullary_t = decltype(nullary);
|
||||||
|
using unary_t = decltype(unary);
|
||||||
|
const auto higher1st = [](nullary_t f){ return f(); };
|
||||||
|
const auto higher2nd = [unary](nullary_t f1){
|
||||||
|
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
|
||||||
|
};
|
||||||
|
return higher1st(nullary) + higher2nd(nullary)(unary);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_variadic_templates
|
||||||
|
{
|
||||||
|
|
||||||
|
template <int...>
|
||||||
|
struct sum;
|
||||||
|
|
||||||
|
template <int N0, int... N1toN>
|
||||||
|
struct sum<N0, N1toN...>
|
||||||
|
{
|
||||||
|
static constexpr auto value = N0 + sum<N1toN...>::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct sum<>
|
||||||
|
{
|
||||||
|
static constexpr auto value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sum<>::value == 0, "");
|
||||||
|
static_assert(sum<1>::value == 1, "");
|
||||||
|
static_assert(sum<23>::value == 23, "");
|
||||||
|
static_assert(sum<1, 2>::value == 3, "");
|
||||||
|
static_assert(sum<5, 5, 11>::value == 21, "");
|
||||||
|
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
|
||||||
|
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
|
||||||
|
// because of this.
|
||||||
|
namespace test_template_alias_sfinae
|
||||||
|
{
|
||||||
|
|
||||||
|
struct foo {};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using member = typename T::member_type;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void func(...) {}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void func(member<T>*) {}
|
||||||
|
|
||||||
|
void test();
|
||||||
|
|
||||||
|
void test() { func<foo>(0); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cxx11
|
||||||
|
|
||||||
|
#endif // __cplusplus >= 201103L
|
||||||
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Tests for new features in C++14
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
|
||||||
|
|
||||||
|
// If the compiler admits that it is not ready for C++14, why torture it?
|
||||||
|
// Hopefully, this will speed up the test.
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
|
#elif __cplusplus < 201402L
|
||||||
|
|
||||||
|
#error "This is not a C++14 compiler"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace cxx14
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace test_polymorphic_lambdas
|
||||||
|
{
|
||||||
|
|
||||||
|
int
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
const auto lambda = [](auto&&... args){
|
||||||
|
const auto istiny = [](auto x){
|
||||||
|
return (sizeof(x) == 1UL) ? 1 : 0;
|
||||||
|
};
|
||||||
|
const int aretiny[] = { istiny(args)... };
|
||||||
|
return aretiny[0];
|
||||||
|
};
|
||||||
|
return lambda(1, 1L, 1.0f, '1');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_binary_literals
|
||||||
|
{
|
||||||
|
|
||||||
|
constexpr auto ivii = 0b0000000000101010;
|
||||||
|
static_assert(ivii == 42, "wrong value");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_generalized_constexpr
|
||||||
|
{
|
||||||
|
|
||||||
|
template < typename CharT >
|
||||||
|
constexpr unsigned long
|
||||||
|
strlen_c(const CharT *const s) noexcept
|
||||||
|
{
|
||||||
|
auto length = 0UL;
|
||||||
|
for (auto p = s; *p; ++p)
|
||||||
|
++length;
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
static_assert(strlen_c("") == 0UL, "");
|
||||||
|
static_assert(strlen_c("x") == 1UL, "");
|
||||||
|
static_assert(strlen_c("test") == 4UL, "");
|
||||||
|
static_assert(strlen_c("another\0test") == 7UL, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_lambda_init_capture
|
||||||
|
{
|
||||||
|
|
||||||
|
int
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
auto x = 0;
|
||||||
|
const auto lambda1 = [a = x](int b){ return a + b; };
|
||||||
|
const auto lambda2 = [a = lambda1(x)](){ return a; };
|
||||||
|
return lambda2();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_digit_separators
|
||||||
|
{
|
||||||
|
|
||||||
|
constexpr auto ten_million = 100'000'000;
|
||||||
|
static_assert(ten_million == 100000000, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_return_type_deduction
|
||||||
|
{
|
||||||
|
|
||||||
|
auto f(int& x) { return x; }
|
||||||
|
decltype(auto) g(int& x) { return x; }
|
||||||
|
|
||||||
|
template < typename T1, typename T2 >
|
||||||
|
struct is_same
|
||||||
|
{
|
||||||
|
static constexpr auto value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
struct is_same<T, T>
|
||||||
|
{
|
||||||
|
static constexpr auto value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
auto x = 0;
|
||||||
|
static_assert(is_same<int, decltype(f(x))>::value, "");
|
||||||
|
static_assert(is_same<int&, decltype(g(x))>::value, "");
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cxx14
|
||||||
|
|
||||||
|
#endif // __cplusplus >= 201402L
|
||||||
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Tests for new features in C++17
|
||||||
|
|
||||||
|
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
|
||||||
|
|
||||||
|
// If the compiler admits that it is not ready for C++17, why torture it?
|
||||||
|
// Hopefully, this will speed up the test.
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
|
#elif __cplusplus <= 201402L
|
||||||
|
|
||||||
|
#error "This is not a C++17 compiler"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define REALLY_CLANG
|
||||||
|
#else
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define REALLY_GCC
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <utility>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace cxx17
|
||||||
|
{
|
||||||
|
|
||||||
|
#if !defined(REALLY_CLANG)
|
||||||
|
namespace test_constexpr_lambdas
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: test it with clang++ from git
|
||||||
|
|
||||||
|
constexpr int foo = [](){return 42;}();
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // !defined(REALLY_CLANG)
|
||||||
|
|
||||||
|
namespace test::nested_namespace::definitions
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_fold_expression
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
int multiply(Args... args)
|
||||||
|
{
|
||||||
|
return (args * ... * 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
bool all(Args... args)
|
||||||
|
{
|
||||||
|
return (args && ...);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_extended_static_assert
|
||||||
|
{
|
||||||
|
|
||||||
|
static_assert (true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_auto_brace_init_list
|
||||||
|
{
|
||||||
|
|
||||||
|
auto foo = {5};
|
||||||
|
auto bar {5};
|
||||||
|
|
||||||
|
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
|
||||||
|
static_assert(std::is_same<int, decltype(bar)>::value);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_typename_in_template_template_parameter
|
||||||
|
{
|
||||||
|
|
||||||
|
template<template<typename> typename X> struct D;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_fallthrough_nodiscard_maybe_unused_attributes
|
||||||
|
{
|
||||||
|
|
||||||
|
int f1()
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int f2()
|
||||||
|
{
|
||||||
|
[[maybe_unused]] auto unused = f1();
|
||||||
|
|
||||||
|
switch (f1())
|
||||||
|
{
|
||||||
|
case 17:
|
||||||
|
f1();
|
||||||
|
[[fallthrough]];
|
||||||
|
case 42:
|
||||||
|
f1();
|
||||||
|
}
|
||||||
|
return f1();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_extended_aggregate_initialization
|
||||||
|
{
|
||||||
|
|
||||||
|
struct base1
|
||||||
|
{
|
||||||
|
int b1, b2 = 42;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct base2
|
||||||
|
{
|
||||||
|
base2() {
|
||||||
|
b3 = 42;
|
||||||
|
}
|
||||||
|
int b3;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct derived : base1, base2
|
||||||
|
{
|
||||||
|
int d;
|
||||||
|
};
|
||||||
|
|
||||||
|
derived d1 {{1, 2}, {}, 4}; // full initialization
|
||||||
|
derived d2 {{}, {}, 4}; // value-initialized bases
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_general_range_based_for_loop
|
||||||
|
{
|
||||||
|
|
||||||
|
struct iter
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
int& operator* ()
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int& operator* () const
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
iter& operator++()
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sentinel
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator== (const iter& i, const sentinel& s)
|
||||||
|
{
|
||||||
|
return i.i == s.i;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!= (const iter& i, const sentinel& s)
|
||||||
|
{
|
||||||
|
return !(i == s);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct range
|
||||||
|
{
|
||||||
|
iter begin() const
|
||||||
|
{
|
||||||
|
return {0};
|
||||||
|
}
|
||||||
|
|
||||||
|
sentinel end() const
|
||||||
|
{
|
||||||
|
return {5};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
range r {};
|
||||||
|
|
||||||
|
for (auto i : r)
|
||||||
|
{
|
||||||
|
[[maybe_unused]] auto v = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_lambda_capture_asterisk_this_by_value
|
||||||
|
{
|
||||||
|
|
||||||
|
struct t
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int foo()
|
||||||
|
{
|
||||||
|
return [*this]()
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_enum_class_construction
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class byte : unsigned char
|
||||||
|
{};
|
||||||
|
|
||||||
|
byte foo {42};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_constexpr_if
|
||||||
|
{
|
||||||
|
|
||||||
|
template <bool cond>
|
||||||
|
int f ()
|
||||||
|
{
|
||||||
|
if constexpr(cond)
|
||||||
|
{
|
||||||
|
return 13;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace test_selection_statement_with_initializer
|
||||||
|
{
|
||||||
|
|
||||||
|
int f()
|
||||||
|
{
|
||||||
|
return 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
int f2()
|
||||||
|
{
|
||||||
|
if (auto i = f(); i > 0)
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (auto i = f(); i + 4)
|
||||||
|
{
|
||||||
|
case 17:
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(REALLY_CLANG)
|
||||||
|
namespace test_template_argument_deduction_for_class_templates
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: test it with clang++ from git
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct pair
|
||||||
|
{
|
||||||
|
pair (T1 p1, T2 p2)
|
||||||
|
: m1 {p1},
|
||||||
|
m2 {p2}
|
||||||
|
{}
|
||||||
|
|
||||||
|
T1 m1;
|
||||||
|
T2 m2;
|
||||||
|
};
|
||||||
|
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
[[maybe_unused]] auto p = pair{13, 42u};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // !defined(REALLY_CLANG)
|
||||||
|
|
||||||
|
namespace test_non_type_auto_template_parameters
|
||||||
|
{
|
||||||
|
|
||||||
|
template <auto n>
|
||||||
|
struct B
|
||||||
|
{};
|
||||||
|
|
||||||
|
B<5> b1;
|
||||||
|
B<'a'> b2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(REALLY_CLANG)
|
||||||
|
namespace test_structured_bindings
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: test it with clang++ from git
|
||||||
|
|
||||||
|
int arr[2] = { 1, 2 };
|
||||||
|
std::pair<int, int> pr = { 1, 2 };
|
||||||
|
|
||||||
|
auto f1() -> int(&)[2]
|
||||||
|
{
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto f2() -> std::pair<int, int>&
|
||||||
|
{
|
||||||
|
return pr;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
int x1 : 2;
|
||||||
|
volatile double y1;
|
||||||
|
};
|
||||||
|
|
||||||
|
S f3()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto [ x1, y1 ] = f1();
|
||||||
|
auto& [ xr1, yr1 ] = f1();
|
||||||
|
auto [ x2, y2 ] = f2();
|
||||||
|
auto& [ xr2, yr2 ] = f2();
|
||||||
|
const auto [ x3, y3 ] = f3();
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // !defined(REALLY_CLANG)
|
||||||
|
|
||||||
|
#if !defined(REALLY_CLANG)
|
||||||
|
namespace test_exception_spec_type_system
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: test it with clang++ from git
|
||||||
|
|
||||||
|
struct Good {};
|
||||||
|
struct Bad {};
|
||||||
|
|
||||||
|
void g1() noexcept;
|
||||||
|
void g2();
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Bad
|
||||||
|
f(T*, T*);
|
||||||
|
|
||||||
|
template<typename T1, typename T2>
|
||||||
|
Good
|
||||||
|
f(T1*, T2*);
|
||||||
|
|
||||||
|
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // !defined(REALLY_CLANG)
|
||||||
|
|
||||||
|
namespace test_inline_variables
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class T> void f(T)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class T> inline T g(T)
|
||||||
|
{
|
||||||
|
return T{};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> inline void f<>(int)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<> int g<>(int)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cxx17
|
||||||
|
|
||||||
|
#endif // __cplusplus <= 201402L
|
||||||
|
|
||||||
|
]])
|
39
tests/exempi/m4/ax_cxx_compile_stdcxx_11.m4
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# ============================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
|
||||||
|
# ============================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check for baseline language coverage in the compiler for the C++11
|
||||||
|
# standard; if necessary, add switches to CXX and CXXCPP to enable
|
||||||
|
# support.
|
||||||
|
#
|
||||||
|
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
|
||||||
|
# macro with the version set to C++11. The two optional arguments are
|
||||||
|
# forwarded literally as the second and third argument respectively.
|
||||||
|
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
|
||||||
|
# more information. If you want to use this macro, you also need to
|
||||||
|
# download the ax_cxx_compile_stdcxx.m4 file.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||||
|
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||||
|
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
|
||||||
|
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
|
||||||
|
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
#serial 17
|
||||||
|
|
||||||
|
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
|
||||||
|
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
|
96
tests/exempi/m4/ax_ld_check_flag.m4
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://autoconf-archive.cryp.to/ax_ld_check_flag.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_LD_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# This macro tests if the C++ compiler supports the flag FLAG-TO-CHECK. If
|
||||||
|
# successfull execute ACTION-IF-SUCCESS otherwise ACTION-IF-FAILURE.
|
||||||
|
# PROLOGUE and BODY are optional and should be used as in AC_LANG_PROGRAM
|
||||||
|
# macro.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#
|
||||||
|
# AX_LD_CHECK_FLAG([-Wl,-L/usr/lib],[],[],[
|
||||||
|
# ...
|
||||||
|
# ],[
|
||||||
|
# ...
|
||||||
|
# ])
|
||||||
|
#
|
||||||
|
# This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
|
||||||
|
# Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes.
|
||||||
|
#
|
||||||
|
# LAST MODIFICATION
|
||||||
|
#
|
||||||
|
# 2008-04-12
|
||||||
|
#
|
||||||
|
# COPYLEFT
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Macro Archive. When you make and
|
||||||
|
# distribute a modified version of the Autoconf Macro, you may extend this
|
||||||
|
# special exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
AC_DEFUN([AX_LD_CHECK_FLAG],[
|
||||||
|
AC_PREREQ([2.61])
|
||||||
|
AC_REQUIRE([AC_PROG_CXX])
|
||||||
|
AC_REQUIRE([AC_PROG_SED])
|
||||||
|
|
||||||
|
flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([whether the linker accepts the $1 flag],
|
||||||
|
[ax_cv_ld_check_flag_$flag],[
|
||||||
|
|
||||||
|
#AC_LANG_PUSH([C])
|
||||||
|
|
||||||
|
save_LDFLAGS="$LDFLAGS"
|
||||||
|
LDFLAGS="$LDFLAGS $1"
|
||||||
|
AC_LINK_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([$2],[$3])
|
||||||
|
],[
|
||||||
|
eval "ax_cv_ld_check_flag_$flag=yes"
|
||||||
|
],[
|
||||||
|
eval "ax_cv_ld_check_flag_$flag=no"
|
||||||
|
])
|
||||||
|
|
||||||
|
LDFLAGS="$save_LDFLAGS"
|
||||||
|
|
||||||
|
#AC_LANG_POP
|
||||||
|
|
||||||
|
])
|
||||||
|
|
||||||
|
AS_IF([eval "test \"`echo '$ax_cv_ld_check_flag_'$flag`\" = yes"],[
|
||||||
|
:
|
||||||
|
$4
|
||||||
|
],[
|
||||||
|
:
|
||||||
|
$5
|
||||||
|
])
|
||||||
|
])
|
37
tests/exempi/m4/ax_require_defined.m4
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_REQUIRE_DEFINED(MACRO)
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
|
||||||
|
# been defined and thus are available for use. This avoids random issues
|
||||||
|
# where a macro isn't expanded. Instead the configure script emits a
|
||||||
|
# non-fatal:
|
||||||
|
#
|
||||||
|
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
|
||||||
|
#
|
||||||
|
# It's like AC_REQUIRE except it doesn't expand the required macro.
|
||||||
|
#
|
||||||
|
# Here's an example:
|
||||||
|
#
|
||||||
|
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
#serial 1
|
||||||
|
|
||||||
|
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
|
||||||
|
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
|
||||||
|
])dnl AX_REQUIRE_DEFINED
|
78
tests/exempi/m4/ax_tls.m4
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://autoconf-archive.cryp.to/ax_tls.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_TLS
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Provides a test for the compiler support of thread local storage (TLS)
|
||||||
|
# extensions. Defines TLS if it is found. Currently only knows about GCC
|
||||||
|
# and MSVC. I think SunPro uses the same as GCC, and Borland apparently
|
||||||
|
# supports either.
|
||||||
|
#
|
||||||
|
# LAST MODIFICATION
|
||||||
|
#
|
||||||
|
# 2008-04-12
|
||||||
|
#
|
||||||
|
# COPYLEFT
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||||
|
# gives unlimited permission to copy, distribute and modify the configure
|
||||||
|
# scripts that are the output of Autoconf when processing the Macro. You
|
||||||
|
# need not follow the terms of the GNU General Public License when using
|
||||||
|
# or distributing such scripts, even though portions of the text of the
|
||||||
|
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||||
|
# all other use of the material that constitutes the Autoconf Macro.
|
||||||
|
#
|
||||||
|
# This special exception to the GPL applies to versions of the Autoconf
|
||||||
|
# Macro released by the Autoconf Macro Archive. When you make and
|
||||||
|
# distribute a modified version of the Autoconf Macro, you may extend this
|
||||||
|
# special exception to the GPL to apply to your modified version as well.
|
||||||
|
|
||||||
|
AC_DEFUN([AX_TLS], [
|
||||||
|
AC_MSG_CHECKING(for thread local storage (TLS) class)
|
||||||
|
AC_CACHE_VAL(ac_cv_tls, [
|
||||||
|
ax_tls_keywords="__thread __declspec(thread) none"
|
||||||
|
for ax_tls_keyword in $ax_tls_keywords; do
|
||||||
|
case $ax_tls_keyword in
|
||||||
|
none) ac_cv_tls=none ; break ;;
|
||||||
|
*)
|
||||||
|
AC_TRY_COMPILE(
|
||||||
|
[#include <stdlib.h>
|
||||||
|
static void
|
||||||
|
foo(void) {
|
||||||
|
static ] $ax_tls_keyword [ int bar;
|
||||||
|
exit(1);
|
||||||
|
}],
|
||||||
|
[],
|
||||||
|
[ac_cv_tls=$ax_tls_keyword ; break],
|
||||||
|
ac_cv_tls=none
|
||||||
|
)
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
])
|
||||||
|
|
||||||
|
if test "$ac_cv_tls" != "none"; then
|
||||||
|
dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here])
|
||||||
|
AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT($ac_cv_tls)
|
||||||
|
])
|
1560
tests/exempi/m4/boost.m4
Normal file
40
tests/exempi/m4/shave.m4
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
dnl Make automake/libtool output more friendly to humans
|
||||||
|
dnl
|
||||||
|
dnl SHAVE_INIT([shavedir])
|
||||||
|
dnl
|
||||||
|
dnl shavedir: the directory where the shave script is, it defaults to
|
||||||
|
dnl $(top_builddir)
|
||||||
|
dnl
|
||||||
|
dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just
|
||||||
|
dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrite CC and
|
||||||
|
dnl LIBTOOL, you don't want the configure tests to have these variables
|
||||||
|
dnl re-defined.
|
||||||
|
dnl * This macro requires GNU make's -s option.
|
||||||
|
|
||||||
|
AC_DEFUN([SHAVE_INIT], [
|
||||||
|
dnl where can we find the shave scripts?
|
||||||
|
m4_if([$1],,
|
||||||
|
[shavedir='$(top_builddir)'],
|
||||||
|
[shavedir='$(top_builddir)'/$1])
|
||||||
|
AC_SUBST(shavedir)
|
||||||
|
dnl make is now quiet
|
||||||
|
AC_SUBST([MAKEFLAGS], [-s])
|
||||||
|
AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
|
||||||
|
dnl we need sed
|
||||||
|
AC_CHECK_PROG(SED,sed,sed,false)
|
||||||
|
dnl substitute libtool
|
||||||
|
SHAVE_SAVED_LIBTOOL=$LIBTOOL
|
||||||
|
AC_SUBST(SHAVE_SAVED_LIBTOOL)
|
||||||
|
LIBTOOL="\$(SHELL) \$(shavedir)/shave-libtool '\$(SHAVE_SAVED_LIBTOOL)'"
|
||||||
|
AC_SUBST(LIBTOOL)
|
||||||
|
dnl substitute cc
|
||||||
|
SHAVE_SAVED_CC=$CC
|
||||||
|
SHAVE_SAVED_CXX=$CXX
|
||||||
|
AC_SUBST(SHAVE_SAVED_CC)
|
||||||
|
AC_SUBST(SHAVE_SAVED_CXX)
|
||||||
|
CC="\$(SHELL) \$(shavedir)/shave cc '\$(SHAVE_SAVED_CC)'"
|
||||||
|
CXX="\$(SHELL) \$(shavedir)/shave cxx '\$(SHAVE_SAVED_CXX)'"
|
||||||
|
AC_SUBST(CC)
|
||||||
|
AC_SUBST(CXX)
|
||||||
|
])
|
||||||
|
|
BIN
tests/exempi/samples/testfiles/BlueSquare-FAIL.gif
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
tests/exempi/samples/testfiles/BlueSquare.ai
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.avi
Executable file
87
tests/exempi/samples/testfiles/BlueSquare.eps
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.gif
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
tests/exempi/samples/testfiles/BlueSquare.indd
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.jpg
Executable file
After Width: | Height: | Size: 24 KiB |
BIN
tests/exempi/samples/testfiles/BlueSquare.mov
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.mp3
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.pdf
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.png
Executable file
After Width: | Height: | Size: 5.9 KiB |
BIN
tests/exempi/samples/testfiles/BlueSquare.psd
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.tif
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.wav
Executable file
BIN
tests/exempi/samples/testfiles/BlueSquare.webp
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
tests/exempi/samples/testfiles/Image1.jpg
Executable file
After Width: | Height: | Size: 2.0 MiB |
BIN
tests/exempi/samples/testfiles/Image2.jpg
Executable file
After Width: | Height: | Size: 2.8 MiB |
19
tests/tests.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
roles:
|
||||||
|
- role: standard-test-beakerlib
|
||||||
|
tags:
|
||||||
|
- atomic
|
||||||
|
- classic
|
||||||
|
- container
|
||||||
|
tests:
|
||||||
|
- upstream-test-suite
|
||||||
|
required_packages:
|
||||||
|
- exempi
|
||||||
|
- exempi-devel
|
||||||
|
- gcc
|
||||||
|
- gcc-c++
|
||||||
|
- make
|
||||||
|
- autoconf
|
||||||
|
- automake
|
||||||
|
- libtool
|
||||||
|
- boost-devel
|
28
tests/upstream-test-suite
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /usr/share/beakerlib/beakerlib.sh
|
||||||
|
|
||||||
|
TEST="/AppStream/exempi/Sanity/upstream-test-suite"
|
||||||
|
|
||||||
|
PACKAGES=${PACKAGES:-"exempi"}
|
||||||
|
REQUIRES=${REQUIRES:-"exempi-devel gcc gcc-c++ make autoconf automake libtool boost-devel"}
|
||||||
|
|
||||||
|
rlJournalStart
|
||||||
|
rlPhaseStartSetup
|
||||||
|
rlAssertRpm --all
|
||||||
|
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||||
|
rlRun "cp -r exempi/* $TmpDir/." 0 "Copying test suite"
|
||||||
|
rlRun "pushd $TmpDir"
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlPhaseStartTest
|
||||||
|
rlRun "autoreconf -f -i && ./configure --prefix=/usr" 0 "Configuring test suite"
|
||||||
|
rlRun "make check" 0 "Running tests"
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlPhaseStartCleanup
|
||||||
|
rlRun "popd"
|
||||||
|
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||||
|
rlPhaseEnd
|
||||||
|
rlJournalPrintText
|
||||||
|
rlJournalEnd
|