test-field.sh: make sure bt_run_in_py_env() and bt_cli() succeed master
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 9 May 2024 04:48:35 +0000 (00:48 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 10 May 2024 18:12:28 +0000 (14:12 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I26c033a56d2c214087db058bdc19d20312a6f0e1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12535
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
20 files changed:
src/common/macros.h
src/common/prio-heap.c [deleted file]
src/common/prio-heap.h [deleted file]
src/cpp-common/bt2c/fmt.hpp
src/cpp-common/bt2c/logging.hpp
src/cpp-common/vendor/span-lite/span.hpp
src/lib/lib-logging.c
src/lib/trace-ir/clock-class.c
src/lib/trace-ir/clock-class.h
src/lib/trace-ir/event-class.c
src/lib/trace-ir/event-class.h
src/lib/trace-ir/stream-class.c
src/lib/trace-ir/stream-class.h
src/lib/trace-ir/stream.c
src/lib/trace-ir/stream.h
src/lib/trace-ir/trace.c
src/lib/trace-ir/trace.h
src/plugins/ctf/fs-src/query.cpp
tests/plugins/src.ctf.fs/field/test-field.sh
tests/utils/utils.sh

index 8120515c63fe5bbcd81672f8c7b4cf1df89d9ce8..0f2bc8fb116eda78ac663d748ced56368430d4a6 100644 (file)
@@ -45,29 +45,6 @@ extern "C" {
 #define BT_IF_DEV_MODE(txt)
 #endif
 
-/*
- * Yield `ref`'s value while setting `ref` to NULL.
- *
- * This can be used to give a strong reference to a callee:
- *
- *   add_foo_to_list(list, BT_MOVE_REF(foo));
- *
- * or in a simple assignment:
- *
- *   my_struct->foo = BT_MOVE_REF(foo);
- *
- * When moving a reference in a function call, the reference is given to the
- * callee even if that function call fails, so make sure the called function
- * is written accordingly.
- */
-
-#define BT_MOVE_REF(ref)               \
-       ({                              \
-               __typeof__(ref) _ref = ref;     \
-               ref = NULL;             \
-               _ref;                   \
-       })
-
 /* Wrapper for g_array_index that adds bound checking.  */
 #define bt_g_array_index(a, t, i)              \
        g_array_index((a), t, ({ BT_ASSERT_DBG((i) < (a)->len); (i); }))
diff --git a/src/common/prio-heap.c b/src/common/prio-heap.c
deleted file mode 100644 (file)
index 55ed5e8..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Static-sized priority heap containing pointers. Based on CLRS,
- * chapter 6.
- */
-
-#include "common/macros.h"
-#include "common/assert.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "common/prio-heap.h"
-
-#ifdef DEBUG_HEAP
-void check_heap(const struct ptr_heap *heap)
-{
-       size_t i;
-
-       if (!heap->len)
-               return;
-
-       for (i = 1; i < heap->len; i++)
-               BT_ASSERT_DBG(!heap->gt(heap->ptrs[i], heap->ptrs[0]));
-}
-#endif
-
-static
-size_t parent(size_t i)
-{
-       return (i - 1) >> 1;
-}
-
-static
-size_t left(size_t i)
-{
-       return (i << 1) + 1;
-}
-
-static
-size_t right(size_t i)
-{
-       return (i << 1) + 2;
-}
-
-/*
- * Copy of heap->ptrs pointer is invalid after heap_grow.
- */
-static
-int heap_grow(struct ptr_heap *heap, size_t new_len)
-{
-       void **new_ptrs;
-
-       if (G_LIKELY(heap->alloc_len >= new_len))
-               return 0;
-
-       heap->alloc_len = bt_max_t(size_t, new_len, heap->alloc_len << 1);
-       new_ptrs = calloc(heap->alloc_len, sizeof(void *));
-       if (G_UNLIKELY(!new_ptrs))
-               return -ENOMEM;
-       if (G_LIKELY(heap->ptrs))
-               memcpy(new_ptrs, heap->ptrs, heap->len * sizeof(void *));
-       free(heap->ptrs);
-       heap->ptrs = new_ptrs;
-       return 0;
-}
-
-static
-int heap_set_len(struct ptr_heap *heap, size_t new_len)
-{
-       int ret;
-
-       ret = heap_grow(heap, new_len);
-       if (G_UNLIKELY(ret))
-               return ret;
-       heap->len = new_len;
-       return 0;
-}
-
-int bt_heap_init(struct ptr_heap *heap, size_t alloc_len,
-             int gt(void *a, void *b))
-{
-       heap->ptrs = NULL;
-       heap->len = 0;
-       heap->alloc_len = 0;
-       heap->gt = gt;
-       /*
-        * Minimum size allocated is 1 entry to ensure memory allocation
-        * never fails within bt_heap_replace_max.
-        */
-       return heap_grow(heap, bt_max_t(size_t, 1, alloc_len));
-}
-
-void bt_heap_free(struct ptr_heap *heap)
-{
-       free(heap->ptrs);
-}
-
-static void heapify(struct ptr_heap *heap, size_t i)
-{
-       void **ptrs = heap->ptrs;
-       size_t l, r, largest;
-
-       for (;;) {
-               void *tmp;
-
-               l = left(i);
-               r = right(i);
-               if (l < heap->len && heap->gt(ptrs[l], ptrs[i]))
-                       largest = l;
-               else
-                       largest = i;
-               if (r < heap->len && heap->gt(ptrs[r], ptrs[largest]))
-                       largest = r;
-               if (G_UNLIKELY(largest == i))
-                       break;
-               tmp = ptrs[i];
-               ptrs[i] = ptrs[largest];
-               ptrs[largest] = tmp;
-               i = largest;
-       }
-       check_heap(heap);
-}
-
-void *bt_heap_replace_max(struct ptr_heap *heap, void *p)
-{
-       void *res;
-
-       if (G_UNLIKELY(!heap->len)) {
-               (void) heap_set_len(heap, 1);
-               heap->ptrs[0] = p;
-               check_heap(heap);
-               return NULL;
-       }
-
-       /* Replace the current max and heapify */
-       res = heap->ptrs[0];
-       heap->ptrs[0] = p;
-       heapify(heap, 0);
-       return res;
-}
-
-int bt_heap_insert(struct ptr_heap *heap, void *p)
-{
-       void **ptrs;
-       size_t pos;
-       int ret;
-
-       ret = heap_set_len(heap, heap->len + 1);
-       if (G_UNLIKELY(ret))
-               return ret;
-       ptrs = heap->ptrs;
-       pos = heap->len - 1;
-       while (pos > 0 && heap->gt(p, ptrs[parent(pos)])) {
-               /* Move parent down until we find the right spot */
-               ptrs[pos] = ptrs[parent(pos)];
-               pos = parent(pos);
-       }
-       ptrs[pos] = p;
-       check_heap(heap);
-       return 0;
-}
-
-void *bt_heap_remove(struct ptr_heap *heap)
-{
-       switch (heap->len) {
-       case 0:
-               return NULL;
-       case 1:
-               (void) heap_set_len(heap, 0);
-               return heap->ptrs[0];
-       }
-       /* Shrink, replace the current max by previous last entry and heapify */
-       heap_set_len(heap, heap->len - 1);
-       /* len changed. previous last entry is at heap->len */
-       return bt_heap_replace_max(heap, heap->ptrs[heap->len]);
-}
-
-void *bt_heap_cherrypick(struct ptr_heap *heap, void *p)
-{
-       size_t pos, len = heap->len;
-
-       for (pos = 0; pos < len; pos++)
-               if (G_UNLIKELY(heap->ptrs[pos] == p))
-                       goto found;
-       return NULL;
-found:
-       if (G_UNLIKELY(heap->len == 1)) {
-               (void) heap_set_len(heap, 0);
-               check_heap(heap);
-               return heap->ptrs[0];
-       }
-       /* Replace p with previous last entry and heapify. */
-       heap_set_len(heap, heap->len - 1);
-       /* len changed. previous last entry is at heap->len */
-       heap->ptrs[pos] = heap->ptrs[heap->len];
-       heapify(heap, pos);
-       return p;
-}
-
-int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src)
-{
-       int ret;
-
-       ret = bt_heap_init(dst, src->alloc_len, src->gt);
-       if (ret < 0)
-               goto end;
-
-       ret = heap_set_len(dst, src->len);
-       if (ret < 0)
-               goto end;
-
-       memcpy(dst->ptrs, src->ptrs, src->len * sizeof(void *));
-
-end:
-       return ret;
-}
diff --git a/src/common/prio-heap.h b/src/common/prio-heap.h
deleted file mode 100644 (file)
index 7e56521..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Static-sized priority heap containing pointers. Based on CLRS,
- * chapter 6.
- */
-
-#ifndef BABELTRACE_COMMON_PRIO_HEAP_H
-#define BABELTRACE_COMMON_PRIO_HEAP_H
-
-#include <unistd.h>
-#include "common/macros.h"
-
-struct ptr_heap {
-       size_t len, alloc_len;
-       void **ptrs;
-       int (*gt)(void *a, void *b);
-};
-
-#ifdef DEBUG_HEAP
-void check_heap(const struct ptr_heap *heap);
-#else
-static inline
-void check_heap(const struct ptr_heap *heap __attribute__((unused)))
-{
-}
-#endif
-
-/**
- * bt_heap_maximum - return the largest element in the heap
- * @heap: the heap to be operated on
- *
- * Returns the largest element in the heap, without performing any modification
- * to the heap structure. Returns NULL if the heap is empty.
- */
-static inline void *bt_heap_maximum(const struct ptr_heap *heap)
-{
-       check_heap(heap);
-       return G_LIKELY(heap->len) ? heap->ptrs[0] : NULL;
-}
-
-/**
- * bt_heap_init - initialize the heap
- * @heap: the heap to initialize
- * @alloc_len: number of elements initially allocated
- * @gt: function to compare the elements
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_init(struct ptr_heap *heap,
-                    size_t alloc_len,
-                    int gt(void *a, void *b));
-
-/**
- * bt_heap_free - free the heap
- * @heap: the heap to free
- */
-extern void bt_heap_free(struct ptr_heap *heap);
-
-/**
- * bt_heap_insert - insert an element into the heap
- * @heap: the heap to be operated on
- * @p: the element to add
- *
- * Insert an element into the heap.
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_insert(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_remove - remove the largest element from the heap
- * @heap: the heap to be operated on
- *
- * Returns the largest element in the heap. It removes this element from the
- * heap. Returns NULL if the heap is empty.
- */
-extern void *bt_heap_remove(struct ptr_heap *heap);
-
-/**
- * bt_heap_cherrypick - remove a given element from the heap
- * @heap: the heap to be operated on
- * @p: the element
- *
- * Remove the given element from the heap. Return the element if present, else
- * return NULL. This algorithm has a complexity of O(n), which is higher than
- * O(log(n)) provided by the rest of this API.
- */
-extern void *bt_heap_cherrypick(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_replace_max - replace the the largest element from the heap
- * @heap: the heap to be operated on
- * @p: the pointer to be inserted as topmost element replacement
- *
- * Returns the largest element in the heap. It removes this element from the
- * heap. The heap is rebalanced only once after the insertion. Returns NULL if
- * the heap is empty.
- *
- * This is the equivalent of calling bt_heap_remove() and then bt_heap_insert(), but
- * it only rebalances the heap once. It never allocates memory.
- */
-extern void *bt_heap_replace_max(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_copy - copy a heap
- * @dst: the destination heap (must be allocated)
- * @src: the source heap
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src);
-
-#endif /* BABELTRACE_COMMON_PRIO_HEAP_H */
index a78d7a61af83f37bb7f5b4c96c0035b568401908..ab3d6bc875de3514ac5fa2fb4b8e2548f38cece4 100644 (file)
@@ -13,7 +13,7 @@ namespace internal {
 
 template <typename T>
 using EnableIfIsWiseEnum =
-    typename std::enable_if<wise_enum::is_wise_enum<T>::value, const char *>::type;
+    typename std::enable_if<wise_enum::is_wise_enum<T>::value, wise_enum::string_type>::type;
 
 } /* namespace internal */
 
index 970ff9b77d85a8782e147b0a6884422995e9d981..2aa22040bcf107d3516969f5121bf6bf27ab8f87 100644 (file)
@@ -155,16 +155,6 @@ public:
         return _mLevel;
     }
 
-    /*
-     * Current logging level converted to a `bt_log_level` value.
-     *
-     * For legacy code.
-     */
-    bt_log_level cLevel() const noexcept
-    {
-        return static_cast<bt_log_level>(_mLevel);
-    }
-
     /*
      * Whether or not this logger would log at the level `level`.
      */
@@ -285,10 +275,10 @@ public:
      */
     template <Level LevelV, bool AppendCauseV, typename... ArgTs>
     void log(const char * const fileName, const char * const funcName, const unsigned int lineNo,
-             const char * const fmt, ArgTs&&...args) const
+             fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
     {
-        this->_log<_StdLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, {}, "", fmt,
-                                                        std::forward<ArgTs>(args)...);
+        this->_log<_StdLogWriter, LevelV, AppendCauseV>(
+            fileName, funcName, lineNo, {}, "", std::move(fmt), std::forward<ArgTs>(args)...);
     }
 
     /*
@@ -297,10 +287,10 @@ public:
      */
     template <bool AppendCauseV, typename ExcT, typename... ArgTs>
     [[noreturn]] void logErrorAndThrow(const char * const fileName, const char * const funcName,
-                                       const unsigned int lineNo, const char * const fmt,
+                                       const unsigned int lineNo, fmt::format_string<ArgTs...> fmt,
                                        ArgTs&&...args) const
     {
-        this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
+        this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, std::move(fmt),
                                               std::forward<ArgTs>(args)...);
         throw ExcT {};
     }
