1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #define PW_TRACE_MODULE_NAME "TST"
16
17 #include "pw_trace_tokenized/trace_buffer_log.h"
18
19 #include "pw_trace/trace.h"
20 #include "pw_unit_test/framework.h"
21
22 namespace pw::trace {
23 namespace {
24
TEST(TokenizedTrace,DumpSmallBuffer)25 TEST(TokenizedTrace, DumpSmallBuffer) {
26 // TODO: b/235283406 - This test only verifies that the dump function does not
27 // crash, and requires manual inspection to confirm that the log output is
28 // correct. When there is support to mock and verify the calls to pw_log,
29 // these tests should be improved to validate the output.
30 PW_TRACE_SET_ENABLED(true);
31 PW_TRACE_INSTANT("test1");
32 PW_TRACE_INSTANT("test2");
33 ASSERT_EQ(OkStatus(), pw::trace::DumpTraceBufferToLog());
34 }
35
TEST(TokenizedTrace,DumpLargeBuffer)36 TEST(TokenizedTrace, DumpLargeBuffer) {
37 // TODO: b/235283406 - This test only verifies that the dump function does not
38 // crash, and requires manual inspection to confirm that the log output is
39 // correct. When there is support to mock and verify the calls to pw_log,
40 // these tests should be improved to validate the output.
41 PW_TRACE_SET_ENABLED(true);
42 for (int i = 0; i < 100; i++) {
43 PW_TRACE_INSTANT("test");
44 }
45 ASSERT_EQ(OkStatus(), pw::trace::DumpTraceBufferToLog());
46 }
47
48 } // namespace
49 } // namespace pw::trace
50