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 "gtest/gtest.h"
20 #include "pw_trace/trace.h"
21
TEST(TokenizedTrace,DumpSmallBuffer)22 TEST(TokenizedTrace, DumpSmallBuffer) {
23 // TODO(pwbug/266): This test only verifies that the dump function does not
24 // crash, and requires manual inspection to confirm that the log output is
25 // correct. When there is support to mock and verify the calls to pw_log,
26 // these tests should be improved to validate the output.
27 PW_TRACE_SET_ENABLED(true);
28 PW_TRACE_INSTANT("test1");
29 PW_TRACE_INSTANT("test2");
30 pw::trace::DumpTraceBufferToLog();
31 }
32
TEST(TokenizedTrace,DumpLargeBuffer)33 TEST(TokenizedTrace, DumpLargeBuffer) {
34 // TODO(pwbug/266): This test only verifies that the dump function does not
35 // crash, and requires manual inspection to confirm that the log output is
36 // correct. When there is support to mock and verify the calls to pw_log,
37 // these tests should be improved to validate the output.
38 PW_TRACE_SET_ENABLED(true);
39 for (int i = 0; i < 100; i++) {
40 PW_TRACE_INSTANT("test");
41 }
42 pw::trace::DumpTraceBufferToLog();
43 }
44