diff --git a/.clang-tidy b/.clang-tidy index 4c962b94..3fb4ed9c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -21,7 +21,8 @@ Checks: > -performance-enum-size, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-avoid-c-arrays, - -modernize-avoid-c-arrays + -modernize-avoid-c-arrays, + -modernize-deprecated-headers # Treat all clang-tidy warnings as errors. WarningsAsErrors: '*' diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b4e5cfc..c13d4c69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(SolidSyslog C CXX) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") include(LayerGuard) solidsyslog_enforce_layering() +include(Iwyu) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) diff --git a/CMakePresets.json b/CMakePresets.json index b3f2a01c..7989cb45 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -71,6 +71,14 @@ "CMAKE_EXE_LINKER_FLAGS": "-no-pie" } }, + { + "name": "iwyu", + "displayName": "Include-What-You-Use", + "inherits": "clang-debug", + "cacheVariables": { + "ENABLE_IWYU": "ON" + } + }, { "name": "msvc-base", "hidden": true, @@ -98,6 +106,7 @@ { "name": "tidy", "configurePreset": "tidy" }, { "name": "cppcheck", "configurePreset": "cppcheck" }, { "name": "clang-debug", "configurePreset": "clang-debug" }, + { "name": "iwyu", "configurePreset": "iwyu" }, { "name": "msvc-debug", "configurePreset": "msvc-debug", "configuration": "Debug" } ], "testPresets": [ diff --git a/Core/Interface/SolidSyslogBlockDeviceDefinition.h b/Core/Interface/SolidSyslogBlockDeviceDefinition.h index 3479724a..1471ae05 100644 --- a/Core/Interface/SolidSyslogBlockDeviceDefinition.h +++ b/Core/Interface/SolidSyslogBlockDeviceDefinition.h @@ -1,7 +1,10 @@ #ifndef SOLIDSYSLOGBLOCKDEVICEDEFINITION_H #define SOLIDSYSLOGBLOCKDEVICEDEFINITION_H -#include "SolidSyslogBlockDevice.h" +#include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogBlockStore.h b/Core/Interface/SolidSyslogBlockStore.h index 2c9907ff..55641b2c 100644 --- a/Core/Interface/SolidSyslogBlockStore.h +++ b/Core/Interface/SolidSyslogBlockStore.h @@ -1,12 +1,14 @@ #ifndef SOLIDSYSLOGBLOCKSTORE_H #define SOLIDSYSLOGBLOCKSTORE_H +#include +#include + #include "SolidSyslog.h" #include "SolidSyslogSecurityPolicyDefinition.h" -#include "SolidSyslogStore.h" +#include "ExternC.h" -#include -#include +struct SolidSyslogStore; EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogBufferDefinition.h b/Core/Interface/SolidSyslogBufferDefinition.h index 7d10ea4f..25b9c27b 100644 --- a/Core/Interface/SolidSyslogBufferDefinition.h +++ b/Core/Interface/SolidSyslogBufferDefinition.h @@ -1,7 +1,10 @@ #ifndef SOLIDSYSLOGBUFFERDEFINITION_H #define SOLIDSYSLOGBUFFERDEFINITION_H -#include "SolidSyslogBuffer.h" +#include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogConfig.h b/Core/Interface/SolidSyslogConfig.h index c1676a00..59d62730 100644 --- a/Core/Interface/SolidSyslogConfig.h +++ b/Core/Interface/SolidSyslogConfig.h @@ -1,11 +1,11 @@ #ifndef SOLIDSYSLOGCONFIG_H #define SOLIDSYSLOGCONFIG_H -#include "SolidSyslog.h" +#include + #include "SolidSyslogStringFunction.h" #include "SolidSyslogTimestamp.h" - -#include +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogCrc16Policy.h b/Core/Interface/SolidSyslogCrc16Policy.h index faead85a..bc548fa3 100644 --- a/Core/Interface/SolidSyslogCrc16Policy.h +++ b/Core/Interface/SolidSyslogCrc16Policy.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGCRC16POLICY_H #define SOLIDSYSLOGCRC16POLICY_H -#include "SolidSyslogSecurityPolicyDefinition.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogDatagram.h b/Core/Interface/SolidSyslogDatagram.h index b34931dd..235b4196 100644 --- a/Core/Interface/SolidSyslogDatagram.h +++ b/Core/Interface/SolidSyslogDatagram.h @@ -1,11 +1,13 @@ #ifndef SOLIDSYSLOGDATAGRAM_H #define SOLIDSYSLOGDATAGRAM_H -#include "ExternC.h" -#include "SolidSyslogAddress.h" #include #include +#include "ExternC.h" + +struct SolidSyslogAddress; + EXTERN_C_BEGIN struct SolidSyslogDatagram; diff --git a/Core/Interface/SolidSyslogDatagramDefinition.h b/Core/Interface/SolidSyslogDatagramDefinition.h index d052cf59..e8667a49 100644 --- a/Core/Interface/SolidSyslogDatagramDefinition.h +++ b/Core/Interface/SolidSyslogDatagramDefinition.h @@ -1,7 +1,13 @@ #ifndef SOLIDSYSLOGDATAGRAMDEFINITION_H #define SOLIDSYSLOGDATAGRAMDEFINITION_H +#include +#include + #include "SolidSyslogDatagram.h" +#include "ExternC.h" + +struct SolidSyslogAddress; EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogEndpoint.h b/Core/Interface/SolidSyslogEndpoint.h index a1775612..8df38037 100644 --- a/Core/Interface/SolidSyslogEndpoint.h +++ b/Core/Interface/SolidSyslogEndpoint.h @@ -1,11 +1,10 @@ #ifndef SOLIDSYSLOGENDPOINT_H #define SOLIDSYSLOGENDPOINT_H -#include "ExternC.h" -#include "SolidSyslogFormatter.h" - #include +#include "ExternC.h" + EXTERN_C_BEGIN enum diff --git a/Core/Interface/SolidSyslogFileBlockDevice.h b/Core/Interface/SolidSyslogFileBlockDevice.h index 743049ab..dde6a759 100644 --- a/Core/Interface/SolidSyslogFileBlockDevice.h +++ b/Core/Interface/SolidSyslogFileBlockDevice.h @@ -1,11 +1,13 @@ #ifndef SOLIDSYSLOGFILEBLOCKDEVICE_H #define SOLIDSYSLOGFILEBLOCKDEVICE_H -#include "SolidSyslogBlockDevice.h" -#include "SolidSyslogFile.h" - #include +#include "ExternC.h" + +struct SolidSyslogBlockDevice; +struct SolidSyslogFile; + EXTERN_C_BEGIN enum diff --git a/Core/Interface/SolidSyslogFileDefinition.h b/Core/Interface/SolidSyslogFileDefinition.h index 7cf0e192..347f8075 100644 --- a/Core/Interface/SolidSyslogFileDefinition.h +++ b/Core/Interface/SolidSyslogFileDefinition.h @@ -1,7 +1,10 @@ #ifndef SOLIDSYSLOGFILEDEFINITION_H #define SOLIDSYSLOGFILEDEFINITION_H -#include "SolidSyslogFile.h" +#include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogNullBuffer.h b/Core/Interface/SolidSyslogNullBuffer.h index 62e09dc6..44042259 100644 --- a/Core/Interface/SolidSyslogNullBuffer.h +++ b/Core/Interface/SolidSyslogNullBuffer.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGNULLBUFFER_H #define SOLIDSYSLOGNULLBUFFER_H -#include "SolidSyslogBuffer.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogNullSecurityPolicy.h b/Core/Interface/SolidSyslogNullSecurityPolicy.h index e3422157..177df4cc 100644 --- a/Core/Interface/SolidSyslogNullSecurityPolicy.h +++ b/Core/Interface/SolidSyslogNullSecurityPolicy.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGNULLSECURITYPOLICY_H #define SOLIDSYSLOGNULLSECURITYPOLICY_H -#include "SolidSyslogSecurityPolicyDefinition.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogNullStore.h b/Core/Interface/SolidSyslogNullStore.h index 0218c889..354f1663 100644 --- a/Core/Interface/SolidSyslogNullStore.h +++ b/Core/Interface/SolidSyslogNullStore.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGNULLSTORE_H #define SOLIDSYSLOGNULLSTORE_H -#include "SolidSyslogStore.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogResolver.h b/Core/Interface/SolidSyslogResolver.h index e4a2125e..5f01df24 100644 --- a/Core/Interface/SolidSyslogResolver.h +++ b/Core/Interface/SolidSyslogResolver.h @@ -1,12 +1,14 @@ #ifndef SOLIDSYSLOGRESOLVER_H #define SOLIDSYSLOGRESOLVER_H -#include "ExternC.h" -#include "SolidSyslogAddress.h" -#include "SolidSyslogTransport.h" #include #include +#include "ExternC.h" +#include "SolidSyslogTransport.h" + +struct SolidSyslogAddress; + EXTERN_C_BEGIN struct SolidSyslogResolver; diff --git a/Core/Interface/SolidSyslogResolverDefinition.h b/Core/Interface/SolidSyslogResolverDefinition.h index eeb204dd..5043a8ed 100644 --- a/Core/Interface/SolidSyslogResolverDefinition.h +++ b/Core/Interface/SolidSyslogResolverDefinition.h @@ -1,10 +1,13 @@ #ifndef SOLIDSYSLOGRESOLVERDEFINITION_H #define SOLIDSYSLOGRESOLVERDEFINITION_H -#include "SolidSyslogResolver.h" +#include +#include + #include "SolidSyslogTransport.h" +#include "ExternC.h" -#include +struct SolidSyslogAddress; EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogSenderDefinition.h b/Core/Interface/SolidSyslogSenderDefinition.h index 982e24b7..19a31c44 100644 --- a/Core/Interface/SolidSyslogSenderDefinition.h +++ b/Core/Interface/SolidSyslogSenderDefinition.h @@ -1,7 +1,10 @@ #ifndef SOLIDSYSLOGSENDERDEFINITION_H #define SOLIDSYSLOGSENDERDEFINITION_H -#include "SolidSyslogSender.h" +#include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogStoreDefinition.h b/Core/Interface/SolidSyslogStoreDefinition.h index b80680ef..529b51f9 100644 --- a/Core/Interface/SolidSyslogStoreDefinition.h +++ b/Core/Interface/SolidSyslogStoreDefinition.h @@ -1,7 +1,10 @@ #ifndef SOLIDSYSLOGSTOREDEFINITION_H #define SOLIDSYSLOGSTOREDEFINITION_H -#include "SolidSyslogStore.h" +#include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogStream.h b/Core/Interface/SolidSyslogStream.h index 507e21e9..18d5cc8d 100644 --- a/Core/Interface/SolidSyslogStream.h +++ b/Core/Interface/SolidSyslogStream.h @@ -1,12 +1,14 @@ #ifndef SOLIDSYSLOGSTREAM_H #define SOLIDSYSLOGSTREAM_H -#include "ExternC.h" -#include "SolidSyslogAddress.h" #include #include #include +#include "ExternC.h" + +struct SolidSyslogAddress; + EXTERN_C_BEGIN /* Signed byte count. Models POSIX ssize_t using a standard-C type for portability diff --git a/Core/Interface/SolidSyslogStreamDefinition.h b/Core/Interface/SolidSyslogStreamDefinition.h index 5a7860b7..7d12b1b3 100644 --- a/Core/Interface/SolidSyslogStreamDefinition.h +++ b/Core/Interface/SolidSyslogStreamDefinition.h @@ -1,7 +1,13 @@ #ifndef SOLIDSYSLOGSTREAMDEFINITION_H #define SOLIDSYSLOGSTREAMDEFINITION_H +#include +#include + #include "SolidSyslogStream.h" +#include "ExternC.h" + +struct SolidSyslogAddress; EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogStreamSender.h b/Core/Interface/SolidSyslogStreamSender.h index 557009ac..887baac3 100644 --- a/Core/Interface/SolidSyslogStreamSender.h +++ b/Core/Interface/SolidSyslogStreamSender.h @@ -1,12 +1,11 @@ #ifndef SOLIDSYSLOG_STREAM_SENDER_H #define SOLIDSYSLOG_STREAM_SENDER_H -#include "SolidSyslogEndpoint.h" -#include "SolidSyslogResolver.h" -#include "SolidSyslogStream.h" - #include +#include "SolidSyslogEndpoint.h" +#include "ExternC.h" + EXTERN_C_BEGIN struct SolidSyslogSender; diff --git a/Core/Interface/SolidSyslogStructuredDataDefinition.h b/Core/Interface/SolidSyslogStructuredDataDefinition.h index 0a7031fc..239a13f4 100644 --- a/Core/Interface/SolidSyslogStructuredDataDefinition.h +++ b/Core/Interface/SolidSyslogStructuredDataDefinition.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGSTRUCTUREDDATADEFINITION_H #define SOLIDSYSLOGSTRUCTUREDDATADEFINITION_H -#include "SolidSyslogStructuredData.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Interface/SolidSyslogSwitchingSender.h b/Core/Interface/SolidSyslogSwitchingSender.h index 325a0c55..1f9b5977 100644 --- a/Core/Interface/SolidSyslogSwitchingSender.h +++ b/Core/Interface/SolidSyslogSwitchingSender.h @@ -1,12 +1,11 @@ #ifndef SOLIDSYSLOGSWITCHINGSENDER_H #define SOLIDSYSLOGSWITCHINGSENDER_H -#include "ExternC.h" -#include "SolidSyslogSender.h" - #include #include +#include "ExternC.h" + EXTERN_C_BEGIN typedef uint8_t (*SolidSyslogSwitchingSenderSelector)(void); // NOLINT(modernize-redundant-void-arg) -- C idiom diff --git a/Core/Interface/SolidSyslogUdpSender.h b/Core/Interface/SolidSyslogUdpSender.h index b2159230..368f2d77 100644 --- a/Core/Interface/SolidSyslogUdpSender.h +++ b/Core/Interface/SolidSyslogUdpSender.h @@ -1,11 +1,8 @@ #ifndef SOLIDSYSLOGUDPSENDER_H #define SOLIDSYSLOGUDPSENDER_H -#include "SolidSyslogDatagram.h" #include "SolidSyslogEndpoint.h" -#include "SolidSyslogResolver.h" -#include "SolidSyslogSender.h" -#include "SolidSyslogTransport.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Core/Source/SolidSyslog.c b/Core/Source/SolidSyslog.c index e8f2fe09..9d96c7da 100644 --- a/Core/Source/SolidSyslog.c +++ b/Core/Source/SolidSyslog.c @@ -1,4 +1,9 @@ #include "SolidSyslog.h" + +#include +#include +#include + #include "SolidSyslogBuffer.h" #include "SolidSyslogConfig.h" #include "SolidSyslogStore.h" @@ -6,9 +11,11 @@ #include "SolidSyslogMacros.h" #include "SolidSyslogSender.h" #include "SolidSyslogStructuredData.h" +#include "SolidSyslogStringFunction.h" +#include "SolidSyslogTimestamp.h" -#include -#include +struct SolidSyslogFormatter; +struct SolidSyslogStructuredData; enum { diff --git a/Core/Source/SolidSyslogBlockDevice.c b/Core/Source/SolidSyslogBlockDevice.c index 97a5cdf5..cce97b51 100644 --- a/Core/Source/SolidSyslogBlockDevice.c +++ b/Core/Source/SolidSyslogBlockDevice.c @@ -1,4 +1,8 @@ +#include +#include + #include "SolidSyslogBlockDeviceDefinition.h" +#include "SolidSyslogBlockDevice.h" bool SolidSyslogBlockDevice_Acquire(struct SolidSyslogBlockDevice* device, size_t blockIndex) { diff --git a/Core/Source/SolidSyslogBlockStore.c b/Core/Source/SolidSyslogBlockStore.c index ab72cf3d..117a5e12 100644 --- a/Core/Source/SolidSyslogBlockStore.c +++ b/Core/Source/SolidSyslogBlockStore.c @@ -1,4 +1,7 @@ #include "SolidSyslogBlockStore.h" + +#include + #include "BlockSequence.h" #include "RecordStore.h" #include "SolidSyslog.h" diff --git a/Core/Source/SolidSyslogBuffer.c b/Core/Source/SolidSyslogBuffer.c index 8acc6a03..90eebb91 100644 --- a/Core/Source/SolidSyslogBuffer.c +++ b/Core/Source/SolidSyslogBuffer.c @@ -1,4 +1,8 @@ +#include +#include + #include "SolidSyslogBufferDefinition.h" +#include "SolidSyslogBuffer.h" void SolidSyslogBuffer_Write(struct SolidSyslogBuffer* buffer, const void* data, size_t size) { diff --git a/Core/Source/SolidSyslogCrc16Policy.c b/Core/Source/SolidSyslogCrc16Policy.c index ef3141ee..002b4757 100644 --- a/Core/Source/SolidSyslogCrc16Policy.c +++ b/Core/Source/SolidSyslogCrc16Policy.c @@ -1,5 +1,10 @@ #include "SolidSyslogCrc16Policy.h" + +#include +#include + #include "SolidSyslogCrc16.h" +#include "SolidSyslogSecurityPolicyDefinition.h" enum { diff --git a/Core/Source/SolidSyslogDatagram.c b/Core/Source/SolidSyslogDatagram.c index 999dab3e..6d25968f 100644 --- a/Core/Source/SolidSyslogDatagram.c +++ b/Core/Source/SolidSyslogDatagram.c @@ -1,4 +1,10 @@ +#include +#include + #include "SolidSyslogDatagramDefinition.h" +#include "SolidSyslogDatagram.h" + +struct SolidSyslogAddress; bool SolidSyslogDatagram_Open(struct SolidSyslogDatagram* datagram) { diff --git a/Core/Source/SolidSyslogFile.c b/Core/Source/SolidSyslogFile.c index a7f06b2d..d27726bd 100644 --- a/Core/Source/SolidSyslogFile.c +++ b/Core/Source/SolidSyslogFile.c @@ -1,4 +1,8 @@ +#include +#include + #include "SolidSyslogFileDefinition.h" +#include "SolidSyslogFile.h" bool SolidSyslogFile_Open(struct SolidSyslogFile* file, const char* path) { diff --git a/Core/Source/SolidSyslogFileBlockDevice.c b/Core/Source/SolidSyslogFileBlockDevice.c index 110de00d..cae5a583 100644 --- a/Core/Source/SolidSyslogFileBlockDevice.c +++ b/Core/Source/SolidSyslogFileBlockDevice.c @@ -1,7 +1,14 @@ #include "SolidSyslogFileBlockDevice.h" + +#include +#include + #include "SolidSyslogBlockDeviceDefinition.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogMacros.h" +#include "SolidSyslogFile.h" + +struct SolidSyslogFile; enum { diff --git a/Core/Source/SolidSyslogMetaSd.c b/Core/Source/SolidSyslogMetaSd.c index 910bd6b0..3b5113b4 100644 --- a/Core/Source/SolidSyslogMetaSd.c +++ b/Core/Source/SolidSyslogMetaSd.c @@ -1,9 +1,12 @@ #include "SolidSyslogMetaSd.h" + +#include + #include "SolidSyslogAtomicCounter.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogStructuredDataDefinition.h" -#include +struct SolidSyslogFormatter; struct SolidSyslogMetaSd { diff --git a/Core/Source/SolidSyslogNullBuffer.c b/Core/Source/SolidSyslogNullBuffer.c index f9abf6e0..5cb4f0db 100644 --- a/Core/Source/SolidSyslogNullBuffer.c +++ b/Core/Source/SolidSyslogNullBuffer.c @@ -1,4 +1,8 @@ #include "SolidSyslogNullBuffer.h" + +#include +#include + #include "SolidSyslogBufferDefinition.h" #include "SolidSyslogSender.h" diff --git a/Core/Source/SolidSyslogNullSecurityPolicy.c b/Core/Source/SolidSyslogNullSecurityPolicy.c index 494d721e..33ad669e 100644 --- a/Core/Source/SolidSyslogNullSecurityPolicy.c +++ b/Core/Source/SolidSyslogNullSecurityPolicy.c @@ -1,5 +1,10 @@ #include "SolidSyslogNullSecurityPolicy.h" +#include +#include + +#include "SolidSyslogSecurityPolicyDefinition.h" + // NOLINTNEXTLINE(readability-non-const-parameter) -- matches SecurityPolicy vtable signature static void NullComputeIntegrity(const uint8_t* data, uint16_t length, uint8_t* integrityOut) { diff --git a/Core/Source/SolidSyslogNullStore.c b/Core/Source/SolidSyslogNullStore.c index a5b221c4..3f9fe100 100644 --- a/Core/Source/SolidSyslogNullStore.c +++ b/Core/Source/SolidSyslogNullStore.c @@ -1,4 +1,8 @@ #include "SolidSyslogNullStore.h" + +#include +#include + #include "SolidSyslogStoreDefinition.h" static bool Write(struct SolidSyslogStore* self, const void* data, size_t size); diff --git a/Core/Source/SolidSyslogResolver.c b/Core/Source/SolidSyslogResolver.c index b187de4e..04f6d5a9 100644 --- a/Core/Source/SolidSyslogResolver.c +++ b/Core/Source/SolidSyslogResolver.c @@ -1,4 +1,11 @@ +#include +#include + #include "SolidSyslogResolverDefinition.h" +#include "SolidSyslogResolver.h" +#include "SolidSyslogTransport.h" + +struct SolidSyslogAddress; bool SolidSyslogResolver_Resolve(struct SolidSyslogResolver* resolver, enum SolidSyslogTransport transport, const char* host, uint16_t port, struct SolidSyslogAddress* result) diff --git a/Core/Source/SolidSyslogSender.c b/Core/Source/SolidSyslogSender.c index ca2788cd..47396c37 100644 --- a/Core/Source/SolidSyslogSender.c +++ b/Core/Source/SolidSyslogSender.c @@ -1,4 +1,8 @@ +#include +#include + #include "SolidSyslogSenderDefinition.h" +#include "SolidSyslogSender.h" bool SolidSyslogSender_Send(struct SolidSyslogSender* sender, const void* buffer, size_t size) { diff --git a/Core/Source/SolidSyslogStore.c b/Core/Source/SolidSyslogStore.c index 4d052ce4..fe7b61df 100644 --- a/Core/Source/SolidSyslogStore.c +++ b/Core/Source/SolidSyslogStore.c @@ -1,4 +1,8 @@ +#include +#include + #include "SolidSyslogStoreDefinition.h" +#include "SolidSyslogStore.h" bool SolidSyslogStore_Write(struct SolidSyslogStore* store, const void* data, size_t size) { diff --git a/Core/Source/SolidSyslogStream.c b/Core/Source/SolidSyslogStream.c index c6623cf3..d7479b00 100644 --- a/Core/Source/SolidSyslogStream.c +++ b/Core/Source/SolidSyslogStream.c @@ -1,4 +1,10 @@ +#include +#include + #include "SolidSyslogStreamDefinition.h" +#include "SolidSyslogStream.h" + +struct SolidSyslogAddress; bool SolidSyslogStream_Open(struct SolidSyslogStream* stream, const struct SolidSyslogAddress* addr) { diff --git a/Core/Source/SolidSyslogStreamSender.c b/Core/Source/SolidSyslogStreamSender.c index 932ea14d..3f6df64e 100644 --- a/Core/Source/SolidSyslogStreamSender.c +++ b/Core/Source/SolidSyslogStreamSender.c @@ -1,12 +1,19 @@ #include "SolidSyslogStreamSender.h" + +#include +#include +#include + #include "SolidSyslogEndpoint.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogMacros.h" #include "SolidSyslogSenderDefinition.h" +#include "SolidSyslogAddress.h" +#include "SolidSyslogResolver.h" +#include "SolidSyslogStream.h" +#include "SolidSyslogTransport.h" -#include -#include -#include +struct SolidSyslogAddress; struct SolidSyslogStreamSender { diff --git a/Core/Source/SolidSyslogStructuredData.c b/Core/Source/SolidSyslogStructuredData.c index 8f624837..40f03cfd 100644 --- a/Core/Source/SolidSyslogStructuredData.c +++ b/Core/Source/SolidSyslogStructuredData.c @@ -1,4 +1,7 @@ #include "SolidSyslogStructuredDataDefinition.h" +#include "SolidSyslogStructuredData.h" + +struct SolidSyslogFormatter; void SolidSyslogStructuredData_Format(struct SolidSyslogStructuredData* sd, struct SolidSyslogFormatter* formatter) { diff --git a/Core/Source/SolidSyslogSwitchingSender.c b/Core/Source/SolidSyslogSwitchingSender.c index abfb7fe5..b60fa2b1 100644 --- a/Core/Source/SolidSyslogSwitchingSender.c +++ b/Core/Source/SolidSyslogSwitchingSender.c @@ -1,5 +1,10 @@ +#include +#include +#include + #include "SolidSyslogSenderDefinition.h" #include "SolidSyslogSwitchingSender.h" +#include "SolidSyslogSender.h" struct SolidSyslogSwitchingSender { diff --git a/Core/Source/SolidSyslogTimeQualitySd.c b/Core/Source/SolidSyslogTimeQualitySd.c index fc67ef23..baa7220b 100644 --- a/Core/Source/SolidSyslogTimeQualitySd.c +++ b/Core/Source/SolidSyslogTimeQualitySd.c @@ -1,7 +1,14 @@ #include "SolidSyslogTimeQualitySd.h" + +#include +#include +#include + #include "SolidSyslogFormatter.h" #include "SolidSyslogStructuredDataDefinition.h" +struct SolidSyslogFormatter; + struct SolidSyslogTimeQualitySd { struct SolidSyslogStructuredData base; diff --git a/Core/Source/SolidSyslogUdpSender.c b/Core/Source/SolidSyslogUdpSender.c index 9d58fdb8..2f08b1a8 100644 --- a/Core/Source/SolidSyslogUdpSender.c +++ b/Core/Source/SolidSyslogUdpSender.c @@ -1,12 +1,17 @@ +#include +#include +#include + #include "SolidSyslogEndpoint.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogMacros.h" #include "SolidSyslogUdpPayload.h" #include "SolidSyslogUdpSender.h" #include "SolidSyslogSenderDefinition.h" - -#include -#include +#include "SolidSyslogAddress.h" +#include "SolidSyslogDatagram.h" +#include "SolidSyslogResolver.h" +#include "SolidSyslogTransport.h" struct SolidSyslogUdpSender { diff --git a/DEVLOG.md b/DEVLOG.md index 5ce21671..af8147ec 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -2373,3 +2373,89 @@ slice-by-slice review. function be the only "disabled" signal?** Spec mandates both work, so I implemented both. Worth a future review pass — the dual-disable surface is a small foot-gun. + +## 2026-05-04 — S24.01 IWYU CI gate + +Landed the include-what-you-use gate as a CI-friendly preset, then ran +the apply over the whole tree as a discovery exercise. The story body +predicted "single-digit pragmas needed" based on a pre-flight audit; +the reality was 84 files with findings on the first run, dropping to +77 after the project filter. That triggered a rethink mid-stream. + +### Decisions + +- **IWYU lives in the clang container, not the gcc container.** IWYU + is a Clang library tool — building it from source against clang-19 + in `CppUTestDockerClang` was one extra apt line plus a small build + block. Putting it in the gcc image would have meant ~250 MB of LLVM + dev headers in a container whose identity is GCC. Compile commands + also line up cleanly when IWYU and the actual compiler are both + clang. +- **Custom target driven by `iwyu_tool.py`, not the CMake launcher.** + CMake's `CMAKE__INCLUDE_WHAT_YOU_USE` launcher mechanism + intentionally ignores IWYU's exit code (a 3.11 design choice), so + `--error` doesn't fail the build through it. Driving via + `iwyu_tool.py` piped to a project filter keeps the non-zero-on- + finding contract intact and lets the filter be the authoritative + gate. +- **Per-target scope (Core, Platform, Example, Tests) — but not Bdd.** + Story body said Tests/ was out of scope, but narrowing public + headers immediately exposed test code that was relying on transitive + includes; the same hygiene rule has to hold there or the gate keeps + tripping consumers. Bdd/ remains out of scope (it's not in + `compile_commands.json` anyway). +- **Project filter drops three classes of finding IWYU gets wrong:** + redundant `struct Foo;` forward-decls (kept for MISRA/readability — + the in-struct auto-declaration trick is too obscure), `` + removals on dual-language C+C++ headers (IWYU only sees the C++ + side), and `CppUTest/TestHarness.h` removals (IWYU doesn't model + `TEST(...)` macro expansion). Each rule is documented inline in + `scripts/iwyu_filter.py` with the rationale. +- **Custom CppUTest mapping (`cmake/cpputest.imp`) directs IWYU to + suggest the public `TestHarness.h` umbrella over the internal + headers.** Without this, IWYU was asking tests to include + `` directly, which broke the project's CppUTest + convention. +- **Disabled `modernize-deprecated-headers` in `.clang-tidy`.** IWYU + natively suggests `` (the C-style names), which is right + for a C library; clang-tidy's modernize rule was demanding `` + in C++ test code. For an embedded-friendly C library these two + tools were fighting each other; resolving in IWYU's favour matches + the library's identity. +- **Two pragmas added, both for genuinely dual-language headers.** + `Tests/Support/OpenSslFake.h` keeps ``; `Tests/TestUtils.h` + has the CppUTest include relocated inside `#ifdef __cplusplus`. Each + has an inline comment explaining why. +- **`fix_includes.py` blank-line bug.** It inserted 1021 spurious + blank lines between `TEST(...)` macros and their `{` body across 46 + test files. clang-format treated both forms as fixed points so + neither tool surfaced it. Stripped via a small Python script. +- **Two-PR strategy for branch protection.** This PR lands the gate + and the cleanup but does **not** make `analyze-iwyu` a required + status check. Doing so would block any in-flight PR (no in-flight + PR has been through `iwyu-apply`). The follow-up PR flips it on + branch protection. + +### Deferred + +- **`analyze-iwyu` as a required status check** — separate small PR + after this one merges and any in-flight PRs land. +- **Container image bump in this clone.** The active feature-work + clone is using `cpputest-clang:sha-0385cea` via docker-compose; not + bumping the SHA here keeps that stable. The CI workflow change to + add `analyze-iwyu` will pin the new clang-container SHA at the same + time. +- **Whether to switch the default devcontainer from gcc to clang** — + raised in conversation, deferred. Modest lean toward keeping gcc as + default (target deployment compilers are gcc-derived for embedded); + the cleaner cleanup would be slimming each container to a single + identity (gcc + cppcheck + coverage; clang + LLVM tooling). Worth + a separate epic when ready. + +### Open questions + +- **Audit fidelity.** The story body's "single-digit pragmas" estimate + was wrong by an order of magnitude. The audit was done by reading + headers; IWYU's strict purist rule is much narrower than human + intuition. Lesson for future "small CI gate" stories: estimate by + running the tool, not by reading the code. diff --git a/Example/Common/ExampleCommandLine.c b/Example/Common/ExampleCommandLine.c index 4b35a729..df904649 100644 --- a/Example/Common/ExampleCommandLine.c +++ b/Example/Common/ExampleCommandLine.c @@ -3,6 +3,7 @@ #include #include #include +#include enum { diff --git a/Example/Common/ExampleInteractive.c b/Example/Common/ExampleInteractive.c index faeeadf9..1ba26f30 100644 --- a/Example/Common/ExampleInteractive.c +++ b/Example/Common/ExampleInteractive.c @@ -5,6 +5,8 @@ #include #include +#include "SolidSyslog.h" + static const char* const PROMPT = "SolidSyslog> "; enum diff --git a/Example/Common/ExampleInteractive.h b/Example/Common/ExampleInteractive.h index e475d0f0..e8c6a947 100644 --- a/Example/Common/ExampleInteractive.h +++ b/Example/Common/ExampleInteractive.h @@ -1,10 +1,11 @@ #ifndef EXAMPLEINTERACTIVE_H #define EXAMPLEINTERACTIVE_H +#include + #include "ExternC.h" -#include "SolidSyslog.h" -#include +struct SolidSyslogMessage; EXTERN_C_BEGIN diff --git a/Example/Common/ExampleMtlsConfig.c b/Example/Common/ExampleMtlsConfig.c index 00e3eb9f..a8d3e18f 100644 --- a/Example/Common/ExampleMtlsConfig.c +++ b/Example/Common/ExampleMtlsConfig.c @@ -1,8 +1,10 @@ #include "ExampleMtlsConfig.h" -#include "SolidSyslogFormatter.h" #include +#include "SolidSyslogFormatter.h" +#include "SolidSyslogEndpoint.h" + enum { EXAMPLE_MTLS_PORT = 6515 /* S03.09 mTLS source on the BDD syslog-ng */ diff --git a/Example/Common/ExampleMtlsConfig.h b/Example/Common/ExampleMtlsConfig.h index 01f24aa7..ee01e102 100644 --- a/Example/Common/ExampleMtlsConfig.h +++ b/Example/Common/ExampleMtlsConfig.h @@ -1,10 +1,11 @@ #ifndef EXAMPLEMTLSCONFIG_H #define EXAMPLEMTLSCONFIG_H +#include + #include "ExternC.h" -#include "SolidSyslogEndpoint.h" -#include +struct SolidSyslogEndpoint; EXTERN_C_BEGIN diff --git a/Example/Common/ExampleTcpConfig.c b/Example/Common/ExampleTcpConfig.c index bca31b27..69355dee 100644 --- a/Example/Common/ExampleTcpConfig.c +++ b/Example/Common/ExampleTcpConfig.c @@ -1,8 +1,10 @@ #include "ExampleTcpConfig.h" -#include "SolidSyslogFormatter.h" #include +#include "SolidSyslogFormatter.h" +#include "SolidSyslogEndpoint.h" + /* Unprivileged port used by the BDD syslog-ng container — library default is SOLIDSYSLOG_TCP_DEFAULT_PORT (601, RFC 6587 §3.2 / IANA) which requires root. */ enum diff --git a/Example/Common/ExampleTcpConfig.h b/Example/Common/ExampleTcpConfig.h index 8e049047..3010c811 100644 --- a/Example/Common/ExampleTcpConfig.h +++ b/Example/Common/ExampleTcpConfig.h @@ -1,10 +1,11 @@ #ifndef EXAMPLETCPCONFIG_H #define EXAMPLETCPCONFIG_H +#include + #include "ExternC.h" -#include "SolidSyslogEndpoint.h" -#include +struct SolidSyslogEndpoint; EXTERN_C_BEGIN diff --git a/Example/Common/ExampleTlsConfig.c b/Example/Common/ExampleTlsConfig.c index a37e9201..438b665a 100644 --- a/Example/Common/ExampleTlsConfig.c +++ b/Example/Common/ExampleTlsConfig.c @@ -1,9 +1,11 @@ #include "ExampleTlsConfig.h" -#include "SolidSyslogFormatter.h" -#include "SolidSyslogTransport.h" #include +#include "SolidSyslogFormatter.h" +#include "SolidSyslogTransport.h" +#include "SolidSyslogEndpoint.h" + /* Test CA for BDD. Paths are relative to the working directory the example is * launched from (/workspaces/SolidSyslog in the BDD container). */ static const char* const EXAMPLE_TLS_CA_BUNDLE_PATH = "Bdd/syslog-ng/tls/ca.pem"; diff --git a/Example/Common/ExampleTlsConfig.h b/Example/Common/ExampleTlsConfig.h index 0de90802..7644cbd1 100644 --- a/Example/Common/ExampleTlsConfig.h +++ b/Example/Common/ExampleTlsConfig.h @@ -1,10 +1,11 @@ #ifndef EXAMPLETLSCONFIG_H #define EXAMPLETLSCONFIG_H +#include + #include "ExternC.h" -#include "SolidSyslogEndpoint.h" -#include +struct SolidSyslogEndpoint; EXTERN_C_BEGIN diff --git a/Example/Common/ExampleUdpConfig.c b/Example/Common/ExampleUdpConfig.c index 2ac6408d..3ffaf037 100644 --- a/Example/Common/ExampleUdpConfig.c +++ b/Example/Common/ExampleUdpConfig.c @@ -1,8 +1,10 @@ #include "ExampleUdpConfig.h" -#include "SolidSyslogFormatter.h" #include +#include "SolidSyslogFormatter.h" +#include "SolidSyslogEndpoint.h" + /* Unprivileged mirror of SOLIDSYSLOG_UDP_DEFAULT_PORT (514) for BDD containers */ enum { diff --git a/Example/Common/ExampleUdpConfig.h b/Example/Common/ExampleUdpConfig.h index 2ace1b3a..a8009632 100644 --- a/Example/Common/ExampleUdpConfig.h +++ b/Example/Common/ExampleUdpConfig.h @@ -1,10 +1,11 @@ #ifndef EXAMPLEUDPCONFIG_H #define EXAMPLEUDPCONFIG_H +#include + #include "ExternC.h" -#include "SolidSyslogEndpoint.h" -#include +struct SolidSyslogEndpoint; EXTERN_C_BEGIN diff --git a/Example/SingleTask/SolidSyslogExample.c b/Example/SingleTask/SolidSyslogExample.c index 682d0d64..ea0b8d8a 100644 --- a/Example/SingleTask/SolidSyslogExample.c +++ b/Example/SingleTask/SolidSyslogExample.c @@ -1,4 +1,9 @@ #include "SolidSyslogExample.h" + +#include +#include +#include + #include "ExampleAppName.h" #include "ExampleCommandLine.h" #include "ExampleEnterpriseId.h" @@ -25,8 +30,7 @@ #include "SolidSyslogStreamSender.h" #include "SolidSyslogTimeQualitySd.h" #include "SolidSyslogUdpSender.h" - -#include +#include "SolidSyslogTimeQuality.h" static SolidSyslogPosixTcpStreamStorage tcpStreamStorage; static SolidSyslogStreamSenderStorage tcpSenderStorage; diff --git a/Example/Threaded/ExampleTlsSender_OpenSsl.c b/Example/Threaded/ExampleTlsSender_OpenSsl.c index 149caa2c..83bd5d66 100644 --- a/Example/Threaded/ExampleTlsSender_OpenSsl.c +++ b/Example/Threaded/ExampleTlsSender_OpenSsl.c @@ -1,3 +1,5 @@ +#include + #include "ExampleMtlsConfig.h" #include "ExampleTlsConfig.h" #include "ExampleTlsSender.h" @@ -5,6 +7,8 @@ #include "SolidSyslogStreamSender.h" #include "SolidSyslogTlsStream.h" +struct SolidSyslogResolver; + static SolidSyslogPosixTcpStreamStorage underlyingStreamStorage; static struct SolidSyslogStream* underlyingStream; static SolidSyslogTlsStreamStorage tlsStreamStorage; diff --git a/Example/Threaded/main.c b/Example/Threaded/main.c index a7c2381d..11442456 100644 --- a/Example/Threaded/main.c +++ b/Example/Threaded/main.c @@ -1,3 +1,9 @@ +#include +#include +#include +#include +#include + #include "ExampleAppName.h" #include "ExampleCommandLine.h" #include "ExampleEnterpriseId.h" @@ -11,7 +17,6 @@ #include "ExampleUdpConfig.h" #include "SolidSyslog.h" #include "SolidSyslogAtomicCounter.h" -#include "SolidSyslogBlockDevice.h" #include "SolidSyslogConfig.h" #include "SolidSyslogCrc16Policy.h" #include "SolidSyslogFileBlockDevice.h" @@ -33,11 +38,9 @@ #include "SolidSyslogSwitchingSender.h" #include "SolidSyslogStreamSender.h" #include "SolidSyslogUdpSender.h" +#include "SolidSyslogTimeQuality.h" -#include -#include -#include -#include +struct SolidSyslogStore; static const char* const STORE_PATH_PREFIX = "/tmp/STORE"; static const char* const THRESHOLD_MARKER_PATH = "/tmp/solidsyslog_threshold_marker.log"; diff --git a/Platform/Atomics/Source/SolidSyslogStdAtomicOps.c b/Platform/Atomics/Source/SolidSyslogStdAtomicOps.c index 2279ca7a..86375b88 100644 --- a/Platform/Atomics/Source/SolidSyslogStdAtomicOps.c +++ b/Platform/Atomics/Source/SolidSyslogStdAtomicOps.c @@ -1,9 +1,11 @@ #include "SolidSyslogStdAtomicOps.h" -#include "SolidSyslogAtomicOpsDefinition.h" - #include #include +#include +#include + +#include "SolidSyslogAtomicOpsDefinition.h" struct SolidSyslogStdAtomicOps { diff --git a/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h b/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h index ae5d8142..17f91509 100644 --- a/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h +++ b/Platform/OpenSsl/Interface/SolidSyslogTlsStream.h @@ -1,10 +1,12 @@ #ifndef SOLIDSYSLOGTLSSTREAM_H #define SOLIDSYSLOGTLSSTREAM_H -#include "SolidSyslogStream.h" - #include +#include "ExternC.h" + +struct SolidSyslogStream; + EXTERN_C_BEGIN enum diff --git a/Platform/OpenSsl/Source/SolidSyslogTlsStream.c b/Platform/OpenSsl/Source/SolidSyslogTlsStream.c index 76209787..956ec545 100644 --- a/Platform/OpenSsl/Source/SolidSyslogTlsStream.c +++ b/Platform/OpenSsl/Source/SolidSyslogTlsStream.c @@ -1,8 +1,16 @@ +#include +#include +#include +#include +#include +#include + #include "SolidSyslogMacros.h" #include "SolidSyslogStreamDefinition.h" #include "SolidSyslogTlsStream.h" +#include "SolidSyslogStream.h" -#include +struct SolidSyslogAddress; struct SolidSyslogTlsStream { diff --git a/Platform/Posix/Interface/SolidSyslogGetAddrInfoResolver.h b/Platform/Posix/Interface/SolidSyslogGetAddrInfoResolver.h index da72788f..209209fd 100644 --- a/Platform/Posix/Interface/SolidSyslogGetAddrInfoResolver.h +++ b/Platform/Posix/Interface/SolidSyslogGetAddrInfoResolver.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGGETADDRINFORESOLVERH #define SOLIDSYSLOGGETADDRINFORESOLVERH -#include "SolidSyslogResolver.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Platform/Posix/Interface/SolidSyslogPosixClock.h b/Platform/Posix/Interface/SolidSyslogPosixClock.h index 6a69d273..f25f3289 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixClock.h +++ b/Platform/Posix/Interface/SolidSyslogPosixClock.h @@ -1,7 +1,9 @@ #ifndef SOLIDSYSLOGPOSIXCLOCK_H #define SOLIDSYSLOGPOSIXCLOCK_H -#include "SolidSyslogTimestamp.h" +#include "ExternC.h" + +struct SolidSyslogTimestamp; EXTERN_C_BEGIN diff --git a/Platform/Posix/Interface/SolidSyslogPosixDatagram.h b/Platform/Posix/Interface/SolidSyslogPosixDatagram.h index 5ba01f88..9821b246 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixDatagram.h +++ b/Platform/Posix/Interface/SolidSyslogPosixDatagram.h @@ -1,7 +1,7 @@ #ifndef SOLIDSYSLOGPOSIXDATAGRAM_H #define SOLIDSYSLOGPOSIXDATAGRAM_H -#include "SolidSyslogDatagram.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Platform/Posix/Interface/SolidSyslogPosixFile.h b/Platform/Posix/Interface/SolidSyslogPosixFile.h index e587ddf1..56bf8ea2 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixFile.h +++ b/Platform/Posix/Interface/SolidSyslogPosixFile.h @@ -1,10 +1,12 @@ #ifndef SOLIDSYSLOGPOSIXFILE_H #define SOLIDSYSLOGPOSIXFILE_H -#include "SolidSyslogFile.h" - #include +#include "ExternC.h" + +struct SolidSyslogFile; + EXTERN_C_BEGIN enum diff --git a/Platform/Posix/Interface/SolidSyslogPosixHostname.h b/Platform/Posix/Interface/SolidSyslogPosixHostname.h index bd32eb94..44028cb1 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixHostname.h +++ b/Platform/Posix/Interface/SolidSyslogPosixHostname.h @@ -1,7 +1,9 @@ #ifndef SOLIDSYSLOGPOSIXHOSTNAME_H #define SOLIDSYSLOGPOSIXHOSTNAME_H -#include "SolidSyslogConfig.h" +#include "ExternC.h" + +struct SolidSyslogFormatter; EXTERN_C_BEGIN diff --git a/Platform/Posix/Interface/SolidSyslogPosixMessageQueueBuffer.h b/Platform/Posix/Interface/SolidSyslogPosixMessageQueueBuffer.h index d9e303b5..1010591b 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixMessageQueueBuffer.h +++ b/Platform/Posix/Interface/SolidSyslogPosixMessageQueueBuffer.h @@ -1,10 +1,10 @@ #ifndef SOLIDSYSLOGPOSIXMESSAGEQUEUEBUFFER_H #define SOLIDSYSLOGPOSIXMESSAGEQUEUEBUFFER_H -#include "SolidSyslogBuffer.h" - #include +#include "ExternC.h" + EXTERN_C_BEGIN struct SolidSyslogBuffer* SolidSyslogPosixMessageQueueBuffer_Create(size_t maxMessageSize, long maxMessages); diff --git a/Platform/Posix/Interface/SolidSyslogPosixProcessId.h b/Platform/Posix/Interface/SolidSyslogPosixProcessId.h index c995b7d9..f557982a 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixProcessId.h +++ b/Platform/Posix/Interface/SolidSyslogPosixProcessId.h @@ -1,7 +1,9 @@ #ifndef SOLIDSYSLOGPOSIXPROCESSID_H #define SOLIDSYSLOGPOSIXPROCESSID_H -#include "SolidSyslogConfig.h" +#include "ExternC.h" + +struct SolidSyslogFormatter; EXTERN_C_BEGIN diff --git a/Platform/Posix/Interface/SolidSyslogPosixTcpStream.h b/Platform/Posix/Interface/SolidSyslogPosixTcpStream.h index aa97a75b..eecf92b8 100644 --- a/Platform/Posix/Interface/SolidSyslogPosixTcpStream.h +++ b/Platform/Posix/Interface/SolidSyslogPosixTcpStream.h @@ -1,10 +1,12 @@ #ifndef SOLIDSYSLOGPOSIXTCPSTREAM_H #define SOLIDSYSLOGPOSIXTCPSTREAM_H -#include "SolidSyslogStream.h" -#include "SolidSyslogTransport.h" #include +#include "ExternC.h" + +struct SolidSyslogStream; + EXTERN_C_BEGIN enum diff --git a/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c b/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c index 16ed25a0..8d628c52 100644 --- a/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c +++ b/Platform/Posix/Source/SolidSyslogGetAddrInfoResolver.c @@ -1,11 +1,18 @@ #include "SolidSyslogGetAddrInfoResolver.h" -#include "SolidSyslogAddressInternal.h" -#include "SolidSyslogResolverDefinition.h" #include #include #include #include +#include +#include +#include + +#include "SolidSyslogAddressInternal.h" +#include "SolidSyslogResolverDefinition.h" +#include "SolidSyslogTransport.h" + +struct SolidSyslogAddress; enum { diff --git a/Platform/Posix/Source/SolidSyslogPosixClock.c b/Platform/Posix/Source/SolidSyslogPosixClock.c index 17234258..a4eec252 100644 --- a/Platform/Posix/Source/SolidSyslogPosixClock.c +++ b/Platform/Posix/Source/SolidSyslogPosixClock.c @@ -2,6 +2,12 @@ #include #include +#include + +#include "SolidSyslogTimestamp.h" + +struct timespec; +struct tm; static inline bool GetBrokenDownTime(struct timespec* now, struct tm* breakdown); static inline void PopulateTimestamp(struct SolidSyslogTimestamp* timestamp, const struct timespec* now, const struct tm* breakdown); diff --git a/Platform/Posix/Source/SolidSyslogPosixDatagram.c b/Platform/Posix/Source/SolidSyslogPosixDatagram.c index 221988a3..48ae7cab 100644 --- a/Platform/Posix/Source/SolidSyslogPosixDatagram.c +++ b/Platform/Posix/Source/SolidSyslogPosixDatagram.c @@ -1,7 +1,4 @@ #include "SolidSyslogPosixDatagram.h" -#include "SolidSyslogAddressInternal.h" -#include "SolidSyslogDatagramDefinition.h" -#include "SolidSyslogUdpPayload.h" #include #include @@ -9,6 +6,14 @@ #include #include #include +#include + +#include "SolidSyslogAddressInternal.h" +#include "SolidSyslogDatagramDefinition.h" +#include "SolidSyslogUdpPayload.h" +#include "SolidSyslogDatagram.h" + +struct SolidSyslogAddress; enum { diff --git a/Platform/Posix/Source/SolidSyslogPosixFile.c b/Platform/Posix/Source/SolidSyslogPosixFile.c index d6abf2c6..e4278152 100644 --- a/Platform/Posix/Source/SolidSyslogPosixFile.c +++ b/Platform/Posix/Source/SolidSyslogPosixFile.c @@ -1,10 +1,14 @@ #include "SolidSyslogPosixFile.h" -#include "SolidSyslogFileDefinition.h" -#include "SolidSyslogMacros.h" #include #include #include +#include +#include +#include + +#include "SolidSyslogFileDefinition.h" +#include "SolidSyslogMacros.h" #define OWNER_READ_WRITE (S_IRUSR | S_IWUSR) #define DEFAULT_FILE_PERMISSIONS OWNER_READ_WRITE diff --git a/Platform/Posix/Source/SolidSyslogPosixHostname.c b/Platform/Posix/Source/SolidSyslogPosixHostname.c index 73d74a41..dfaaf7c1 100644 --- a/Platform/Posix/Source/SolidSyslogPosixHostname.c +++ b/Platform/Posix/Source/SolidSyslogPosixHostname.c @@ -1,9 +1,11 @@ #include "SolidSyslogPosixHostname.h" -#include "SolidSyslogFormatter.h" -#include #include +#include "SolidSyslogFormatter.h" + +struct SolidSyslogFormatter; + enum { MAX_HOSTNAME_SIZE = 256 diff --git a/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c b/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c index f500d17c..74b51743 100644 --- a/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c +++ b/Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c @@ -1,11 +1,14 @@ #include "SolidSyslogPosixMessageQueueBuffer.h" + +#include +#include +#include +#include + #include "SolidSyslogBufferDefinition.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogPosixProcessId.h" -#include -#include - enum { MAX_NAME_SIZE = 64 diff --git a/Platform/Posix/Source/SolidSyslogPosixProcessId.c b/Platform/Posix/Source/SolidSyslogPosixProcessId.c index d18bd1d5..6d9a1803 100644 --- a/Platform/Posix/Source/SolidSyslogPosixProcessId.c +++ b/Platform/Posix/Source/SolidSyslogPosixProcessId.c @@ -1,7 +1,11 @@ #include "SolidSyslogPosixProcessId.h" -#include "SolidSyslogFormatter.h" #include +#include + +#include "SolidSyslogFormatter.h" + +struct SolidSyslogFormatter; void SolidSyslogPosixProcessId_Get(struct SolidSyslogFormatter* formatter) { diff --git a/Platform/Posix/Source/SolidSyslogPosixTcpStream.c b/Platform/Posix/Source/SolidSyslogPosixTcpStream.c index 42b5c9ce..57946422 100644 --- a/Platform/Posix/Source/SolidSyslogPosixTcpStream.c +++ b/Platform/Posix/Source/SolidSyslogPosixTcpStream.c @@ -1,7 +1,4 @@ #include "SolidSyslogPosixTcpStream.h" -#include "SolidSyslogAddressInternal.h" -#include "SolidSyslogMacros.h" -#include "SolidSyslogStreamDefinition.h" #include #include @@ -9,6 +6,16 @@ #include #include #include +#include +#include +#include + +#include "SolidSyslogAddressInternal.h" +#include "SolidSyslogMacros.h" +#include "SolidSyslogStreamDefinition.h" +#include "SolidSyslogStream.h" + +struct SolidSyslogAddress; enum { diff --git a/Tests/BlockSequenceTest.cpp b/Tests/BlockSequenceTest.cpp index bacbaab1..e956afd4 100644 --- a/Tests/BlockSequenceTest.cpp +++ b/Tests/BlockSequenceTest.cpp @@ -1,14 +1,16 @@ #include #include #include +#include +#include #include "CppUTest/TestHarness.h" +#include "SolidSyslogBlockStore.h" extern "C" { #include "BlockSequence.h" } -#include "SolidSyslogBlockDevice.h" #include "SolidSyslogBlockDeviceDefinition.h" namespace diff --git a/Tests/BufferFake.c b/Tests/BufferFake.c index 27e053de..80a6813c 100644 --- a/Tests/BufferFake.c +++ b/Tests/BufferFake.c @@ -1,8 +1,10 @@ #include "BufferFake.h" -#include "SolidSyslogBufferDefinition.h" -#include "TestUtils.h" #include +#include + +#include "SolidSyslogBufferDefinition.h" +#include "TestUtils.h" enum { diff --git a/Tests/BufferFake.h b/Tests/BufferFake.h index 09103247..98db6b51 100644 --- a/Tests/BufferFake.h +++ b/Tests/BufferFake.h @@ -1,7 +1,7 @@ #ifndef BUFFERFAKE_H #define BUFFERFAKE_H -#include "SolidSyslogBuffer.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Tests/BufferFakeTest.cpp b/Tests/BufferFakeTest.cpp index 9359fa4b..1a9d8de8 100644 --- a/Tests/BufferFakeTest.cpp +++ b/Tests/BufferFakeTest.cpp @@ -1,5 +1,8 @@ -#include "CppUTest/TestHarness.h" +#include + #include "BufferFake.h" +#include "SolidSyslogBuffer.h" +#include "CppUTest/TestHarness.h" static const char* const TEST_MESSAGE = "hello"; static const size_t TEST_MESSAGE_LEN = 5; diff --git a/Tests/ClockFakeTest.cpp b/Tests/ClockFakeTest.cpp index 4b434f28..a43f4a80 100644 --- a/Tests/ClockFakeTest.cpp +++ b/Tests/ClockFakeTest.cpp @@ -1,5 +1,7 @@ -#include "CppUTest/TestHarness.h" +#include + #include "ClockFake.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(ClockFake) diff --git a/Tests/DatagramFake.c b/Tests/DatagramFake.c index 18759f2a..06da618e 100644 --- a/Tests/DatagramFake.c +++ b/Tests/DatagramFake.c @@ -1,7 +1,9 @@ #include "DatagramFake.h" -#include "SolidSyslogDatagramDefinition.h" #include +#include + +#include "SolidSyslogDatagramDefinition.h" enum { diff --git a/Tests/DatagramFake.h b/Tests/DatagramFake.h index 61a7473a..3e52a628 100644 --- a/Tests/DatagramFake.h +++ b/Tests/DatagramFake.h @@ -1,11 +1,12 @@ #ifndef DATAGRAMFAKE_H #define DATAGRAMFAKE_H +#include + #include "ExternC.h" #include "SolidSyslogDatagram.h" -#include -#include +struct SolidSyslogDatagram; EXTERN_C_BEGIN diff --git a/Tests/DatagramFakeTest.cpp b/Tests/DatagramFakeTest.cpp index 9fab7371..42ef0e53 100644 --- a/Tests/DatagramFakeTest.cpp +++ b/Tests/DatagramFakeTest.cpp @@ -1,6 +1,6 @@ -#include "CppUTest/TestHarness.h" #include "DatagramFake.h" #include "SolidSyslogDatagram.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(DatagramFake) diff --git a/Tests/Example/ExampleAppNameTest.cpp b/Tests/Example/ExampleAppNameTest.cpp index 616b0944..8d1f333e 100644 --- a/Tests/Example/ExampleAppNameTest.cpp +++ b/Tests/Example/ExampleAppNameTest.cpp @@ -1,6 +1,6 @@ -#include "CppUTest/TestHarness.h" #include "ExampleAppName.h" #include "SolidSyslogFormatter.h" +#include "CppUTest/TestHarness.h" enum { diff --git a/Tests/Example/ExampleCommandLineTest.cpp b/Tests/Example/ExampleCommandLineTest.cpp index 4905be79..02c23c42 100644 --- a/Tests/Example/ExampleCommandLineTest.cpp +++ b/Tests/Example/ExampleCommandLineTest.cpp @@ -1,7 +1,7 @@ -#include "CppUTest/TestHarness.h" -#include "ExampleCommandLine.h" +#include -#include +#include "ExampleCommandLine.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(ExampleCommandLine) diff --git a/Tests/Example/ExampleIpsTest.cpp b/Tests/Example/ExampleIpsTest.cpp index 306d385e..d699d8a9 100644 --- a/Tests/Example/ExampleIpsTest.cpp +++ b/Tests/Example/ExampleIpsTest.cpp @@ -1,6 +1,6 @@ -#include "CppUTest/TestHarness.h" #include "ExampleIps.h" #include "SolidSyslogFormatter.h" +#include "CppUTest/TestHarness.h" enum { diff --git a/Tests/Example/ExampleLanguageTest.cpp b/Tests/Example/ExampleLanguageTest.cpp index 7ec50fa8..a5593963 100644 --- a/Tests/Example/ExampleLanguageTest.cpp +++ b/Tests/Example/ExampleLanguageTest.cpp @@ -1,6 +1,6 @@ -#include "CppUTest/TestHarness.h" #include "ExampleLanguage.h" #include "SolidSyslogFormatter.h" +#include "CppUTest/TestHarness.h" enum { diff --git a/Tests/Example/ExampleServiceThreadTest.cpp b/Tests/Example/ExampleServiceThreadTest.cpp index a351ac37..33c27ac2 100644 --- a/Tests/Example/ExampleServiceThreadTest.cpp +++ b/Tests/Example/ExampleServiceThreadTest.cpp @@ -1,4 +1,5 @@ -#include "CppUTest/TestHarness.h" +#include + #include "ExampleServiceThread.h" #include "ExampleUdpConfig.h" #include "SolidSyslog.h" @@ -12,6 +13,8 @@ #include "SolidSyslogNullStore.h" #include "SocketFake.h" #include "ClockFake.h" +#include "SolidSyslogPrival.h" +#include "CppUTest/TestHarness.h" static void ExampleEndpoint(struct SolidSyslogEndpoint* endpoint) { diff --git a/Tests/Example/ExampleSwitchConfigTest.cpp b/Tests/Example/ExampleSwitchConfigTest.cpp index fd349d6f..3b48d875 100644 --- a/Tests/Example/ExampleSwitchConfigTest.cpp +++ b/Tests/Example/ExampleSwitchConfigTest.cpp @@ -1,5 +1,5 @@ -#include "CppUTest/TestHarness.h" #include "ExampleSwitchConfig.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(ExampleSwitchConfig) diff --git a/Tests/Example/SolidSyslogExampleTest.cpp b/Tests/Example/SolidSyslogExampleTest.cpp index be1143a0..362d6152 100644 --- a/Tests/Example/SolidSyslogExampleTest.cpp +++ b/Tests/Example/SolidSyslogExampleTest.cpp @@ -1,11 +1,12 @@ -#include "CppUTest/TestHarness.h" +#include +#include +#include +#include + #include "SolidSyslogExample.h" #include "ClockFake.h" #include "SocketFake.h" - -#include -#include -#include +#include "CppUTest/TestHarness.h" static const char* const STDIN_SEND_ONE = "/tmp/solidsyslog_test_send1.txt"; static const char* const STDIN_SEND_THREE = "/tmp/solidsyslog_test_send3.txt"; diff --git a/Tests/FileFake.c b/Tests/FileFake.c index 9f86a0f3..7067d259 100644 --- a/Tests/FileFake.c +++ b/Tests/FileFake.c @@ -1,12 +1,14 @@ #include "FileFake.h" + +#include +#include + #include "SafeString.h" #include "SolidSyslog.h" #include "SolidSyslogFileDefinition.h" #include "SolidSyslogMacros.h" #include "TestAssert.h" -#include - enum { /* Per-file storage. Sized to comfortably hold the worst-case test diff --git a/Tests/FileFake.h b/Tests/FileFake.h index 03f553c1..2b1d9117 100644 --- a/Tests/FileFake.h +++ b/Tests/FileFake.h @@ -1,9 +1,11 @@ #ifndef FILEFAKE_H #define FILEFAKE_H -#include "SolidSyslogFile.h" +#include -#include +#include "ExternC.h" + +struct SolidSyslogFile; EXTERN_C_BEGIN diff --git a/Tests/FileFakeTest.cpp b/Tests/FileFakeTest.cpp index 6be88964..f8a37885 100644 --- a/Tests/FileFakeTest.cpp +++ b/Tests/FileFakeTest.cpp @@ -1,9 +1,9 @@ -#include "CppUTest/TestHarness.h" -#include "FileFake.h" - -#include #include +#include "FileFake.h" +#include "SolidSyslogFile.h" +#include "CppUTest/TestHarness.h" + // clang-format off TEST_GROUP(FileFake) { diff --git a/Tests/OpenSslFakeTest.cpp b/Tests/OpenSslFakeTest.cpp index 3037de89..d7368bd8 100644 --- a/Tests/OpenSslFakeTest.cpp +++ b/Tests/OpenSslFakeTest.cpp @@ -1,6 +1,10 @@ -#include "CppUTest/TestHarness.h" -#include "OpenSslFake.h" #include +#include +#include +#include + +#include "OpenSslFake.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(OpenSslFake) diff --git a/Tests/OpenSslIntegration/BioPairStream.c b/Tests/OpenSslIntegration/BioPairStream.c index 79e3bae7..fe52e61c 100644 --- a/Tests/OpenSslIntegration/BioPairStream.c +++ b/Tests/OpenSslIntegration/BioPairStream.c @@ -1,10 +1,14 @@ #include "BioPairStream.h" -#include "SolidSyslogStreamDefinition.h" #include #include #include +#include "SolidSyslogStreamDefinition.h" +#include "SolidSyslogStream.h" + +struct SolidSyslogAddress; + struct BioPairStream { struct SolidSyslogStream base; diff --git a/Tests/OpenSslIntegration/BioPairStream.h b/Tests/OpenSslIntegration/BioPairStream.h index a2783e25..73b6893e 100644 --- a/Tests/OpenSslIntegration/BioPairStream.h +++ b/Tests/OpenSslIntegration/BioPairStream.h @@ -1,9 +1,11 @@ #ifndef BIOPAIRSTREAM_H #define BIOPAIRSTREAM_H +#include + #include "ExternC.h" -#include "SolidSyslogStream.h" -#include + +struct SolidSyslogStream; EXTERN_C_BEGIN diff --git a/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp b/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp index 0fb0e71a..d222c31d 100644 --- a/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp +++ b/Tests/OpenSslIntegration/SolidSyslogTlsStreamIntegrationTest.cpp @@ -1,17 +1,17 @@ +#include +#include +#include +#include +#include +#include + #include "BioPairStream.h" -#include "CppUTest/TestHarness.h" #include "SolidSyslogAddress.h" #include "SolidSyslogStream.h" #include "SolidSyslogTlsStream.h" #include "TlsTestCert.h" #include "TlsTestServer.h" - -#include -#include -#include -#include -#include -#include +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(TlsStreamIntegration) diff --git a/Tests/OpenSslIntegration/TlsTestCert.c b/Tests/OpenSslIntegration/TlsTestCert.c index 47425abf..af5843f6 100644 --- a/Tests/OpenSslIntegration/TlsTestCert.c +++ b/Tests/OpenSslIntegration/TlsTestCert.c @@ -1,14 +1,15 @@ #include "TlsTestCert.h" #include -#include #include #include #include #include #include -#include #include +#include +#include +#include enum { diff --git a/Tests/OpenSslIntegration/TlsTestCert.h b/Tests/OpenSslIntegration/TlsTestCert.h index 979af1a6..4d2320bc 100644 --- a/Tests/OpenSslIntegration/TlsTestCert.h +++ b/Tests/OpenSslIntegration/TlsTestCert.h @@ -1,10 +1,10 @@ #ifndef TLSTESTCERT_H #define TLSTESTCERT_H -#include "ExternC.h" -#include -#include #include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Tests/OpenSslIntegration/TlsTestServer.c b/Tests/OpenSslIntegration/TlsTestServer.c index 1770e997..47d68f32 100644 --- a/Tests/OpenSslIntegration/TlsTestServer.c +++ b/Tests/OpenSslIntegration/TlsTestServer.c @@ -5,6 +5,9 @@ #include #include #include +#include + +#include "TlsTestCert.h" struct TlsTestServer { diff --git a/Tests/OpenSslIntegration/TlsTestServer.h b/Tests/OpenSslIntegration/TlsTestServer.h index 2eed957b..463420ef 100644 --- a/Tests/OpenSslIntegration/TlsTestServer.h +++ b/Tests/OpenSslIntegration/TlsTestServer.h @@ -1,9 +1,9 @@ #ifndef TLSTESTSERVER_H #define TLSTESTSERVER_H +#include + #include "ExternC.h" -#include "TlsTestCert.h" -#include EXTERN_C_BEGIN diff --git a/Tests/SenderFake.c b/Tests/SenderFake.c index b18b6f54..a222891d 100644 --- a/Tests/SenderFake.c +++ b/Tests/SenderFake.c @@ -1,10 +1,12 @@ #include "SenderFake.h" -#include "SolidSyslog.h" -#include "SolidSyslogSenderDefinition.h" -#include "TestUtils.h" #include #include +#include + +#include "SolidSyslog.h" +#include "SolidSyslogSenderDefinition.h" +#include "TestUtils.h" struct SenderFake { diff --git a/Tests/SenderFake.h b/Tests/SenderFake.h index a9477261..918a05ef 100644 --- a/Tests/SenderFake.h +++ b/Tests/SenderFake.h @@ -1,7 +1,11 @@ #ifndef SENDERFAKE_H #define SENDERFAKE_H -#include "SolidSyslogSender.h" +#include + +#include "ExternC.h" + +struct SolidSyslogSender; EXTERN_C_BEGIN diff --git a/Tests/SenderFakeTest.cpp b/Tests/SenderFakeTest.cpp index f8d02a2d..f0940fb9 100644 --- a/Tests/SenderFakeTest.cpp +++ b/Tests/SenderFakeTest.cpp @@ -1,7 +1,6 @@ -#include "CppUTest/TestHarness.h" #include "SenderFake.h" #include "SolidSyslogSender.h" -#include +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(SenderFake) diff --git a/Tests/SocketFakeTest.cpp b/Tests/SocketFakeTest.cpp index 7d86d72a..16c47baf 100644 --- a/Tests/SocketFakeTest.cpp +++ b/Tests/SocketFakeTest.cpp @@ -1,8 +1,8 @@ -#include "CppUTest/TestHarness.h" -#include "SocketFake.h" - #include +#include "SocketFake.h" +#include "CppUTest/TestHarness.h" + // clang-format off TEST_GROUP(SocketFake) { diff --git a/Tests/SolidSyslogAddressTest.cpp b/Tests/SolidSyslogAddressTest.cpp index 44c2172e..b427d65a 100644 --- a/Tests/SolidSyslogAddressTest.cpp +++ b/Tests/SolidSyslogAddressTest.cpp @@ -1,5 +1,5 @@ -#include "CppUTest/TestHarness.h" #include "SolidSyslogAddress.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(SolidSyslogAddress) diff --git a/Tests/SolidSyslogAtomicCounterTest.cpp b/Tests/SolidSyslogAtomicCounterTest.cpp index 2e648166..ef71f3a0 100644 --- a/Tests/SolidSyslogAtomicCounterTest.cpp +++ b/Tests/SolidSyslogAtomicCounterTest.cpp @@ -1,7 +1,9 @@ #include "AtomicOpsFake.h" -#include "CppUTest/TestHarness.h" #include "SolidSyslogAtomicCounter.h" #include "TestAtomicOps.h" +#include "CppUTest/TestHarness.h" + +struct SolidSyslogAtomicCounter; enum { diff --git a/Tests/SolidSyslogBlockDeviceTest.cpp b/Tests/SolidSyslogBlockDeviceTest.cpp index 798af399..ce5e2fa9 100644 --- a/Tests/SolidSyslogBlockDeviceTest.cpp +++ b/Tests/SolidSyslogBlockDeviceTest.cpp @@ -1,6 +1,8 @@ -#include "CppUTest/TestHarness.h" +#include + #include "SolidSyslogBlockDevice.h" #include "SolidSyslogBlockDeviceDefinition.h" +#include "CppUTest/TestHarness.h" namespace { diff --git a/Tests/SolidSyslogBlockStorePosixTest.cpp b/Tests/SolidSyslogBlockStorePosixTest.cpp index 102b6fe6..fe49770e 100644 --- a/Tests/SolidSyslogBlockStorePosixTest.cpp +++ b/Tests/SolidSyslogBlockStorePosixTest.cpp @@ -1,14 +1,15 @@ +#include +#include +#include +#include + #include "CppUTest/TestHarness.h" -#include "SolidSyslogBlockDevice.h" #include "SolidSyslogFileBlockDevice.h" #include "SolidSyslogBlockStore.h" #include "SolidSyslogPosixFile.h" +#include "SolidSyslogStore.h" #include "SolidSyslog.h" -#include -#include -#include - static const char* const TEST_PATH_PREFIX = "/tmp/test_posix_store"; static SolidSyslogBlockStoreStorage storeStorage = {}; diff --git a/Tests/SolidSyslogBlockStoreTest.cpp b/Tests/SolidSyslogBlockStoreTest.cpp index df11467d..6c447f79 100644 --- a/Tests/SolidSyslogBlockStoreTest.cpp +++ b/Tests/SolidSyslogBlockStoreTest.cpp @@ -1,14 +1,17 @@ +#include +#include +#include + #include "CppUTest/TestHarness.h" #include "SolidSyslogBlockStore.h" -#include "SolidSyslogBlockDevice.h" #include "SolidSyslogCrc16Policy.h" +#include "SolidSyslogFile.h" #include "SolidSyslogFileBlockDevice.h" #include "SolidSyslogSecurityPolicyDefinition.h" +#include "SolidSyslogStore.h" #include "SolidSyslog.h" #include "FileFake.h" -#include - static const char* const TEST_PATH_PREFIX = "/tmp/test_store"; static const char* const TEST_DATA = "hello"; static const size_t TEST_DATA_LEN = 5; diff --git a/Tests/SolidSyslogCrc16PolicyTest.cpp b/Tests/SolidSyslogCrc16PolicyTest.cpp index 95cbecf9..0891b7a4 100644 --- a/Tests/SolidSyslogCrc16PolicyTest.cpp +++ b/Tests/SolidSyslogCrc16PolicyTest.cpp @@ -1,7 +1,8 @@ +#include + #include "CppUTest/TestHarness.h" #include "SolidSyslogCrc16Policy.h" - -#include +#include "SolidSyslogSecurityPolicyDefinition.h" // clang-format off TEST_GROUP(SolidSyslogCrc16Policy) diff --git a/Tests/SolidSyslogCrc16Test.cpp b/Tests/SolidSyslogCrc16Test.cpp index a1678d41..345cf390 100644 --- a/Tests/SolidSyslogCrc16Test.cpp +++ b/Tests/SolidSyslogCrc16Test.cpp @@ -1,8 +1,9 @@ -#include "CppUTest/TestHarness.h" +#include +#include + #include "SolidSyslogCrc16.h" #include "SolidSyslog.h" - -#include +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(SolidSyslogCrc16) diff --git a/Tests/SolidSyslogFileBlockDeviceTest.cpp b/Tests/SolidSyslogFileBlockDeviceTest.cpp index a58867b4..fdbca75d 100644 --- a/Tests/SolidSyslogFileBlockDeviceTest.cpp +++ b/Tests/SolidSyslogFileBlockDeviceTest.cpp @@ -1,7 +1,15 @@ -#include "CppUTest/TestHarness.h" #include "FileFake.h" #include "SolidSyslogBlockDevice.h" #include "SolidSyslogFileBlockDevice.h" +#include "SolidSyslogFile.h" +#include "CppUTest/TestHarness.h" + +class TEST_SolidSyslogFileBlockDevice_AcquireSecondBlockPreservesFirstBlockContent_Test; +class TEST_SolidSyslogFileBlockDevice_AppendsAccumulateAtEnd_Test; +class TEST_SolidSyslogFileBlockDevice_OverlargeBlockIndexLeavesValidBlockUntouched_Test; +class TEST_SolidSyslogFileBlockDevice_ReadAtOffsetReturnsBytesFromOffset_Test; +class TEST_SolidSyslogFileBlockDevice_ReadReturnsAppendedBytes_Test; +class TEST_SolidSyslogFileBlockDevice_WriteAtMutatesByteInPlace_Test; static const char* const TEST_PATH_PREFIX = "/tmp/blockdev_"; diff --git a/Tests/SolidSyslogFormatterTest.cpp b/Tests/SolidSyslogFormatterTest.cpp index 8ecf6048..9eba43bc 100644 --- a/Tests/SolidSyslogFormatterTest.cpp +++ b/Tests/SolidSyslogFormatterTest.cpp @@ -1,7 +1,109 @@ -#include "CppUTest/TestHarness.h" +#include +#include + #include "SolidSyslogFormatter.h" +#include "CppUTest/TestHarness.h" -#include +class TEST_SolidSyslogFormatter_AsFormattedBufferReturnsFormattedContent_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferTrimsFourByteLeadWithOnlyOneContinuation_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferTrimsFourByteLeadWithOnlyTwoContinuations_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferTrimsThreeByteLeadWithOnlyOneContinuation_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferTrimsTruncatedFourByteLeadAtBufferTail_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferTrimsTruncatedThreeByteLeadAtBufferTail_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferTrimsTruncatedTwoByteLeadAtBufferTail_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferZerosBothOrphanContinuationsWhenFourByteTrimmedAtAntepenultimate_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferZerosOrphanContinuationWhenFourByteTrimmedAtPenultimate_Test; +class TEST_SolidSyslogFormatter_AsFormattedBufferZerosOrphanContinuationWhenThreeByteTrimmedAtPenultimate_Test; +class TEST_SolidSyslogFormatter_AsciiCharacterAcceptsSpace_Test; +class TEST_SolidSyslogFormatter_AsciiCharacterStopsWhenFull_Test; +class TEST_SolidSyslogFormatter_AsciiCharacterSubstitutesControlCharWithQuestionMark_Test; +class TEST_SolidSyslogFormatter_AsciiCharacterSubstitutesDelWithQuestionMark_Test; +class TEST_SolidSyslogFormatter_AsciiCharacterSubstitutesHighBitByteWithQuestionMark_Test; +class TEST_SolidSyslogFormatter_AsciiCharacterWritesIntoBuffer_Test; +class TEST_SolidSyslogFormatter_BomWritesUtf8ByteOrderMark_Test; +class TEST_SolidSyslogFormatter_BoundedStringAppendsAfterAsciiCharacter_Test; +class TEST_SolidSyslogFormatter_BoundedStringFillsExactCapacity_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesFourByteCodepointWithF1LeadThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesHighestValidTwoByteCodepointThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesMiddleValidTwoByteCodepointThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesSecondValidTwoByteCodepointThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesThreeByteCodepointWithE1LeadThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesValidFourByteCodepointThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesValidThreeByteCodepointThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringPassesValidTwoByteCodepointThrough_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacementHiddenFromAsFormattedBufferWhenOutputTooSmall_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesF5AsFourByteLead_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesF6AsFourByteLead_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesF7AsFourByteLead_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesFourByteEncodingBeyondUnicodeRange_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesInvalidLeadByteWithReplacementChar_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesInvalidLeadsF5ToFF_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesInvalidLeadsInF8ToFFMid_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesOverlongFourByteEncodingPerByte_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesOverlongLeadC0_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesOverlongThreeByteEncodingAtSubrangeTop_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesOverlongThreeByteEncodingPerByte_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesOverlongTwoByteEncodingPerByte_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesSmallestContinuationByte_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesStragglingFourByteLeadWhenSourceTruncated_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesStragglingThreeByteLeadWhenSourceTruncated_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesStragglingTwoByteLeadWhenSourceTruncated_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesThreeByteLeadFollowedByAscii_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesTopOfThreeByteLeadRangeWhenInvalid_Test; +class TEST_SolidSyslogFormatter_BoundedStringReplacesUtf16SurrogateEncodingPerByte_Test; +class TEST_SolidSyslogFormatter_BoundedStringStopsAtBufferCapacity_Test; +class TEST_SolidSyslogFormatter_BoundedStringTruncatesAtMaxLength_Test; +class TEST_SolidSyslogFormatter_BoundedStringValidCodepointHiddenFromAsFormattedBufferWhenOutputTooSmall_Test; +class TEST_SolidSyslogFormatter_BoundedStringWritesNothingWhenFull_Test; +class TEST_SolidSyslogFormatter_BoundedStringWritesStringIntoBuffer_Test; +class TEST_SolidSyslogFormatter_EscapedStringBreaksWhenReplacementDoesNotFitDecodedBudget_Test; +class TEST_SolidSyslogFormatter_EscapedStringEscapesAllThreeSpecialsInOneValue_Test; +class TEST_SolidSyslogFormatter_EscapedStringEscapesBackslash_Test; +class TEST_SolidSyslogFormatter_EscapedStringEscapesCloseBracket_Test; +class TEST_SolidSyslogFormatter_EscapedStringEscapesDoubleQuote_Test; +class TEST_SolidSyslogFormatter_EscapedStringMaxDecodedLengthBoundsDecoderBufferNotEncodedOutput_Test; +class TEST_SolidSyslogFormatter_EscapedStringPassesOrdinaryCharacterThrough_Test; +class TEST_SolidSyslogFormatter_EscapedStringPassesValidUtf8CodepointsThroughAroundEscapedSpecial_Test; +class TEST_SolidSyslogFormatter_EscapedStringReplacementClaimsThreeBytesOfDecodedBudget_Test; +class TEST_SolidSyslogFormatter_EscapedStringReplacesInvalidUtf8ByteWithReplacementChar_Test; +class TEST_SolidSyslogFormatter_EscapedStringReplacesStragglingMultiByteLeadWhenSourceTruncated_Test; +class TEST_SolidSyslogFormatter_EscapedStringTruncatesAtMaxDecodedLength_Test; +class TEST_SolidSyslogFormatter_EscapedStringWithEmptyInputWritesNothing_Test; +class TEST_SolidSyslogFormatter_FourDigitBeyondMaxFormatsLeastSignificant_Test; +class TEST_SolidSyslogFormatter_FourDigitFormatsAllDigits_Test; +class TEST_SolidSyslogFormatter_FourDigitFormatsMax_Test; +class TEST_SolidSyslogFormatter_FourDigitFormatsZero_Test; +class TEST_SolidSyslogFormatter_LengthAdvancesWithWrites_Test; +class TEST_SolidSyslogFormatter_LengthStartsAtZero_Test; +class TEST_SolidSyslogFormatter_OneByteBufferHoldsOnlyNullTerminator_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringPassesBangAndTildeBoundariesThrough_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringPassesPrintableCharacterThrough_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringSubstitutesControlCharacter_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringSubstitutesDel_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringSubstitutesHighBitByte_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringSubstitutesSpace_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringTruncatesAtMaxLength_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringTruncationBoundsSubstitution_Test; +class TEST_SolidSyslogFormatter_PrintUsAsciiStringWithEmptyInputWritesNothing_Test; +class TEST_SolidSyslogFormatter_SixDigitBeyondMaxFormatsLeastSignificant_Test; +class TEST_SolidSyslogFormatter_SixDigitFormatsAllDigits_Test; +class TEST_SolidSyslogFormatter_SixDigitFormatsMax_Test; +class TEST_SolidSyslogFormatter_SixDigitFormatsZero_Test; +class TEST_SolidSyslogFormatter_TwoAsciiCharactersAppendInSequence_Test; +class TEST_SolidSyslogFormatter_TwoDigitBeyondMaxFormatsLeastSignificant_Test; +class TEST_SolidSyslogFormatter_TwoDigitFormatsAllDigits_Test; +class TEST_SolidSyslogFormatter_TwoDigitFormatsMax_Test; +class TEST_SolidSyslogFormatter_TwoDigitFormatsZero_Test; +class TEST_SolidSyslogFormatter_Uint32AppendsAfterAsciiCharacter_Test; +class TEST_SolidSyslogFormatter_Uint32FitsExactly_Test; +class TEST_SolidSyslogFormatter_Uint32FormatsMultipleDigits_Test; +class TEST_SolidSyslogFormatter_Uint32FormatsSingleDigit_Test; +class TEST_SolidSyslogFormatter_Uint32FormatsZero_Test; +class TEST_SolidSyslogFormatter_Uint32TruncatedWhenBufferTooSmall_Test; +class TEST_SolidSyslogFormatter_ZeroSizeAsciiCharacterIsNoOp_Test; +class TEST_SolidSyslogFormatter_ZeroSizeBoundedStringIsNoOp_Test; +class TEST_SolidSyslogFormatter_ZeroSizeUint32IsNoOp_Test; +struct TEST_GROUP_CppUTestGroupSolidSyslogFormatter; // NOLINTBEGIN(cppcoreguidelines-macro-usage) -- test helper macros for readability; CppUTest requires macros for correct failure location diff --git a/Tests/SolidSyslogGetAddrInfoResolverTest.cpp b/Tests/SolidSyslogGetAddrInfoResolverTest.cpp index 0f5d048b..5cb15487 100644 --- a/Tests/SolidSyslogGetAddrInfoResolverTest.cpp +++ b/Tests/SolidSyslogGetAddrInfoResolverTest.cpp @@ -1,12 +1,14 @@ -#include "CppUTest/TestHarness.h" +#include +#include +#include +#include + #include "SolidSyslogAddress.h" #include "SolidSyslogGetAddrInfoResolver.h" #include "SolidSyslogResolver.h" #include "SocketFake.h" -#include -#include -#include -#include +#include "SolidSyslogTransport.h" +#include "CppUTest/TestHarness.h" // clang-format off static const char* const TEST_HOST = "127.0.0.1"; diff --git a/Tests/SolidSyslogMetaSdTest.cpp b/Tests/SolidSyslogMetaSdTest.cpp index f4e38ef4..ec5e46eb 100644 --- a/Tests/SolidSyslogMetaSdTest.cpp +++ b/Tests/SolidSyslogMetaSdTest.cpp @@ -1,12 +1,28 @@ -#include "CppUTest/TestHarness.h" +#include +#include + #include "SolidSyslogAtomicCounter.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogMetaSd.h" #include "SolidSyslogStructuredData.h" #include "TestAtomicOps.h" +#include "CppUTest/TestHarness.h" -#include -#include +class TEST_SolidSyslogMetaSd_FirstFormatProducesSequenceId1_Test; +class TEST_SolidSyslogMetaSd_FormatEscapesBackslashInLanguage_Test; +class TEST_SolidSyslogMetaSd_FormatEscapesBracketInLanguage_Test; +class TEST_SolidSyslogMetaSd_FormatEscapesQuoteInLanguage_Test; +class TEST_SolidSyslogMetaSd_FormatIncludesDifferentLanguageFromCallback_Test; +class TEST_SolidSyslogMetaSd_FormatIncludesDifferentSysUpTimeFromCallback_Test; +class TEST_SolidSyslogMetaSd_FormatIncludesLanguageFromCallback_Test; +class TEST_SolidSyslogMetaSd_FormatIncludesSysUpTimeAtMaxUint32_Test; +class TEST_SolidSyslogMetaSd_FormatIncludesSysUpTimeAtZero_Test; +class TEST_SolidSyslogMetaSd_FormatIncludesSysUpTimeFromCallback_Test; +class TEST_SolidSyslogMetaSd_SecondFormatProducesSequenceId2_Test; +class TEST_SolidSyslogMetaSd_ThirdFormatProducesSequenceId3_Test; +struct SolidSyslogAtomicCounter; +struct SolidSyslogFormatter; +struct SolidSyslogStructuredData; enum { diff --git a/Tests/SolidSyslogNullBufferTest.cpp b/Tests/SolidSyslogNullBufferTest.cpp index 20fd5a8e..b3432585 100644 --- a/Tests/SolidSyslogNullBufferTest.cpp +++ b/Tests/SolidSyslogNullBufferTest.cpp @@ -1,4 +1,7 @@ +#include + #include "CppUTest/TestHarness.h" +#include "SolidSyslogBuffer.h" #include "SolidSyslogNullBuffer.h" #include "SenderFake.h" @@ -75,6 +78,7 @@ TEST(SolidSyslogNullBuffer, ReadReturnsNothingToSend) } IGNORE_TEST(SolidSyslogNullBuffer, HappyPathOnly) + { // Error handling not yet implemented — see Epic #31 // Create with NULL sender returns NULL diff --git a/Tests/SolidSyslogNullSecurityPolicyTest.cpp b/Tests/SolidSyslogNullSecurityPolicyTest.cpp index 795fa461..cda56148 100644 --- a/Tests/SolidSyslogNullSecurityPolicyTest.cpp +++ b/Tests/SolidSyslogNullSecurityPolicyTest.cpp @@ -1,5 +1,6 @@ #include "CppUTest/TestHarness.h" #include "SolidSyslogNullSecurityPolicy.h" +#include "SolidSyslogSecurityPolicyDefinition.h" // clang-format off TEST_GROUP(SolidSyslogNullSecurityPolicy) diff --git a/Tests/SolidSyslogNullStoreTest.cpp b/Tests/SolidSyslogNullStoreTest.cpp index 50dfa220..7b120faf 100644 --- a/Tests/SolidSyslogNullStoreTest.cpp +++ b/Tests/SolidSyslogNullStoreTest.cpp @@ -1,5 +1,8 @@ +#include + #include "CppUTest/TestHarness.h" #include "SolidSyslogNullStore.h" +#include "SolidSyslogStore.h" // clang-format off TEST_GROUP(SolidSyslogNullStore) diff --git a/Tests/SolidSyslogOriginSdTest.cpp b/Tests/SolidSyslogOriginSdTest.cpp index 619ed972..bdfe778a 100644 --- a/Tests/SolidSyslogOriginSdTest.cpp +++ b/Tests/SolidSyslogOriginSdTest.cpp @@ -1,13 +1,22 @@ -#include "CppUTest/TestHarness.h" -#include "SolidSyslogFormatter.h" -#include "SolidSyslogOriginSd.h" -#include "SolidSyslogStructuredData.h" - #include #include #include #include +#include "SolidSyslogFormatter.h" +#include "SolidSyslogOriginSd.h" +#include "SolidSyslogStructuredData.h" +#include "CppUTest/TestHarness.h" + +class TEST_SolidSyslogOriginSd_EnterpriseIdContainingSpecialsIsEscaped_Test; +class TEST_SolidSyslogOriginSd_FormatIncludesDifferentEnterpriseIdFromConfig_Test; +class TEST_SolidSyslogOriginSd_FormatIncludesDifferentIpFromCallback_Test; +class TEST_SolidSyslogOriginSd_FormatIncludesEnterpriseIdFromConfig_Test; +class TEST_SolidSyslogOriginSd_FormatIncludesOneIpFromCallback_Test; +class TEST_SolidSyslogOriginSd_IpContainingSpecialsIsEscaped_Test; +struct SolidSyslogFormatter; +struct SolidSyslogStructuredData; + enum { /* Worst-case fully-escaped output is 337 bytes — see diff --git a/Tests/SolidSyslogPosixClockTest.cpp b/Tests/SolidSyslogPosixClockTest.cpp index 647ff6aa..11d42354 100644 --- a/Tests/SolidSyslogPosixClockTest.cpp +++ b/Tests/SolidSyslogPosixClockTest.cpp @@ -1,5 +1,8 @@ +#include + #include "CppUTest/TestHarness.h" #include "SolidSyslogPosixClock.h" +#include "SolidSyslogTimestamp.h" #include "ClockFake.h" // 2025-04-02T00:00:00Z diff --git a/Tests/SolidSyslogPosixDatagramTest.cpp b/Tests/SolidSyslogPosixDatagramTest.cpp index f6881d5d..4084a385 100644 --- a/Tests/SolidSyslogPosixDatagramTest.cpp +++ b/Tests/SolidSyslogPosixDatagramTest.cpp @@ -1,4 +1,5 @@ #include "CppUTest/TestHarness.h" +#include "SolidSyslogAddress.h" #include "SolidSyslogDatagram.h" #include "SolidSyslogPosixDatagram.h" #include "SolidSyslogUdpPayload.h" diff --git a/Tests/SolidSyslogPosixFileTest.cpp b/Tests/SolidSyslogPosixFileTest.cpp index 64a60566..d4566acd 100644 --- a/Tests/SolidSyslogPosixFileTest.cpp +++ b/Tests/SolidSyslogPosixFileTest.cpp @@ -1,4 +1,5 @@ #include "CppUTest/TestHarness.h" +#include "SolidSyslogFile.h" #include "SolidSyslogPosixFile.h" #include "SocketFake.h" diff --git a/Tests/SolidSyslogPosixMessageQueueBufferTest.cpp b/Tests/SolidSyslogPosixMessageQueueBufferTest.cpp index 7380b455..4f9639c8 100644 --- a/Tests/SolidSyslogPosixMessageQueueBufferTest.cpp +++ b/Tests/SolidSyslogPosixMessageQueueBufferTest.cpp @@ -1,10 +1,15 @@ +#include + #include "CppUTest/TestHarness.h" +#include "SolidSyslogBuffer.h" #include "SolidSyslogPosixMessageQueueBuffer.h" #include "SolidSyslog.h" #include "SolidSyslogConfig.h" #include "SolidSyslogNullStore.h" #include "SenderFake.h" -#include +#include "SolidSyslogPrival.h" + +struct SolidSyslogStore; static const char* const TEST_MESSAGE = "hello"; static const size_t TEST_MESSAGE_LEN = 5; @@ -106,6 +111,7 @@ TEST(SolidSyslogPosixMessageQueueBuffer, ServiceSendsMessageWrittenViaLog) } IGNORE_TEST(SolidSyslogPosixMessageQueueBuffer, HappyPathOnly) + { // Error handling not yet implemented — see Epic #31 // Create with zero maxMessageSize or maxMessages diff --git a/Tests/SolidSyslogPosixSysUpTimeTest.cpp b/Tests/SolidSyslogPosixSysUpTimeTest.cpp index 152446f9..76f7e16b 100644 --- a/Tests/SolidSyslogPosixSysUpTimeTest.cpp +++ b/Tests/SolidSyslogPosixSysUpTimeTest.cpp @@ -1,8 +1,8 @@ -#include "CppUTest/TestHarness.h" +#include + #include "ClockFake.h" #include "SolidSyslogPosixSysUpTime.h" - -#include +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(SolidSyslogPosixSysUpTime) diff --git a/Tests/SolidSyslogPosixTcpStreamTest.cpp b/Tests/SolidSyslogPosixTcpStreamTest.cpp index 0ab10cd7..bb0056ba 100644 --- a/Tests/SolidSyslogPosixTcpStreamTest.cpp +++ b/Tests/SolidSyslogPosixTcpStreamTest.cpp @@ -1,14 +1,17 @@ +#include +#include +#include +#include +#include +#include +#include + #include "CppUTest/TestHarness.h" #include "SolidSyslogAddress.h" #include "SolidSyslogPosixTcpStream.h" #include "SolidSyslogStream.h" +#include "SolidSyslogTransport.h" #include "SocketFake.h" -#include -#include -#include -#include -#include -#include // clang-format off static const char* const TEST_MESSAGE = "hello"; diff --git a/Tests/SolidSyslogPrivalTest.cpp b/Tests/SolidSyslogPrivalTest.cpp index 82627f45..afad3407 100644 --- a/Tests/SolidSyslogPrivalTest.cpp +++ b/Tests/SolidSyslogPrivalTest.cpp @@ -1,5 +1,5 @@ -#include "CppUTest/TestHarness.h" #include "SolidSyslogPrival.h" +#include "CppUTest/TestHarness.h" TEST_GROUP(SolidSyslogPrival){}; diff --git a/Tests/SolidSyslogStdAtomicOpsTest.cpp b/Tests/SolidSyslogStdAtomicOpsTest.cpp index e832a745..cb0d7727 100644 --- a/Tests/SolidSyslogStdAtomicOpsTest.cpp +++ b/Tests/SolidSyslogStdAtomicOpsTest.cpp @@ -1,6 +1,6 @@ -#include "CppUTest/TestHarness.h" #include "SolidSyslogAtomicOpsDefinition.h" #include "SolidSyslogStdAtomicOps.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(SolidSyslogStdAtomicOps) diff --git a/Tests/SolidSyslogStreamSenderTest.cpp b/Tests/SolidSyslogStreamSenderTest.cpp index e4269652..c56419f7 100644 --- a/Tests/SolidSyslogStreamSenderTest.cpp +++ b/Tests/SolidSyslogStreamSenderTest.cpp @@ -1,4 +1,9 @@ -#include "CppUTest/TestHarness.h" +#include +#include +#include +#include +#include + #include "SolidSyslogEndpoint.h" #include "SolidSyslogFormatter.h" #include "SolidSyslogGetAddrInfoResolver.h" @@ -6,8 +11,7 @@ #include "SolidSyslogSender.h" #include "SolidSyslogStreamSender.h" #include "SocketFake.h" -#include -#include +#include "CppUTest/TestHarness.h" // clang-format off static const char* const TEST_HOST = "127.0.0.1"; diff --git a/Tests/SolidSyslogSwitchingSenderTest.cpp b/Tests/SolidSyslogSwitchingSenderTest.cpp index 173c2fa9..ed28647a 100644 --- a/Tests/SolidSyslogSwitchingSenderTest.cpp +++ b/Tests/SolidSyslogSwitchingSenderTest.cpp @@ -1,8 +1,11 @@ -#include "CppUTest/TestHarness.h" +#include +#include + #include "SenderFake.h" #include "SolidSyslogSender.h" #include "SolidSyslogSwitchingSender.h" #include "TestUtils.h" +#include "CppUTest/TestHarness.h" using namespace CososoTesting; // NOLINT(google-build-using-namespace) -- test-file scope only; brings NEVER/ONCE/TWICE/THRICE into scope for CALLED_FUNCTION diff --git a/Tests/SolidSyslogTest.cpp b/Tests/SolidSyslogTest.cpp index 8e77bff6..4c1d9d41 100644 --- a/Tests/SolidSyslogTest.cpp +++ b/Tests/SolidSyslogTest.cpp @@ -1,4 +1,7 @@ -#include "CppUTest/TestHarness.h" +#include +#include +#include + #include "SolidSyslog.h" #include "SolidSyslogAtomicCounter.h" #include "SolidSyslogConfig.h" @@ -13,8 +16,93 @@ #include "StoreFake.h" #include "SenderFake.h" #include "StringFake.h" -#include -#include +#include "SolidSyslogBuffer.h" +#include "SolidSyslogPrival.h" +#include "SolidSyslogStore.h" +#include "SolidSyslogTimeQuality.h" +#include "SolidSyslogTimestamp.h" +#include "CppUTest/TestHarness.h" + +class TEST_SolidSyslogTimestamp_Day0ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_Day1FormatsAs01_Test; +class TEST_SolidSyslogTimestamp_Day31FormatsAs31_Test; +class TEST_SolidSyslogTimestamp_Day32ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_DayFormatsAsTwoDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_Hour0FormatsAs00_Test; +class TEST_SolidSyslogTimestamp_Hour23FormatsAs23_Test; +class TEST_SolidSyslogTimestamp_Hour24ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_HourFormatsAsTwoDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_Microsecond0FormatsAs000000_Test; +class TEST_SolidSyslogTimestamp_Microsecond1000000ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_Microsecond999999FormatsAs999999_Test; +class TEST_SolidSyslogTimestamp_MicrosecondFormatsAsSixDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_Minute0FormatsAs00_Test; +class TEST_SolidSyslogTimestamp_Minute59FormatsAs59_Test; +class TEST_SolidSyslogTimestamp_Minute60ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_MinuteFormatsAsTwoDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_Month0ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_Month12FormatsAs12_Test; +class TEST_SolidSyslogTimestamp_Month13ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_Month1FormatsAs01_Test; +class TEST_SolidSyslogTimestamp_MonthFormatsAsTwoDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_NegativeOffsetFormatsAsMinusHHMM_Test; +class TEST_SolidSyslogTimestamp_NullClockProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_PositiveOffsetFormatsAsPlusHHMM_Test; +class TEST_SolidSyslogTimestamp_Second0FormatsAs00_Test; +class TEST_SolidSyslogTimestamp_Second59FormatsAs59_Test; +class TEST_SolidSyslogTimestamp_Second60ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_SecondFormatsAsTwoDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_TimestampAppearsInCorrectMessageFieldPosition_Test; +class TEST_SolidSyslogTimestamp_UtcOffsetMinus720FormatsAsMinus1200_Test; +class TEST_SolidSyslogTimestamp_UtcOffsetMinus721ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_UtcOffsetPlus840FormatsAsPlus1400_Test; +class TEST_SolidSyslogTimestamp_UtcOffsetPlus841ProducesNilvalue_Test; +class TEST_SolidSyslogTimestamp_Year9999FormatsAs9999_Test; +class TEST_SolidSyslogTimestamp_YearFormatsAsFourDigitZeroPadded_Test; +class TEST_SolidSyslogTimestamp_YearZeroFormatsAs0000_Test; +class TEST_SolidSyslogTimestamp_ZeroOffsetFormatsAsZ_Test; +class TEST_SolidSyslog_AllFieldsAtMaxLengthProducesValidMessage_Test; +class TEST_SolidSyslog_AppNameAt48CharsIsAccepted_Test; +class TEST_SolidSyslog_AppNameAt49CharsIsTruncatedTo48_Test; +class TEST_SolidSyslog_AppNameCallbackIsInvokedPerLogCall_Test; +class TEST_SolidSyslog_AppNameFromGetAppNameAppearsInMessage_Test; +class TEST_SolidSyslog_AppNameNonPrintableByteIsSubstitutedWithQuestionMark_Test; +class TEST_SolidSyslog_EmptyAppNameProducesNilvalue_Test; +class TEST_SolidSyslog_EmptyHostnameProducesNilvalue_Test; +class TEST_SolidSyslog_EmptyMessageIdProducesNilvalue_Test; +class TEST_SolidSyslog_EmptyProcessIdProducesNilvalue_Test; +class TEST_SolidSyslog_FacilityAppearsInPrival_Test; +class TEST_SolidSyslog_HighestFacilityProducesCorrectPrival_Test; +class TEST_SolidSyslog_HighestSeverityProducesCorrectPrival_Test; +class TEST_SolidSyslog_HostnameAt255CharsIsAccepted_Test; +class TEST_SolidSyslog_HostnameAt256CharsIsTruncatedTo255_Test; +class TEST_SolidSyslog_HostnameCallbackIsInvokedPerLogCall_Test; +class TEST_SolidSyslog_HostnameFromGetHostnameAppearsInMessage_Test; +class TEST_SolidSyslog_HostnameNonPrintableByteIsSubstitutedWithQuestionMark_Test; +class TEST_SolidSyslog_LogAfterDestroyAndRecreateWithNullFunctionsProducesNilvalues_Test; +class TEST_SolidSyslog_LowestFacilityProducesCorrectPrival_Test; +class TEST_SolidSyslog_LowestSeverityProducesCorrectPrival_Test; +class TEST_SolidSyslog_MessageIdAppearsInMessage_Test; +class TEST_SolidSyslog_MessageIdAt32CharsIsAccepted_Test; +class TEST_SolidSyslog_MessageIdAt33CharsIsTruncatedTo32_Test; +class TEST_SolidSyslog_MessageIdIsNotHardCoded_Test; +class TEST_SolidSyslog_MessageIdNonPrintableByteIsSubstitutedWithQuestionMark_Test; +class TEST_SolidSyslog_NullGetAppNameProducesNilvalue_Test; +class TEST_SolidSyslog_NullGetHostnameProducesNilvalue_Test; +class TEST_SolidSyslog_NullGetProcessIdProducesNilvalue_Test; +class TEST_SolidSyslog_NullMessageIdProducesNilvalue_Test; +class TEST_SolidSyslog_OutOfRangeFacilityProducesErrorPrival_Test; +class TEST_SolidSyslog_OutOfRangeSeverityProducesErrorPrival_Test; +class TEST_SolidSyslog_PriValIs134_Test; +class TEST_SolidSyslog_ProcessIdAt128CharsIsAccepted_Test; +class TEST_SolidSyslog_ProcessIdAt129CharsIsTruncatedTo128_Test; +class TEST_SolidSyslog_ProcessIdCallbackIsInvokedPerLogCall_Test; +class TEST_SolidSyslog_ProcessIdFromGetProcessIdAppearsInMessage_Test; +class TEST_SolidSyslog_ProcessIdNonPrintableByteIsSubstitutedWithQuestionMark_Test; +class TEST_SolidSyslog_SeverityAppearsInPrival_Test; +struct SolidSyslogAtomicCounter; +struct SolidSyslogBuffer; +struct SolidSyslogStore; // clang-format off static const char * const TEST_PRIVAL = "<134>"; @@ -1418,6 +1506,7 @@ TEST(SolidSyslog, LogAfterDestroyAndRecreateWithNullFunctionsProducesNilvalues) } IGNORE_TEST(SolidSyslog, HappyPathOnly) + { // Error handling not yet implemented — see Epic #31 // SolidSyslog_Create with a NULL config does not crash diff --git a/Tests/SolidSyslogTimeQualitySdTest.cpp b/Tests/SolidSyslogTimeQualitySdTest.cpp index 6abb0d02..d53f0e02 100644 --- a/Tests/SolidSyslogTimeQualitySdTest.cpp +++ b/Tests/SolidSyslogTimeQualitySdTest.cpp @@ -1,9 +1,14 @@ -#include "CppUTest/TestHarness.h" +#include +#include + #include "SolidSyslogFormatter.h" #include "SolidSyslogTimeQualitySd.h" #include "SolidSyslogStructuredData.h" +#include "SolidSyslogTimeQuality.h" +#include "CppUTest/TestHarness.h" -#include +struct SolidSyslogFormatter; +struct SolidSyslogStructuredData; enum { diff --git a/Tests/SolidSyslogTlsStreamTest.cpp b/Tests/SolidSyslogTlsStreamTest.cpp index 86c81078..f5c663fb 100644 --- a/Tests/SolidSyslogTlsStreamTest.cpp +++ b/Tests/SolidSyslogTlsStreamTest.cpp @@ -1,11 +1,16 @@ -#include "CppUTest/TestHarness.h" +#include +#include +#include +#include +#include + #include "OpenSslFake.h" #include "SolidSyslogAddress.h" #include "SolidSyslogStream.h" #include "SolidSyslogTlsStream.h" #include "SolidSyslogTransport.h" #include "StreamFake.h" -#include +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(SolidSyslogTlsStream) diff --git a/Tests/SolidSyslogUdpPayloadTest.cpp b/Tests/SolidSyslogUdpPayloadTest.cpp index 950cca9c..a92c6ce8 100644 --- a/Tests/SolidSyslogUdpPayloadTest.cpp +++ b/Tests/SolidSyslogUdpPayloadTest.cpp @@ -1,7 +1,8 @@ -#include "CppUTest/TestHarness.h" -#include "SolidSyslogUdpPayload.h" #include +#include "SolidSyslogUdpPayload.h" +#include "CppUTest/TestHarness.h" + // clang-format off TEST_GROUP(SolidSyslogUdpPayload) { diff --git a/Tests/SolidSyslogUdpSenderTest.cpp b/Tests/SolidSyslogUdpSenderTest.cpp index 891b22b2..d009355f 100644 --- a/Tests/SolidSyslogUdpSenderTest.cpp +++ b/Tests/SolidSyslogUdpSenderTest.cpp @@ -1,4 +1,9 @@ -#include "CppUTest/TestHarness.h" +#include +#include +#include +#include +#include + #include "DatagramFake.h" #include "SolidSyslogEndpoint.h" #include "SolidSyslogFormatter.h" @@ -7,9 +12,8 @@ #include "SolidSyslogUdpSender.h" #include "SolidSyslogSender.h" #include "SocketFake.h" -#include -#include -#include +#include "SolidSyslogDatagram.h" +#include "CppUTest/TestHarness.h" // clang-format off static const char* const TEST_MESSAGE = "hello"; @@ -274,6 +278,7 @@ TEST(SolidSyslogUdpSender, EndpointVersionChangeUsesNewPortOnReconnect) } IGNORE_TEST(SolidSyslogUdpSender, HappyPathOnly) + { // Error handling not yet implemented — see Epic #31 // Create with NULL config returns NULL diff --git a/Tests/SolidSyslogWindowsClockTest.cpp b/Tests/SolidSyslogWindowsClockTest.cpp index 98032a13..d6c74741 100644 --- a/Tests/SolidSyslogWindowsClockTest.cpp +++ b/Tests/SolidSyslogWindowsClockTest.cpp @@ -1,4 +1,5 @@ #include "CppUTest/TestHarness.h" +#include "SolidSyslogTimestamp.h" #include "SolidSyslogWindowsClock.h" #include "SolidSyslogWindowsClockInternal.h" diff --git a/Tests/SolidSyslogWindowsFileTest.cpp b/Tests/SolidSyslogWindowsFileTest.cpp index 65a81469..1594979a 100644 --- a/Tests/SolidSyslogWindowsFileTest.cpp +++ b/Tests/SolidSyslogWindowsFileTest.cpp @@ -1,4 +1,5 @@ #include "CppUTest/TestHarness.h" +#include "SolidSyslogFile.h" #include "SolidSyslogWindowsFile.h" #include diff --git a/Tests/SolidSyslogWinsockDatagramTest.cpp b/Tests/SolidSyslogWinsockDatagramTest.cpp index 7fb72153..f82cb876 100644 --- a/Tests/SolidSyslogWinsockDatagramTest.cpp +++ b/Tests/SolidSyslogWinsockDatagramTest.cpp @@ -1,4 +1,5 @@ #include "CppUTest/TestHarness.h" +#include "SolidSyslogAddress.h" #include "SolidSyslogDatagram.h" #include "SolidSyslogUdpPayload.h" #include "SolidSyslogWinsockDatagram.h" diff --git a/Tests/StoreFake.c b/Tests/StoreFake.c index 5af64d0c..2c4fc31e 100644 --- a/Tests/StoreFake.c +++ b/Tests/StoreFake.c @@ -1,8 +1,10 @@ #include "StoreFake.h" -#include "SolidSyslogStoreDefinition.h" -#include "TestUtils.h" #include +#include + +#include "SolidSyslogStoreDefinition.h" +#include "TestUtils.h" enum { diff --git a/Tests/StoreFake.h b/Tests/StoreFake.h index 4d903439..2b80d63b 100644 --- a/Tests/StoreFake.h +++ b/Tests/StoreFake.h @@ -1,7 +1,7 @@ #ifndef STOREFAKE_H #define STOREFAKE_H -#include "SolidSyslogStore.h" +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Tests/StoreFakeTest.cpp b/Tests/StoreFakeTest.cpp index dc7dd8ce..86a20b6b 100644 --- a/Tests/StoreFakeTest.cpp +++ b/Tests/StoreFakeTest.cpp @@ -1,5 +1,8 @@ -#include "CppUTest/TestHarness.h" +#include + #include "StoreFake.h" +#include "SolidSyslogStore.h" +#include "CppUTest/TestHarness.h" static const char* const TEST_MESSAGE = "hello"; static const size_t TEST_MESSAGE_LEN = 5; diff --git a/Tests/StreamFake.h b/Tests/StreamFake.h index 0a53aa60..9d8ff24d 100644 --- a/Tests/StreamFake.h +++ b/Tests/StreamFake.h @@ -1,15 +1,16 @@ #ifndef STREAMFAKE_H #define STREAMFAKE_H +#include +#include + #include "ExternC.h" #include "SolidSyslogStream.h" -#include -#include - EXTERN_C_BEGIN struct SolidSyslogStream; + struct SolidSyslogAddress; struct SolidSyslogStream* StreamFake_Create(void); diff --git a/Tests/StreamFakeTest.cpp b/Tests/StreamFakeTest.cpp index 0ac32633..141523ce 100644 --- a/Tests/StreamFakeTest.cpp +++ b/Tests/StreamFakeTest.cpp @@ -1,7 +1,7 @@ -#include "CppUTest/TestHarness.h" #include "SolidSyslogAddress.h" #include "SolidSyslogStream.h" #include "StreamFake.h" +#include "CppUTest/TestHarness.h" // clang-format off TEST_GROUP(StreamFake) diff --git a/Tests/StringFake.c b/Tests/StringFake.c index d70737bb..5699317c 100644 --- a/Tests/StringFake.c +++ b/Tests/StringFake.c @@ -1,8 +1,11 @@ #include "StringFake.h" -#include "SolidSyslogFormatter.h" #include +#include "SolidSyslogFormatter.h" + +struct SolidSyslogFormatter; + static const char* fakeHostname; static const char* fakeAppName; static const char* fakeProcessId; diff --git a/Tests/StringFake.h b/Tests/StringFake.h index 2cf07b5b..90b8b2e5 100644 --- a/Tests/StringFake.h +++ b/Tests/StringFake.h @@ -1,7 +1,9 @@ #ifndef STRINGFAKE_H #define STRINGFAKE_H -#include "SolidSyslogConfig.h" +#include "ExternC.h" + +struct SolidSyslogFormatter; EXTERN_C_BEGIN diff --git a/Tests/StringFakeTest.cpp b/Tests/StringFakeTest.cpp index 4880674f..c1a9d584 100644 --- a/Tests/StringFakeTest.cpp +++ b/Tests/StringFakeTest.cpp @@ -1,6 +1,8 @@ -#include "CppUTest/TestHarness.h" #include "SolidSyslogFormatter.h" #include "StringFake.h" +#include "CppUTest/TestHarness.h" + +struct SolidSyslogFormatter; enum { diff --git a/Tests/Support/AtomicOpsFake.c b/Tests/Support/AtomicOpsFake.c index 8fd3396f..fe7cd1bd 100644 --- a/Tests/Support/AtomicOpsFake.c +++ b/Tests/Support/AtomicOpsFake.c @@ -2,6 +2,8 @@ #include +#include "SolidSyslogAtomicOpsDefinition.h" + static uint32_t loadValue; static bool nextCompareAndSwapShouldFail; static uint32_t loadShiftValue; diff --git a/Tests/Support/AtomicOpsFake.h b/Tests/Support/AtomicOpsFake.h index 5672e9ca..219c2f1f 100644 --- a/Tests/Support/AtomicOpsFake.h +++ b/Tests/Support/AtomicOpsFake.h @@ -1,11 +1,10 @@ #ifndef ATOMICOPSFAKE_H #define ATOMICOPSFAKE_H -#include "ExternC.h" -#include "SolidSyslogAtomicOpsDefinition.h" - #include +#include "ExternC.h" + EXTERN_C_BEGIN void AtomicOpsFake_Reset(void); diff --git a/Tests/Support/ClockFake.c b/Tests/Support/ClockFake.c index 09645d52..3371d56e 100644 --- a/Tests/Support/ClockFake.c +++ b/Tests/Support/ClockFake.c @@ -1,7 +1,10 @@ #include "ClockFake.h" -#include #include +#include + +struct timespec; +struct tm; static time_t fakeSeconds; static long fakeNanoseconds; diff --git a/Tests/Support/ClockFake.h b/Tests/Support/ClockFake.h index 914a0555..ee7c343d 100644 --- a/Tests/Support/ClockFake.h +++ b/Tests/Support/ClockFake.h @@ -1,9 +1,11 @@ #ifndef CLOCKFAKE_H #define CLOCKFAKE_H +#include + #include "ExternC.h" -#include +struct tm; EXTERN_C_BEGIN diff --git a/Tests/Support/OpenSslFake.c b/Tests/Support/OpenSslFake.c index 142190c8..a2e1e37f 100644 --- a/Tests/Support/OpenSslFake.c +++ b/Tests/Support/OpenSslFake.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include /* ------------------------------------------------------------------------- * Captured state — one section per OpenSSL API call. Tests read these via diff --git a/Tests/Support/OpenSslFake.h b/Tests/Support/OpenSslFake.h index 8ebae21a..dda5939b 100644 --- a/Tests/Support/OpenSslFake.h +++ b/Tests/Support/OpenSslFake.h @@ -3,7 +3,7 @@ #include "ExternC.h" -#include +#include // IWYU pragma: keep — dual-use header (C and C++ TUs); IWYU only sees the C++ side and would drop this. /* Forward-declared OpenSSL types — full definitions live in . */ struct ssl_ctx_st; diff --git a/Tests/Support/SocketFake.h b/Tests/Support/SocketFake.h index 284ecf28..d78af8cd 100644 --- a/Tests/Support/SocketFake.h +++ b/Tests/Support/SocketFake.h @@ -1,10 +1,12 @@ #ifndef SOCKETFAKE_H #define SOCKETFAKE_H -#include "ExternC.h" #include #include #include +#include + +#include "ExternC.h" EXTERN_C_BEGIN diff --git a/Tests/TestUtils.h b/Tests/TestUtils.h index 62907c3d..ae279a22 100644 --- a/Tests/TestUtils.h +++ b/Tests/TestUtils.h @@ -10,6 +10,8 @@ static inline size_t MinSize(size_t a, size_t b) #ifdef __cplusplus +#include "CppUTest/TestHarness.h" // IWYU pragma: keep — only used by the C++ macros below; placed inside the __cplusplus guard so C consumers don't pull in C++ headers. + namespace CososoTesting { /* Expected call counts — readable names for CALLED_FUNCTION assertions. diff --git a/cmake/Iwyu.cmake b/cmake/Iwyu.cmake new file mode 100644 index 00000000..f7bf0089 --- /dev/null +++ b/cmake/Iwyu.cmake @@ -0,0 +1,72 @@ +# Include-what-you-use (IWYU) opt-in. +# +# When ENABLE_IWYU is ON, two custom targets are defined: +# +# iwyu — runs IWYU over Core/, Platform/, Example/. Pipes IWYU's +# output through scripts/iwyu_filter.py, which drops +# redundant-forward-declaration findings (see filter docstring +# for the MISRA rationale). Exits non-zero if any actionable +# finding remains. +# iwyu-apply — applies the surviving suggestions via fix_includes.py. +# Used during cleanup, never invoked from CI. +# +# Bdd/ is out of scope per CLAUDE.md tier table. Tests/ is included even +# though it's Tier 4 ("out of scope for support") because narrowing the +# public Core headers exposes test code that was relying on transitive +# includes; the same hygiene rule needs to hold there or the gate keeps +# tripping consumers. +# +# We don't use CMake's CMAKE__INCLUDE_WHAT_YOU_USE launcher mechanism +# because CMake (since 3.11) intentionally ignores the launcher's exit code, +# so `--error` would not fail the build. + +option(ENABLE_IWYU "Define iwyu/iwyu-apply targets that run include-what-you-use over Core/Platform/Example" OFF) + +if(ENABLE_IWYU) + find_program(IWYU_EXECUTABLE NAMES include-what-you-use REQUIRED) + find_program(IWYU_TOOL NAMES iwyu_tool.py iwyu_tool REQUIRED) + find_program(IWYU_FIX NAMES fix_includes.py fix_includes REQUIRED) + find_program(BASH_EXECUTABLE NAMES bash REQUIRED) + + set(_iwyu_mapping_dir "/usr/local/share/include-what-you-use") + set(_iwyu_filter "${CMAKE_SOURCE_DIR}/scripts/iwyu_filter.py") + + # No explicit source-file list — iwyu_tool.py iterates every entry in + # compile_commands.json, so the active configuration's sources are exactly + # what gets analysed. (Listing files explicitly produced spurious "not found + # in compilation database" warnings for Windows-only sources on Linux.) + # IWYU's own --error flag is intentionally NOT set: with --error, IWYU + # exits non-zero on any finding, including the filtered-out classes + # (forward decls, dual-language headers, CppUTest macros). That non-zero + # exit propagates through iwyu_tool.py and pipefail before our filter + # gets a chance to suppress benign findings. Instead, IWYU always exits 0 + # and scripts/iwyu_filter.py is the authoritative gate. + set(_iwyu_invocation + "${IWYU_TOOL} -p ${CMAKE_BINARY_DIR} -- \ +-Xiwyu --check_also=*Interface/*.h \ +-Xiwyu --check_also=*Example/*/*.h \ +-Xiwyu --check_also=*Tests/*.h \ +-Xiwyu --mapping_file=${_iwyu_mapping_dir}/gcc.libc.imp \ +-Xiwyu --mapping_file=${_iwyu_mapping_dir}/stl.c.headers.imp \ +-Xiwyu --mapping_file=${_iwyu_mapping_dir}/stl.public.imp \ +-Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/cmake/cpputest.imp" + ) + + add_custom_target(iwyu + COMMAND "${BASH_EXECUTABLE}" -c + "set -o pipefail; ${_iwyu_invocation} | python3 ${_iwyu_filter}" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Running include-what-you-use (filtered) over Core/, Platform/, Example/" + VERBATIM + USES_TERMINAL + ) + + add_custom_target(iwyu-apply + COMMAND "${BASH_EXECUTABLE}" -c + "${_iwyu_invocation} | python3 ${_iwyu_filter} --filter-only | ${IWYU_FIX} --nosafe_headers" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Applying include-what-you-use suggestions (filtered)" + VERBATIM + USES_TERMINAL + ) +endif() diff --git a/cmake/cpputest.imp b/cmake/cpputest.imp new file mode 100644 index 00000000..296b142e --- /dev/null +++ b/cmake/cpputest.imp @@ -0,0 +1,21 @@ +[ + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] }, + { "include": ["", "private", "\"CppUTest/TestHarness.h\"", "public"] } +] diff --git a/scripts/iwyu_filter.py b/scripts/iwyu_filter.py new file mode 100755 index 00000000..6786a3e4 --- /dev/null +++ b/scripts/iwyu_filter.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +"""Filter IWYU output to drop categories that don't apply to this project. + +IWYU's analysis is enabled in CI as a ratchet against include-hygiene drift. +Three classes of 'should remove' finding are filtered out before the gate +evaluates, because each represents IWYU producing the wrong answer for this +codebase rather than a real drift: + +1. '- struct ;' — explicit forward declarations. + In C, 'struct Foo* member;' inside another struct definition itself + introduces 'struct Foo' at file scope, so IWYU considers preceding + explicit 'struct Foo;' lines redundant. The project deliberately keeps + them — clearer to a reader, more MISRA-aligned (Directive 4.8 still + applies: forward-decl over full-include where a pointer is all that's + used). + +2. '- #include ' — dual-language headers. + Public Core headers expose 'bool' in C-callable function signatures and + are consumed from both C TUs (production) and C++ TUs (CppUTest tests). + IWYU sees the C++ side, where 'bool' is built-in, and concludes the + include is unused. Removing it would break C consumers. + +3. '- #include "CppUTest/TestHarness.h"' — test-framework macros. + IWYU does not model how TEST_GROUP / TEST / CHECK_* macros expand. + It thinks the include is unused because the symbols it provides are + only invoked via macros. Removing it would break every test file. + +Reads IWYU output (typically the stdout of iwyu_tool.py) on stdin, emits +filtered output on stdout. File blocks whose only findings are filtered +removals are suppressed entirely, so the report shows only actionable +findings. + +Exit code: + 0 — no actionable findings remain after filtering + 1 — actionable findings remain (default 'check' behaviour) +""" + +import re +import sys + +FILTERED_REMOVALS = ( + re.compile(r"^- struct \w+;\s*//"), + re.compile(r"^- #include \s*//"), + re.compile(r"^- #include \"CppUTest/TestHarness\.h\"\s*//"), +) + + +def _is_filtered_removal(line): + return any(pat.match(line) for pat in FILTERED_REMOVALS) + + +def filter_iwyu(stream_in, stream_out): + """Filter IWYU output; return count of files with actionable findings.""" + lines = stream_in.readlines() + files_with_findings = 0 + i = 0 + n = len(lines) + + while i < n: + line = lines[i] + # 'should add these lines:' marks the start of a per-file block. + # Block ends at the next '---' separator. + if " should add these lines:" in line: + block_end = i + while block_end < n and not lines[block_end].startswith("---"): + block_end += 1 + # Include the '---' line in the block. + if block_end < n: + block_end += 1 + + block = lines[i:block_end] + kept_block, has_finding = _filter_block(block) + if has_finding: + files_with_findings += 1 + stream_out.writelines(kept_block) + i = block_end + else: + stream_out.write(line) + i += 1 + + return files_with_findings + + +def _filter_block(block): + """Filter one per-file IWYU block; return (kept_lines, has_actionable_finding).""" + add_lines = [] + remove_lines = [] + tail_lines = [] + + section = "header" # header | add | remove | tail + for line in block: + if " should add these lines:" in line: + section = "add" + header = line + continue + if " should remove these lines:" in line: + section = "remove" + continue + if line.startswith("The full include-list for ") or line.startswith("---"): + section = "tail" + tail_lines.append(line) + continue + if section == "add": + add_lines.append(line) + elif section == "remove": + remove_lines.append(line) + elif section == "tail": + tail_lines.append(line) + + add_real = [l for l in add_lines if l.strip()] + remove_real = [ + l for l in remove_lines + if l.strip() and not _is_filtered_removal(l) + ] + + if not add_real and not remove_real: + return [], False + + out = [header] + out.extend(add_lines) + out.append("\n") + out.append(header.replace(" should add these lines:", " should remove these lines:")) + if remove_real: + out.extend(remove_real) + out.append("\n") + out.extend(tail_lines) + return out, True + + +def main(): + files_with_findings = filter_iwyu(sys.stdin, sys.stdout) + if "--filter-only" in sys.argv: + return 0 + return 1 if files_with_findings else 0 + + +if __name__ == "__main__": + sys.exit(main())