git: 77c26601e625 - stable/15 - contrib/kyua: update to 0.15.2
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Nov 2026 01:18:46 UTC
The branch stable/15 has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=77c26601e6255c515e0d0d1c21b1b0e8d617d16a
commit 77c26601e6255c515e0d0d1c21b1b0e8d617d16a
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-11-19 07:02:06 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-11-23 01:17:41 +0000
contrib/kyua: update to 0.15.2
This change contains a few bugfixes to the test executor.
MFC after: 1 week
Merge commit 'dab80d5deaf7d998d587b99f7941890237960638'
(cherry picked from commit c16da33701d07751bbe6871ad39582006d5281fc)
---
contrib/kyua/NEWS | 18 ++
contrib/kyua/README.md | 4 +-
contrib/kyua/config.h | 3 +
contrib/kyua/utils/Kyuafile | 1 -
contrib/kyua/utils/auto_array.hpp | 102 ----------
contrib/kyua/utils/auto_array.ipp | 227 ----------------------
contrib/kyua/utils/auto_array_fwd.hpp | 43 ----
contrib/kyua/utils/auto_array_test.cpp | 312 ------------------------------
contrib/kyua/utils/cmdline/parser.cpp | 16 +-
contrib/kyua/utils/datetime.cpp | 88 +++++++++
contrib/kyua/utils/datetime.hpp | 28 +++
contrib/kyua/utils/datetime_fwd.hpp | 1 +
contrib/kyua/utils/datetime_test.cpp | 117 +++++++++++
contrib/kyua/utils/fs/operations.cpp | 16 +-
contrib/kyua/utils/process/systembuf.cpp | 7 +-
contrib/kyua/utils/signals/timer.cpp | 75 +++++--
contrib/kyua/utils/signals/timer.hpp | 8 +-
contrib/kyua/utils/signals/timer_test.cpp | 111 +++++++++--
contrib/kyua/utils/text/regex.cpp | 33 ++--
contrib/kyua/utils/text/templates.cpp | 2 +-
20 files changed, 442 insertions(+), 770 deletions(-)
diff --git a/contrib/kyua/NEWS b/contrib/kyua/NEWS
index 50a2c8257370..3b7099fc6dbd 100644
--- a/contrib/kyua/NEWS
+++ b/contrib/kyua/NEWS
@@ -1,5 +1,23 @@
# Major changes between releases
+## Changes in version 0.15.2
+
+**Released on 2026/11/19.**
+
+### Bugfixes
+
+* #345: Use monotonic time for timer deadlines
+* #352: Get rid of utils::auto_array
+* #355: Use absolute deadlines in some timer activation tests
+* #357: Fix UB related to iterator lifetime in text templates
+* #360: fix(ci): update LLVM toolchains on macOS and Ubuntu
+
+### Developer Workflow Changes
+
+* #361: Port over dev workflow items from ATF project (commit-check, pre-commit)
+
+**Full Changelog**: https://github.com/freebsd/lutok/compare/kyua-0.15.1...kyua-0.15.2
+
## Changes in version 0.15.1
**Released on 2026/10/25.**
diff --git a/contrib/kyua/README.md b/contrib/kyua/README.md
index b8b54d0413de..a5bc8db0509b 100644
--- a/contrib/kyua/README.md
+++ b/contrib/kyua/README.md
@@ -27,9 +27,9 @@ This is not an official Google product.
## Download
-The latest version of Kyua is 0.15.0 and was released on October 7th, 2026.
+The latest version of Kyua is 0.15.1 and was released on October 25th, 2026.
-Download: [kyua-0.15.0](../../releases/tag/kyua-0.15.0).
+Download: [kyua-0.15.1](../../releases/tag/kyua-0.15.1).
See the [release notes](NEWS) for information about the changes in this
and all previous releases.
diff --git a/contrib/kyua/config.h b/contrib/kyua/config.h
index eba9c9cb1448..cccfe36ae3a2 100644
--- a/contrib/kyua/config.h
+++ b/contrib/kyua/config.h
@@ -4,6 +4,9 @@
/* Define to the optind value to reset getopt processing */
#define GETOPT_OPTIND_RESET_VALUE 1
+/* Define to 1 if you have the 'clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
/* define if the compiler supports basic C++20 syntax */
#define HAVE_CXX20 1
diff --git a/contrib/kyua/utils/Kyuafile b/contrib/kyua/utils/Kyuafile
index 042ad77a3fe4..4955349f2ac9 100644
--- a/contrib/kyua/utils/Kyuafile
+++ b/contrib/kyua/utils/Kyuafile
@@ -2,7 +2,6 @@ syntax(2)
test_suite("kyua")
-atf_test_program{name="auto_array_test"}
atf_test_program{name="datetime_test"}
atf_test_program{name="env_test"}
atf_test_program{name="memory_test"}
diff --git a/contrib/kyua/utils/auto_array.hpp b/contrib/kyua/utils/auto_array.hpp
deleted file mode 100644
index 93b3e20223cf..000000000000
--- a/contrib/kyua/utils/auto_array.hpp
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2010 The Kyua Authors.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Google Inc. nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without 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.
-
-/// \file utils/auto_array.hpp
-/// Provides the utils::auto_array class.
-///
-/// The class is provided as a separate module on its own to minimize
-/// header-inclusion side-effects.
-
-#if !defined(UTILS_AUTO_ARRAY_HPP)
-#define UTILS_AUTO_ARRAY_HPP
-
-#include "utils/auto_array_fwd.hpp"
-
-#include <cstddef>
-
-namespace utils {
-
-
-namespace detail {
-
-
-/// Wrapper class to provide reference semantics for utils::auto_array.
-///
-/// This class is internally used, for example, to allow returning a
-/// utils::auto_array from a function.
-template< class T >
-class auto_array_ref {
- /// Internal pointer to the dynamically-allocated array.
- T* _ptr;
-
- template< class > friend class utils::auto_array;
-
-public:
- explicit auto_array_ref(T*);
-};
-
-
-} // namespace detail
-
-
-/// A simple smart pointer for arrays providing strict ownership semantics.
-///
-/// This class is the counterpart of std::unique_ptr for arrays. The semantics of
-/// the API of this class are the same as those of std::unique_ptr.
-///
-/// The wrapped pointer must be NULL or must have been allocated using operator
-/// new[].
-template< class T >
-class auto_array {
- /// Internal pointer to the dynamically-allocated array.
- T* _ptr;
-
-public:
- auto_array(T* = NULL) throw();
- auto_array(auto_array< T >&) throw();
- auto_array(detail::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=(detail::auto_array_ref< T >) throw();
- T& operator[](int) throw();
- const T& operator[](int) const throw();
- operator detail::auto_array_ref< T >(void) throw();
-};
-
-
-} // namespace utils
-
-
-#endif // !defined(UTILS_AUTO_ARRAY_HPP)
diff --git a/contrib/kyua/utils/auto_array.ipp b/contrib/kyua/utils/auto_array.ipp
deleted file mode 100644
index fd29311def8c..000000000000
--- a/contrib/kyua/utils/auto_array.ipp
+++ /dev/null
@@ -1,227 +0,0 @@
-// Copyright 2010 The Kyua Authors.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Google Inc. nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without 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.
-
-#if !defined(UTILS_AUTO_ARRAY_IPP)
-#define UTILS_AUTO_ARRAY_IPP
-
-#include "utils/auto_array.hpp"
-
-namespace utils {
-
-
-namespace detail {
-
-
-/// Constructs a new auto_array_ref from a pointer.
-///
-/// \param ptr The pointer to wrap.
-template< class T > inline
-auto_array_ref< T >::auto_array_ref(T* ptr) :
- _ptr(ptr)
-{
-}
-
-
-} // namespace detail
-
-
-/// Constructs a new auto_array from a given pointer.
-///
-/// This grabs ownership of the pointer unless it is NULL.
-///
-/// \param ptr The pointer to wrap. If not NULL, the memory pointed to must
-/// have been allocated with operator new[].
-template< class T > inline
-auto_array< T >::auto_array(T* ptr) throw() :
- _ptr(ptr)
-{
-}
-
-
-/// Constructs a copy of an auto_array.
-///
-/// \param ptr The pointer to copy from. This pointer is invalidated and the
-/// new copy grabs ownership of the object pointed to.
-template< class T > inline
-auto_array< T >::auto_array(auto_array< T >& ptr) throw() :
- _ptr(ptr.release())
-{
-}
-
-
-/// Constructs a new auto_array form a reference.
-///
-/// Internal function used to construct a new auto_array from an object
-/// returned, for example, from a function.
-///
-/// \param ref The reference.
-template< class T > inline
-auto_array< T >::auto_array(detail::auto_array_ref< T > ref) throw() :
- _ptr(ref._ptr)
-{
-}
-
-
-/// Destructor for auto_array objects.
-template< class T > inline
-auto_array< T >::~auto_array(void) throw()
-{
- if (_ptr != NULL)
- delete [] _ptr;
-}
-
-
-/// Gets the value of the wrapped pointer without releasing ownership.
-///
-/// \return The raw mutable pointer.
-template< class T > inline
-T*
-auto_array< T >::get(void) throw()
-{
- return _ptr;
-}
-
-
-/// Gets the value of the wrapped pointer without releasing ownership.
-///
-/// \return The raw immutable pointer.
-template< class T > inline
-const T*
-auto_array< T >::get(void) const throw()
-{
- return _ptr;
-}
-
-
-/// Gets the value of the wrapped pointer and releases ownership.
-///
-/// \return The raw mutable pointer.
-template< class T > inline
-T*
-auto_array< T >::release(void) throw()
-{
- T* ptr = _ptr;
- _ptr = NULL;
- return ptr;
-}
-
-
-/// Changes the value of the wrapped pointer.
-///
-/// If the auto_array was pointing to an array, such array is released and the
-/// wrapped pointer is replaced with the new pointer provided.
-///
-/// \param ptr The pointer to use as a replacement; may be NULL.
-template< class T > inline
-void
-auto_array< T >::reset(T* ptr) throw()
-{
- if (_ptr != NULL)
- delete [] _ptr;
- _ptr = ptr;
-}
-
-
-/// Assignment operator.
-///
-/// \param ptr The object to copy from. This is invalidated after the copy.
-/// \return A reference to the auto_array object itself.
-template< class T > inline
-auto_array< T >&
-auto_array< T >::operator=(auto_array< T >& ptr) throw()
-{
- reset(ptr.release());
- return *this;
-}
-
-
-/// Internal assignment operator for function returns.
-///
-/// \param ref The reference object to copy from.
-/// \return A reference to the auto_array object itself.
-template< class T > inline
-auto_array< T >&
-auto_array< T >::operator=(detail::auto_array_ref< T > ref) throw()
-{
- if (_ptr != ref._ptr) {
- delete [] _ptr;
- _ptr = ref._ptr;
- }
- return *this;
-}
-
-
-/// Subscript operator to access the array by position.
-///
-/// This does not perform any bounds checking, in particular because auto_array
-/// does not know the size of the arrays pointed to by it.
-///
-/// \param pos The position to access, indexed from zero.
-///
-/// \return A mutable reference to the element at the specified position.
-template< class T > inline
-T&
-auto_array< T >::operator[](int pos) throw()
-{
- return _ptr[pos];
-}
-
-
-/// Subscript operator to access the array by position.
-///
-/// This does not perform any bounds checking, in particular because auto_array
-/// does not know the size of the arrays pointed to by it.
-///
-/// \param pos The position to access, indexed from zero.
-///
-/// \return An immutable reference to the element at the specified position.
-template< class T > inline
-const T&
-auto_array< T >::operator[](int pos) const throw()
-{
- return _ptr[pos];
-}
-
-
-/// Internal conversion to a reference wrapper.
-///
-/// This is used internally to support returning auto_array objects from
-/// functions. The auto_array is invalidated when used.
-///
-/// \return A new detail::auto_array_ref object holding the pointer.
-template< class T > inline
-auto_array< T >::operator detail::auto_array_ref< T >(void) throw()
-{
- return detail::auto_array_ref< T >(release());
-}
-
-
-} // namespace utils
-
-
-#endif // !defined(UTILS_AUTO_ARRAY_IPP)
diff --git a/contrib/kyua/utils/auto_array_fwd.hpp b/contrib/kyua/utils/auto_array_fwd.hpp
deleted file mode 100644
index e1522a25bf7d..000000000000
--- a/contrib/kyua/utils/auto_array_fwd.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2015 The Kyua Authors.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Google Inc. nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without 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.
-
-/// \file utils/auto_array_fwd.hpp
-/// Forward declarations for utils/auto_array.hpp
-
-#if !defined(UTILS_AUTO_ARRAY_FWD_HPP)
-#define UTILS_AUTO_ARRAY_FWD_HPP
-
-namespace utils {
-
-
-template< class > class auto_array;
-
-
-} // namespace utils
-
-#endif // !defined(UTILS_AUTO_ARRAY_FWD_HPP)
diff --git a/contrib/kyua/utils/auto_array_test.cpp b/contrib/kyua/utils/auto_array_test.cpp
deleted file mode 100644
index 041eb65863ba..000000000000
--- a/contrib/kyua/utils/auto_array_test.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-// Copyright 2010 The Kyua Authors.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Google Inc. nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without 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 "utils/auto_array.ipp"
-
-extern "C" {
-#include <sys/types.h>
-}
-
-#include <iostream>
-
-#include <atf-c++.hpp>
-
-#include "utils/defs.hpp"
-
-using utils::auto_array;
-
-
-namespace {
-
-
-/// Mock class to capture calls to the new and delete operators.
-class test_array {
-public:
- /// User-settable cookie to disambiguate instances of this class.
- int m_value;
-
- /// The current balance of existing test_array instances.
- static ssize_t m_nblocks;
-
- /// Captures invalid calls to new on an array.
- ///
- /// \return Nothing; this always fails the test case.
- void*
- operator new(const size_t /* size */)
- {
- ATF_FAIL("New called but should have been new[]");
- return new int(5);
- }
-
- /// Obtains memory for a new instance and increments m_nblocks.
- ///
- /// \param size The amount of memory to allocate, in bytes.
- ///
- /// \return A pointer to the allocated memory.
- ///
- /// \throw std::bad_alloc If the memory cannot be allocated.
- void*
- operator new[](const size_t size)
- {
- void* mem = ::operator new(size);
- m_nblocks++;
- std::cout << "Allocated 'test_array' object " << mem << "\n";
- return mem;
- }
-
- /// Captures invalid calls to delete on an array.
- ///
- /// \return Nothing; this always fails the test case.
- void
- operator delete(void* /* mem */)
- {
- ATF_FAIL("Delete called but should have been delete[]");
- }
-
- /// Deletes a previously allocated array and decrements m_nblocks.
- ///
- /// \param mem The pointer to the memory to be deleted.
- 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;
-
-
-} // anonymous namespace
-
-
-ATF_TEST_CASE(scope);
-ATF_TEST_CASE_HEAD(scope)
-{
- set_md_var("descr", "Tests the automatic scope handling in the "
- "auto_array smart pointer class");
-}
-ATF_TEST_CASE_BODY(scope)
-{
- 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(copy);
-ATF_TEST_CASE_HEAD(copy)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' copy "
- "constructor");
-}
-ATF_TEST_CASE_BODY(copy)
-{
- 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(copy_ref);
-ATF_TEST_CASE_HEAD(copy_ref)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' copy "
- "constructor through the auxiliary ref object");
-}
-ATF_TEST_CASE_BODY(copy_ref)
-{
- 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(get);
-ATF_TEST_CASE_HEAD(get)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' get "
- "method");
-}
-ATF_TEST_CASE_BODY(get)
-{
- test_array* ta = new test_array[10];
- auto_array< test_array > t(ta);
- ATF_REQUIRE_EQ(t.get(), ta);
-}
-
-
-ATF_TEST_CASE(release);
-ATF_TEST_CASE_HEAD(release)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' release "
- "method");
-}
-ATF_TEST_CASE_BODY(release)
-{
- 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(reset);
-ATF_TEST_CASE_HEAD(reset)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' reset "
- "method");
-}
-ATF_TEST_CASE_BODY(reset)
-{
- 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(assign);
-ATF_TEST_CASE_HEAD(assign)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' "
- "assignment operator");
-}
-ATF_TEST_CASE_BODY(assign)
-{
- 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(assign_ref);
-ATF_TEST_CASE_HEAD(assign_ref)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' "
- "assignment operator through the auxiliary ref "
- "object");
-}
-ATF_TEST_CASE_BODY(assign_ref)
-{
- 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(access);
-ATF_TEST_CASE_HEAD(access)
-{
- set_md_var("descr", "Tests the auto_array smart pointer class' access "
- "operator");
-}
-ATF_TEST_CASE_BODY(access)
-{
- 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);
-}
-
-
-ATF_INIT_TEST_CASES(tcs)
-{
- ATF_ADD_TEST_CASE(tcs, scope);
- ATF_ADD_TEST_CASE(tcs, copy);
- ATF_ADD_TEST_CASE(tcs, copy_ref);
- ATF_ADD_TEST_CASE(tcs, get);
- ATF_ADD_TEST_CASE(tcs, release);
- ATF_ADD_TEST_CASE(tcs, reset);
- ATF_ADD_TEST_CASE(tcs, assign);
- ATF_ADD_TEST_CASE(tcs, assign_ref);
- ATF_ADD_TEST_CASE(tcs, access);
-}
diff --git a/contrib/kyua/utils/cmdline/parser.cpp b/contrib/kyua/utils/cmdline/parser.cpp
index 29dd4612f6ad..32fb14c25e97 100644
--- a/contrib/kyua/utils/cmdline/parser.cpp
+++ b/contrib/kyua/utils/cmdline/parser.cpp
@@ -39,8 +39,8 @@ extern "C" {
#include <cstdlib>
#include <cstring>
#include <limits>
+#include <vector>
-#include "utils/auto_array.ipp"
#include "utils/cmdline/exceptions.hpp"
#include "utils/cmdline/options.hpp"
#include "utils/format/macros.hpp"
@@ -61,7 +61,7 @@ struct getopt_data : utils::noncopyable {
std::string short_options;
/// Representation of the long options as expected by getopt_long(3).
- utils::auto_array< ::option > long_options;
+ std::vector< ::option > long_options;
/// Auto-generated identifiers to be able to parse long options.
std::map< int, const cmdline::base_option* > ids;
@@ -78,7 +78,7 @@ options_to_getopt_data(const cmdline::options_vector& options,
getopt_data& data)
{
data.short_options.clear();
- data.long_options.reset(new ::option[options.size() + 1]);
+ data.long_options.resize(options.size() + 1);
int cur_id = 512;
@@ -189,7 +189,7 @@ find_option_name(const getopt_data& data, const int getopt_optopt,
const char ch = static_cast< char >(getopt_optopt);
return F("-%s") % ch;
} else {
- for (const ::option* opt = &data.long_options[0]; opt->name != NULL;
+ for (const ::option* opt = data.long_options.data(); opt->name != NULL;
opt++) {
if (opt->val == getopt_optopt)
return F("--%s") % opt->name;
@@ -284,11 +284,11 @@ cmdline::parse(const cmdline::args_vector& args,
{
PRE_MSG(args.size() >= 1, "No progname or command name found");
- utils::auto_array< const char* > argv(new const char*[args.size() + 1]);
+ std::vector< const char* > argv(args.size() + 1);
for (args_vector::size_type i = 0; i < args.size(); i++)
argv[i] = args[i].c_str();
- argv[args.size()] = NULL;
- return parse(static_cast< int >(args.size()), argv.get(), options);
+ argv.back() = nullptr;
+ return parse(static_cast< int >(args.size()), argv.data(), options);
}
@@ -342,7 +342,7 @@ cmdline::parse(const int argc, const char* const* argv,
while ((ch = ::getopt_long(mutable_argc, mutable_argv,
("+:" + data.short_options).c_str(),
- data.long_options.get(), NULL)) != -1) {
+ data.long_options.data(), NULL)) != -1) {
if (ch == ':' ) {
const std::string name = find_option_name(
data, ::optopt, mutable_argv, ::optind);
diff --git a/contrib/kyua/utils/datetime.cpp b/contrib/kyua/utils/datetime.cpp
index 174d830031d2..62101637b3b9 100644
--- a/contrib/kyua/utils/datetime.cpp
+++ b/contrib/kyua/utils/datetime.cpp
@@ -612,3 +612,91 @@ datetime::operator<<(std::ostream& output, const timestamp& object)
{
return (output << object.to_microseconds() << "us");
}
+
+
+/// Constructs a monotonic time point measured in microseconds.
+///
+/// \param useconds Microseconds since the monotonic clock's origin.
+datetime::monotonic_timestamp::monotonic_timestamp(const int64_t useconds) :
+ _useconds(useconds)
+{
+}
+
+
+/// Constructs a monotonic time point from a count of microseconds.
+///
+/// \param useconds Microseconds since the monotonic clock's origin.
+///
+/// \return A new monotonic time point.
+datetime::monotonic_timestamp
+datetime::monotonic_timestamp::from_microseconds(const int64_t useconds)
+{
+ return monotonic_timestamp(useconds);
+}
+
+
+/// Constructs a time point representing the current monotonic time.
+///
+/// The monotonic clock is independent of calendar clock adjustments.
+///
+/// \return A new monotonic time point.
+datetime::monotonic_timestamp
+datetime::monotonic_timestamp::now(void)
+{
+ ::timespec data;
+ if (::clock_gettime(CLOCK_MONOTONIC, &data) == -1)
+ UNREACHABLE_MSG("clock_gettime(CLOCK_MONOTONIC) failed");
+ return monotonic_timestamp(static_cast< int64_t >(data.tv_sec) * 1000000 +
+ data.tv_nsec / 1000);
+}
+
+
+/// Returns the number of microseconds since the monotonic clock's origin.
+///
+/// \return A number of microseconds, unrelated to the calendar epoch.
+int64_t
+datetime::monotonic_timestamp::to_microseconds(void) const
+{
+ return _useconds;
+}
+
+
+/// Calculates the addition of a delta to a monotonic time point.
+///
+/// \param other The delta to add.
+///
+/// \return A new monotonic time point at the resulting deadline.
+datetime::monotonic_timestamp
+datetime::monotonic_timestamp::operator+(const datetime::delta& other) const
+{
+ return monotonic_timestamp(_useconds + other.to_microseconds());
+}
+
+
+/// Calculates the delta between two monotonic time points.
+///
+/// \param other The subtrahend.
+///
+/// \return The difference between this object and the other object.
+///
+/// \throw std::runtime_error If the subtraction would result in a negative time
+/// delta, which is not supported.
+datetime::delta
+datetime::monotonic_timestamp::operator-(
+ const monotonic_timestamp& other) const
+{
+ return delta::from_microseconds(_useconds - other._useconds);
+}
+
+
+/// Injects the object into a stream.
+///
+/// \param output The stream into which to inject the object.
+/// \param object The object to format.
+///
+/// \return The output stream.
+std::ostream&
+datetime::operator<<(std::ostream& output, const monotonic_timestamp& object)
+{
+ return output << object.to_microseconds() << "us";
+}
diff --git a/contrib/kyua/utils/datetime.hpp b/contrib/kyua/utils/datetime.hpp
index 0c24f332f6d3..83ff866dc9c8 100644
--- a/contrib/kyua/utils/datetime.hpp
+++ b/contrib/kyua/utils/datetime.hpp
@@ -38,6 +38,7 @@ extern "C" {
#include <stdint.h>
}
*** 740 LINES SKIPPED ***