@@ -310,10 +300,10 @@ public:
      */
     template <bool AppendCauseV, typename... ArgTs>
     [[noreturn]] void logErrorAndRethrow(const char * const fileName, const char * const funcName,
-                                         const unsigned int lineNo, const char * const fmt,
-                                         ArgTs&&...args) const
+                                         const unsigned int lineNo,
+                                         fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
     {
-        this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, fmt,
+        this->log<Level::Error, AppendCauseV>(fileName, funcName, lineNo, std::move(fmt),
                                               std::forward<ArgTs>(args)...);
         throw;
     }
@@ -343,12 +333,12 @@ public:
      */
     template <Level LevelV, bool AppendCauseV, typename... ArgTs>
     void logErrno(const char * const fileName, const char * const funcName,
-                  const unsigned int lineNo, const char * const initMsg, const char * const fmt,
-                  ArgTs&&...args) const
+                  const unsigned int lineNo, const char * const initMsg,
+                  fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
     {
-        this->_log<_InitMsgLogWriter, LevelV, AppendCauseV>(fileName, funcName, lineNo, {},
-                                                            this->_errnoIntroStr(initMsg).c_str(),
-                                                            fmt, std::forward<ArgTs>(args)...);
+        this->_log<_InitMsgLogWriter, LevelV, AppendCauseV>(
+            fileName, funcName, lineNo, {}, this->_errnoIntroStr(initMsg).c_str(), std::move(fmt),
+            std::forward<ArgTs>(args)...);
     }
 
     /*
@@ -358,11 +348,11 @@ public:
     template <bool AppendCauseV, typename ExcT, typename... ArgTs>
     [[noreturn]] void logErrorErrnoAndThrow(const char * const fileName,
                                             const char * const funcName, const unsigned int lineNo,
-                                            const char * const initMsg, const char * const fmt,
-                                            ArgTs&&...args) const
+                                            const char * const initMsg,
+                                            fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
     {
-        this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
-                                                   std::forward<ArgTs>(args)...);
+        this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
+                                                   std::move(fmt), std::forward<ArgTs>(args)...);
         throw ExcT {};
     }
 
@@ -370,13 +360,13 @@ public:
      * Like logErrno() with the `Level::Error` level, but also rethrows.
      */
     template <bool AppendCauseV, typename... ArgTs>
