Skip to content

Commit

Permalink
Split of tests per type or image format.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Apr 3, 2022
1 parent a15ff20 commit 598ae16
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 445 deletions.
49 changes: 34 additions & 15 deletions test/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,31 @@ namespace test
# define testSuiteMain( testName )\
static test::TestResults launch##testName( test::TestSuite & suite, test::TestCounts & testCounts )

#if defined( _MSC_VER )
# define testEval( V ) V

# define testConcat2( lhs, rhs )\
testEval( lhs ) ## testEval( rhs )

# define testConcat3( lhs, mid, rhs )\
testConcat2( lhs, mid ) ## testEval( rhs )

# define testConcat( lhs, rhs )\
testConcat3( lhs, _, rhs )
#else
# define testConcat2( lhs, rhs )\
lhs ## rhs

# define testConcat( lhs, rhs )\
lhs ## _ ## rhs
#endif

#if defined( SDW_COMPILE_TESTS )
# define testSuiteLaunchEx( testName, suiteType )\
int main( int argv, char ** argc )\
{\
suiteType suite{ #testName };\
suite.registerTests< suiteType >( #testName, launch##testName );\
suite.registerTests< suiteType >( #testName, testConcat2( launch, testName ) );\
return suite.run();\
}
#else
Expand All @@ -239,14 +258,14 @@ namespace test
#define testStringify( x )\
#x

#define testConcat2( x, y )\
#define testConcatStr2( x, y )\
testStringify( x ) testStringify( y )

#define testConcat3( x, y, z )\
testConcat2( x, y ) testStringify( z )
#define testConcatStr3( x, y, z )\
testConcatStr2( x, y ) testStringify( z )

#define testConcat4( x, y, z, w )\
testConcat3( x, y, z ) testStringify( w )
#define testConcatStr4( x, y, z, w )\
testConcatStr3( x, y, z ) testStringify( w )

#define testSuiteBeginEx( testCounts )\
testCounts.initialise();\
Expand Down Expand Up @@ -304,7 +323,7 @@ namespace test
}\
catch ( ... )\
{\
test::reportFailure( testConcat2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}

#define beginRequire( x )\
Expand All @@ -320,7 +339,7 @@ namespace test
}\
catch ( ... )\
{\
test::reportFailure( testConcat2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}

#define check( x )\
Expand All @@ -329,12 +348,12 @@ namespace test
testCounts.incTest();\
if ( !( x ) )\
{\
test::reportFailure( testConcat2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}\
}\
catch ( ... )\
{\
test::reportFailure( testConcat2( x, " failed: Unhandled exception." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed: Unhandled exception." ), __FUNCTION__, __LINE__, testCounts );\
}

#define checkEqual( x, y )\
Expand All @@ -348,7 +367,7 @@ namespace test
}\
catch ( ... )\
{\
test::reportFailure( testConcat4( x, " == ", y, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr4( x, " == ", y, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}

#define checkNotEqual( x, y )\
Expand All @@ -362,15 +381,15 @@ namespace test
}\
catch ( ... )\
{\
test::reportFailure( testConcat4( x, " != ", y, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr4( x, " != ", y, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}

#define checkThrow( x )\
try\
{\
testCounts.incTest();\
( x ); \
test::reportFailure( testConcat2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}\
catch ( ... )\
{\
Expand All @@ -385,10 +404,10 @@ namespace test
catch ( std::exception & exc )\
{\
test::reportFailure( exc.what(), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcat2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}\
catch ( ... )\
{\
test::reportFailure( testConcat2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
test::reportFailure( testConcatStr2( x, " failed." ), __FUNCTION__, __LINE__, testCounts );\
}
}
101 changes: 99 additions & 2 deletions test/ShaderWriter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,71 @@ if ( PROJECTS_COVERAGE )
)
endif ()

foreach ( TEST_FILE ${TEST_FILES} )
get_filename_component( TEST_NAME ${TEST_FILE} NAME_WE )
set( IMAGE_FORMATS
eRgba32f
eRgba16f
eRg32f
eRg16f
eR32f
eR16f
eRgba32i
eRgba16i
eRgba8i
eRg32i
eRg16i
eRg8i
eR32i
eR16i
eR8i
eRgba32u
eRgba16u
eRgba8u
eRg32u
eRg16u
eRg8u
eR32u
eR16u
eR8u
)

set( BO_TYPES
Int
UInt
Float
Double
Vec2
Vec3
Vec4
DVec2
DVec3
DVec4
IVec2
IVec3
IVec4
UVec2
UVec3
UVec4
Mat2x2
Mat2x3
Mat2x4
Mat3x2
Mat3x3
Mat3x4
Mat4x2
Mat4x3
Mat4x4
DMat2x2
DMat2x3
DMat2x4
DMat3x2
DMat3x3
DMat3x4
DMat4x2
DMat4x3
DMat4x4
)

function( SDW_AddTest TEST_FILE TEST_NAME ADDITIONAL_DEFINITIONS )
if ( PROJECTS_COVERAGE )
set( PROJECTS_COVERAGE_SRC_FILES
${PROJECTS_COVERAGE_SRC_FILES}
Expand All @@ -271,6 +334,7 @@ foreach ( TEST_FILE ${TEST_FILES} )
)
target_compile_definitions( ${TEST_NAME} PRIVATE
${TargetCompileDefinitions}
${ADDITIONAL_DEFINITIONS}
SDW_COMPILE_TESTS
)
target_add_compilation_flags( ${TEST_NAME} )
Expand All @@ -296,6 +360,39 @@ foreach ( TEST_FILE ${TEST_FILES} )
NAME ${TEST_NAME}
COMMAND ${TEST_NAME}
)
endfunction( SDW_AddTest )

foreach ( TEST_FILE ${TEST_FILES} )
get_filename_component( TEST_NAME ${TEST_FILE} NAME_WE )
string( FIND ${TEST_FILE} "Image" IS_IMAGE )
string( FIND ${TEST_FILE} "Ssbo" IS_SSBO )
string( FIND ${TEST_FILE} "Ubo" IS_UBO )
string( FIND ${TEST_FILE} "Struct" IS_STRUCT )
string( FIND ${TEST_FILE} "Pcb" IS_PCB )

if ( IS_IMAGE GREATER -1 )
foreach( FORMAT ${IMAGE_FORMATS} )
SDW_AddTest( ${TEST_FILE} ${TEST_NAME}_${FORMAT} "SDW_TestImageFormat=${FORMAT}" )
endforeach ()
elseif ( IS_SSBO GREATER -1 )
foreach( BO_TYPE ${BO_TYPES} )
SDW_AddTest( ${TEST_FILE} ${TEST_NAME}_${BO_TYPE} "SDW_TestType=${BO_TYPE}" )
endforeach ()
elseif ( IS_UBO GREATER -1 )
foreach( BO_TYPE ${BO_TYPES} )
SDW_AddTest( ${TEST_FILE} ${TEST_NAME}_${BO_TYPE} "SDW_TestType=${BO_TYPE}" )
endforeach ()
elseif ( IS_STRUCT GREATER -1 )
foreach( BO_TYPE ${BO_TYPES} )
SDW_AddTest( ${TEST_FILE} ${TEST_NAME}_${BO_TYPE} "SDW_TestType=${BO_TYPE}" )
endforeach ()
elseif ( IS_PCB GREATER -1 )
foreach( BO_TYPE ${BO_TYPES} )
SDW_AddTest( ${TEST_FILE} ${TEST_NAME}_${BO_TYPE} "SDW_TestType=${BO_TYPE}" )
endforeach ()
else ()
SDW_AddTest( ${TEST_FILE} ${TEST_NAME} "" )
endif ()
endforeach ()

if ( PROJECTS_COVERAGE )
Expand Down
76 changes: 6 additions & 70 deletions test/ShaderWriter/TestWriterArraySsboDeclarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,78 +131,14 @@ namespace
}
}

sdwTestSuiteMain( TestWriterArraySsboDeclarations )
#define testName testConcat( TestWriterArraySsboDeclarations, SDW_TestType )

sdwTestSuiteMain( testName )
{
sdwTestSuiteBegin();
testStructuredSsbo< sdw::Int >( testCounts );
testStructuredSsbo< sdw::UInt >( testCounts );
testStructuredSsbo< sdw::Float >( testCounts );
testStructuredSsbo< sdw::Double >( testCounts );
testStructuredSsbo< sdw::Vec2 >( testCounts );
testStructuredSsbo< sdw::Vec3 >( testCounts );
testStructuredSsbo< sdw::Vec4 >( testCounts );
testStructuredSsbo< sdw::DVec2 >( testCounts );
testStructuredSsbo< sdw::DVec3 >( testCounts );
testStructuredSsbo< sdw::DVec4 >( testCounts );
testStructuredSsbo< sdw::IVec2 >( testCounts );
testStructuredSsbo< sdw::IVec3 >( testCounts );
testStructuredSsbo< sdw::IVec4 >( testCounts );
testStructuredSsbo< sdw::UVec2 >( testCounts );
testStructuredSsbo< sdw::UVec3 >( testCounts );
testStructuredSsbo< sdw::UVec4 >( testCounts );
testStructuredSsbo< sdw::Mat2 >( testCounts );
testStructuredSsbo< sdw::Mat2x3 >( testCounts );
testStructuredSsbo< sdw::Mat2x4 >( testCounts );
testStructuredSsbo< sdw::Mat3 >( testCounts );
testStructuredSsbo< sdw::Mat3x2 >( testCounts );
testStructuredSsbo< sdw::Mat3x4 >( testCounts );
testStructuredSsbo< sdw::Mat4 >( testCounts );
testStructuredSsbo< sdw::Mat4x2 >( testCounts );
testStructuredSsbo< sdw::Mat4x3 >( testCounts );
testStructuredSsbo< sdw::DMat2 >( testCounts );
testStructuredSsbo< sdw::DMat2x3 >( testCounts );
testStructuredSsbo< sdw::DMat2x4 >( testCounts );
testStructuredSsbo< sdw::DMat3 >( testCounts );
testStructuredSsbo< sdw::DMat3x2 >( testCounts );
testStructuredSsbo< sdw::DMat3x4 >( testCounts );
testStructuredSsbo< sdw::DMat4 >( testCounts );
testStructuredSsbo< sdw::DMat4x2 >( testCounts );
testStructuredSsbo< sdw::DMat4x3 >( testCounts );
testArraySsbo< sdw::Int >( testCounts );
testArraySsbo< sdw::UInt >( testCounts );
testArraySsbo< sdw::Float >( testCounts );
testArraySsbo< sdw::Double >( testCounts );
testArraySsbo< sdw::Vec2 >( testCounts );
testArraySsbo< sdw::Vec3 >( testCounts );
testArraySsbo< sdw::Vec4 >( testCounts );
testArraySsbo< sdw::DVec2 >( testCounts );
testArraySsbo< sdw::DVec3 >( testCounts );
testArraySsbo< sdw::DVec4 >( testCounts );
testArraySsbo< sdw::IVec2 >( testCounts );
testArraySsbo< sdw::IVec3 >( testCounts );
testArraySsbo< sdw::IVec4 >( testCounts );
testArraySsbo< sdw::UVec2 >( testCounts );
testArraySsbo< sdw::UVec3 >( testCounts );
testArraySsbo< sdw::UVec4 >( testCounts );
testArraySsbo< sdw::Mat2 >( testCounts );
testArraySsbo< sdw::Mat2x3 >( testCounts );
testArraySsbo< sdw::Mat2x4 >( testCounts );
testArraySsbo< sdw::Mat3 >( testCounts );
testArraySsbo< sdw::Mat3x2 >( testCounts );
testArraySsbo< sdw::Mat3x4 >( testCounts );
testArraySsbo< sdw::Mat4 >( testCounts );
testArraySsbo< sdw::Mat4x2 >( testCounts );
testArraySsbo< sdw::Mat4x3 >( testCounts );
testArraySsbo< sdw::DMat2 >( testCounts );
testArraySsbo< sdw::DMat2x3 >( testCounts );
testArraySsbo< sdw::DMat2x4 >( testCounts );
testArraySsbo< sdw::DMat3 >( testCounts );
testArraySsbo< sdw::DMat3x2 >( testCounts );
testArraySsbo< sdw::DMat3x4 >( testCounts );
testArraySsbo< sdw::DMat4 >( testCounts );
testArraySsbo< sdw::DMat4x2 >( testCounts );
testArraySsbo< sdw::DMat4x3 >( testCounts );
testStructuredSsbo< sdw::SDW_TestType >( testCounts );
testArraySsbo< sdw::SDW_TestType >( testCounts );
sdwTestSuiteEnd();
}

sdwTestSuiteLaunch( TestWriterArraySsboDeclarations )
sdwTestSuiteLaunch( testName )
31 changes: 5 additions & 26 deletions test/ShaderWriter/TestWriterCombinedImageAccesses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2230,38 +2230,17 @@ namespace
template< template< ast::type::ImageFormat, ast::type::ImageDim, bool, bool, bool, typename Enable = void > typename TesterT >
void testsTextures( test::sdw_test::TestCounts & testCounts )
{
testsTexture< ast::type::ImageFormat::eRgba32f, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba16f, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg32f, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg16f, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR32f, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR16f, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba32i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba16i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba8i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg32i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg16i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg8i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR32i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR16i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR8i, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba32u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba16u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRgba8u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg32u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg16u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eRg8u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR32u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR16u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::eR8u, TesterT >( testCounts );
testsTexture< ast::type::ImageFormat::SDW_TestImageFormat, TesterT >( testCounts );
}
/**@}*/
#pragma endregion
}

#endif

sdwTestSuiteMain( TestWriterCombinedImageAccesses )
#define testName testConcat( TestWriterCombinedImageAccesses, SDW_TestImageFormat )

sdwTestSuiteMain( testName )
{
sdwTestSuiteBegin();
#if !defined( __APPLE__ )
Expand Down Expand Up @@ -2296,4 +2275,4 @@ sdwTestSuiteMain( TestWriterCombinedImageAccesses )
sdwTestSuiteEnd();
}

sdwTestSuiteLaunch( TestWriterCombinedImageAccesses )
sdwTestSuiteLaunch( testName )
Loading

0 comments on commit 598ae16

Please sign in to comment.