diff options
author | Mike Leach <mike.leach@linaro.org> | 2022-10-27 00:02:34 +0100 |
---|---|---|
committer | Mike Leach <mike.leach@linaro.org> | 2022-10-31 23:07:14 +0000 |
commit | 930e1e671a51270903fa22895671bd6c74c4e75c (patch) | |
tree | 6c7c3f5cdfa12537ded6f10c208336f2ebb091ac | |
parent | b35fc0ea6285018878ea382254c1e6a4b516669a (diff) | |
download | OpenCSD-930e1e671a51270903fa22895671bd6c74c4e75c.tar.gz |
opencsd: tests: Test program for Trace Demux module.
A series of tests to ensure that the Trace Demux module is working correctly.
Signed-off-by: Mike Leach <mike.leach@linaro.org>
11 files changed, 856 insertions, 0 deletions
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile index 54dd031..5515737 100644 --- a/decoder/build/linux/makefile +++ b/decoder/build/linux/makefile @@ -173,6 +173,7 @@ tests: libs cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && $(MAKE) cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && $(MAKE) cd $(OCSD_ROOT)/tests/build/linux/mem_buffer_eg && $(MAKE) + cd $(OCSD_ROOT)/tests/build/linux/frame_demux_test && $(MAKE) # # build docs @@ -198,6 +199,7 @@ clean_tests: cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && $(MAKE) clean cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && $(MAKE) clean cd $(OCSD_ROOT)/tests/build/linux/mem_buffer_eg && $(MAKE) clean + cd $(OCSD_ROOT)/tests/build/linux/frame_demux_test && $(MAKE) clean -rmdir $(OCSD_TESTS)/lib clean_docs: diff --git a/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.sln b/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.sln index 2dedc95..ce4ee29 100644 --- a/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.sln +++ b/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.sln @@ -27,6 +27,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "trc_pkt_lister", "..\..\..\ {7F500891-CC76-405F-933F-F682BC39F923} = {7F500891-CC76-405F-933F-F682BC39F923} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "frame_demux_test", "..\..\..\tests\build\win-vs2022\frame_demux_test\frame_demux_test.vcxproj", "{98EE9884-A4EB-4C75-A911-DFEDF992754F}" + ProjectSection(ProjectDependencies) = postProject + {7F500891-CC76-405F-933F-F682BC39F923} = {7F500891-CC76-405F-933F-F682BC39F923} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -139,6 +144,18 @@ Global {18ABC652-AB11-4993-9491-1A7FB7117339}.Release|x64.Build.0 = Release|x64 {18ABC652-AB11-4993-9491-1A7FB7117339}.Release-dll|Win32.ActiveCfg = Release|Win32 {18ABC652-AB11-4993-9491-1A7FB7117339}.Release-dll|x64.ActiveCfg = Release|x64 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Debug|Win32.ActiveCfg = Debug|Win32 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Debug|Win32.Build.0 = Debug|Win32 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Debug|x64.ActiveCfg = Debug|x64 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Debug|x64.Build.0 = Debug|x64 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Debug-dll|Win32.ActiveCfg = Debug|Win32 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Debug-dll|x64.ActiveCfg = Debug|x64 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Release|Win32.ActiveCfg = Release|Win32 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Release|Win32.Build.0 = Release|Win32 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Release|x64.ActiveCfg = Release|x64 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Release|x64.Build.0 = Release|x64 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Release-dll|Win32.ActiveCfg = Release|Win32 + {98EE9884-A4EB-4C75-A911-DFEDF992754F}.Release-dll|x64.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/decoder/tests/build/linux/frame_demux_test/makefile b/decoder/tests/build/linux/frame_demux_test/makefile new file mode 100644 index 0000000..29c75a0 --- /dev/null +++ b/decoder/tests/build/linux/frame_demux_test/makefile @@ -0,0 +1,88 @@ +######################################################## +# Copyright 2022 ARM Limited. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. 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 HOLDER 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. +# +################################################################################# + +######## +# opencsd: makefile for the frame demux test program +# + +CXX := $(MASTER_CXX) +LINKER := $(MASTER_LINKER) + +PROG = frame-demux-test + +BUILD_DIR=./$(PLAT_DIR) + +VPATH = $(OCSD_TESTS)/source + +CXX_INCLUDES = \ + -I$(OCSD_TESTS)/source \ + -I$(OCSD_INCLUDE) + +OBJECTS = $(BUILD_DIR)/frame_demux_test.o + +LIBS = -L$(LIB_TEST_TARGET_DIR) -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME) + +all: copy_libs + +test_app: $(BIN_TEST_TARGET_DIR)/$(PROG) + + + $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS) | build_dir + mkdir -p $(BIN_TEST_TARGET_DIR) + $(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG) + +build_dir: + mkdir -p $(BUILD_DIR) + +.PHONY: copy_libs +copy_libs: $(BIN_TEST_TARGET_DIR)/$(PROG) + cp $(LIB_TARGET_DIR)/*.so* $(BIN_TEST_TARGET_DIR)/. + + + +#### build rules +## object dependencies +DEPS := $(OBJECTS:%.o=%.d) + +-include $(DEPS) + +## object compile +$(BUILD_DIR)/%.o : %.cpp | build_dir + $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@ + +#### clean +.PHONY: clean +clean : + -rm $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS) + -rm $(DEPS) + -rm $(BIN_TEST_TARGET_DIR)/*.so* + -rmdir $(BUILD_DIR) + +# end of file makefile diff --git a/decoder/tests/build/win-vs2022/frame_demux_test/Win32/Release/frame_demux_test.exe.recipe b/decoder/tests/build/win-vs2022/frame_demux_test/Win32/Release/frame_demux_test.exe.recipe new file mode 100644 index 0000000..b85a437 --- /dev/null +++ b/decoder/tests/build/win-vs2022/frame_demux_test/Win32/Release/frame_demux_test.exe.recipe @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project> + <ProjectOutputs> + <ProjectOutput> + <FullPath>C:\work\OpenCSD\ocsd-linaro\decoder\tests\bin\win32\rel\frame_demux_test.exe</FullPath> + </ProjectOutput> + </ProjectOutputs> + <ContentFiles /> + <SatelliteDlls /> + <NonRecipeFileRefs /> +</Project>
\ No newline at end of file diff --git a/decoder/tests/build/win-vs2022/frame_demux_test/Win32/Release/frame_demux_test.vcxproj.FileListAbsolute.txt b/decoder/tests/build/win-vs2022/frame_demux_test/Win32/Release/frame_demux_test.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/decoder/tests/build/win-vs2022/frame_demux_test/Win32/Release/frame_demux_test.vcxproj.FileListAbsolute.txt diff --git a/decoder/tests/build/win-vs2022/frame_demux_test/frame_demux_test.vcxproj b/decoder/tests/build/win-vs2022/frame_demux_test/frame_demux_test.vcxproj new file mode 100644 index 0000000..117f9f9 --- /dev/null +++ b/decoder/tests/build/win-vs2022/frame_demux_test/frame_demux_test.vcxproj @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>16.0</VCProjectVersion> + <Keyword>Win32Proj</Keyword> + <ProjectGuid>{98ee9884-a4eb-4c75-a911-dfedf992754f}</ProjectGuid> + <RootNamespace>framedemuxtest</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + <EnableASAN>true</EnableASAN> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\..\..\build\win-vs2022\opencsd.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\..\..\build\win-vs2022\opencsd.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\..\..\build\win-vs2022\opencsd.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\..\..\build\win-vs2022\opencsd.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\bin\win$(PlatformArchitecture)\dbg\</OutDir> + <IntDir>$(Platform)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\bin\win$(PlatformArchitecture)\rel\</OutDir> + <IntDir>$(Platform)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\bin\win$(PlatformArchitecture)\rel\</OutDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>false</SDLCheck> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories> + <BasicRuntimeChecks> + </BasicRuntimeChecks> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\dbg\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\dbg\</AdditionalLibraryDirectories> + <AdditionalDependencies>lib$(LIB_BASE_NAME).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\rel\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\rel\</AdditionalLibraryDirectories> + <AdditionalDependencies>lib$(LIB_BASE_NAME).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\dbg\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\dbg\</AdditionalLibraryDirectories> + <AdditionalDependencies>lib$(LIB_BASE_NAME).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\rel\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\rel\</AdditionalLibraryDirectories> + <AdditionalDependencies>lib$(LIB_BASE_NAME).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\..\source\frame_demux_test.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/decoder/tests/build/win-vs2022/frame_demux_test/frame_demux_test.vcxproj.filters b/decoder/tests/build/win-vs2022/frame_demux_test/frame_demux_test.vcxproj.filters new file mode 100644 index 0000000..8069d24 --- /dev/null +++ b/decoder/tests/build/win-vs2022/frame_demux_test/frame_demux_test.vcxproj.filters @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\..\source\frame_demux_test.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/decoder/tests/build/win-vs2022/frame_demux_test/x64/Release/frame_demux_test.exe.recipe b/decoder/tests/build/win-vs2022/frame_demux_test/x64/Release/frame_demux_test.exe.recipe new file mode 100644 index 0000000..c98207c --- /dev/null +++ b/decoder/tests/build/win-vs2022/frame_demux_test/x64/Release/frame_demux_test.exe.recipe @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project> + <ProjectOutputs> + <ProjectOutput> + <FullPath>C:\work\OpenCSD\ocsd-linaro\decoder\tests\bin\win64\rel\frame_demux_test.exe</FullPath> + </ProjectOutput> + </ProjectOutputs> + <ContentFiles /> + <SatelliteDlls /> + <NonRecipeFileRefs /> +</Project>
\ No newline at end of file diff --git a/decoder/tests/build/win-vs2022/frame_demux_test/x64/Release/frame_demux_test.vcxproj.FileListAbsolute.txt b/decoder/tests/build/win-vs2022/frame_demux_test/x64/Release/frame_demux_test.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/decoder/tests/build/win-vs2022/frame_demux_test/x64/Release/frame_demux_test.vcxproj.FileListAbsolute.txt diff --git a/decoder/tests/run_pkt_decode_tests.bash b/decoder/tests/run_pkt_decode_tests.bash index 9ecb034..27a855e 100755 --- a/decoder/tests/run_pkt_decode_tests.bash +++ b/decoder/tests/run_pkt_decode_tests.bash @@ -114,3 +114,12 @@ if [ "$1" != "use-installed" ]; then echo "moving result file." mv ./c_api_test.log ./${OUT_DIR}/c_api_test.ppl fi + +# === run the Frame decoder test - program not installed === +if [ "$1" != "use-installed" ]; then + echo "Running Frame demux test" + ${BIN_DIR}frame-demux-test > /dev/null + echo "Done : Return $?" + echo "moving result file." + mv ./frame_demux_test.ppl ./${OUT_DIR}/. +fi diff --git a/decoder/tests/source/frame_demux_test.cpp b/decoder/tests/source/frame_demux_test.cpp new file mode 100644 index 0000000..69856cc --- /dev/null +++ b/decoder/tests/source/frame_demux_test.cpp @@ -0,0 +1,524 @@ +/* +* \file frame_demux_test.cpp +* \brief OpenCSD: Test the frame demux code for robustness with correct and invalid data. +* +* \copyright Copyright (c) 2022, ARM Limited. All Rights Reserved. +*/ + +/* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* 2. 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. +* +* 3. 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 HOLDER 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. +*/ + +/* Runs sets of test data through the frame demuxer to ensure that it is robust for valid and + * invalid inputs + */ + +#include <cstdio> +#include <string> +#include <iostream> +#include <sstream> +#include <cstring> + +#include "opencsd.h" // the library + + /* Decode tree is the main decoder framework - contains the frame demuxer + and will have an output printer attached to the raw output */ +static DecodeTree* pDecoder = 0; +static const uint32_t base_cfg = OCSD_DFRMTR_FRAME_MEM_ALIGN | + OCSD_DFRMTR_PACKED_RAW_OUT | OCSD_DFRMTR_UNPACKED_RAW_OUT; +static ocsdDefaultErrorLogger err_log; +static ocsdMsgLogger logger; + +/* test data */ +#define ID_BYTE_ID(id) ((uint8_t)(id) << 1 | 0x01) +#define ID_BYTE_DATA(data) ((uint8_t)(data & 0xFE)) +#define FLAGS_BYTE(id0, id1, id2, id3, id4, id5, id6, id7) ((uint8_t) ( \ + ((id7 & 0x1) << 7) | ((id6 & 0x1) << 6) | ((id5 & 0x1) << 5) | ((id4 & 0x1) << 4) | \ + ((id3 & 0x1) << 3) | ((id2 & 0x1) << 2) | ((id1 & 0x1) << 1) | (id0 & 0x1) )) +#define HSYNC_BYTES() 0xff, 0x7f +#define FSYNC_BYTES() 0xff, 0xff, 0xff, 0x7f +#define DATASIZE(array) static const size_t array##_sz = sizeof(array) / sizeof(array[0]) + + +static const uint8_t buf_hsync_fsync[] = { + FSYNC_BYTES(), + ID_BYTE_ID(0x10), 0x01, ID_BYTE_DATA(0x2), 0x03, + HSYNC_BYTES(), ID_BYTE_ID(0x20), 0x4, ID_BYTE_DATA(0x5), 0x6, + ID_BYTE_DATA(0x7), 0x08, HSYNC_BYTES(), ID_BYTE_DATA(0x9), 0xA, + ID_BYTE_ID(0x10), 0x0B, ID_BYTE_DATA(0xC), + FLAGS_BYTE(0, 0, 0, 1, 1, 1, 1, 0), +}; +DATASIZE(buf_hsync_fsync); + +static const uint8_t buf_mem_align[] = { + ID_BYTE_ID(0x10), 0x01, ID_BYTE_DATA(0x02), 0x03, + ID_BYTE_DATA(0x04), 0x05, ID_BYTE_DATA(0x06), 0x07, + ID_BYTE_ID(0x20), 0x08, ID_BYTE_DATA(0x09), 0x0A, + ID_BYTE_DATA(0x0B), 0x0C, ID_BYTE_DATA(0x0D), + FLAGS_BYTE(0, 0, 0, 0, 0, 1, 1, 1), + ID_BYTE_DATA(0x0E), 0x0F, ID_BYTE_ID(0x30), 0x10, + ID_BYTE_DATA(0x11), 0x12, ID_BYTE_DATA(0x13), 0x14, + ID_BYTE_DATA(0x15), 0x16, ID_BYTE_ID(0x10), 0x17, + ID_BYTE_DATA(0x18), 0x19, ID_BYTE_DATA(0x20), + FLAGS_BYTE(0, 0, 1, 1, 1, 1, 0, 0), +}; +DATASIZE(buf_mem_align); + +static const uint8_t buf_mem_align_8id[] = { + ID_BYTE_ID(0x10), 0x01, ID_BYTE_DATA(0x02), 0x03, + ID_BYTE_DATA(0x04), 0x05, ID_BYTE_DATA(0x06), 0x07, + ID_BYTE_ID(0x20), 0x08, ID_BYTE_DATA(0x09), 0x0A, + ID_BYTE_DATA(0x0B), 0x0C, ID_BYTE_DATA(0x0D), + FLAGS_BYTE(0, 0, 0, 0, 0, 1, 1, 1), + // 8 IDs, all with prev flag + ID_BYTE_ID(0x01), 0x0E, ID_BYTE_ID(0x02), 0x0F, + ID_BYTE_ID(0x03), 0x10, ID_BYTE_ID(0x04), 0x11, + ID_BYTE_ID(0x05), 0x12, ID_BYTE_ID(0x06), 0x13, + ID_BYTE_ID(0x07), 0x14, ID_BYTE_DATA(0x50), + FLAGS_BYTE(1, 1, 1, 1, 1, 1, 1, 1), + ID_BYTE_DATA(0x15), 0x16, ID_BYTE_DATA(0x17), 0x18, + ID_BYTE_DATA(0x19), 0x1A, ID_BYTE_DATA(0x1B), 0x1C, + ID_BYTE_ID(0x20), 0x1D, ID_BYTE_DATA(0x1E), 0x1F, + ID_BYTE_DATA(0x20), 0x21, ID_BYTE_DATA(0x22), + FLAGS_BYTE(1, 1, 1, 1, 0, 0, 0, 0), +}; +DATASIZE(buf_mem_align_8id); + +static const uint8_t buf_mem_align_st_rst[] = { + FSYNC_BYTES(), FSYNC_BYTES(), FSYNC_BYTES(), FSYNC_BYTES(), + ID_BYTE_ID(0x10), 0x01, ID_BYTE_DATA(0x02), 0x03, + ID_BYTE_DATA(0x04), 0x05, ID_BYTE_DATA(0x06), 0x07, + ID_BYTE_ID(0x20), 0x08, ID_BYTE_DATA(0x09), 0x0A, + ID_BYTE_DATA(0x0B), 0x0C, ID_BYTE_DATA(0x0D), + FLAGS_BYTE(0, 0, 0, 0, 0, 1, 1, 1), + ID_BYTE_DATA(0x0E), 0x0F, ID_BYTE_ID(0x30), 0x10, + ID_BYTE_DATA(0x11), 0x12, ID_BYTE_DATA(0x13), 0x14, + ID_BYTE_DATA(0x15), 0x16, ID_BYTE_ID(0x10), 0x17, + ID_BYTE_DATA(0x18), 0x19, ID_BYTE_DATA(0x20), + FLAGS_BYTE(0, 0, 1, 1, 1, 1, 0, 0), +}; +DATASIZE(buf_mem_align_st_rst); + +static const uint8_t buf_mem_align_mid_rst[] = { + ID_BYTE_ID(0x10), 0x01, ID_BYTE_DATA(0x02), 0x03, + ID_BYTE_DATA(0x04), 0x05, ID_BYTE_DATA(0x06), 0x07, + ID_BYTE_ID(0x20), 0x08, ID_BYTE_DATA(0x09), 0x0A, + ID_BYTE_DATA(0x0B), 0x0C, ID_BYTE_DATA(0x0D), + FLAGS_BYTE(0, 0, 0, 0, 0, 1, 1, 1), + FSYNC_BYTES(), FSYNC_BYTES(), FSYNC_BYTES(), FSYNC_BYTES(), + ID_BYTE_DATA(0x0E), 0x0F, ID_BYTE_ID(0x30), 0x10, + ID_BYTE_DATA(0x11), 0x12, ID_BYTE_DATA(0x13), 0x14, + ID_BYTE_DATA(0x15), 0x16, ID_BYTE_ID(0x10), 0x17, + ID_BYTE_DATA(0x18), 0x19, ID_BYTE_DATA(0x20), + FLAGS_BYTE(0, 0, 1, 1, 1, 1, 0, 0), +}; +DATASIZE(buf_mem_align_mid_rst); + +static const uint8_t buf_mem_align_en_rst[] = { + ID_BYTE_ID(0x10), 0x01, ID_BYTE_DATA(0x02), 0x03, + ID_BYTE_DATA(0x04), 0x05, ID_BYTE_DATA(0x06), 0x07, + ID_BYTE_ID(0x20), 0x08, ID_BYTE_DATA(0x09), 0x0A, + ID_BYTE_DATA(0x0B), 0x0C, ID_BYTE_DATA(0x0D), + FLAGS_BYTE(0, 0, 0, 0, 0, 1, 1, 1), + ID_BYTE_DATA(0x0E), 0x0F, ID_BYTE_ID(0x30), 0x10, + ID_BYTE_DATA(0x11), 0x12, ID_BYTE_DATA(0x13), 0x14, + ID_BYTE_DATA(0x15), 0x16, ID_BYTE_ID(0x10), 0x17, + ID_BYTE_DATA(0x18), 0x19, ID_BYTE_DATA(0x20), + FLAGS_BYTE(0, 0, 1, 1, 1, 1, 0, 0), + FSYNC_BYTES(), FSYNC_BYTES(), FSYNC_BYTES(), FSYNC_BYTES(), +}; +DATASIZE(buf_mem_align_en_rst); + +static const uint8_t buf_bad_data[] = { +0xff, 0xff, 0xff, 0x7f, 0x30, 0xff, 0x53, 0x54, 0x4d, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0, 0x36, 0xff, 0xb1, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x2b, +0x36, 0x36, 0x3a, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, +0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, +0x36, 0x36, 0x36, 0x36, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, +0, 0x2c, 0, 0, 0, 0x32, 0x1, 0, +}; +DATASIZE(buf_bad_data); + +static ocsd_err_t initDecoder(int init_opts) +{ + pDecoder = DecodeTree::CreateDecodeTree(OCSD_TRC_SRC_FRAME_FORMATTED, init_opts); + if (!pDecoder) + return OCSD_ERR_MEM; + return OCSD_OK; +} + +static void destroyDecoder() +{ + delete pDecoder; + pDecoder = 0; +} + +static void printTestHeaderStr(const char* hdr_str) +{ + std::ostringstream oss; + + oss << "\n---------------------------------------------------------\n"; + oss << hdr_str; + oss << "\n---------------------------------------------------------\n"; + logger.LogMsg(oss.str()); +} + +static void printSubTestName(const int test_num, const char* name) +{ + std::ostringstream oss; + + oss << "\n..Sub Test " << test_num << " : " << name << "\n"; + logger.LogMsg(oss.str()); +} + +static ocsd_err_t setConfig(uint32_t flags) +{ + TraceFormatterFrameDecoder* pFmt = pDecoder->getFrameDeformatter(); + return pFmt->Configure(flags); + +} + +// fail and print on none RESP_CONT response. +static ocsd_datapath_resp_t checkDataPathValue(ocsd_datapath_resp_t resp, int& failed_count) +{ + if (resp == OCSD_RESP_CONT) + return resp; + + std::ostringstream oss; + oss << "\nTest Datapath error response: " << ocsdDataRespStr(resp).getStr() << "\n"; + logger.LogMsg(oss.str()); + failed_count++; + return resp; +} + +static void resetDecoder(int& failed) +{ + checkDataPathValue(pDecoder->TraceDataIn(OCSD_OP_RESET, 0, 0, 0, 0), failed); +} + + +static void checkInOutSizes(const char *test, size_t in, size_t out, int& failed) +{ + if (in != out) { + failed++; + std::ostringstream oss; + oss << test << " test failed - mismatch between processed and input sizes:"; + oss << " In=" << in << "; Out=" << out; + logger.LogMsg(oss.str()); + } +} + +static int checkResult(int failed) +{ + std::ostringstream oss; + oss << "\nTEST : " << ((failed) ? "FAIL" : "PASS") << "\n"; + logger.LogMsg(oss.str()); + return failed; +} +static int testDemuxInit() +{ + ocsd_err_t err; + std::ostringstream oss; + int failed = 0; + + printTestHeaderStr("Demux Init Tests - check bad input rejected"); + + // init with invalid no flags + oss.str(""); + oss << "\nCheck 0 flag error: "; + err = initDecoder(0); + if (err) { + err = err_log.GetLastError()->getErrorCode(); + } + if (err != OCSD_ERR_INVALID_PARAM_VAL) { + oss << "FAIL: expected error code not returned\n"; + failed++; + } + else + oss << "PASS\n"; + logger.LogMsg(oss.str()); + + // init with invalid unknown flags + oss.str(""); + oss << "\nCheck unknown flag error: "; + err = initDecoder(0x80 | OCSD_DFRMTR_FRAME_MEM_ALIGN); + if (err) { + err = err_log.GetLastError()->getErrorCode(); + } + if (err != OCSD_ERR_INVALID_PARAM_VAL) { + oss << "FAIL: expected error code not returned\n"; + failed++; + } + else + oss << "PASS\n"; + logger.LogMsg(oss.str()); + + // init with bad combo + oss.str(""); + oss << "\nCheck bad combination flag error: "; + err = initDecoder(OCSD_DFRMTR_FRAME_MEM_ALIGN | OCSD_DFRMTR_HAS_FSYNCS); + if (err) { + err = err_log.GetLastError()->getErrorCode(); + } + if (err != OCSD_ERR_INVALID_PARAM_VAL) { + oss << "FAIL: expected error code not returned\n"; + failed++; + } + else + oss << "PASS\n"; + logger.LogMsg(oss.str()); + + return failed; +} + +static int runDemuxBadDataTest() +{ + + int failed = 0; + uint32_t processed = 0; + std::ostringstream oss; + ocsd_datapath_resp_t resp; + + printTestHeaderStr("Demux Bad Data Test - arbitrary test data input"); + + setConfig(base_cfg | OCSD_DFRMTR_RESET_ON_4X_FSYNC); + + // reset the decoder. + resetDecoder(failed); + resp = checkDataPathValue(pDecoder->TraceDataIn(OCSD_OP_DATA, 0, buf_bad_data_sz, buf_bad_data, &processed), failed); + if ((resp == OCSD_RESP_FATAL_INVALID_DATA) && + (err_log.GetLastError()->getErrorCode() == OCSD_ERR_DFMTR_BAD_FHSYNC)) + { + failed--; // cancel the fail - we require that the error happens for bad input + oss << "Got correct error response for invalid input\n"; + } + else + { + oss << "Expected error code not returned\n"; + } + logger.LogMsg(oss.str()); + + setConfig(base_cfg); + return checkResult(failed); +} + +static int runHSyncFSyncTest() +{ + uint32_t cfg_flags = base_cfg; + uint32_t processed = 0, total = 0; + ocsd_trc_index_t index = 0; + int failed = 0; + ocsd_datapath_resp_t resp; + std::ostringstream oss; + + printTestHeaderStr("FSYNC & HSYNC tests: check hander code for TPIU captures works."); + + // set for hsync / fsync operation + cfg_flags &= ~OCSD_DFRMTR_FRAME_MEM_ALIGN; // clear mem align + cfg_flags |= OCSD_DFRMTR_HAS_HSYNCS | OCSD_DFRMTR_HAS_FSYNCS; + setConfig(cfg_flags); + + // straight frame test with fsync + hsync + printSubTestName(1, "HSyncFSync frame"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, index, buf_hsync_fsync_sz, buf_hsync_fsync, &processed), + failed); + checkInOutSizes("HSyncFSync frame", buf_hsync_fsync_sz, processed, failed); + + // test fsync broken across 2 input blocks + printSubTestName(2, "HSyncFSync split frame"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, index, 2, buf_hsync_fsync, &processed), + failed); + total += processed; + index += processed; + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, index, buf_hsync_fsync_sz - processed, buf_hsync_fsync + processed, &processed), + failed); + total += processed; + checkInOutSizes("HSyncFSync split frame", buf_hsync_fsync_sz, total, failed); + + // check bad input data is rejected. + printSubTestName(3, "HSyncFSync bad input data"); + resetDecoder(failed); + resp = checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, index, buf_bad_data_sz, buf_bad_data, &processed), + failed); + if ((resp == OCSD_RESP_FATAL_INVALID_DATA) && + (err_log.GetLastError()->getErrorCode() == OCSD_ERR_DFMTR_BAD_FHSYNC)) + { + failed--; // cancel the fail - we require that the error happens for bad input + oss << "Got correct error response for invalid input\n"; + } + else + { + oss << "Expected error code not returned\n"; + } + logger.LogMsg(oss.str()); + + + setConfig(base_cfg); + return checkResult(failed); +} + +static int runMemAlignTest() +{ + uint32_t processed = 0; + int failed = 0; + + printTestHeaderStr("MemAligned Buffer tests: exercise the 16 byte frame buffer handler"); + + // default decoder set to mem align so just run the test. + + // straight frame pair + printSubTestName(1, "MemAlignFrame"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, 0, buf_mem_align_sz, buf_mem_align, &processed), + failed); + checkInOutSizes("MemAlignFrame", buf_mem_align_sz, processed, failed); + + // frame with 8 id test + printSubTestName(2, "MemAlignFrame-8-ID"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, 0, buf_mem_align_8id_sz, buf_mem_align_8id, &processed), + failed); + checkInOutSizes("MemAlignFrame-8-ID", buf_mem_align_8id_sz, processed, failed); + + // check reset FSYNC frame handling + setConfig(base_cfg | OCSD_DFRMTR_RESET_ON_4X_FSYNC); + printSubTestName(3, "MemAlignFrame-rst_st"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, 0, buf_mem_align_st_rst_sz, buf_mem_align_st_rst, &processed), + failed); + checkInOutSizes("MemAlignFrame-rst_st", buf_mem_align_st_rst_sz, processed, failed); + + printSubTestName(4, "MemAlignFrame-rst_mid"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, 0, buf_mem_align_mid_rst_sz, buf_mem_align_mid_rst, &processed), + failed); + checkInOutSizes("MemAlignFrame-rst_mid", buf_mem_align_mid_rst_sz, processed, failed); + + printSubTestName(5, "MemAlignFrame-rst_en"); + resetDecoder(failed); + checkDataPathValue( + pDecoder->TraceDataIn(OCSD_OP_DATA, 0, buf_mem_align_en_rst_sz, buf_mem_align_en_rst, &processed), + failed); + checkInOutSizes("MemAlignFrame-rst_en", buf_mem_align_en_rst_sz, processed, failed); + + setConfig(base_cfg); + return checkResult(failed); +} + +int main(int argc, char* argv[]) +{ + int failed = 0; + ocsd_err_t err; + std::ostringstream moss; + RawFramePrinter* framePrinter = 0; + + /* initialise logger */ + + static const int logOpts = ocsdMsgLogger::OUT_STDOUT | ocsdMsgLogger::OUT_FILE; + + logger.setLogOpts(logOpts); + logger.setLogFileName("frame_demux_test.ppl"); + moss << "---------------------------------------------------------\n"; + moss << "Trace Demux Frame Test - check CoreSight frame processing\n"; + moss << "---------------------------------------------------------\n\n"; + moss << "** Library Version : " << ocsdVersion::vers_str() << "\n\n"; + logger.LogMsg(moss.str()); + + /* initialise error logger */ + err_log.initErrorLogger(OCSD_ERR_SEV_INFO); + err_log.setOutputLogger(&logger); + DecodeTree::setAlternateErrorLogger(&err_log); + + /* run the init tests */ + failed += testDemuxInit(); + + /* create a decoder for the remainder of the tests */ + err = initDecoder(base_cfg); + moss.str(""); + moss << "Creating Decoder for active Demux testing\n"; + if (!err && pDecoder) { + err = pDecoder->addRawFramePrinter(&framePrinter, OCSD_DFRMTR_PACKED_RAW_OUT | OCSD_DFRMTR_UNPACKED_RAW_OUT); + if (err) + moss << "Failed to add Frame printer\n"; + } + if (err || !pDecoder) { + + moss << "Failed to initialise decoder for remainder of the tests\nSkipping active demux tests\n"; + failed++; + } + + /* remainder of the tests that need an active decoder */ + if (!err) { + try { + failed += runMemAlignTest(); + failed += runHSyncFSyncTest(); + failed += runDemuxBadDataTest(); + } + catch (ocsdError& err) { + moss.str(""); + moss << "*** TEST ERROR: Unhandled error from tests. Aborting test run ***\n"; + moss << err.getErrorString(err) << "\n"; + logger.LogMsg(moss.str()); + failed++; + } + } + + /* testing done */ + moss.str(""); + moss << "\n\n---------------------------------------------------------\n"; + moss << "Trace Demux Testing Complete\n"; + if (failed) + moss << "FAILED: recorded " << failed << " errors or failures.\n"; + else + moss << "PASSED ALL tests\n"; + moss << "\n\n---------------------------------------------------------\n"; + + logger.LogMsg(moss.str()); + + if (pDecoder) + destroyDecoder(); + + return failed ? -1 : 0; +} |