-    [[noreturn]] void logErrorErrnoAndRethrow(const char * const fileName,
-                                              const char * const funcName,
-                                              const unsigned int lineNo, const char * const initMsg,
-                                              const char * const fmt, ArgTs&&...args) const
+    [[noreturn]] void
+    logErrorErrnoAndRethrow(const char * const fileName, const char * const funcName,
+                            const unsigned int lineNo, const char * const initMsg,
+                            fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
     {
-        this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg, fmt,
-                                                   std::forward<ArgTs>(args)...);
+        this->logErrno<Level::Error, AppendCauseV>(fileName, funcName, lineNo, initMsg,
+                                                   std::move(fmt), std::forward<ArgTs>(args)...);
         throw;
     }
 
@@ -401,10 +391,10 @@ public:
      */
     template <Level LevelV, typename... ArgTs>
     void logMem(const char * const fileName, const char * const funcName, const unsigned int lineNo,
-                const MemData memData, const char * const fmt, ArgTs&&...args) const
+                const MemData memData, fmt::format_string<ArgTs...> fmt, ArgTs&&...args) const
     {
-        this->_log<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, "", fmt,
-                                                 std::forward<ArgTs>(args)...);
+        this->_log<_MemLogWriter, LevelV, false>(fileName, funcName, lineNo, memData, "",
+                                                 std::move(fmt), std::forward<ArgTs>(args)...);
     }
 
 private:
