diff options
Diffstat (limited to 'library/test/unit')
-rw-r--r-- | library/test/unit/CMakeLists.txt | 58 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_build_test.cpp | 193 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_catid32_test.cpp | 532 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_catid64_test.cpp | 530 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_clock_test.cpp | 92 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_crc32_test.cpp | 138 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_disable_test.cpp | 61 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_gtest.h | 249 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_gtest_main.cpp | 46 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_init_test.cpp | 432 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_printf_test.cpp | 709 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_raw_test.cpp | 162 | ||||
-rw-r--r-- | library/test/unit/mipi_syst_string_test.cpp | 325 |
13 files changed, 3527 insertions, 0 deletions
diff --git a/library/test/unit/CMakeLists.txt b/library/test/unit/CMakeLists.txt new file mode 100644 index 0000000..2ac801c --- /dev/null +++ b/library/test/unit/CMakeLists.txt @@ -0,0 +1,58 @@ +#make install of googletest a nop +# +function(install) +endfunction() + +enable_testing() + +add_definitions(-D_VARIADIC_MAX=10) +if (WIN32) + set (gtest_force_shared_crt ON CACHE BOOL "Force GTest to use shared CRT") +endif (WIN32) +add_subdirectory(${SYST_BUILD_GTEST_DIR} ${CMAKE_CURRENT_BINARY_DIR}/gtest) +mark_as_advanced(BUILD_SHARED_LIBS) + +include_directories( + ${SYST_BUILD_GTEST_DIR}/include + ${mipi_syst_Platform_include} + ${mipi_syst_Includes} + ../../platform/src + ../../platform/${SYST_BUILD_PLATFORM_NAME}/src +) + +add_executable(syst_unittest + mipi_syst_gtest_main.cpp + mipi_syst_init_test.cpp + mipi_syst_disable_test.cpp + mipi_syst_clock_test.cpp + mipi_syst_crc32_test.cpp + mipi_syst_catid32_test.cpp + mipi_syst_catid64_test.cpp + mipi_syst_printf_test.cpp + mipi_syst_raw_test.cpp + mipi_syst_string_test.cpp + mipi_syst_build_test.cpp +) + +target_link_libraries(syst_unittest gtest mipi_syst_static) +set_target_properties(syst_unittest PROPERTIES COMPILE_FLAGS "-DMIPI_SYST_EXPORTS") + +foreach (target gtest gtest_main syst_unittest) + set_property(TARGET ${target} PROPERTY FOLDER "Unittests") +endforeach (target) + +add_test( + NAME syst_unittest + COMMAND syst_unittest + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + + +if (CMAKE_CONFIGURATION_TYPES) + add_custom_target(RUN_TEST_VERBOSE COMMAND ${CMAKE_CTEST_COMMAND} + --force-new-ctest-process --verbose + --build-config "$<CONFIGURATION>") +else() + add_custom_target(RUN_TEST_VERBOSE COMMAND ${CMAKE_CTEST_COMMAND} + --force-new-ctest-process --verbose) +endif()
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_build_test.cpp b/library/test/unit/mipi_syst_build_test.cpp new file mode 100644 index 0000000..1acaf62 --- /dev/null +++ b/library/test/unit/mipi_syst_build_test.cpp @@ -0,0 +1,193 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) &&\ + defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) &&\ + defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP) &&\ + defined(MIPI_SYST_PCFG_ENABLE_BUILD_API) + +class MipiSysTFixtureBuild : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown(){ + MipiSysTFixtureOutput::TearDown(); + } + + const char * mipi_syst_write_build_message( + struct mipi_syst_handle* svh, + struct mipi_syst_msglocation* loc, + enum mipi_syst_severity severity, + mipi_syst_u64 subtype, + const char * data, + mipi_syst_u16 length) + { + sstr.str(""); + + ::mipi_syst_write_build_message(svh, loc, severity, subtype, data, length); + result = sstr.str(); + + return result.c_str(); + } + + static std::string result; +}; + +std::string MipiSysTFixtureBuild::result; + + +#if defined(MIPI_SYST_PCFG_ENABLE_BUILD_API) +TEST_F(MipiSysTFixtureBuild, syst_build_long) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_BUILD(NULL, MIPI_SYST_SEVERITY_MAX, 0x1122334455667788ull, "some text", 10) + ); + + EXPECT_STREQ( + xform("<D32TS>02012200[typ=0:2 mu=1:2 sev=0 len]<D16>0012<D64>1122334455667788<D64>78657420656d6f73<D16>0074<FLAG>"), + MIPI_SYST_BUILD(ph, MIPI_SYST_SEVERITY_MAX, 0x1122334455667788ull, "some text", 10) + ); + EXPECT_STREQ( + xform("<D32TS>02012200[typ=0:2 mu=1:2 sev=0 len]<D16>0008<D64>1122334455667788<FLAG>"), + MIPI_SYST_BUILD(ph, MIPI_SYST_SEVERITY_MAX, 0x1122334455667788ull, NULL, 0) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012300[typ=0:2 mu=1:2 sev=0 loc len]<D8>03<D64>12345678aabbccdd<D16>0012<D64>1122334455667788<D64>78657420656d6f73<D16>0074<FLAG>"), + MIPI_SYST_BUILD_LOCADDR(ph, MIPI_SYST_SEVERITY_MAX, 0x1122334455667788ull, "some text", 10) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012300[typ=0:2 mu=1:2 sev=0 loc len]<D8>02<D32>12345678<D16>0012<D64>1122334455667788<D64>78657420656d6f73<D16>0074<FLAG>"), + MIPI_SYST_BUILD_LOCADDR(ph, MIPI_SYST_SEVERITY_MAX, 0x1122334455667788ull, "some text", 10) + ); + +#endif +#endif + + EXPECT_STREQ( + xform("<D32TS>02012300[typ=0:2 mu=1:2 sev=0 loc len]<D8>00<D32>5678abcd<D16>0012<D64>1122334455667788<D64>78657420656d6f73<D16>0074<FLAG>"), + MIPI_SYST_BUILD_LOC16(ph, MIPI_SYST_SEVERITY_MAX, 0xabcd, 0x1122334455667788ull, "some text", 10) + ); + + EXPECT_STREQ( + xform("<D32TS>02012300[typ=0:2 mu=1:2 sev=0 loc len]<D8>01<D64>12345678aabbccdd<D16>0012<D64>1122334455667788<D64>78657420656d6f73<D16>0074<FLAG>"), + MIPI_SYST_BUILD_LOC32(ph, MIPI_SYST_SEVERITY_MAX, 0xaabbccdd, 0x1122334455667788ull, "some text", 10) + ); +#endif +} + +#endif /* defined(MIPI_SYST_PCFG_ENABLE_BUILD_API)*/ + +#endif + +TEST_F(MipiSysTFixtureOutput, syst_build_compact_null) +{ + std::string str; + + MIPI_SYST_BUILD_COMPACT64(0, 0x0000000000000000ull); + str = sstr.str(); + + EXPECT_STREQ( + xform(""), + str.c_str() + ); + + MIPI_SYST_BUILD_COMPACT32(0, 0); + str = sstr.str(); + + EXPECT_STREQ( + xform(""), + str.c_str() + ); +} + +TEST_F(MipiSysTFixtureOutput, syst_build_compact64) +{ + std::string str; + + MIPI_SYST_BUILD_COMPACT64(ph, 0x0000000000000000ull); + str = sstr.str(); + + EXPECT_STREQ( + xform("<D64MTS>0000000001000000"), + str.c_str() + ); + sstr.str(""); + + MIPI_SYST_BUILD_COMPACT64(ph, 0x3FFFFFFFFFFFFFull); + str = sstr.str(); + + EXPECT_STREQ( + xform("<D64MTS>ffffffffc1fffff0"), + str.c_str() + ); + sstr.str(""); +} + +TEST_F(MipiSysTFixtureOutput, syst_build_compact32) +{ + std::string str; + + MIPI_SYST_BUILD_COMPACT32(ph, 0x00000000ull); + str = sstr.str(); + + EXPECT_STREQ( + xform("<D32MTS>00000000"), + str.c_str() + ); + sstr.str(""); + + MIPI_SYST_BUILD_COMPACT32(ph, 0x3FFFFF); + str = sstr.str(); + + EXPECT_STREQ( + xform("<D32MTS>c0fffff0"), + str.c_str() + ); + sstr.str(""); +}
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_catid32_test.cpp b/library/test/unit/mipi_syst_catid32_test.cpp new file mode 100644 index 0000000..a2e0a27 --- /dev/null +++ b/library/test/unit/mipi_syst_catid32_test.cpp @@ -0,0 +1,532 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) &&\ + defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) &&\ + defined(MIPI_SYST_PCFG_ENABLE_CATID32_API) + +class MipiSysTFixtureCatId32 : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown(){ + MipiSysTFixtureOutput::TearDown(); + } + + const char * mipi_syst_write_catalog32_message(struct mipi_syst_handle* svh, + struct mipi_syst_msglocation* loc, + enum mipi_syst_severity severity, + mipi_syst_u32 catid) + { + static std::string result; + + ::mipi_syst_write_catalog32_message(svh, loc, severity, catid); + result = sstr.str(); + sstr.str(""); + + return result.c_str(); + } +}; + +TEST_F(MipiSysTFixtureCatId32, syst_catid32_basic) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_0(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_1(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE,1 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_2(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_3(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_4(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_5(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2,3,4,5 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_6(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2,3,4,5,6 ) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) + + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_0_LOC16(0,MIPI_SYST_SEVERITY_WARNING, 1, 0xCAFEBABE ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_0_LOC32(0,MIPI_SYST_SEVERITY_WARNING, 1, 0xCAFEBABE ) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG32_0_LOCADDR(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); +#endif +#endif +} + +TEST_F(MipiSysTFixtureCatId32, syst_catid32_noloc_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATALOG32_0(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG32_1(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG32_2(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG32_3(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG32_4(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG32_5(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG32_6(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4, 5, 6) + ); +} + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +TEST_F(MipiSysTFixtureCatId32, syst_catid32_locaddr_output) +{ +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATALOG32_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATALOG32_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG32_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG32_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG32_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG32_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG32_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG32_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG32_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG32_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG32_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4, 5) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG32_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4, 5) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG32_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4, 5, 6) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG32_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4, 5, 6) + ); +#endif +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS + +TEST_F(MipiSysTFixtureCatId32, syst_catid32_loc16_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATALOG32_0_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG32_1_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG32_2_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG32_3_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG32_4_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG32_5_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG32_6_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, 1, 2, 3, 4, 5, 6) + ); +} + +TEST_F(MipiSysTFixtureCatId32, syst_catid32_loc32_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATALOG32_0_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG32_1_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG32_2_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG32_3_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG32_4_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG32_5_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG32_6_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, 1, 2, 3, 4, 5, 6) + ); +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD + + +TEST_F(MipiSysTFixtureCatId32, syst_catprintf32_noloc_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATPRINTF32_0(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy" ) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF32_1(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF32_2(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF32_3(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF32_4(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF32_5(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>01012233[typ=3:1 mu=1:2 sev=3 len]<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF32_6(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5, 6) + ); +} + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +TEST_F(MipiSysTFixtureCatId32, syst_catprintf32_locaddr_output) +{ +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATPRINTF32_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy") + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATPRINTF32_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy") + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF32_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF32_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF32_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF32_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF32_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF32_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF32_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF32_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF32_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF32_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF32_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5, 6) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF32_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5, 6) + ); +#endif +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS + +TEST_F(MipiSysTFixtureCatId32, syst_catprintf2_loc16_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATPRINTF32_0_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy") + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF32_1_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF32_2_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy", 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF32_3_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy", 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF32_4_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy", 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF32_5_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF32_6_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5, 6) + ); +} + +TEST_F(MipiSysTFixtureCatId32, syst_catprintf32_loc32_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0004<D32>cafebabe<FLAG>"), + MIPI_SYST_CATPRINTF32_0_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy") + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0008<D32>cafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF32_1_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>000c<D32>cafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF32_2_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy", 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0010<D32>cafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF32_3_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy", 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0014<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF32_4_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy", 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0018<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF32_5_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>01012333[typ=3:1 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>001c<D32>cafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF32_6_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xCAFEBABE, "dummy", 1, 2, 3, 4, 5, 6) + ); +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD +#endif //MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA && MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE && MIPI_SYST_PCFG_ENABLE_CATID32_API
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_catid64_test.cpp b/library/test/unit/mipi_syst_catid64_test.cpp new file mode 100644 index 0000000..8842632 --- /dev/null +++ b/library/test/unit/mipi_syst_catid64_test.cpp @@ -0,0 +1,530 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) && defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) && defined(MIPI_SYST_PCFG_ENABLE_CATID64_API) + +class MipiSysTFixtureCatId64 : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown(){ + MipiSysTFixtureOutput::TearDown(); + } + + const char * mipi_syst_write_catalog64_message(struct mipi_syst_handle* svh, + struct mipi_syst_msglocation* loc, + enum mipi_syst_severity severity, + mipi_syst_u64 catid) + { + static std::string result; + + ::mipi_syst_write_catalog64_message(svh, loc, severity, catid); + result = sstr.str(); + sstr.str(""); + + return result.c_str(); + } +}; + +TEST_F(MipiSysTFixtureCatId64, syst_catid64_basic) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_0(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_1(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE,1 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_2(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_3(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_4(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2, 3, 4 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_5(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2,3,4,5 ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_6(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE, 1, 2,3,4,5,6 ) + ); +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) + + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_0_LOC16(0,MIPI_SYST_SEVERITY_WARNING, 1, 0xCAFEBABE ) + ); + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_0_LOC32(0,MIPI_SYST_SEVERITY_WARNING, 1, 0xCAFEBABE ) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATALOG64_0_LOCADDR(0,MIPI_SYST_SEVERITY_WARNING, 0xCAFEBABE) + ); +#endif +#endif +} + +TEST_F(MipiSysTFixtureCatId64, syst_catid64_noloc_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATALOG64_0(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG64_1(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG64_2(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG64_3(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG64_4(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG64_5(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG64_6(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5, 6) + ); +} + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +TEST_F(MipiSysTFixtureCatId64, syst_catid64_locaddr_output) +{ +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATALOG64_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATALOG64_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG64_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG64_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG64_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG64_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG64_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG64_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG64_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG64_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG64_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG64_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG64_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5, 6) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG64_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5, 6) + ); +#endif +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS + +TEST_F(MipiSysTFixtureCatId64, syst_catid64_loc16_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATALOG64_0_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG64_1_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG64_2_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG64_3_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG64_4_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG64_5_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG64_6_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5, 6) + ); +} + +TEST_F(MipiSysTFixtureCatId64, syst_catid64_loc32_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATALOG64_0_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATALOG64_1_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATALOG64_2_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATALOG64_3_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATALOG64_4_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATALOG64_5_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATALOG64_6_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, 1, 2, 3, 4, 5, 6) + ); +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD + + +TEST_F(MipiSysTFixtureCatId64, syst_printf64_noloc_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATPRINTF64_0(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy") + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF64_1(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF64_2(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF64_3(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF64_4(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF64_5(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>02012233[typ=3:2 mu=1:2 sev=3 len]<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF64_6(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5, 6) + ); +} + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +TEST_F(MipiSysTFixtureCatId64, syst_printf64_locaddr_output) +{ +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATPRINTF64_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy") + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATPRINTF64_0_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy") + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF64_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF64_1_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF64_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF64_2_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF64_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF64_3_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF64_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF64_4_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF64_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF64_5_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5) + ); +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF64_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5, 6) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF64_6_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5, 6) + ); +#endif +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS + +TEST_F(MipiSysTFixtureCatId64, syst_printf64_loc16_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATPRINTF64_0_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy") + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF64_1_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF64_2_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy", 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF64_3_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF64_4_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF64_5_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF64_6_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5, 6) + ); +} + +TEST_F(MipiSysTFixtureCatId64, syst_printf64_loc32_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0008<D64>000decafcafebabe<FLAG>"), + MIPI_SYST_CATPRINTF64_0_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy") + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>000c<D64>000decafcafebabe<D32>00000001<FLAG>"), + MIPI_SYST_CATPRINTF64_1_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0010<D64>000decafcafebabe<D64>0000000200000001<FLAG>"), + MIPI_SYST_CATPRINTF64_2_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy", 1, 2) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0014<D64>000decafcafebabe<D64>0000000200000001<D32>00000003<FLAG>"), + MIPI_SYST_CATPRINTF64_3_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0018<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<FLAG>"), + MIPI_SYST_CATPRINTF64_4_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>001c<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D32>00000005<FLAG>"), + MIPI_SYST_CATPRINTF64_5_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5) + ); + + EXPECT_STREQ( + xform("<D32TS>02012333[typ=3:2 mu=1:2 sev=3 loc len]<D8>01<D64>12345678aabbccdd<D16>0020<D64>000decafcafebabe<D64>0000000200000001<D64>0000000400000003<D64>0000000600000005<FLAG>"), + MIPI_SYST_CATPRINTF64_6_LOC32(ph, MIPI_SYST_SEVERITY_WARNING, 0xaabbccdd, 0xDECAFCAFEBABEull, "dummy", 1, 2, 3, 4, 5, 6) + ); +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD + +#endif //MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA && MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE && MIPI_SYST_PCFG_ENABLE_CATID64_API
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_clock_test.cpp b/library/test/unit/mipi_syst_clock_test.cpp new file mode 100644 index 0000000..384a289 --- /dev/null +++ b/library/test/unit/mipi_syst_clock_test.cpp @@ -0,0 +1,92 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) &&\ + defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) &&\ + defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP) + +class MipiSysTFixtureClock : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown(){ + MipiSysTFixtureOutput::TearDown(); + } + + const char * mipi_syst_write_clock(struct mipi_syst_handle* svh, + struct mipi_syst_msglocation* loc, + enum mipi_syst_subtype_clock fmt, + mipi_syst_u64 clock, + mipi_syst_u64 freq) + { + static std::string result; + + ::mipi_syst_write_clock(svh, loc,fmt, clock, freq); + result = sstr.str(); + sstr.str(""); + + return result.c_str(); + } +}; + +#if defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP) +TEST_F(MipiSysTFixtureClock, syst_clock_sync_null) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_CLOCK_SYNC(NULL, MIPI_SYST_PLATFORM_CLOCK(), MIPI_SYST_PLATFORM_FREQ()) + ); +} +TEST_F(MipiSysTFixtureClock, syst_clock_sync_output) +{ + MIPI_SYST_ENABLE_HANDLE_TIMESTAMP(ph, 0); + + EXPECT_STREQ( + xform("<D32TS>01012208[typ=8:1 mu=1:2 sev=0 len]<D16>0010<D64>12345678aabbccdd<D64>00000000000f4240<FLAG>"), + MIPI_SYST_CLOCK_SYNC(ph, MIPI_SYST_PLATFORM_CLOCK(), MIPI_SYST_PLATFORM_FREQ()) + ); +} + +#endif /* defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP)*/ + +#endif
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_crc32_test.cpp b/library/test/unit/mipi_syst_crc32_test.cpp new file mode 100644 index 0000000..780903e --- /dev/null +++ b/library/test/unit/mipi_syst_crc32_test.cpp @@ -0,0 +1,138 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ +#include "mipi_syst_gtest.h" + +#ifdef MIPI_SYST_PCFG_ENABLE_CHECKSUM + +#include "../../include/mipi_syst/crc32.h" +#include "../../src/mipi_syst_crc32.c" + +/* Test input data for crc calculation tests. The last value shown +* in the array name is the reference crc32C. +*/ +static mipi_syst_u8 crc_input_u8_0xB5D83007[] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' +}; + +static mipi_syst_u16 crc_input_u16_0xAA2741E5[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20 +}; + +static mipi_syst_u32 crc_input_u32_0xCDBDE657[] = { + 0x00000000, 0xABCDEF12, 0x12345678, 0xFADEDBAD, 0xAA55AA55 +}; + +static mipi_syst_u64 crc_input_u64_0x61A6DF0B[] = { + 0x1122334455667788ull, 0x1122334455667788ull, 0xABCDEFAABBCCDDEEull, + 0x0000000000000000ull, 0xFFFFFFFFFFFFFFFFull, 0x0101010101010101ull +}; + +class MipiSysTFixtureCrc32 : public testing::Test +{ +public: + void SetUp() { + crc = MIPI_SYST_CRC32_INIT(0); + } + + void TearDown(){ + } + + mipi_syst_u32 crc32_byte_array( mipi_syst_u8 *pData, mipi_syst_u32 bytes) + { + while (bytes--) { + MIPI_SYST_CRC32_U8(crc, *pData++); + } + return MIPI_SYST_CRC32_GET(crc); + } + + mipi_syst_u32 crc32_word_array( mipi_syst_u16 *pData, mipi_syst_u32 words) + { + while (words--) { + MIPI_SYST_CRC32_U16(crc, *pData++); + } + return MIPI_SYST_CRC32_GET(crc); + } + + mipi_syst_u32 crc32_dword_array( mipi_syst_u32 *pData, mipi_syst_u32 dwords) + { + while (dwords--) { + MIPI_SYST_CRC32_U32(crc, *pData++); + } + return MIPI_SYST_CRC32_GET(crc); + } + + mipi_syst_u32 crc32_qword_array( mipi_syst_u64 *pData, mipi_syst_u32 qwords) + { + while (qwords--) { + MIPI_SYST_CRC32_U64(crc, *pData++); + } + return MIPI_SYST_CRC32_GET(crc); + } +protected: + mipi_syst_u32 crc; +}; + +/* Test structure sizes used in binary output processing +*/ +TEST_F(MipiSysTFixtureCrc32, syst_crc32_bytes) +{ + EXPECT_EQ(0xB5D83007 ,crc32_byte_array(crc_input_u8_0xB5D83007 , + sizeof(crc_input_u8_0xB5D83007))) << "MIPI_SYST_CRC32_U8() test"; +} + +TEST_F(MipiSysTFixtureCrc32, syst_crc32_halfwords) +{ + EXPECT_EQ(0xAA2741E5,crc32_word_array((mipi_syst_u16*)crc_input_u16_0xAA2741E5, + sizeof(crc_input_u16_0xAA2741E5) / sizeof(mipi_syst_u16))) << "MIPI_SYST_CRC32_U16() test"; +} + +TEST_F(MipiSysTFixtureCrc32, syst_crc32_dwords) +{ + EXPECT_EQ(0xCDBDE657,crc32_dword_array((mipi_syst_u32*)crc_input_u32_0xCDBDE657, + sizeof(crc_input_u32_0xCDBDE657) / sizeof(mipi_syst_u32))) << "MIPI_SYST_CRC32_U32() test"; +} + +TEST_F(MipiSysTFixtureCrc32, syst_crc32_quadwords) +{ + EXPECT_EQ(0x61A6DF0B,crc32_qword_array((mipi_syst_u64*)crc_input_u64_0x61A6DF0B, + sizeof(crc_input_u64_0x61A6DF0B) / sizeof(mipi_syst_u64))) << "MIPI_SYST_CRC32_U64() test"; +} + +#endif
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_disable_test.cpp b/library/test/unit/mipi_syst_disable_test.cpp new file mode 100644 index 0000000..b33afdc --- /dev/null +++ b/library/test/unit/mipi_syst_disable_test.cpp @@ -0,0 +1,61 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#define MIPI_SYST_DISABLE_ALL + +// Need to rename MipiSysTFixtureBase here as we otherwise link in versions +// of this class with different SYS-T defines. It then becomes unpredictable +// which one is used during linking. +// +#define MipiSysTFixtureBase MipiSysTFixtureBaseDisabled + +#include "mipi_syst_gtest.h" + +TEST_F(MipiSysTFixtureBase, syst_disabled_test) +{ + struct mipi_syst_handle* ph; + + ph = MIPI_SYST_ALLOC_HANDLE((void*)0xC0FFEBABE ); + EXPECT_EQ((struct mipi_syst_handle*)0, MIPI_SYST_ALLOC_HANDLE(xx)); + + MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2); + + MIPI_SYST_DEBUG(a, xx, yy , zz); + + MIPI_SYST_DELETE_HANDLE(ph); +}
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_gtest.h b/library/test/unit/mipi_syst_gtest.h new file mode 100644 index 0000000..0268711 --- /dev/null +++ b/library/test/unit/mipi_syst_gtest.h @@ -0,0 +1,249 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include <gtest/gtest.h> +#include <string> + +#define MIPI_SYST_UNIT_TEST + +#include "mipi_syst.h" + +/* hard code compiler dependend standard defines to fixed values for +* unit test support. Regression tests expect to see these values. +*/ +#undef MIPI_SYST_FUNCTION_NAME +#define MIPI_SYST_FUNCTION_NAME "0123456789" + +#undef MIPI_SYST_LINE +#define MIPI_SYST_LINE 0x12345678 + +#undef MIPI_SYST_FILE +#define MIPI_SYST_FILE "unittest.c" + + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) +#define mipi_syst_return_addr() (void*)0x12345678aabbccdd +#else +#define mipi_syst_return_addr() (void*)0x12345678 +#endif + + +/* replace output handlers with unit test versions +*/ +#undef MIPI_SYST_OUTPUT_D32MTS +#undef MIPI_SYST_OUTPUT_D64MTS +#undef MIPI_SYST_OUTPUT_D32TS +#undef MIPI_SYST_OUTPUT_D8 +#undef MIPI_SYST_OUTPUT_D16 +#undef MIPI_SYST_OUTPUT_D32 +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) +#undef MIPI_SYST_OUTPUT_D64 +#endif +#undef MIPI_SYST_OUTPUT_FLAG + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) +#define MIPI_SYST_OUTPUT_D32MTS(syst_handle, data) \ + MipiSysTFixtureOutput::d32mts((syst_handle), (data)) +#define MIPI_SYST_OUTPUT_D64MTS(syst_handle, data) \ + MipiSysTFixtureOutput::d64mts((syst_handle), (data)) +#define MIPI_SYST_OUTPUT_D32TS(syst_handle, data) \ + MipiSysTFixtureOutput::d32ts((syst_handle), (data)) +#define MIPI_SYST_OUTPUT_D8(syst_handle, data) \ + MipiSysTFixtureOutput::d8((syst_handle), (data)) +#define MIPI_SYST_OUTPUT_D16(syst_handle, data) \ + MipiSysTFixtureOutput::d16((syst_handle), (data)) +#define MIPI_SYST_OUTPUT_D32(syst_handle, data) \ + MipiSysTFixtureOutput::d32((syst_handle), (data)) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) +#define MIPI_SYST_OUTPUT_D64(syst_handle, data) \ + MipiSysTFixtureOutput::d64((syst_handle), (data)) +#endif +#define MIPI_SYST_OUTPUT_FLAG(syst_handle) \ + MipiSysTFixtureOutput::flag((syst_handle)) +#else +#define MIPI_SYST_OUTPUT_D32MTS(syst_handle, data) +#define MIPI_SYST_OUTPUT_D32TS(syst_handle, data) +#define MIPI_SYST_OUTPUT_D8(syst_handle, data) +#define MIPI_SYST_OUTPUT_D16(syst_handle, data) +#define MIPI_SYST_OUTPUT_D32(syst_handle, data) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) +#define MIPI_SYST_OUTPUT_D64(syst_handle, data) +#endif +#define MIPI_SYST_OUTPUT_FLAG(syst_handle) +#endif // MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA + +class MipiSysTFixtureBase : public testing::Test +{ +public: + void SetUp() { + MIPI_SYST_INIT(mipi_syst_platform_init, (void*)0);} + + void TearDown(){ + MIPI_SYST_SHUTDOWN(mipi_syst_platform_destroy); + } + + static struct mipi_syst_origin origin; +}; + +class MipiSysTFixtureOutput : public MipiSysTFixtureBase +{ +public: + void SetUp() { + MipiSysTFixtureBase::SetUp(); + + ph = MIPI_SYST_INIT_HANDLE(&sh, &origin); + MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2); + MIPI_SYST_ENABLE_HANDLE_LENGTH(ph, 1); + + sstr.str(""); + } + + void TearDown(){ + MIPI_SYST_DELETE_HANDLE(ph); + + MipiSysTFixtureBase::TearDown(); + } + +public: + struct mipi_syst_handle sh; + struct mipi_syst_handle* ph; + + static std::stringstream sstr; + std::string x4m; + + /* unit test IO driver function to print the access output into local string */ + static void d64(struct mipi_syst_handle* systh, mipi_syst_u64 v) + { sstr << "<D64>"<< std::hex << std::setfill('0') << std::setw(16) << v; } + static void d32(struct mipi_syst_handle* systh, mipi_syst_u32 v) + { sstr << "<D32>"<< std::hex << std::setfill('0') << std::setw(8) << v; } + static void d16(struct mipi_syst_handle* systh, mipi_syst_u16 v) + { sstr << "<D16>"<< std::hex << std::setfill('0') << std::setw(4) << v; } + static void d8(struct mipi_syst_handle* systh, mipi_syst_u8 v) + { sstr << "<D8>"<< std::hex << std::setfill('0') << std::setw(2) << (mipi_syst_u16)v; } + static void d32ts(struct mipi_syst_handle* systh, mipi_syst_u32 v) + { + sstr << "<D32TS>"<< std::hex << std::setfill('0') << std::setw(8) << v; + union { + mipi_syst_u32 val; + struct mipi_syst_msg_tag tag; + }u = { v }; + + sstr << "[typ=" << u.tag.et_type << ":" << u.tag.et_subtype + << " mu=" << (u.tag.et_modunit >> 4) << ":" << (u.tag.et_modunit & 0xF) + << " sev=" << u.tag.et_severity; + + if (u.tag.et_res7) sstr << " res7"; + if (u.tag.et_location) sstr << " loc"; + if (u.tag.et_res30) sstr << " res30"; + if (u.tag.et_length) sstr << " len"; + if (u.tag.et_chksum) sstr << " chk"; + sstr << "]"; + } + static void d32mts(struct mipi_syst_handle* systh, mipi_syst_u32 v) + { sstr << "<D32MTS>"<< std::hex << std::setfill('0') << std::setw(8) << v; } + static void d64mts(struct mipi_syst_handle* systh, mipi_syst_u64 v) + { sstr << "<D64MTS>"<< std::hex << std::setfill('0') << std::setw(16) << v; } + static void flag(struct mipi_syst_handle* systh) + { sstr << "<FLAG>"; } + + /* output string transformation to match platform properties */ + const char* xform(const char* input) + { + size_t pos(0); + x4m=input; +#if !defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) + pos = std::string::npos; + while((pos=x4m.find("<D64>")) != std::string::npos){ + std::string val = x4m.substr(pos+5,16); + std::string upperVal = val.substr(8,8); + std::string lowerVal = val.substr(0,8); + std::string replacement = "<D32>"; + replacement += upperVal; + replacement += "<D32>"; + replacement += lowerVal; + x4m.erase(pos,21); + x4m.insert(pos,replacement); + } +#endif +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + /* need to adapt 32bit catalog type for 64bit packing settings */ + pos = x4m.find("[typ=3:1 "); + if (pos != std::string::npos) { + x4m.replace(pos, 9, std::string("[typ=3:5 ")); + x4m.replace(0, 9, std::string("<D32TS>05")); + } + + /* need to adapt 64bit catalog type for 64bit packing settings */ + pos = x4m.find("[typ=3:2 "); + if (pos != std::string::npos) { + x4m.replace(pos, 9, std::string("[typ=3:6 ")); + x4m.replace(0, 9, std::string("<D32TS>06")); + } + + pos = x4m.find("[typ=2:b "); + if (pos != std::string::npos) { + x4m.replace(pos, 9, std::string("[typ=2:c ")); + x4m.replace(0, 9, std::string("<D32TS>0c")); + } +#endif +#if !defined(MIPI_SYST_PCFG_LENGTH_FIELD) + /* take out len parts from comparsion string */ + pos = x4m.find(" len"); + if (pos != std::string::npos) { + x4m.replace(pos, 4, ""); + + std::stringstream sstr(x4m.substr(7, 8)); + mipi_syst_u32 tag; + sstr >> std::hex >> tag; + tag &= ~(1 << 9); + sstr.str(std::string()); + sstr.clear(); + sstr << std::hex << std::setfill('0') << std::setw(8) + << std::noshowbase << tag; + x4m.replace(7, 8, sstr.str()); + + pos = x4m.find("<D16>"); + if (pos != std::string::npos) { + x4m.replace(pos, 9, ""); + } + } +#endif + + return x4m.c_str(); + } +}; diff --git a/library/test/unit/mipi_syst_gtest_main.cpp b/library/test/unit/mipi_syst_gtest_main.cpp new file mode 100644 index 0000000..f709a91 --- /dev/null +++ b/library/test/unit/mipi_syst_gtest_main.cpp @@ -0,0 +1,46 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "gtest/gtest.h" + +int main(int argc, char * argv[]) +{ + ::testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +}
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_init_test.cpp b/library/test/unit/mipi_syst_init_test.cpp new file mode 100644 index 0000000..16abc5e --- /dev/null +++ b/library/test/unit/mipi_syst_init_test.cpp @@ -0,0 +1,432 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#include "../../src/mipi_syst_init.c" +#include "mipi_syst_platform.c" +#include "../../src/mipi_syst_writer.c" + +std::stringstream MipiSysTFixtureOutput::sstr; + +struct mipi_syst_origin MipiSysTFixtureBase::origin = MIPI_SYST_GEN_ORIGIN_MODULE(1, 2); + +/* Test structure sizes used in binary output processing +*/ +TEST_F(MipiSysTFixtureBase, syst_structure_sizes) +{ + EXPECT_EQ(1, sizeof(mipi_syst_u8)) << "mipi_syst_u8 not 1 byte long"; + EXPECT_EQ(2, sizeof(mipi_syst_u16)) << "mipi_syst_u16 not 2 byte long"; + EXPECT_EQ(4, sizeof(mipi_syst_u32)) << "mipi_syst_u32 not 4 byte long"; + EXPECT_EQ(8, sizeof(mipi_syst_u64)) << "mipi_syst_u64 not 8 byte long"; + + EXPECT_EQ(1, sizeof(mipi_syst_s8)) << "mipi_syst_s8 not 1 byte long"; + EXPECT_EQ(2, sizeof(mipi_syst_s16)) << "mipi_syst_s16 not 2 byte long"; + EXPECT_EQ(4, sizeof(mipi_syst_s32)) << "mipi_syst_s32 not 4 byte long"; + EXPECT_EQ(8, sizeof(mipi_syst_s64)) << "mipi_syst_s64 not 8 byte long"; + + EXPECT_EQ(16, sizeof(struct mipi_syst_guid)) << "struct mipi_syst_guid not 16 byte long"; + + EXPECT_EQ(4, sizeof(struct mipi_syst_msg_tag)) << "struct mipi_syst_msg_tag must be 32bit"; + EXPECT_EQ(4, sizeof(struct mipi_syst_scatter_prog )) << "syst_scatter_prog_t must be 32bit"; + EXPECT_EQ(4, sizeof(union mipi_syst_msglocation32)) << "mipi_syst_msglocation32 must be 32bit"; + EXPECT_EQ(8, sizeof(union mipi_syst_msglocation64)) << "mipi_syst_msglocation64 must be 64bit"; +} + +TEST_F(MipiSysTFixtureBase, syst_little_endian_swap) +{ + union { mipi_syst_u16 v; mipi_syst_u8 b[2]; } v16 = { MIPI_SYST_HTOLE16(0x1234) }; + EXPECT_EQ(v16.b[0], 0x34); + EXPECT_EQ(v16.b[1], 0x12); + + union { mipi_syst_u32 v; mipi_syst_u8 b[4]; } v32 = { MIPI_SYST_HTOLE32(0x12345678) }; + EXPECT_EQ(v32.b[0], 0x78); + EXPECT_EQ(v32.b[1], 0x56); + EXPECT_EQ(v32.b[2], 0x34); + EXPECT_EQ(v32.b[3], 0x12); + + union { mipi_syst_u64 v; mipi_syst_u8 b[8]; } v64 = { MIPI_SYST_HTOLE64(0x12345678AABBCCDDull) }; + EXPECT_EQ(v64.b[0], 0xDD); + EXPECT_EQ(v64.b[1], 0xCC); + EXPECT_EQ(v64.b[2], 0xBB); + EXPECT_EQ(v64.b[3], 0xAA); + EXPECT_EQ(v64.b[4], 0x78); + EXPECT_EQ(v64.b[5], 0x56); + EXPECT_EQ(v64.b[6], 0x34); + EXPECT_EQ(v64.b[7], 0x12); +} + + +/* test header bitfield alignment*/ +TEST_F(MipiSysTFixtureBase, syst_header_bit_alignment) +{ + union { + mipi_syst_msg_tag tag; + mipi_syst_u32 val; + mipi_syst_u8 b[4]; + } native, little; + + little.val = native.val = 0; + native.tag.et_type = 0xF; + little.b[0] = 0xF; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (type)"; + + little.val = native.val = 0; + native.tag.et_severity = 0x7; + little.b[0] = 0x7<< 4; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (severity)"; + + little.val = native.val = 0; + native.tag.et_res7 = 1; + little.b[0] = 0x80; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (res7)"; + + little.val = native.val = 0; + native.tag.et_location = 1; + little.b[1] = 1; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (location)"; + + little.val = native.val = 0; + native.tag.et_length = 1; + little.b[1] = 1<<1; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (length)"; + + little.val = native.val = 0; + native.tag.et_chksum = 1; + little.b[1] = 1<<2; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (chksum)"; + + little.val = native.val = 0; + native.tag.et_timestamp = 1; + little.b[1] = 1<<3; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (timestamp)"; + + little.val = native.val = 0; + native.tag.et_modunit = 0x7FF; + little.b[1] = 0xF << 4; + little.b[2] = 0x7F; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (origin)"; + + little.val = native.val = 0; + native.tag.et_guid = 1; + little.b[2] = 0x80; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (guid)"; + + little.val = native.val = 0; + native.tag.et_subtype = 0x3F; + little.b[3] = 0x3F; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (subtype)"; + + little.val = native.val = 0; + native.tag.et_res30 = 1; + little.b[3] = 0x40; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (res30)"; + + little.val = native.val = 0; + native.tag.et_res31 = 1; + little.b[3] = 0x80; + EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (res31)"; +} + +/* Check initialization of global state +*/ +TEST_F(MipiSysTFixtureBase, syst_global_state_creation) +{ + struct mipi_syst_header* ph = &syst_hdr; + + EXPECT_EQ(ph->systh_version, MIPI_SYST_VERSION_CODE) << "syst header has unexpected version"; +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA) + EXPECT_EQ(ph->systh_inith, &platform_handle_init) << "syst header handle init hook wrong"; + EXPECT_EQ(ph->systh_releaseh, &platform_handle_release) << "syst header handle release hook wrong"; +#endif +#if defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) + EXPECT_EQ(ph->systh_writer, &mipi_syst_scatter_write) << "syst header writer function wrong "; +#endif +} + +TEST_F(MipiSysTFixtureBase, syst_custom_state_creation) +{ + struct mipi_syst_header custom_hdr; + + MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0); + + EXPECT_EQ(custom_hdr.systh_version, MIPI_SYST_VERSION_CODE) << "syst header has unexpected version"; +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA) + EXPECT_EQ(custom_hdr.systh_inith, &platform_handle_init) << "syst header handle init hook wrong"; + EXPECT_EQ(custom_hdr.systh_releaseh, &platform_handle_release) << "syst header handle release hook wrong"; +#endif +#if defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) + EXPECT_EQ(custom_hdr.systh_writer, &mipi_syst_scatter_write) << "syst header writer function wrong "; +#endif + + MIPI_SYST_SHUTDOWN_STATE(&custom_hdr, mipi_syst_platform_destroy); +} + +/* Check initialization of handle state +*/ +TEST_F(MipiSysTFixtureBase, syst_handle_static_creation) +{ + struct mipi_syst_handle sh; + struct mipi_syst_handle* ph; + + ph = MIPI_SYST_INIT_HANDLE(&sh, NULL); + MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2); + + ASSERT_EQ(ph, &sh) << "static allocation did not return passed pointer"; + + EXPECT_EQ(&syst_hdr, ph->systh_header) << "header not set in handle"; + EXPECT_EQ(0, ph->systh_flags.shf_alloc) << "handle indicates allocation, but is static"; + EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "module id not set in handle"; + + MIPI_SYST_DELETE_HANDLE(ph); +} + +TEST_F(MipiSysTFixtureBase, syst_custom_handle_static_creation) +{ + struct mipi_syst_handle sh; + struct mipi_syst_handle* ph; + + struct mipi_syst_header custom_hdr; + MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0); + + ph = MIPI_SYST_INIT_HANDLE_STATE(&custom_hdr, &sh, &origin); + + ASSERT_EQ(ph, &sh) << "static allocation did not return passed pointer"; + + EXPECT_EQ(&custom_hdr, ph->systh_header) << "custom header not set in handle"; + EXPECT_EQ(0, ph->systh_flags.shf_alloc) << "handle indicates allocation, but is static"; +#if defined(MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID) + EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "origin id not set in handle"; +#endif + MIPI_SYST_DELETE_HANDLE(ph); + MIPI_SYST_SHUTDOWN_STATE(&custom_hdr, mipi_syst_platform_destroy); +} + +#if defined(MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID) +TEST_F(MipiSysTFixtureBase, syst_test_guid_origin_handle_creation) +{ + struct mipi_syst_handle sh; + struct mipi_syst_handle* ph; + struct mipi_syst_origin guid_origin = + MIPI_SYST_GEN_ORIGIN_GUID( + 0x494E5443, 0xA2AE, 0x4C70, 0xABB5, 0xD1A79E9CEA35, + 0x7FF); + + ph = MIPI_SYST_INIT_HANDLE(&sh, &guid_origin); + + ASSERT_EQ(ph, &sh) << "static allocation did not return passed pointer"; + + EXPECT_EQ(&syst_hdr, ph->systh_header) << "header not set in handle"; + EXPECT_EQ(0, ph->systh_flags.shf_alloc) << "handle indicates allocation, but is static"; + EXPECT_EQ(0x7FF, ph->systh_tag.et_modunit) << "module id not set in handle"; + EXPECT_EQ(ph->systh_guid.u.ll[0], MIPI_SYST_HTOLE64(guid_origin.guid.u.ll[0])); + EXPECT_EQ(ph->systh_guid.u.ll[1], MIPI_SYST_HTOLE64(guid_origin.guid.u.ll[1])); + MIPI_SYST_DELETE_HANDLE(ph); +} +#endif + +#if defined(MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY) +TEST_F(MipiSysTFixtureBase, syst_handle_dynamic_creation) +{ + struct mipi_syst_handle* ph; + + ph = MIPI_SYST_ALLOC_HANDLE(NULL); + MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2); + + ASSERT_NE(ph, (struct mipi_syst_handle*)0) << "allocation failed"; + + EXPECT_EQ(&syst_hdr, ph->systh_header) << "header not set in handle"; + EXPECT_EQ(1, ph->systh_flags.shf_alloc) << "handle indicates static, but is allocated"; + EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "origin id not set in handle"; + + MIPI_SYST_DELETE_HANDLE(ph); +} + +TEST_F(MipiSysTFixtureBase, syst_custom_handle_dynamic_creation) +{ + struct mipi_syst_handle* ph; + struct mipi_syst_header custom_hdr; + MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0); + + ph = MIPI_SYST_ALLOC_HANDLE_STATE(&custom_hdr, NULL); + MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2); + + ASSERT_NE(ph, (struct mipi_syst_handle*)0) << "allocation failed"; + + EXPECT_EQ(&custom_hdr, ph->systh_header) << "custom header not set in handle"; + EXPECT_EQ(1, ph->systh_flags.shf_alloc) << "handle indicates static, but is allocated"; + EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "origin id not set in handle"; + + MIPI_SYST_DELETE_HANDLE(ph); +} +#endif + +TEST_F(MipiSysTFixtureBase, syst_message_flags) +{ + struct mipi_syst_handle* ph; + struct mipi_syst_header custom_hdr; + MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0); + + ph = MIPI_SYST_ALLOC_HANDLE_STATE(&custom_hdr, &origin); + + ASSERT_NE(ph, (struct mipi_syst_handle*)0) << "allocation failed"; + + +#if defined(MIPI_SYST_PCFG_ENABLE_CHECKSUM) + EXPECT_EQ(0,MIPI_SYST_GET_HANDLE_CHECKSUM(ph)); + + MIPI_SYST_ENABLE_HANDLE_CHECKSUM(ph, 1); + EXPECT_NE(0, MIPI_SYST_GET_HANDLE_CHECKSUM(ph)); + + MIPI_SYST_ENABLE_HANDLE_CHECKSUM(ph, 0); + EXPECT_EQ(0, MIPI_SYST_GET_HANDLE_CHECKSUM(ph)); +#endif +#if defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP) + EXPECT_EQ(0,MIPI_SYST_GET_HANDLE_TIMESTAMP(ph)); + + MIPI_SYST_ENABLE_HANDLE_TIMESTAMP(ph, 1); + EXPECT_NE(0, MIPI_SYST_GET_HANDLE_TIMESTAMP(ph)); + + MIPI_SYST_ENABLE_HANDLE_TIMESTAMP(ph, 0); + EXPECT_EQ(0, MIPI_SYST_GET_HANDLE_TIMESTAMP(ph)); +#endif + MIPI_SYST_DELETE_HANDLE(ph); +} + + +TEST_F(MipiSysTFixtureBase, syst_version_macro) +{ + mipi_syst_u32 version = (MIPI_SYST_VERSION_MAJOR<<16) |(MIPI_SYST_VERSION_MINOR<<8)|MIPI_SYST_VERSION_PATCH; + std::stringstream sstr; + sstr << MIPI_SYST_VERSION_MAJOR << "." << MIPI_SYST_VERSION_MINOR << "." << MIPI_SYST_VERSION_PATCH; + std::string verstr(sstr.str()); + + EXPECT_STREQ(verstr.c_str(), MIPI_SYST_VERSION_STRING); + + EXPECT_EQ(MIPI_SYST_VERSION_CODE, version) << "unexpected version code"; + + + ASSERT_LT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3), + MIPI_SYST_MAKE_VERSION_CODE(2,0,0)); + ASSERT_LT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3), + MIPI_SYST_MAKE_VERSION_CODE(1,3,3)); + ASSERT_LT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3), + MIPI_SYST_MAKE_VERSION_CODE(1,2,4)); + + ASSERT_GT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3), + MIPI_SYST_MAKE_VERSION_CODE(0,2,3)); + ASSERT_GT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3), + MIPI_SYST_MAKE_VERSION_CODE(1,1,3)); + ASSERT_GT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3), + MIPI_SYST_MAKE_VERSION_CODE(1,2,2)); +} + +TEST_F(MipiSysTFixtureBase, syst_handle_nullptr) +{ + MIPI_SYST_INIT_HANDLE(0,NULL); + MIPI_SYST_DELETE_HANDLE(0); + + EXPECT_EQ(0,0); // only reached if above calls don't crash +} + +// {1DBBA102-DFFD-4A05-8CED-F744046715ED} + +struct mipi_syst_guid guid1= +{{0x1d, 0xbb, 0xa1, 0x02, 0xdf, 0xfd, 0x4a, 0x05, 0x8c, 0xed, 0xf7, 0x44, 0x4, 0x67, 0x15, 0xed} }; + +struct mipi_syst_guid guid2 = MIPI_SYST_GEN_GUID(0x1DBBA102, 0xDFFD, 0x4A05, 0x8CED, 0xF744046715ED); + +TEST_F(MipiSysTFixtureBase, syst_guid) +{ + union { + struct mipi_syst_guid g; mipi_syst_u64 ll[2]; + } v; + + v.ll[0] = MIPI_SYST_HTOLE64(guid2.u.ll[0]); + v.ll[1] = MIPI_SYST_HTOLE64(guid2.u.ll[1]); + + EXPECT_EQ(guid1.u.b[0], guid2.u.b[0]); + EXPECT_EQ(guid1.u.b[1], guid2.u.b[1]); + EXPECT_EQ(guid1.u.b[2], guid2.u.b[2]); + EXPECT_EQ(guid1.u.b[3], guid2.u.b[3]); + EXPECT_EQ(guid1.u.b[4], guid2.u.b[4]); + EXPECT_EQ(guid1.u.b[5], guid2.u.b[5]); + EXPECT_EQ(guid1.u.b[6], guid2.u.b[6]); + EXPECT_EQ(guid1.u.b[7], guid2.u.b[7]); + EXPECT_EQ(guid1.u.b[8], guid2.u.b[8]); + EXPECT_EQ(guid1.u.b[9], guid2.u.b[9]); + EXPECT_EQ(guid1.u.b[10], guid2.u.b[10]); + EXPECT_EQ(guid1.u.b[11], guid2.u.b[11]); + EXPECT_EQ(guid1.u.b[12], guid2.u.b[12]); + EXPECT_EQ(guid1.u.b[13], guid2.u.b[13]); + EXPECT_EQ(guid1.u.b[14], guid2.u.b[14]); + EXPECT_EQ(guid1.u.b[15], guid2.u.b[15]); +} + +#define LONG_STR \ +"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ +"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" \ +"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" \ +"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + +TEST_F(MipiSysTFixtureBase, syst_hash) +{ + mipi_syst_u32 val1, val2, val3; + + val1 = _MIPI_SYST_HASH_AT_CPP_TIME("", 0); + val2 = _MIPI_SYST_HASH_AT_RUN_TIME("", 0); + EXPECT_EQ(val1, val2); + + EXPECT_EQ(0x0, _MIPI_SYST_HASH_AT_RUN_TIME("", 0)); + EXPECT_EQ(0x19ae84c4, _MIPI_SYST_HASH_AT_RUN_TIME("hello world", 0)); + + val1 = _MIPI_SYST_HASH_AT_CPP_TIME("hello world", 0); + val2 = _MIPI_SYST_HASH_AT_RUN_TIME("hello world", 0); + EXPECT_EQ(val1, val2); + + val1 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 0); + val2 = _MIPI_SYST_HASH_AT_RUN_TIME(LONG_STR, 0); + EXPECT_EQ(val1, val2); + + val1 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 0); + val2 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 1); + val3 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 3); + EXPECT_NE(val1, val2); + EXPECT_NE(val1, val3); + EXPECT_NE(val2, val3); +}
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_printf_test.cpp b/library/test/unit/mipi_syst_printf_test.cpp new file mode 100644 index 0000000..d9c19bd --- /dev/null +++ b/library/test/unit/mipi_syst_printf_test.cpp @@ -0,0 +1,709 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include <string> +#include <stdint.h> +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) &&\ + defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) &&\ + defined(MIPI_SYST_PCFG_ENABLE_PRINTF_API) + +#define mipi_syst_write_printf_string(a,b,c, ...) \ + (sstr.str(""),\ + ::mipi_syst_write_printf_string(a,b,c, __VA_ARGS__ ),\ + result = sstr.str(),\ + result.c_str()) + +#define mipi_syst_write_printf_catalog64(a,b,c, ...) \ + (sstr.str(""),\ + ::mipi_syst_write_printf_catalog64(a,b,c, __VA_ARGS__ ),\ + result = sstr.str(),\ + result.c_str()) + +#define mipi_syst_write_printf_catalog32(a,b,c, ...) \ + (sstr.str(""),\ + ::mipi_syst_write_printf_catalog32(a,b,c, __VA_ARGS__ ),\ + result = sstr.str(),\ + result.c_str()) + +class MipiSysTFixturePrintf : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown() { + MipiSysTFixtureOutput::TearDown(); + } + + static std::string result; +}; + +std::string MipiSysTFixturePrintf::result; + +TEST_F(MipiSysTFixturePrintf, syst_printf_null) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_PRINTF(0, MIPI_SYST_SEVERITY_INFO, (char*) 0) + ); + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0007<D32>6c756e28<D16>296c<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, (char*) 0) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_basic) +{ + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0001<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "") + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0003<D16>2525<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%%") + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000e<D64>6f77206f6c6c6568<D32>20646c72<D16>0021<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "hello world !") + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_invalid) +{ + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0007<D32>6c756e28<D16>296c<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, 0) + ); + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0003<D16>6225<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%b", 1) + ); + std::string tooLong(MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE, 'X'); + + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0020<D64>5858585858585858<D64>5858585858585858<D64>5858585858585858<D64>5858585858585858<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, tooLong.c_str(), 1) + ); + + tooLong.resize(MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE /2); + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0006<D32>25207325<D16>0073<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%s %s", tooLong.c_str(), tooLong.c_str()) + ); +} +TEST_F(MipiSysTFixturePrintf, syst_printf_flags) +{ + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>1122334400642b25<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%+d", 0x11223344) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>1122334400642d25<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%-d", 0x11223344) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>1122334400642025<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "% d", 0x11223344) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>1122334400642325<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%#d", 0x11223344) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>1122334400643025<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%0d", 0x11223344) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_width) +{ + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>1122334400643325<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%3d", 0x11223344) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>000000ab00642a25<D32>11223344<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%*d", 0xab, 0x11223344) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0012<D64>ccdd00642a2e2a25<D64>334412345678aabb<D16>1122<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%*.*d", 0xaabbccdd, 0x12345678, 0x11223344) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_floatingpoint) +{ + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea006625<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%f", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea004625<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%F", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea006525<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%e", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea004525<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%E", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea006725<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%g", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea006125<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%a", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea004125<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%A", 3.14159265359) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea004725<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%G", 3.14159265359) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>54442eea00664c25<D32>400921fb<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%Lf", (long double)3.14159265359) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_floatingpoint_precison) +{ + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>fb54442eea006625<D16>0921<D8>40<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%f", 3.14159265359) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>54442eea00663325<D32>400921fb<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%3f", 3.14159265359) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0010<D64>006630312e313125<D64>400921fb54442eea<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%11.10f", 3.14159265359) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0016<D64>000a00662a2e2a25<D64>2eea0000000b0000<D32>21fb5444<D16>4009<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%*.*f", 10, 11, 3.14159265359) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_modifier) +{ + unsigned int hh = 0x12; + unsigned short int h = 0x1234; + long int l = (long int)-1; + unsigned long long int ll = 0x1122334455667788ull; + uintmax_t j = 0x1122334455667788ull; + size_t z = (size_t)-1; + ptrdiff_t t = (ptrdiff_t)-1; + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0009<D64>0000120064686825<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%hhd", hh) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>0000123400646825<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%hd", h) + ); +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>ffffffff00646c25<D32>ffffffff<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%ld", l) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>ffffffff00647a25<D32>ffffffff<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%zd", z) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>ffffffff00647425<D32>ffffffff<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%td", t) + ); +#else + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>ffffffff00646c25<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%ld", l) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>ffffffff00647a25<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%zd", z) + ); + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>ffffffff00647425<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%td", t) + ); +#endif + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000d<D64>66778800646c6c25<D32>22334455<D8>11<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%lld", ll) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000c<D64>5566778800646a25<D32>11223344<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%jd", j) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_pointer) +{ + void * p = (void*)-1; + + if (sizeof(p) == 8) { + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>000b<D64>ffffffffff007025<D16>ffff<D8>ff<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%p", p) + ); + } else { + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0007<D32>ff007025<D16>ffff<D8>ff<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%p", p) + ); + } +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_char) +{ + char c = 'C'; + wint_t w = 'W'; + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0007<D32>43006325<D16>0000<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%c", c) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0008<D64>0000005700636c25<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "%lc", w) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_printf_combinations) +{ + EXPECT_STREQ( + xform("<D32TS>0b012242[typ=2:b mu=1:2 sev=4 len]<D16>0031<D64>6a20732520656854<D64>766f206465706d75<D64>2520656874207265<D64>6d69742064252073<D64>00776f63002e7365<D64>000005006e6f6f6d<D8>00<FLAG>"), + MIPI_SYST_PRINTF(ph, MIPI_SYST_SEVERITY_INFO, "The %s jumped over the %s %d times.", "cow", "moon", 5) + ); +} +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +TEST_F(MipiSysTFixturePrintf, syst_printf_loc) +{ + EXPECT_STREQ( + xform("<D32TS>0b012342[typ=2:b mu=1:2 sev=4 loc len]<D8>00<D32>5678abcd<D16>0031<D64>6a20732520656854<D64>766f206465706d75<D64>2520656874207265<D64>6d69742064252073<D64>00776f63002e7365<D64>000005006e6f6f6d<D8>00<FLAG>"), + MIPI_SYST_PRINTF_LOC16(ph, MIPI_SYST_SEVERITY_INFO, 0xabcd, "The %s jumped over the %s %d times.", "cow", "moon", 5) + ); + + EXPECT_STREQ( + xform("<D32TS>0b012342[typ=2:b mu=1:2 sev=4 loc len]<D8>01<D64>12345678aabbccdd<D16>0031<D64>6a20732520656854<D64>766f206465706d75<D64>2520656874207265<D64>6d69742064252073<D64>00776f63002e7365<D64>000005006e6f6f6d<D8>00<FLAG>"), + MIPI_SYST_PRINTF_LOC32(ph, MIPI_SYST_SEVERITY_INFO, 0xaabbccdd, "The %s jumped over the %s %d times.", "cow", "moon", 5) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>0b012342[typ=2:b mu=1:2 sev=4 loc len]<D8>03<D64>12345678aabbccdd<D16>0031<D64>6a20732520656854<D64>766f206465706d75<D64>2520656874207265<D64>6d69742064252073<D64>00776f63002e7365<D64>000005006e6f6f6d<D8>00<FLAG>"), + MIPI_SYST_PRINTF_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO, "The %s jumped over the %s %d times.", "cow", "moon", 5) + ); +#else + EXPECT_STREQ( + xform("<D32TS>0b012342[typ=2:b mu=1:2 sev=4 loc len]<D8>02<D32>12345678<D16>0031<D64>6a20732520656854<D64>766f206465706d75<D64>2520656874207265<D64>6d69742064252073<D64>00776f63002e7365<D64>000005006e6f6f6d<D8>00<FLAG>"), + MIPI_SYST_PRINTF_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO, "The %s jumped over the %s %d times.", "cow", "moon", 5) + ); +#endif +} +#endif // MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD + +#if defined(MIPI_SYST_PCFG_ENABLE_CATID64_API) + +TEST_F(MipiSysTFixturePrintf, syst_catalog64_printf_null) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATPRINTF64(NULL, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, "") + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog64_printf_invalid) +{ + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0007<D32>61746163<D16>6772<D8>00<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, -1, -1) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog64_printf_basic) +{ + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0008<D64>1122334455667788<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, "") + ); + + // check that formt string is not added into payload + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0008<D64>1122334455667788<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, "Hello world") + ); + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>00000058<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%c", MIPI_SYST_PARAM_CHAR('X')) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>00000058<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%c", MIPI_SYST_PARAM_WCHAR(L'X')) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>abcd1234<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%c", MIPI_SYST_PARAM_INT(0xabcd1234)) + ); + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>1234567887654321<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%lld", MIPI_SYST_PARAM_LONGLONG(0x1234567887654321ull)) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>0000000012345678<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%ld", MIPI_SYST_PARAM_LONG(0x12345678)) + ); + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>1234567887654321<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%z", MIPI_SYST_PARAM_SIZE_T(0x1234567887654321ull)) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>1234567887654321<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%t", MIPI_SYST_PARAM_PTRDIFF_T(0x1234567887654321ull)) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>1234567887654321<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%p", MIPI_SYST_PARAM_PTR(0x1234567887654321ull)) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%ld", MIPI_SYST_PARAM_LONG(0x12345678)) + ); + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%z", MIPI_SYST_PARAM_SIZE_T(0x12345678)) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%t", MIPI_SYST_PARAM_PTRDIFF_T(0x12345678)) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>000c<D64>1122334455667788<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%p", MIPI_SYST_PARAM_PTR(0x12345678)) + ); +#endif //defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>4000000000000000<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%f", MIPI_SYST_PARAM_FLOAT((float)2.0)) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>4000000000000000<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%f", MIPI_SYST_PARAM_DOUBLE((double)2.0)) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0010<D64>1122334455667788<D64>4000000000000000<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788ull, + "%lf", MIPI_SYST_PARAM_LONGDOUBLE((long double)2.0)) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog64_printf_string) +{ + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0009<D64>1122334455667788<D8>00<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, + "%s", MIPI_SYST_PARAM_CSTR("")) + ); + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0016<D64>1122334455667788<D64>6f77206f6c6c6568<D32>20646c72<D16>0021<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, + "%s", MIPI_SYST_PARAM_CSTR("hello world !")) + ); + + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>0035<D64>1122334455667788<D64>3333003232003100<D64>3500343434340033<D64>3636360035353535<D64>3737373700363636<D64>3838383800373737<D32>38383838<D8>00<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, + "%s", + MIPI_SYST_PARAM_CSTR(""), + MIPI_SYST_PARAM_CSTR("1"), + MIPI_SYST_PARAM_CSTR("22"), + MIPI_SYST_PARAM_CSTR("333"), + MIPI_SYST_PARAM_CSTR("4444"), + MIPI_SYST_PARAM_CSTR("55555"), + MIPI_SYST_PARAM_CSTR("666666"), + MIPI_SYST_PARAM_CSTR("7777777"), + MIPI_SYST_PARAM_CSTR("88888888") + ) + ); + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>001e<D64>1122334455667788<D64>6f77206f6c6c6568<D64>3231002120646c72<D32>12340033<D16>abcd<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, + "%s %s %d", + MIPI_SYST_PARAM_CSTR("hello world !"), + MIPI_SYST_PARAM_CSTR("123"), + MIPI_SYST_PARAM_INT(0xabcd1234) + ) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog64_printf_mixed) +{ + EXPECT_STREQ( + xform("<D32TS>02012243[typ=3:2 mu=1:2 sev=4 len]<D16>001e<D64>1122334455667788<D64>6f77206f6c6c6568<D64>3231002120646c72<D32>12340033<D16>abcd<FLAG>"), + MIPI_SYST_CATPRINTF64(ph, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, + "%s %s %d", + MIPI_SYST_PARAM_CSTR("hello world !"), + MIPI_SYST_PARAM_CSTR("123"), + MIPI_SYST_PARAM_INT(0xabcd1234) + ) + ); +} +#endif // #if defined(MIPI_SYST_PCFG_ENABLE_CATID64_API) + +#if defined(MIPI_SYST_PCFG_ENABLE_CATID32_API) + +TEST_F(MipiSysTFixturePrintf, syst_catalog32_printf_null) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_CATPRINTF32(NULL, MIPI_SYST_SEVERITY_INFO, 0x11223344, "") + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog32_printf_invalid) +{ + EXPECT_STREQ( + xform("<D32TS>05012242[typ=2:5 mu=1:2 sev=4 len]<D16>0007<D32>61746163<D16>6772<D8>00<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, -1, -1) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog32_printf_basic) +{ + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0004<D32>11223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, "") + ); + + // check that format string is not added into payload + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0004<D32>11223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, "Hello world") + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>0000005811223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%c", MIPI_SYST_PARAM_CHAR('X')) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>0000123411223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%hhd", MIPI_SYST_PARAM_SHORT(0x1234)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>0000005811223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%lc", MIPI_SYST_PARAM_WCHAR(L'X')) + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>abcd123411223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%d", MIPI_SYST_PARAM_INT(0xabcd1234)) + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>8765432111223344<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%lld", MIPI_SYST_PARAM_LONGLONG(0x1234567887654321ull)) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>1234567811223344<D32>00000000<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%ld", MIPI_SYST_PARAM_LONG(0x12345678)) + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>8765432111223344<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%z", MIPI_SYST_PARAM_SIZE_T(0x1234567887654321ull)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>8765432111223344<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%t", MIPI_SYST_PARAM_PTRDIFF_T(0x1234567887654321ull)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>8765432111223344<D32>12345678<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%p", MIPI_SYST_PARAM_PTR(0x1234567887654321ull)) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>1234567811223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%ld", MIPI_SYST_PARAM_LONG(0x12345678)) + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>1234567811223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%z", MIPI_SYST_PARAM_SIZE_T(0x12345678)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>1234567811223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%t", MIPI_SYST_PARAM_PTRDIFF_T(0x12345678)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0008<D64>1234567811223344<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%p", MIPI_SYST_PARAM_PTR(0x12345678)) + ); +#endif //defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>0000000011223344<D32>40000000<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%f", MIPI_SYST_PARAM_FLOAT((float)2.0)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>0000000011223344<D32>40000000<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%f", MIPI_SYST_PARAM_DOUBLE((double)2.0)) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>000c<D64>0000000011223344<D32>40000000<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344ull, + "%lf", MIPI_SYST_PARAM_LONGDOUBLE((long double)2.0)) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog32_printf_string) +{ + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0005<D32>11223344<D8>00<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, + "%s", MIPI_SYST_PARAM_CSTR("")) + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0012<D64>6c6c656811223344<D64>20646c726f77206f<D16>0021<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, + "%s", MIPI_SYST_PARAM_CSTR("hello world !")) + ); + + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>0031<D64>3200310011223344<D64>3434003333330032<D64>3535353535003434<D64>0036363636363600<D64>0037373737373737<D64>3838383838383838<D8>00<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, + "%s", + MIPI_SYST_PARAM_CSTR(""), + MIPI_SYST_PARAM_CSTR("1"), + MIPI_SYST_PARAM_CSTR("22"), + MIPI_SYST_PARAM_CSTR("333"), + MIPI_SYST_PARAM_CSTR("4444"), + MIPI_SYST_PARAM_CSTR("55555"), + MIPI_SYST_PARAM_CSTR("666666"), + MIPI_SYST_PARAM_CSTR("7777777"), + MIPI_SYST_PARAM_CSTR("88888888") + ) + ); + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>001a<D64>6c6c656811223344<D64>20646c726f77206f<D64>1234003332310021<D16>abcd<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, + "%s %s %d", + MIPI_SYST_PARAM_CSTR("hello world !"), + MIPI_SYST_PARAM_CSTR("123"), + MIPI_SYST_PARAM_INT(0xabcd1234) + ) + ); +} + +TEST_F(MipiSysTFixturePrintf, syst_catalog32_printf_mixed) +{ + EXPECT_STREQ( + xform("<D32TS>01012243[typ=3:1 mu=1:2 sev=4 len]<D16>001a<D64>6c6c656811223344<D64>20646c726f77206f<D64>1234003332310021<D16>abcd<FLAG>"), + MIPI_SYST_CATPRINTF32(ph, MIPI_SYST_SEVERITY_INFO, 0x11223344, + "%s %s %d", + MIPI_SYST_PARAM_CSTR("hello world !"), + MIPI_SYST_PARAM_CSTR("123"), + MIPI_SYST_PARAM_INT(0xabcd1234) + ) + ); +} +#endif // #if defined(MIPI_SYST_PCFG_ENABLE_CATID32_API) +#endif //MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA && MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE && MIPI_SYST_PCFG_ENABLE_PRINTF_API
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_raw_test.cpp b/library/test/unit/mipi_syst_raw_test.cpp new file mode 100644 index 0000000..bcb1b4a --- /dev/null +++ b/library/test/unit/mipi_syst_raw_test.cpp @@ -0,0 +1,162 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) &&\ + defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) &&\ + defined(MIPI_SYST_PCFG_ENABLE_WRITE_API) + +class MipiSysTFixtureRaw : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown(){ + MipiSysTFixtureOutput::TearDown(); + } + + const char * mipi_syst_write_raw_message( + struct mipi_syst_handle* svh, + struct mipi_syst_msglocation* loc, + enum mipi_syst_severity severity, + mipi_syst_u8 subtype, + const void * data, + mipi_syst_u16 length) + { + sstr.str(""); + + ::mipi_syst_write_raw_message(svh, loc, severity, subtype, data, length); + result = sstr.str(); + + return result.c_str(); + } + + static std::string result; +}; + +std::string MipiSysTFixtureRaw::result; + +TEST_F(MipiSysTFixtureRaw, syst_raw_nullptr) +{ + EXPECT_STREQ( + "", + MIPI_SYST_WRITE(NULL, MIPI_SYST_SEVERITY_INFO, 0x3f, NULL, 0) + ); + + EXPECT_STREQ( + xform("<D32TS>3f012246[typ=6:3f mu=1:2 sev=4 len]<D16>0000<FLAG>"), + MIPI_SYST_WRITE(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, NULL, 0) + ); +} + +TEST_F(MipiSysTFixtureRaw, syst_raw_output) +{ + mipi_syst_u8 byte = 0xab; + mipi_syst_u16 word =MIPI_SYST_HTOLE16(0xabcd); + mipi_syst_u32 dword =MIPI_SYST_HTOLE32(0xaabbccdd); + mipi_syst_u64 qword =MIPI_SYST_HTOLE64(0x1122aabbccddeeffull); + + EXPECT_STREQ( + xform("<D32TS>3f012246[typ=6:3f mu=1:2 sev=4 len]<D16>0001<D8>ab<FLAG>"), + MIPI_SYST_WRITE(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, &byte, 1) + ); + EXPECT_STREQ( + xform("<D32TS>3f012246[typ=6:3f mu=1:2 sev=4 len]<D16>0002<D16>abcd<FLAG>"), + MIPI_SYST_WRITE(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, &word, 2) + ); + EXPECT_STREQ( + xform("<D32TS>3f012246[typ=6:3f mu=1:2 sev=4 len]<D16>0004<D32>aabbccdd<FLAG>"), + MIPI_SYST_WRITE(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, &dword, 4) + ); + EXPECT_STREQ( + xform("<D32TS>3f012246[typ=6:3f mu=1:2 sev=4 len]<D16>0008<D64>1122aabbccddeeff<FLAG>"), + MIPI_SYST_WRITE(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, &qword, 8) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) + EXPECT_STREQ( + xform("<D32TS>3f012346[typ=6:3f mu=1:2 sev=4 loc len]<D8>00<D32>5678abcd<D16>0001<D8>ab<FLAG>"), + MIPI_SYST_WRITE_LOC16(ph, MIPI_SYST_SEVERITY_INFO, 0xabcd, 0x3f, &byte, 1) + ); + + EXPECT_STREQ( + xform("<D32TS>3f012346[typ=6:3f mu=1:2 sev=4 loc len]<D8>01<D64>12345678aabbccdd<D16>0001<D8>ab<FLAG>"), + MIPI_SYST_WRITE_LOC32(ph, MIPI_SYST_SEVERITY_INFO, 0x12345678aabbccddull, 0x3f, &byte, 1) + ); +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>3f012346[typ=6:3f mu=1:2 sev=4 loc len]<D8>03<D64>12345678aabbccdd<D16>0001<D8>ab<FLAG>"), + MIPI_SYST_WRITE_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, &byte, 1) + ); +#else + EXPECT_STREQ( + xform("<D32TS>3f012346[typ=6:3f mu=1:2 sev=4 loc len]<D8>02<D32>12345678<D16>0001<D8>ab<FLAG>"), + MIPI_SYST_WRITE_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO, 0x3f, &byte, 1) + ); +#endif //MIPI_SYST_PCFG_ENABLE_64BIT_ADDR +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD +} + +#endif //MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA && MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE && MIPI_SYST_PCFG_ENABLE_WRITE_API + +TEST_F(MipiSysTFixtureOutput, syst_short) +{ + std::string str; + + MIPI_SYST_SHORT32(ph, 0x02345678); + str = sstr.str(); + + EXPECT_STREQ( + xform("<D32MTS>23456781"), + str.c_str() + ); + + sstr.str(""); + MIPI_SYST_SHORT64(ph, 0x0122334455667788); + str = sstr.str(); + + EXPECT_STREQ( + xform("<D64MTS>1223344556677887"), + str.c_str() + ); +}
\ No newline at end of file diff --git a/library/test/unit/mipi_syst_string_test.cpp b/library/test/unit/mipi_syst_string_test.cpp new file mode 100644 index 0000000..c2fdbcf --- /dev/null +++ b/library/test/unit/mipi_syst_string_test.cpp @@ -0,0 +1,325 @@ +/* +Copyright (c) 2018, MIPI Alliance, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Contributors: + * Norbert Schulz (Intel Corporation) - Initial API and implementation + */ + +#include "mipi_syst_gtest.h" + +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) &&\ + defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE) &&\ + defined(MIPI_SYST_PCFG_ENABLE_STRING_API) + + +class MipiSysTFixtureDebugString : public MipiSysTFixtureOutput +{ +public: + void SetUp() { + MipiSysTFixtureOutput::SetUp(); + } + + void TearDown(){ + MipiSysTFixtureOutput::TearDown(); + } + + const char * mipi_syst_write_debug_string(struct mipi_syst_handle* svh, + struct mipi_syst_msglocation* loc, + enum mipi_syst_subtype_string type, + enum mipi_syst_severity severity, + mipi_syst_u16 len, + const char * str) + { + sstr.str(""); + + ::mipi_syst_write_debug_string(svh, loc, type, severity, len, str); + result = sstr.str(); + + return result.c_str(); + } + + static std::string result; +}; + +std::string MipiSysTFixtureDebugString::result; + +TEST_F(MipiSysTFixtureDebugString, syst_string_null) +{ + EXPECT_STREQ( + xform(""), + MIPI_SYST_DEBUG(NULL, MIPI_SYST_SEVERITY_WARNING, "", 1) + ); + + EXPECT_STREQ( + xform("<D32TS>05012232[typ=2:5 mu=1:2 sev=3 len]<D16>0007<D32>6c756e28<D16>296c<D8>00<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_WARNING, NULL, 1) + ); +} + +TEST_F(MipiSysTFixtureDebugString, syst_func_enter_output) +{ + EXPECT_STREQ( + xform("<D32TS>02012232[typ=2:2 mu=1:2 sev=3 len]<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_ENTER(ph, MIPI_SYST_SEVERITY_WARNING) + ); +} + +TEST_F(MipiSysTFixtureDebugString, syst_func_exit_output) +{ + EXPECT_STREQ( + xform("<D32TS>03012232[typ=2:3 mu=1:2 sev=3 len]<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_EXIT(ph, MIPI_SYST_SEVERITY_WARNING) + ); +} + + +TEST_F(MipiSysTFixtureDebugString, syst_debugstring_output) +{ + EXPECT_STREQ( + xform("<D32TS>01012232[typ=2:1 mu=1:2 sev=3 len]<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!" , 12) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_CHECKSUM) + MIPI_SYST_ENABLE_HANDLE_CHECKSUM(ph,1); +#if defined(MIPI_SYST_PCFG_LENGTH_FIELD) + EXPECT_STREQ( + xform("<D32TS>01012632[typ=2:1 mu=1:2 sev=3 len chk]<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<D32>eab806d3<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!" , 12) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012432[typ=2:1 mu=1:2 sev=3 chk]<D64>6f77206f6c6c6548<D32>21646c72<D32>ff19ff90<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!", 12) + ); +#endif + MIPI_SYST_ENABLE_HANDLE_CHECKSUM(ph,0); +#endif + + +#if defined(MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID) + // {8887160A-C965-463b-9F43-1EFE9FDFE3F9} + const struct mipi_syst_guid aguid = MIPI_SYST_GEN_GUID(0x8887160A, 0xC965, 0x463b, 0x9F43, 0x1EFE9FDFE3F9); + + MIPI_SYST_SET_HANDLE_GUID_UNIT(ph, aguid, 7); + EXPECT_STREQ( + xform("<D32TS>01807252[typ=2:1 mu=0:7 sev=5 len]<D64>3b4665c90a168788<D64>f9e3df9ffe1e439f<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_USER1, "Hello world!" , 12) + ); +#endif +} + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +TEST_F(MipiSysTFixtureDebugString, syst_debugstring_loc) +{ + EXPECT_STREQ( + xform("<D32TS>01012332[typ=2:1 mu=1:2 sev=3 loc len]<D8>00<D32>5678abcd<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG_LOC16(ph, MIPI_SYST_SEVERITY_WARNING, 0xabcd, "Hello world!" , 12) + ); + + EXPECT_STREQ( + xform("<D32TS>01012332[typ=2:1 mu=1:2 sev=3 loc len]<D8>01<D64>123456780000abcd<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG_LOC32(ph, MIPI_SYST_SEVERITY_WARNING,0xabcd, "Hello world!" , 12) + ); +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>01012332[typ=2:1 mu=1:2 sev=3 loc len]<D8>03<D64>12345678aabbccdd<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!" , 12) + ); +#else + EXPECT_STREQ( + xform("<D32TS>01012332[typ=2:1 mu=1:2 sev=3 loc len]<D8>02<D32>12345678<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG_LOCADDR(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!" , 12) + ); +#endif +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD + +TEST_F(MipiSysTFixtureDebugString, syst_debugstring_nolength) +{ + MIPI_SYST_ENABLE_HANDLE_LENGTH(ph,0); + EXPECT_STREQ( + xform("<D32TS>01012032[typ=2:1 mu=1:2 sev=3]<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!" , 12) + ); + + MIPI_SYST_ENABLE_HANDLE_LENGTH(ph,1); + + EXPECT_STREQ( + xform("<D32TS>01012232[typ=2:1 mu=1:2 sev=3 len]<D16>000c<D64>6f77206f6c6c6548<D32>21646c72<FLAG>"), + MIPI_SYST_DEBUG(ph, MIPI_SYST_SEVERITY_WARNING, "Hello world!" , 12) + ); +} + +TEST_F(MipiSysTFixtureDebugString, syst_func_enter) +{ + EXPECT_STREQ( + xform("<D32TS>02012242[typ=2:2 mu=1:2 sev=4 len]<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_ENTER(ph, MIPI_SYST_SEVERITY_INFO) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) + EXPECT_STREQ( + xform("<D32TS>02012342[typ=2:2 mu=1:2 sev=4 loc len]<D8>00<D32>5678abcd<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_ENTER_LOC16(ph, MIPI_SYST_SEVERITY_INFO,0xabcd) + ); + + EXPECT_STREQ( + xform("<D32TS>02012342[typ=2:2 mu=1:2 sev=4 loc len]<D8>01<D64>123456780000abcd<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_ENTER_LOC32(ph, MIPI_SYST_SEVERITY_INFO,0xabcd) + ); +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>02012342[typ=2:2 mu=1:2 sev=4 loc len]<D8>03<D64>12345678aabbccdd<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_ENTER_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO) + ); +#else + EXPECT_STREQ( + xform("<D32TS>02012342[typ=2:2 mu=1:2 sev=4 loc len]<D8>02<D32>12345678<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_ENTER_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO) + ); +#endif //MIPI_SYST_PCFG_ENABLE_64BIT_ADDR +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD +} + +TEST_F(MipiSysTFixtureDebugString, syst_func_exit) +{ + EXPECT_STREQ( + xform("<D32TS>03012242[typ=2:3 mu=1:2 sev=4 len]<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_EXIT(ph, MIPI_SYST_SEVERITY_INFO) + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) + EXPECT_STREQ( + xform("<D32TS>03012342[typ=2:3 mu=1:2 sev=4 loc len]<D8>00<D32>5678abcd<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_EXIT_LOC16(ph, MIPI_SYST_SEVERITY_INFO,0xabcd) + ); + + EXPECT_STREQ( + xform("<D32TS>03012342[typ=2:3 mu=1:2 sev=4 loc len]<D8>01<D64>123456780000abcd<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_EXIT_LOC32(ph, MIPI_SYST_SEVERITY_INFO,0xabcd) + ); +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>03012342[typ=2:3 mu=1:2 sev=4 loc len]<D8>03<D64>12345678aabbccdd<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_EXIT_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO) + ); +#else + EXPECT_STREQ( + xform("<D32TS>03012342[typ=2:3 mu=1:2 sev=4 loc len]<D8>02<D32>12345678<D16>000b<D64>3736353433323130<D16>3938<D8>00<FLAG>"), + MIPI_SYST_FUNC_EXIT_LOCADDR(ph, MIPI_SYST_SEVERITY_INFO) + ); +#endif //MIPI_SYST_PCFG_ENABLE_64BIT_ADDR +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD +} + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD) +TEST_F(MipiSysTFixtureDebugString, syst_debug_assert) +{ + MIPI_SYST_ASSERT(ph, MIPI_SYST_SEVERITY_ERROR, 0); + + EXPECT_STREQ( + xform("<D32TS>07012222[typ=2:7 mu=1:2 sev=2 len]<D16>0018<D64>7473657474696e75<D64>33323178303a632e<D64>0030203837363534<FLAG>"), + result.c_str() + ); + + result = ""; + MIPI_SYST_ASSERT(ph, MIPI_SYST_SEVERITY_ERROR, 1); + + EXPECT_STREQ( + "", + result.c_str() + ); + +#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS) + MIPI_SYST_ASSERT_LOCADDR(ph, MIPI_SYST_SEVERITY_ERROR, 0); +#if defined(MIPI_SYST_PCFG_ENABLE_64BIT_ADDR) + EXPECT_STREQ( + xform("<D32TS>07012322[typ=2:7 mu=1:2 sev=2 loc len]<D8>03<D64>12345678aabbccdd<D16>0018<D64>7473657474696e75<D64>33323178303a632e<D64>0030203837363534<FLAG>"), + result.c_str() + ); +#else + EXPECT_STREQ( + xform("<D32TS>07012322[typ=2:7 mu=1:2 sev=2 loc len]<D8>02<D32>12345678<D16>0018<D64>7473657474696e75<D64>33323178303a632e<D64>0030203837363534<FLAG>"), + result.c_str() + ); +#endif + result = ""; + MIPI_SYST_ASSERT_LOCADDR(ph, MIPI_SYST_SEVERITY_ERROR, 1); + + EXPECT_STREQ( + "", + result.c_str() + ); +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS + + MIPI_SYST_ASSERT_LOC16(ph, MIPI_SYST_SEVERITY_ERROR, 0xabcd, 0); + + EXPECT_STREQ( + xform("<D32TS>07012322[typ=2:7 mu=1:2 sev=2 loc len]<D8>00<D32>5678abcd<D16>0018<D64>7473657474696e75<D64>33323178303a632e<D64>0030203837363534<FLAG>"), + result.c_str() + ); + + result = ""; + MIPI_SYST_ASSERT_LOC16(ph, MIPI_SYST_SEVERITY_ERROR,0xabcd, 1); + + EXPECT_STREQ( + "", + result.c_str() + ); + + MIPI_SYST_ASSERT_LOC32(ph, MIPI_SYST_SEVERITY_ERROR, 0xabcd, 0); + + EXPECT_STREQ( + xform("<D32TS>07012322[typ=2:7 mu=1:2 sev=2 loc len]<D8>01<D64>123456780000abcd<D16>0018<D64>7473657474696e75<D64>33323178303a632e<D64>0030203837363534<FLAG>"), + result.c_str() + ); + + result = ""; + MIPI_SYST_ASSERT_LOC32(ph, MIPI_SYST_SEVERITY_ERROR, 0xabcd, 1); + + EXPECT_STREQ( + "", + result.c_str() + ); +} +#endif //MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD + +#endif //MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA && MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE && MIPI_SYST_PCFG_ENABLE_STRING_API
\ No newline at end of file |