aboutsummaryrefslogtreecommitdiff
path: root/pw_trace_tokenized/trace_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'pw_trace_tokenized/trace_test.cc')
-rw-r--r--pw_trace_tokenized/trace_test.cc44
1 files changed, 24 insertions, 20 deletions
diff --git a/pw_trace_tokenized/trace_test.cc b/pw_trace_tokenized/trace_test.cc
index 5e6d2a42c..616d90826 100644
--- a/pw_trace_tokenized/trace_test.cc
+++ b/pw_trace_tokenized/trace_test.cc
@@ -21,14 +21,17 @@
// clang-format on
#include <deque>
+
#include "gtest/gtest.h"
namespace {
-// Moving these to other lines will require updating the variables
-#define kTraceFunctionLine 32
-#define kTraceFunctionGroupLine 33
-#define kTraceFunctionIdLine 35
+// These are line numbers for the functions below. Moving these functions to
+// other lines will require updating these macros.
+#define TRACE_FUNCTION_LINE 35
+#define TRACE_FUNCTION_GROUP_LINE 36
+#define TRACE_FUNCTION_ID_LINE 38
+
void TraceFunction() { PW_TRACE_FUNCTION(); }
void TraceFunctionGroup() { PW_TRACE_FUNCTION("FunctionGroup"); }
void TraceFunctionTraceId(uint32_t id) {
@@ -86,10 +89,9 @@ class TraceTestInterface {
pw_trace_EventType event_type,
const char* module,
uint32_t trace_id,
- uint8_t flags) {
+ uint8_t /* flags */) {
TraceTestInterface* test_interface =
reinterpret_cast<TraceTestInterface*>(user_data);
- PW_UNUSED(flags);
pw_trace_TraceEventReturnFlags ret = 0;
if (test_interface->action_ != ActionOnEvent::None &&
(test_interface->event_match_.trace_ref == trace_ref ||
@@ -127,7 +129,7 @@ class TraceTestInterface {
size_t size) {
TraceTestInterface* test_interface =
reinterpret_cast<TraceTestInterface*>(user_data);
- PW_UNUSED(bytes);
+ static_cast<void>(bytes);
test_interface->sink_bytes_received_ += size;
}
@@ -477,12 +479,14 @@ TEST(TokenizedTrace, Function) {
TraceFunction();
// Check results
- EXPECT_TRACE(test_interface,
- PW_TRACE_TYPE_DURATION_START,
- PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, kTraceFunctionLine));
- EXPECT_TRACE(test_interface,
- PW_TRACE_TYPE_DURATION_END,
- PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, kTraceFunctionLine));
+ EXPECT_TRACE(
+ test_interface,
+ PW_TRACE_TYPE_DURATION_START,
+ PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, TRACE_FUNCTION_LINE));
+ EXPECT_TRACE(
+ test_interface,
+ PW_TRACE_TYPE_DURATION_END,
+ PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, TRACE_FUNCTION_LINE));
EXPECT_TRUE(test_interface.GetEvents().empty());
}
@@ -495,12 +499,12 @@ TEST(TokenizedTrace, FunctionGroup) {
EXPECT_TRACE(
test_interface,
PW_TRACE_TYPE_DURATION_GROUP_START,
- PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, kTraceFunctionGroupLine),
+ PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, TRACE_FUNCTION_GROUP_LINE),
"FunctionGroup");
EXPECT_TRACE(
test_interface,
PW_TRACE_TYPE_DURATION_GROUP_END,
- PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, kTraceFunctionGroupLine),
+ PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, TRACE_FUNCTION_GROUP_LINE),
"FunctionGroup");
EXPECT_TRUE(test_interface.GetEvents().empty());
}
@@ -514,13 +518,13 @@ TEST(TokenizedTrace, FunctionTraceId) {
EXPECT_TRACE(
test_interface,
PW_TRACE_TYPE_ASYNC_START,
- PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, kTraceFunctionIdLine),
+ PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, TRACE_FUNCTION_ID_LINE),
"FunctionGroup",
kTraceId);
EXPECT_TRACE(
test_interface,
PW_TRACE_TYPE_ASYNC_END,
- PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, kTraceFunctionIdLine),
+ PW_TRACE_FUNCTION_LABEL_FILE_LINE(__FILE__, TRACE_FUNCTION_ID_LINE),
"FunctionGroup",
kTraceId);
EXPECT_TRUE(test_interface.GetEvents().empty());
@@ -578,12 +582,12 @@ TEST(TokenizedTrace, QueueFull) {
constexpr size_t kQueueSize = 5;
pw::trace::internal::TraceQueue<kQueueSize> queue;
for (size_t i = 0; i < kQueueSize; i++) {
- EXPECT_EQ(queue.TryPushBack(QUEUE_TESTS_ARGS(i)), pw::Status::OK);
+ EXPECT_EQ(queue.TryPushBack(QUEUE_TESTS_ARGS(i)), pw::OkStatus());
}
EXPECT_FALSE(queue.IsEmpty());
EXPECT_TRUE(queue.IsFull());
EXPECT_EQ(queue.TryPushBack(QUEUE_TESTS_ARGS(1)),
- pw::Status::RESOURCE_EXHAUSTED);
+ pw::Status::ResourceExhausted());
for (size_t i = 0; i < kQueueSize; i++) {
EXPECT_TRUE(QUEUE_CHECK_RESULT(kQueueSize, queue.PeekFront(), i));
@@ -598,7 +602,7 @@ TEST(TokenizedTrace, Clear) {
constexpr size_t kQueueSize = 5;
pw::trace::internal::TraceQueue<kQueueSize> queue;
for (size_t i = 0; i < kQueueSize; i++) {
- EXPECT_EQ(queue.TryPushBack(QUEUE_TESTS_ARGS(i)), pw::Status::OK);
+ EXPECT_EQ(queue.TryPushBack(QUEUE_TESTS_ARGS(i)), pw::OkStatus());
}
EXPECT_FALSE(queue.IsEmpty());
EXPECT_TRUE(queue.IsFull());