@@ -421,7 +411,7 @@ private:
      */
     template <typename LogWriterT, Level LevelV, bool AppendCauseV, typename... ArgTs>
     void _log(const char * const fileName, const char * const funcName, const unsigned int lineNo,
-              const MemData memData, const char * const initMsg, const char * const fmt,
+              const MemData memData, const char * const initMsg, fmt::format_string<ArgTs...> fmt,
               ArgTs&&...args) const
     {
         const auto wouldLog = this->wouldLog(LevelV);
@@ -433,8 +423,7 @@ private:
              * append a null character).
              */
             _mBuf.clear();
-            BT_ASSERT(fmt);
-            fmt::format_to(std::back_inserter(_mBuf), fmt, std::forward<ArgTs>(args)...);
+            fmt::format_to(std::back_inserter(_mBuf), std::move(fmt), std::forward<ArgTs>(args)...);
             _mBuf.push_back('\0');
         }
 
index 3d2d86a427f48c55d108b45302ac45789fe9bc15..9a7182f5b0b2c4e93b5307c2f2d667eb6ea51bc7 100644 (file)
@@ -1870,7 +1870,7 @@ using span_lite::byte_span;
 
 #endif // span_FEATURE( BYTE_SPAN )
 
-#if span_HAVE( STRUCT_BINDING )
+#if !span_USES_STD_SPAN && span_HAVE( STRUCT_BINDING )
 
 #if   span_CPP14_OR_GREATER
 # include <tuple>
@@ -1938,7 +1938,7 @@ span_constexpr ElementType const & get( nonstd::span<ElementType, Extent> const
 
 } // end namespace std
 
-#endif // span_HAVE( STRUCT_BINDING )
+#endif // !span_USES_STD_SPAN && span_HAVE( STRUCT_BINDING )
 
 #if ! span_USES_STD_SPAN
 span_RESTORE_WARNINGS()
