1 // Copyright 2021 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 #pragma once 15 16 #include <stddef.h> 17 #include <stdint.h> 18 19 #include "pw_log_tokenized/log_tokenized.h" 20 #include "pw_preprocessor/arguments.h" 21 #include "pw_preprocessor/compiler.h" 22 #include "pw_preprocessor/util.h" 23 24 // Create a fake version of the tokenization macro. 25 #undef PW_LOG_TOKENIZED_ENCODE_MESSAGE 26 #define PW_LOG_TOKENIZED_ENCODE_MESSAGE(payload, message, ...) \ 27 pw_log_tokenized_CaptureArgs(payload, \ 28 PW_MACRO_ARG_COUNT(__VA_ARGS__), \ 29 message PW_COMMA_ARGS(__VA_ARGS__)) 30 31 PW_EXTERN_C_START 32 33 typedef struct { 34 uintptr_t metadata; 35 const char* format_string; 36 size_t arg_count; 37 } pw_log_tokenized_CapturedLog; 38 39 extern pw_log_tokenized_CapturedLog last_log; 40 41 void pw_log_tokenized_CaptureArgs(uintptr_t payload, 42 size_t arg_count, 43 const char* message, 44 ...) PW_PRINTF_FORMAT(3, 4); 45 46 // C versions of tests. 47 void pw_log_tokenized_Test_LogMetadata_LevelTooLarge_Clamps(void); 48 void pw_log_tokenized_Test_LogMetadata_TooManyFlags_Truncates(void); 49 void pw_log_tokenized_Test_LogMetadata_LogMetadata_VariousValues(void); 50 void pw_log_tokenized_Test_LogMetadata_LogMetadata_Zero(void); 51 52 PW_EXTERN_C_END 53