summaryrefslogtreecommitdiffstats
path: root/contrib/atf/atf-c++/detail
diff options
context:
space:
mode:
authorjmmv <jmmv@FreeBSD.org>2013-12-29 02:57:10 +0000
committerjmmv <jmmv@FreeBSD.org>2013-12-29 02:57:10 +0000
commit2cc168fb9fc9be682ff4c984b6306ddfe22c033d (patch)
tree65f81fcb32677687d7156f496d0c2c2b05ab505c /contrib/atf/atf-c++/detail
parent17b80845b0ba13495186831d3505af8c20eeb6ac (diff)
downloadFreeBSD-src-2cc168fb9fc9be682ff4c984b6306ddfe22c033d.zip
FreeBSD-src-2cc168fb9fc9be682ff4c984b6306ddfe22c033d.tar.gz
Update atf to 0.18 and remove the code of the deprecated tools.
This is a MFC into stable/10 of: - r258286 Update notes for imports of atf. - r258289 MFV: Import atf-0.18. - r258290 Drop all ATF tools code. This is "make tinderbox" clean as run on ref10-amd64 with the default WITHOUT_TESTS option. A "make buildworld" with WITH_TESTS set now works as well.
Diffstat (limited to 'contrib/atf/atf-c++/detail')
-rw-r--r--contrib/atf/atf-c++/detail/Atffile13
-rw-r--r--contrib/atf/atf-c++/detail/Kyuafile1
-rw-r--r--contrib/atf/atf-c++/detail/Makefile.am.inc99
-rw-r--r--contrib/atf/atf-c++/detail/auto_array.hpp179
-rw-r--r--contrib/atf/atf-c++/detail/auto_array_test.cpp304
-rw-r--r--contrib/atf/atf-c++/detail/parser.hpp6
-rw-r--r--contrib/atf/atf-c++/detail/process.cpp4
-rw-r--r--contrib/atf/atf-c++/detail/process.hpp5
-rw-r--r--contrib/atf/atf-c++/detail/test_helpers.cpp41
-rw-r--r--contrib/atf/atf-c++/detail/test_helpers.hpp2
10 files changed, 491 insertions, 163 deletions
diff --git a/contrib/atf/atf-c++/detail/Atffile b/contrib/atf/atf-c++/detail/Atffile
deleted file mode 100644
index ead6ec3..0000000
--- a/contrib/atf/atf-c++/detail/Atffile
+++ /dev/null
@@ -1,13 +0,0 @@
-Content-Type: application/X-atf-atffile; version="1"
-
-prop: test-suite = atf
-
-tp: application_test
-tp: env_test
-tp: exceptions_test
-tp: expand_test
-tp: fs_test
-tp: parser_test
-tp: sanity_test
-tp: text_test
-tp: ui_test
diff --git a/contrib/atf/atf-c++/detail/Kyuafile b/contrib/atf/atf-c++/detail/Kyuafile
index 472c122..fd0d7ab 100644
--- a/contrib/atf/atf-c++/detail/Kyuafile
+++ b/contrib/atf/atf-c++/detail/Kyuafile
@@ -3,6 +3,7 @@ syntax("kyuafile", 1)
test_suite("atf")
atf_test_program{name="application_test"}
+atf_test_program{name="auto_array_test"}
atf_test_program{name="env_test"}
atf_test_program{name="exceptions_test"}
atf_test_program{name="expand_test"}
diff --git a/contrib/atf/atf-c++/detail/Makefile.am.inc b/contrib/atf/atf-c++/detail/Makefile.am.inc
deleted file mode 100644
index fcadd77..0000000
--- a/contrib/atf/atf-c++/detail/Makefile.am.inc
+++ /dev/null
@@ -1,99 +0,0 @@
-#
-# Automated Testing Framework (atf)
-#
-# Copyright (c) 2007 The NetBSD Foundation, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
-#
-
-libatf_c___la_SOURCES += atf-c++/detail/application.cpp \
- atf-c++/detail/application.hpp \
- atf-c++/detail/env.cpp \
- atf-c++/detail/env.hpp \
- atf-c++/detail/exceptions.cpp \
- atf-c++/detail/exceptions.hpp \
- atf-c++/detail/expand.cpp \
- atf-c++/detail/expand.hpp \
- atf-c++/detail/fs.cpp \
- atf-c++/detail/fs.hpp \
- atf-c++/detail/parser.cpp \
- atf-c++/detail/parser.hpp \
- atf-c++/detail/process.cpp \
- atf-c++/detail/process.hpp \
- atf-c++/detail/sanity.hpp \
- atf-c++/detail/text.cpp \
- atf-c++/detail/text.hpp \
- atf-c++/detail/ui.cpp \
- atf-c++/detail/ui.hpp
-
-tests_atf_c___detail_DATA = atf-c++/detail/Atffile \
- atf-c++/detail/Kyuafile
-tests_atf_c___detaildir = $(pkgtestsdir)/atf-c++/detail
-EXTRA_DIST += $(tests_atf_c___detail_DATA)
-
-noinst_LTLIBRARIES += atf-c++/detail/libtest_helpers.la
-atf_c___detail_libtest_helpers_la_SOURCES = atf-c++/detail/test_helpers.cpp \
- atf-c++/detail/test_helpers.hpp
-
-tests_atf_c___detail_PROGRAMS = atf-c++/detail/application_test
-atf_c___detail_application_test_SOURCES = atf-c++/detail/application_test.cpp
-atf_c___detail_application_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/env_test
-atf_c___detail_env_test_SOURCES = atf-c++/detail/env_test.cpp
-atf_c___detail_env_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/exceptions_test
-atf_c___detail_exceptions_test_SOURCES = atf-c++/detail/exceptions_test.cpp
-atf_c___detail_exceptions_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/expand_test
-atf_c___detail_expand_test_SOURCES = atf-c++/detail/expand_test.cpp
-atf_c___detail_expand_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/fs_test
-atf_c___detail_fs_test_SOURCES = atf-c++/detail/fs_test.cpp
-atf_c___detail_fs_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/parser_test
-atf_c___detail_parser_test_SOURCES = atf-c++/detail/parser_test.cpp
-atf_c___detail_parser_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/process_test
-atf_c___detail_process_test_SOURCES = atf-c++/detail/process_test.cpp
-atf_c___detail_process_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/sanity_test
-atf_c___detail_sanity_test_SOURCES = atf-c++/detail/sanity_test.cpp
-atf_c___detail_sanity_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/text_test
-atf_c___detail_text_test_SOURCES = atf-c++/detail/text_test.cpp
-atf_c___detail_text_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-tests_atf_c___detail_PROGRAMS += atf-c++/detail/ui_test
-atf_c___detail_ui_test_SOURCES = atf-c++/detail/ui_test.cpp
-atf_c___detail_ui_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
-
-# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
diff --git a/contrib/atf/atf-c++/detail/auto_array.hpp b/contrib/atf/atf-c++/detail/auto_array.hpp
new file mode 100644
index 0000000..1459284
--- /dev/null
+++ b/contrib/atf/atf-c++/detail/auto_array.hpp
@@ -0,0 +1,179 @@
+//
+// Automated Testing Framework (atf)
+//
+// Copyright (c) 2007 The NetBSD Foundation, Inc.
+// 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.
+//
+// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+//
+
+#if !defined(_ATF_CXX_AUTO_ARRAY_HPP_)
+#define _ATF_CXX_AUTO_ARRAY_HPP_
+
+#include <cstddef>
+
+namespace atf {
+
+// ------------------------------------------------------------------------
+// The "auto_array" class.
+// ------------------------------------------------------------------------
+
+template< class T >
+struct auto_array_ref {
+ T* m_ptr;
+
+ explicit auto_array_ref(T*);
+};
+
+template< class T >
+auto_array_ref< T >::auto_array_ref(T* ptr) :
+ m_ptr(ptr)
+{
+}
+
+template< class T >
+class auto_array {
+ T* m_ptr;
+
+public:
+ auto_array(T* = NULL) throw();
+ auto_array(auto_array< T >&) throw();
+ auto_array(auto_array_ref< T >) throw();
+ ~auto_array(void) throw();
+
+ T* get(void) throw();
+ const T* get(void) const throw();
+ T* release(void) throw();
+ void reset(T* = NULL) throw();
+
+ auto_array< T >& operator=(auto_array< T >&) throw();
+ auto_array< T >& operator=(auto_array_ref< T >) throw();
+
+ T& operator[](int) throw();
+ operator auto_array_ref< T >(void) throw();
+};
+
+template< class T >
+auto_array< T >::auto_array(T* ptr)
+ throw() :
+ m_ptr(ptr)
+{
+}
+
+template< class T >
+auto_array< T >::auto_array(auto_array< T >& ptr)
+ throw() :
+ m_ptr(ptr.release())
+{
+}
+
+template< class T >
+auto_array< T >::auto_array(auto_array_ref< T > ref)
+ throw() :
+ m_ptr(ref.m_ptr)
+{
+}
+
+template< class T >
+auto_array< T >::~auto_array(void)
+ throw()
+{
+ if (m_ptr != NULL)
+ delete [] m_ptr;
+}
+
+template< class T >
+T*
+auto_array< T >::get(void)
+ throw()
+{
+ return m_ptr;
+}
+
+template< class T >
+const T*
+auto_array< T >::get(void)
+ const throw()
+{
+ return m_ptr;
+}
+
+template< class T >
+T*
+auto_array< T >::release(void)
+ throw()
+{
+ T* ptr = m_ptr;
+ m_ptr = NULL;
+ return ptr;
+}
+
+template< class T >
+void
+auto_array< T >::reset(T* ptr)
+ throw()
+{
+ if (m_ptr != NULL)
+ delete [] m_ptr;
+ m_ptr = ptr;
+}
+
+template< class T >
+auto_array< T >&
+auto_array< T >::operator=(auto_array< T >& ptr)
+ throw()
+{
+ reset(ptr.release());
+ return *this;
+}
+
+template< class T >
+auto_array< T >&
+auto_array< T >::operator=(auto_array_ref< T > ref)
+ throw()
+{
+ if (m_ptr != ref.m_ptr) {
+ delete [] m_ptr;
+ m_ptr = ref.m_ptr;
+ }
+ return *this;
+}
+
+template< class T >
+T&
+auto_array< T >::operator[](int pos)
+ throw()
+{
+ return m_ptr[pos];
+}
+
+template< class T >
+auto_array< T >::operator auto_array_ref< T >(void)
+ throw()
+{
+ return auto_array_ref< T >(release());
+}
+
+} // namespace atf
+
+#endif // !defined(_ATF_CXX_AUTO_ARRAY_HPP_)
diff --git a/contrib/atf/atf-c++/detail/auto_array_test.cpp b/contrib/atf/atf-c++/detail/auto_array_test.cpp
new file mode 100644
index 0000000..dcfe415
--- /dev/null
+++ b/contrib/atf/atf-c++/detail/auto_array_test.cpp
@@ -0,0 +1,304 @@
+//
+// Automated Testing Framework (atf)
+//
+// Copyright (c) 2007 The NetBSD Foundation, Inc.
+// 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.
+//
+// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+//
+
+extern "C" {
+#include <sys/types.h>
+}
+
+#include <iostream>
+
+#include "atf-c/defs.h"
+
+#include "../macros.hpp"
+
+#include "auto_array.hpp"
+
+// ------------------------------------------------------------------------
+// Tests for the "auto_array" class.
+// ------------------------------------------------------------------------
+
+class test_array {
+public:
+ int m_value;
+
+ static ssize_t m_nblocks;
+
+ static
+ atf::auto_array< test_array >
+ do_copy(atf::auto_array< test_array >& ta)
+ {
+ return atf::auto_array< test_array >(ta);
+ }
+
+ void* operator new(size_t size ATF_DEFS_ATTRIBUTE_UNUSED)
+ {
+ ATF_FAIL("New called but should have been new[]");
+ return new int(5);
+ }
+
+ void* operator new[](size_t size)
+ {
+ m_nblocks++;
+ void* mem = ::operator new(size);
+ std::cout << "Allocated 'test_array' object " << mem << "\n";
+ return mem;
+ }
+
+ void operator delete(void* mem ATF_DEFS_ATTRIBUTE_UNUSED)
+ {
+ ATF_FAIL("Delete called but should have been delete[]");
+ }
+
+ void operator delete[](void* mem)
+ {
+ std::cout << "Releasing 'test_array' object " << mem << "\n";
+ if (m_nblocks == 0)
+ ATF_FAIL("Unbalanced delete[]");
+ m_nblocks--;
+ ::operator delete(mem);
+ }
+};
+
+ssize_t test_array::m_nblocks = 0;
+
+ATF_TEST_CASE(auto_array_scope);
+ATF_TEST_CASE_HEAD(auto_array_scope)
+{
+ set_md_var("descr", "Tests the automatic scope handling in the "
+ "auto_array smart pointer class");
+}
+ATF_TEST_CASE_BODY(auto_array_scope)
+{
+ using atf::auto_array;
+
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ {
+ auto_array< test_array > t(new test_array[10]);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_copy);
+ATF_TEST_CASE_HEAD(auto_array_copy)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' copy "
+ "constructor");
+}
+ATF_TEST_CASE_BODY(auto_array_copy)
+{
+ using atf::auto_array;
+
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ {
+ auto_array< test_array > t1(new test_array[10]);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+
+ {
+ auto_array< test_array > t2(t1);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_copy_ref);
+ATF_TEST_CASE_HEAD(auto_array_copy_ref)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' copy "
+ "constructor through the auxiliary auto_array_ref object");
+}
+ATF_TEST_CASE_BODY(auto_array_copy_ref)
+{
+ using atf::auto_array;
+
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ {
+ auto_array< test_array > t1(new test_array[10]);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+
+ {
+ auto_array< test_array > t2 = test_array::do_copy(t1);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_get);
+ATF_TEST_CASE_HEAD(auto_array_get)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' get "
+ "method");
+}
+ATF_TEST_CASE_BODY(auto_array_get)
+{
+ using atf::auto_array;
+
+ test_array* ta = new test_array[10];
+ auto_array< test_array > t(ta);
+ ATF_REQUIRE_EQ(t.get(), ta);
+}
+
+ATF_TEST_CASE(auto_array_release);
+ATF_TEST_CASE_HEAD(auto_array_release)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' release "
+ "method");
+}
+ATF_TEST_CASE_BODY(auto_array_release)
+{
+ using atf::auto_array;
+
+ test_array* ta1 = new test_array[10];
+ {
+ auto_array< test_array > t(ta1);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ test_array* ta2 = t.release();
+ ATF_REQUIRE_EQ(ta2, ta1);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ delete [] ta1;
+}
+
+ATF_TEST_CASE(auto_array_reset);
+ATF_TEST_CASE_HEAD(auto_array_reset)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' reset "
+ "method");
+}
+ATF_TEST_CASE_BODY(auto_array_reset)
+{
+ using atf::auto_array;
+
+ test_array* ta1 = new test_array[10];
+ test_array* ta2 = new test_array[10];
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
+
+ {
+ auto_array< test_array > t(ta1);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
+ t.reset(ta2);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ t.reset();
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_assign);
+ATF_TEST_CASE_HEAD(auto_array_assign)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' "
+ "assignment operator");
+}
+ATF_TEST_CASE_BODY(auto_array_assign)
+{
+ using atf::auto_array;
+
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ {
+ auto_array< test_array > t1(new test_array[10]);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+
+ {
+ auto_array< test_array > t2;
+ t2 = t1;
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_assign_ref);
+ATF_TEST_CASE_HEAD(auto_array_assign_ref)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' "
+ "assignment operator through the auxiliary auto_array_ref "
+ "object");
+}
+ATF_TEST_CASE_BODY(auto_array_assign_ref)
+{
+ using atf::auto_array;
+
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ {
+ auto_array< test_array > t1(new test_array[10]);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+
+ {
+ auto_array< test_array > t2;
+ t2 = test_array::do_copy(t1);
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+ }
+ ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_access);
+ATF_TEST_CASE_HEAD(auto_array_access)
+{
+ set_md_var("descr", "Tests the auto_array smart pointer class' access "
+ "operator");
+}
+ATF_TEST_CASE_BODY(auto_array_access)
+{
+ using atf::auto_array;
+
+ auto_array< test_array > t(new test_array[10]);
+
+ for (int i = 0; i < 10; i++)
+ t[i].m_value = i * 2;
+
+ for (int i = 0; i < 10; i++)
+ ATF_REQUIRE_EQ(t[i].m_value, i * 2);
+}
+
+// ------------------------------------------------------------------------
+// Main.
+// ------------------------------------------------------------------------
+
+ATF_INIT_TEST_CASES(tcs)
+{
+ // Add the test for the "auto_array" class.
+ ATF_ADD_TEST_CASE(tcs, auto_array_scope);
+ ATF_ADD_TEST_CASE(tcs, auto_array_copy);
+ ATF_ADD_TEST_CASE(tcs, auto_array_copy_ref);
+ ATF_ADD_TEST_CASE(tcs, auto_array_get);
+ ATF_ADD_TEST_CASE(tcs, auto_array_release);
+ ATF_ADD_TEST_CASE(tcs, auto_array_reset);
+ ATF_ADD_TEST_CASE(tcs, auto_array_assign);
+ ATF_ADD_TEST_CASE(tcs, auto_array_assign_ref);
+ ATF_ADD_TEST_CASE(tcs, auto_array_access);
+}
diff --git a/contrib/atf/atf-c++/detail/parser.hpp b/contrib/atf/atf-c++/detail/parser.hpp
index f1595f5..f55973f 100644
--- a/contrib/atf/atf-c++/detail/parser.hpp
+++ b/contrib/atf/atf-c++/detail/parser.hpp
@@ -259,7 +259,7 @@ tokenizer< IS >::next(void)
t = token(m_lineno, m_text_type, text);
quoted = true;
} else {
- m_is.unget();
+ m_is.putback(ch);
done = true;
}
} else {
@@ -271,13 +271,13 @@ tokenizer< IS >::next(void)
t = token(m_lineno, (*idelim).second,
std::string("") + ch);
else
- m_is.unget();
+ m_is.putback(ch);
} else if (ch == '\n') {
done = true;
if (text.empty())
t = token(m_lineno, m_nl_type, "<<NEWLINE>>");
else
- m_is.unget();
+ m_is.putback(ch);
} else if (m_skipws && (ch == ' ' || ch == '\t')) {
if (!text.empty())
done = true;
diff --git a/contrib/atf/atf-c++/detail/process.cpp b/contrib/atf/atf-c++/detail/process.cpp
index deb1158..f7ae6d4 100644
--- a/contrib/atf/atf-c++/detail/process.cpp
+++ b/contrib/atf/atf-c++/detail/process.cpp
@@ -50,10 +50,10 @@ namespace impl = atf::process;
// ------------------------------------------------------------------------
template< class C >
-atf::utils::auto_array< const char* >
+atf::auto_array< const char* >
collection_to_argv(const C& c)
{
- atf::utils::auto_array< const char* > argv(new const char*[c.size() + 1]);
+ atf::auto_array< const char* > argv(new const char*[c.size() + 1]);
std::size_t pos = 0;
for (typename C::const_iterator iter = c.begin(); iter != c.end();
diff --git a/contrib/atf/atf-c++/detail/process.hpp b/contrib/atf/atf-c++/detail/process.hpp
index 6e33e00..bc55a57 100644
--- a/contrib/atf/atf-c++/detail/process.hpp
+++ b/contrib/atf/atf-c++/detail/process.hpp
@@ -41,11 +41,10 @@ extern "C" {
#include <string>
#include <vector>
+#include "auto_array.hpp"
#include "exceptions.hpp"
#include "fs.hpp"
-#include "../utils.hpp"
-
namespace atf {
namespace process {
@@ -64,7 +63,7 @@ class argv_array {
// std::tr1::shared_array instead when it becomes widely available.
// The reason would be to remove all copy constructors and assignment
// operators from this class.
- utils::auto_array< const char* > m_exec_argv;
+ auto_array< const char* > m_exec_argv;
void ctor_init_exec_argv(void);
public:
diff --git a/contrib/atf/atf-c++/detail/test_helpers.cpp b/contrib/atf/atf-c++/detail/test_helpers.cpp
index 107b45a..d13b124 100644
--- a/contrib/atf/atf-c++/detail/test_helpers.cpp
+++ b/contrib/atf/atf-c++/detail/test_helpers.cpp
@@ -27,10 +27,6 @@
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
-extern "C" {
-#include <regex.h>
-}
-
#include <fstream>
#include <iostream>
#include <string>
@@ -92,43 +88,6 @@ get_process_helpers_path(const atf::tests::tc& tc, bool is_detail)
".." / "atf-c" / "detail" / "process_helpers";
}
-bool
-grep_file(const char* name, const char* regex)
-{
- std::ifstream is(name);
- ATF_REQUIRE(is);
-
- bool found = false;
-
- std::string line;
- std::getline(is, line);
- while (!found && is.good()) {
- if (grep_string(line, regex))
- found = true;
- else
- std::getline(is, line);
- }
-
- return found;
-}
-
-bool
-grep_string(const std::string& str, const char* regex)
-{
- int res;
- regex_t preg;
-
- std::cout << "Looking for '" << regex << "' in '" << str << "'\n";
- ATF_REQUIRE(::regcomp(&preg, regex, REG_EXTENDED) == 0);
-
- res = ::regexec(&preg, str.c_str(), 0, NULL, 0);
- ATF_REQUIRE(res == 0 || res == REG_NOMATCH);
-
- ::regfree(&preg);
-
- return res == 0;
-}
-
void
test_helpers_detail::check_equal(const char* expected[],
const string_vector& actual)
diff --git a/contrib/atf/atf-c++/detail/test_helpers.hpp b/contrib/atf/atf-c++/detail/test_helpers.hpp
index 1f9c41c..09232ef 100644
--- a/contrib/atf/atf-c++/detail/test_helpers.hpp
+++ b/contrib/atf/atf-c++/detail/test_helpers.hpp
@@ -87,8 +87,6 @@ class tc;
void header_check(const char*);
void build_check_cxx_o(const atf::tests::tc&, const char*, const char*, bool);
atf::fs::path get_process_helpers_path(const atf::tests::tc&, bool);
-bool grep_file(const char*, const char*);
-bool grep_string(const std::string&, const char*);
struct run_h_tc_data {
const atf::tests::vars_map& m_config;
OpenPOWER on IntegriCloud