index a22e000f0ee3f56ca0b6140e1446768c5cc29600..6d98a0ce5e0dc38d87949f20e6559c27000dd01b 100644 (file)
@@ -497,8 +497,8 @@ static inline void format_trace(char **buf_ch, bool extended,
 {
        char tmp_prefix[TMP_PREFIX_LEN];
 
-       if (trace->name.value) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value));
+       if (trace->name) {
+               BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name));
        }
 
        if (!extended) {
@@ -534,9 +534,9 @@ static inline void format_stream_class(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id));
 
-       if (stream_class->name.value) {
+       if (stream_class->name) {
                BUF_APPEND(", %sname=\"%s\"",
-                       PRFIELD(stream_class->name.value));
+                       PRFIELD(stream_class->name));
        }
 
        if (!extended) {
@@ -593,9 +593,9 @@ static inline void format_event_class(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id));
 
-       if (event_class->name.value) {
+       if (event_class->name) {
                BUF_APPEND(", %sname=\"%s\"",
-                       PRFIELD(event_class->name.value));
+                       PRFIELD(event_class->name));
        }
 
        if (!extended) {
@@ -610,9 +610,9 @@ static inline void format_event_class(char **buf_ch, bool extended,
                                (int) event_class->log_level.value)));
        }
 
-       if (event_class->emf_uri.value) {
+       if (event_class->emf_uri) {
                BUF_APPEND(", %semf-uri=\"%s\"",
-                       PRFIELD(event_class->emf_uri.value));
+                       PRFIELD(event_class->emf_uri));
        }
 
        BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p",
@@ -649,8 +649,8 @@ static inline void format_stream(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id));
 
-       if (stream->name.value) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name.value));
+       if (stream->name) {
+               BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name));
        }
 
        if (!extended) {
@@ -777,8 +777,8 @@ static inline void format_clock_class(char **buf_ch, bool extended,
 {
        char tmp_prefix[TMP_PREFIX_LEN];
 
-       if (clock_class->name.value) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name.value));
+       if (clock_class->name) {
+               BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name));
        }
 
        BUF_APPEND(", %sfreq=%" PRIu64, PRFIELD(clock_class->frequency));
@@ -787,9 +787,9 @@ static inline void format_clock_class(char **buf_ch, bool extended,
                return;
        }
 
-       if (clock_class->description.value) {
+       if (clock_class->description) {
                BUF_APPEND(", %spartial-descr=\"%.32s\"",
-                       PRFIELD(clock_class->description.value));
+                       PRFIELD(clock_class->description));
        }
 
        if (clock_class->uuid.value) {
index 10030155b5c1ece5ad791f803bfae618c0d13f99..886501ec3b0944888cdea1ea5ce769bd965cf312 100644 (file)
@@ -35,18 +35,8 @@ void destroy_clock_class(struct bt_object *obj)
        BT_LIB_LOGD("Destroying clock class: %!+K", clock_class);
        BT_OBJECT_PUT_REF_AND_RESET(clock_class->user_attributes);
 
-       if (clock_class->name.str) {
-               g_string_free(clock_class->name.str, TRUE);
-               clock_class->name.str = NULL;
-               clock_class->name.value = NULL;
-       }
-
-       if (clock_class->description.str) {
-               g_string_free(clock_class->description.str, TRUE);
-               clock_class->description.str = NULL;
-               clock_class->description.value = NULL;
-       }
-
+       g_free(clock_class->name);
+       g_free(clock_class->description);
        bt_object_pool_finalize(&clock_class->cs_pool);
        g_free(clock_class);
 }
@@ -91,18 +81,6 @@ struct bt_clock_class *bt_clock_class_create(bt_self_component *self_comp)
                goto error;
        }
 
-       clock_class->name.str = g_string_new(NULL);
-       if (!clock_class->name.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
-               goto error;
-       }
-
-       clock_class->description.str = g_string_new(NULL);
-       if (!clock_class->description.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
-               goto error;
-       }
-
        clock_class->frequency = UINT64_C(1000000000);
        clock_class->origin_is_unix_epoch = BT_TRUE;
        set_base_offset(clock_class);
@@ -132,7 +110,7 @@ BT_EXPORT
 const char *bt_clock_class_get_name(const struct bt_clock_class *clock_class)
 {
        BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
-       return clock_class->name.value;
+       return clock_class->name;
 }
 
 BT_EXPORT
@@ -143,8 +121,8 @@ enum bt_clock_class_set_name_status bt_clock_class_set_name(
        BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
        BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class);
-       g_string_assign(clock_class->name.str, name);
-       clock_class->name.value = clock_class->name.str->str;
+       g_free(clock_class->name);
+       clock_class->name = g_strdup(name);
        BT_LIB_LOGD("Set clock class's name: %!+K", clock_class);
        return BT_FUNC_STATUS_OK;
 }
@@ -154,7 +132,7 @@ const char *bt_clock_class_get_description(
                const struct bt_clock_class *clock_class)
 {
        BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
-       return clock_class->description.value;
+       return clock_class->description;
 }
 
 BT_EXPORT
@@ -165,8 +143,8 @@ enum bt_clock_class_set_description_status bt_clock_class_set_description(
        BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
        BT_ASSERT_PRE_DESCR_NON_NULL(descr);
        BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class);
-       g_string_assign(clock_class->description.str, descr);
-       clock_class->description.value = clock_class->description.str->str;
+       g_free(clock_class->description);
+       clock_class->description = g_strdup(descr);
        BT_LIB_LOGD("Set clock class's description: %!+K",
                clock_class);
        return BT_FUNC_STATUS_OK;
index e2e90412c797f53e01cb5f279a8ac2f83b673b21..54eeb0c85de21bd8d2398b9c99d5b1314aaa4688 100644 (file)
@@ -27,19 +27,8 @@ struct bt_clock_class {
        /* Owned by this */
        struct bt_value *user_attributes;
 
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } name;
-
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } description;
+       gchar *name;
+       gchar *description;
 
        uint64_t frequency;
        uint64_t precision;
index 0d90717561ca9727a5eddcce141450de73edc87b..76ad226bf2b532425c2d8b2a372cf360c9a43dea 100644 (file)
@@ -41,16 +41,8 @@ void destroy_event_class(struct bt_object *obj)
        BT_LIB_LOGD("Destroying event class: %!+E", event_class);
        BT_OBJECT_PUT_REF_AND_RESET(event_class->user_attributes);
 
-       if (event_class->name.str) {
-               g_string_free(event_class->name.str, TRUE);
-               event_class->name.str = NULL;
-       }
-
-       if (event_class->emf_uri.str) {
-               g_string_free(event_class->emf_uri.str, TRUE);
-               event_class->emf_uri.str = NULL;
-       }
-
+       g_free(event_class->name);
+       g_free(event_class->emf_uri);
        BT_LOGD_STR("Putting context field class.");
        BT_OBJECT_PUT_REF_AND_RESET(event_class->specific_context_fc);
        BT_LOGD_STR("Putting payload field class.");
@@ -119,17 +111,6 @@ struct bt_event_class *create_event_class_with_id(
        event_class->id = id;
        bt_property_uint_init(&event_class->log_level,
                        BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE, 0);
-       event_class->name.str = g_string_new(NULL);
-       if (!event_class->name.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
-               goto error;
-       }
-
-       event_class->emf_uri.str = g_string_new(NULL);
-       if (!event_class->emf_uri.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
-               goto error;
-       }
 
        ret = bt_object_pool_initialize(&event_class->event_pool,
                (bt_object_pool_new_object_func) bt_event_new,
@@ -187,7 +168,7 @@ BT_EXPORT
 const char *bt_event_class_get_name(const struct bt_event_class *event_class)
 {
        BT_ASSERT_PRE_DEV_EC_NON_NULL(event_class);
-       return event_class->name.value;
+       return event_class->name;
 }
 
 BT_EXPORT
@@ -198,8 +179,8 @@ enum bt_event_class_set_name_status bt_event_class_set_name(
        BT_ASSERT_PRE_EC_NON_NULL(event_class);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
        BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class);
-       g_string_assign(event_class->name.str, name);
-       event_class->name.value = event_class->name.str->str;
+       g_free(event_class->name);
+       event_class->name = g_strdup(name);
        BT_LIB_LOGD("Set event class's name: %!+E", event_class);
        return BT_FUNC_STATUS_OK;
 }
@@ -240,7 +221,7 @@ BT_EXPORT
 const char *bt_event_class_get_emf_uri(const struct bt_event_class *event_class)
 {
        BT_ASSERT_PRE_DEV_EC_NON_NULL(event_class);
-       return event_class->emf_uri.value;
+       return event_class->emf_uri;
 }
 
 BT_EXPORT
@@ -252,8 +233,8 @@ enum bt_event_class_set_emf_uri_status bt_event_class_set_emf_uri(
        BT_ASSERT_PRE_EC_NON_NULL(event_class);
        BT_ASSERT_PRE_NON_NULL("emf-uri", emf_uri, "EMF URI");
        BT_ASSERT_PRE_DEV_EVENT_CLASS_HOT(event_class);
-       g_string_assign(event_class->emf_uri.str, emf_uri);
-       event_class->emf_uri.value = event_class->emf_uri.str->str;
+       g_free(event_class->emf_uri);
+       event_class->emf_uri = g_strdup(emf_uri);
        BT_LIB_LOGD("Set event class's EMF URI: %!+E", event_class);
        return BT_FUNC_STATUS_OK;
 }
index 67d93695e84711c271c1a5fd012396fb8651ca19..ccbc0009778c90a0baa0255d81c9a8fec9dc480f 100644 (file)
@@ -29,22 +29,12 @@ struct bt_event_class {
        /* Owned by this */
        struct bt_value *user_attributes;
 
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } name;
+       gchar *name;
 
        uint64_t id;
        struct bt_property_uint log_level;
 
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } emf_uri;
+       gchar *emf_uri;
 
        /* Pool of `struct bt_event *` */
        struct bt_object_pool event_pool;
index 08395849b03c9331fde5cfe8b7422d00ccb6f077..c997086101cee2a48707d976beb8fd4ff9d6be4e 100644 (file)
@@ -47,12 +47,7 @@ void destroy_stream_class(struct bt_object *obj)
                stream_class->event_classes = NULL;
        }
 
-       if (stream_class->name.str) {
-               g_string_free(stream_class->name.str, TRUE);
-               stream_class->name.str = NULL;
-               stream_class->name.value = NULL;
-       }
-
+       g_free(stream_class->name);
        BT_LOGD_STR("Putting packet context field class.");
        BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
        BT_LOGD_STR("Putting event common context field class.");
@@ -117,12 +112,6 @@ struct bt_stream_class *create_stream_class_with_id(
                goto error;
        }
 
-       stream_class->name.str = g_string_new(NULL);
-       if (!stream_class->name.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
-               goto error;
-       }
-
        stream_class->id = id;
        stream_class->assigns_automatic_event_class_id = true;
        stream_class->assigns_automatic_stream_id = true;
@@ -203,7 +192,7 @@ BT_EXPORT
 const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
 {
        BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
-       return stream_class->name.value;
+       return stream_class->name;
 }
 
 BT_EXPORT
@@ -215,8 +204,8 @@ enum bt_stream_class_set_name_status bt_stream_class_set_name(
        BT_ASSERT_PRE_SC_NON_NULL(stream_class);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
        BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
-       g_string_assign(stream_class->name.str, name);
-       stream_class->name.value = stream_class->name.str->str;
+       g_free(stream_class->name);
+       stream_class->name = g_strdup(name);
        BT_LIB_LOGD("Set stream class's name: %!+S", stream_class);
        return BT_FUNC_STATUS_OK;
 }
index 771a5899197d22161e0098f7f95b4e4de05f25c5..a1d9ab60e073cb49e885874d3ae25dbbc6599ec5 100644 (file)
@@ -23,12 +23,7 @@ struct bt_stream_class {
        /* Owned by this */
        struct bt_value *user_attributes;
 
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } name;
+       gchar *name;
 
        uint64_t id;
        bool assigns_automatic_event_class_id;
index 7cb124f425bfe5661436d94a38169952e582f297..471623e8c0412bcabb03c96b1e5d13fca08af51e 100644 (file)
@@ -37,12 +37,7 @@ void destroy_stream(struct bt_object *obj)
        BT_LIB_LOGD("Destroying stream object: %!+s", stream);
        BT_OBJECT_PUT_REF_AND_RESET(stream->user_attributes);
 
-       if (stream->name.str) {
-               g_string_free(stream->name.str, TRUE);
-               stream->name.str = NULL;
-               stream->name.value = NULL;
-       }
-
+       g_free(stream->name);
        BT_LOGD_STR("Putting stream's class.");
        bt_object_put_ref(stream->class);
        bt_object_pool_finalize(&stream->packet_pool);
@@ -114,12 +109,6 @@ struct bt_stream *create_stream_with_id(struct bt_stream_class *stream_class,
                goto error;
        }
 
-       stream->name.str = g_string_new(NULL);
-       if (!stream->name.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
-               goto error;
-       }
-
        stream->id = id;
        ret = bt_object_pool_initialize(&stream->packet_pool,
                (bt_object_pool_new_object_func) bt_packet_new,
@@ -211,7 +200,7 @@ BT_EXPORT
 const char *bt_stream_get_name(const struct bt_stream *stream)
 {
        BT_ASSERT_PRE_DEV_STREAM_NON_NULL(stream);
-       return stream->name.value;
+       return stream->name;
 }
 
 BT_EXPORT
@@ -222,8 +211,8 @@ enum bt_stream_set_name_status bt_stream_set_name(struct bt_stream *stream,
        BT_ASSERT_PRE_STREAM_NON_NULL(stream);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
        BT_ASSERT_PRE_DEV_STREAM_HOT(stream);
-       g_string_assign(stream->name.str, name);
-       stream->name.value = stream->name.str->str;
+       g_free(stream->name);
+       stream->name = g_strdup(name);
        BT_LIB_LOGD("Set stream's name: %!+s", stream);
        return BT_FUNC_STATUS_OK;
 }
index 89d7bf73afd47e3018e16d2290981f69f82abc10..89e236a65105317be427af36e25674d16a36892c 100644 (file)
@@ -26,12 +26,7 @@ struct bt_stream {
        /* Owned by this */
        struct bt_stream_class *class;
 
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } name;
+       gchar *name;
 
        uint64_t id;
 
index 8cc005a785530654984cd837d5e2a7e7107212c4..ef9581ee0e6d01f175eed5de0d45b01f6698ed48 100644 (file)
@@ -105,11 +105,7 @@ void destroy_trace(struct bt_object *obj)
                }
        }
 
-       if (trace->name.str) {
-               g_string_free(trace->name.str, TRUE);
-               trace->name.str = NULL;
-               trace->name.value = NULL;
-       }
+       g_free(trace->name);
 
        if (trace->environment) {
                BT_LOGD_STR("Destroying environment attributes.");
@@ -170,12 +166,6 @@ struct bt_trace *bt_trace_create(struct bt_trace_class *tc)
                goto error;
        }
 
-       trace->name.str = g_string_new(NULL);
-       if (!trace->name.str) {
-               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GString.");
-               goto error;
-       }
-
        trace->environment = bt_attributes_create();
        if (!trace->environment) {
                BT_LIB_LOGE_APPEND_CAUSE("Cannot create empty attributes object.");
@@ -205,7 +195,7 @@ BT_EXPORT
 const char *bt_trace_get_name(const struct bt_trace *trace)
 {
        BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
-       return trace->name.value;
+       return trace->name;
 }
 
 BT_EXPORT
@@ -216,8 +206,8 @@ enum bt_trace_set_name_status bt_trace_set_name(struct bt_trace *trace,
        BT_ASSERT_PRE_TRACE_NON_NULL(trace);
        BT_ASSERT_PRE_NAME_NON_NULL(name);
        BT_ASSERT_PRE_DEV_TRACE_HOT(trace);
-       g_string_assign(trace->name.str, name);
-       trace->name.value = trace->name.str->str;
+       g_free(trace->name);
+       trace->name = g_strdup(name);
        BT_LIB_LOGD("Set trace's name: %!+t", trace);
        return BT_FUNC_STATUS_OK;
 }
index 294e8943cd2ffb5933cb7a14888092e435f2b7a7..ed0df692f7bcb059fc8178407864536a2ba43bd0 100644 (file)
@@ -31,12 +31,7 @@ struct bt_trace {
        /* Owned by this */
        struct bt_trace_class *class;
 
-       struct {
-               GString *str;
-
-               /* NULL or `str->str` above */
-               const char *value;
-       } name;
+       gchar *name;
 
        struct {
                bt_uuid_t uuid;
index 0b700e91250458ba0df0c8d05522b5747356d753..4143f9c0888ffb6a2872189bfbc7fdf339e1cf15 100644 (file)
@@ -74,7 +74,7 @@ bt2::Value::Shared metadata_info_query(const bt2::ConstMapValue params, const bt
     ctf_metadata_decoder_up decoder = ctf_metadata_decoder_create(&decoder_cfg);
     if (!decoder) {
         BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(
-            logger, bt2::Error, "Cannot create metadata decoder: path=\"{}}\".", path);
+            logger, bt2::Error, "Cannot create metadata decoder: path=\"{}\".", path);
     }
 
     rewind(metadataFp.get());
index df035d36509f6551ac6179fdbe9bc091fb353410..7c73aa2b9bc776ff58bea91c42edc3e5c3844214 100755 (executable)
@@ -21,13 +21,27 @@ data_dir=$BT_TESTS_DATADIR/plugins/src.ctf.fs/field
 test_pass() {
     local -r mp_path=$1
     local -r output_dir=$(mktemp -d)
+    local -r py_cmd=(
+        "$BT_TESTS_PYTHON_BIN" "$data_dir/data_from_mp.py"
+        "$mp_path" "$output_dir"
+    )
 
-    run_python "$BT_TESTS_PYTHON_BIN" "$data_dir/data_from_mp.py" "$mp_path" "$output_dir"
+    if ! bt_run_in_py_env "${py_cmd[@]}"; then
+        fail "Failed to run \`${py_cmd[*]}\`"
+        return 1
+    fi
 
     local -r res_path=$(mktemp)
-
-    bt_cli "$res_path" /dev/null --plugin-path="$data_dir" \
+    local -r cli_cmd=(
+        "$res_path" /dev/null --plugin-path="$data_dir"
         -c sink.test-text.single "$output_dir/trace"
+    )
+
+    if ! bt_cli "${cli_cmd[@]}"; then
+        fail "Failed to run \`bt_cli ${cli_cmd[*]}\`"
+        return 1
+    fi
+
     bt_diff "$res_path" "$output_dir/expect"
     ok $? "$mp_path"
     rm -rf "$output_dir" "$res_path"
index 692def5d7656d58e7b68e39b99481b038dbdf401..f3d4d94572482114443dd0f21dbbbb67bf78d18e 100644 (file)
@@ -239,6 +239,16 @@ bt_diff() {
        local -r expected_file=$1
        local -r actual_file=$2
 
+       if [[ ! -e $expected_file ]]; then
+               echo "ERROR: expected file \`$expected_file\` doesn't exist" >&2
+               return 1
+       fi
+
+       if [[ ! -e $actual_file ]]; then
+               echo "ERROR: actual file \`$actual_file\` doesn't exist" >&2
+               return 1
+       fi
+
        diff -u <(bt_remove_cr_inline "$expected_file") <(bt_remove_cr_inline "$actual_file") 1>&2
 }
 
This page took 0.042949 seconds and 4 git commands to generate.