Author SHA1 Message Date
jfmcarreira c854e76fd8 Add GitHub action to build code using cmake 2021-04-06 22:27:40 +01:00
jfmcarreira 8f290d6351 Remove unused file and update .gitignore 2021-04-06 21:47:06 +01:00
jfmcarreira fc038eb62f Tests: Add general tests for modules
The idea of these tests is to check whether the modules will work
with different kinds of inputs. The modules should be able to initialize
or return an error indication. But in all cases they should be able to handle
default arguments all different inputs
2021-02-17 02:30:13 +00:00
11 changed files with 238 additions and 112 deletions

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
name: Build and Test
on:
push:
branches:
- devel
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: sudo apt-get install cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
- name: Build CMake
uses: ashutoshvarma/action-cmake-build@v1
with:
build-dir: ${{ runner.workspace }}/build
# will set the CC & CXX for cmake
cc: gcc
cxx: g++
build-type: Release
# Extra options pass to cmake while configuring project
configure-options: -DBUILD_TESTS=ON -DUSE_WERROR=ON
run-test: true
#ctest-options: -R mytest
# install the build using cmake --install
install-build: true
# run build using '-j [parallel]' to use multiple threads to build
parallel: 14
+4 -5
View File
@@ -136,11 +136,10 @@ fabric.properties
### vscode ### ### vscode ###
.vscode/* .vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace *.code-workspace
# Documentation # Documentation
doc/ doc/
# CLang
compile_commands.json
+1
View File
@@ -45,6 +45,7 @@ EightBitsSampling::EightBitsSampling()
bool EightBitsSampling::create( std::vector<CalypFrame*> apcFrameList ) bool EightBitsSampling::create( std::vector<CalypFrame*> apcFrameList )
{ {
_BASIC_MODULE_API_2_CHECK_
m_iBitSifting = int( apcFrameList[0]->getBitsPel() ) - m_iNumberOfBits; m_iBitSifting = int( apcFrameList[0]->getBitsPel() ) - m_iNumberOfBits;
if( !m_iBitSifting ) if( !m_iBitSifting )
return false; return false;
+3
View File
@@ -71,6 +71,7 @@ FilterComponentLuma::FilterComponentLuma()
bool FilterComponentLuma::create( std::vector<CalypFrame*> apcFrameList ) bool FilterComponentLuma::create( std::vector<CalypFrame*> apcFrameList )
{ {
_BASIC_MODULE_API_2_CHECK_
return createFilter( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getBitsPel() ); return createFilter( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getBitsPel() );
} }
@@ -88,6 +89,7 @@ FilterComponentChromaU::FilterComponentChromaU()
bool FilterComponentChromaU::create( std::vector<CalypFrame*> apcFrameList ) bool FilterComponentChromaU::create( std::vector<CalypFrame*> apcFrameList )
{ {
_BASIC_MODULE_API_2_CHECK_
if( apcFrameList[0]->getNumberChannels() > 1 ) if( apcFrameList[0]->getNumberChannels() > 1 )
{ {
return createFilter( apcFrameList[0]->getWidth( CLP_CHROMA_U ), apcFrameList[0]->getHeight( CLP_CHROMA_U ), return createFilter( apcFrameList[0]->getWidth( CLP_CHROMA_U ), apcFrameList[0]->getHeight( CLP_CHROMA_U ),
@@ -111,6 +113,7 @@ FilterComponentChromaV::FilterComponentChromaV()
bool FilterComponentChromaV::create( std::vector<CalypFrame*> apcFrameList ) bool FilterComponentChromaV::create( std::vector<CalypFrame*> apcFrameList )
{ {
_BASIC_MODULE_API_2_CHECK_
if( apcFrameList[0]->getNumberChannels() > 1 ) if( apcFrameList[0]->getNumberChannels() > 1 )
{ {
return createFilter( apcFrameList[0]->getWidth( CLP_CHROMA_V ), apcFrameList[0]->getHeight( CLP_CHROMA_V ), return createFilter( apcFrameList[0]->getWidth( CLP_CHROMA_V ), apcFrameList[0]->getHeight( CLP_CHROMA_V ),
+1
View File
@@ -57,6 +57,7 @@ FrameResampling::FrameResampling()
bool FrameResampling::create( std::vector<CalypFrame*> apcFrameList ) bool FrameResampling::create( std::vector<CalypFrame*> apcFrameList )
{ {
_BASIC_MODULE_API_2_CHECK_
switch( m_iInterpolation ) switch( m_iInterpolation )
{ {
case 2: case 2:
+1
View File
@@ -62,6 +62,7 @@ HEVCIntraPrediction::HEVCIntraPrediction()
bool HEVCIntraPrediction::create( std::vector<CalypFrame*> apcFrameList ) bool HEVCIntraPrediction::create( std::vector<CalypFrame*> apcFrameList )
{ {
_BASIC_MODULE_API_2_CHECK_
m_pcPredBlock = NULL; m_pcPredBlock = NULL;
m_pcPredBlock = new CalypFrame( m_iBlockSize * 2 + 1, m_iBlockSize * 2 + 1, CLP_GRAY, apcFrameList[0]->getBitsPel() ); m_pcPredBlock = new CalypFrame( m_iBlockSize * 2 + 1, m_iBlockSize * 2 + 1, CLP_GRAY, apcFrameList[0]->getBitsPel() );
+9 -2
View File
@@ -43,7 +43,9 @@ ThreeSixtyFaceConcatenation::ThreeSixtyFaceConcatenation()
m_pchModuleName = "ThreeSixtyFaceConcatenation"; m_pchModuleName = "ThreeSixtyFaceConcatenation";
m_pchModuleTooltip = "Concatenate 360 video faces"; m_pchModuleTooltip = "Concatenate 360 video faces";
m_uiNumberOfFrames = 1; m_uiNumberOfFrames = 1;
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULES_VARIABLE_NUM_FRAMES; m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY |
CLP_MODULE_REQUIRES_OPTIONS |
CLP_MODULES_VARIABLE_NUM_FRAMES;
m_cModuleOptions.addOptions() /**/ m_cModuleOptions.addOptions() /**/
( "projection", m_uiProjectionType, "Projection [1] \n 1: Cubemap (6 faces)" ) /**/ ( "projection", m_uiProjectionType, "Projection [1] \n 1: Cubemap (6 faces)" ) /**/
@@ -60,6 +62,8 @@ ThreeSixtyFaceConcatenation::ThreeSixtyFaceConcatenation()
bool ThreeSixtyFaceConcatenation::create( std::vector<CalypFrame*> apcFrameList ) bool ThreeSixtyFaceConcatenation::create( std::vector<CalypFrame*> apcFrameList )
{ {
if( apcFrameList.size() < 1 )
return false;
for( unsigned int i = 0; i < apcFrameList.size(); i++ ) for( unsigned int i = 0; i < apcFrameList.size(); i++ )
if( !apcFrameList[i] ) if( !apcFrameList[i] )
return false; return false;
@@ -77,9 +81,12 @@ bool ThreeSixtyFaceConcatenation::create( std::vector<CalypFrame*> apcFrameList
m_uiFacesY = 2 * m_uiNumberOfPartitionsPerFace; m_uiFacesY = 2 * m_uiNumberOfPartitionsPerFace;
break; break;
default: default:
assert( 0 ); return false;
} }
if( apcFrameList.size() != m_uiFacesX * m_uiFacesY )
return false;
unsigned int width = apcFrameList[0]->getWidth() * m_uiFacesX; unsigned int width = apcFrameList[0]->getWidth() * m_uiFacesX;
unsigned int height = apcFrameList[0]->getHeight() * m_uiFacesY; unsigned int height = apcFrameList[0]->getHeight() * m_uiFacesY;
+6
View File
@@ -11,4 +11,10 @@ FOREACH(module ${MODULES_LIST_NAME})
TARGET_COMPILE_DEFINITIONS(TestModuleCreate_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\") TARGET_COMPILE_DEFINITIONS(TestModuleCreate_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\")
TARGET_LINK_LIBRARIES(TestModuleCreate_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main) TARGET_LINK_LIBRARIES(TestModuleCreate_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main)
ADD_TEST(TestModuleCreate_${module} TestModuleCreate_${module}) ADD_TEST(TestModuleCreate_${module} TestModuleCreate_${module})
ADD_EXECUTABLE(TestModuleProcessNumberOfFrames_${module} TestModuleProcessNumberOfFrames.cpp)
TARGET_COMPILE_DEFINITIONS(TestModuleProcessNumberOfFrames_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\")
TARGET_LINK_LIBRARIES(TestModuleProcessNumberOfFrames_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main)
ADD_TEST(TestModuleProcessNumberOfFrames_${module} TestModuleProcessNumberOfFrames_${module})
ENDFOREACH(module ${MODULES_LIST_NAME}) ENDFOREACH(module ${MODULES_LIST_NAME})
+72 -95
View File
@@ -19,13 +19,14 @@
/** /**
* \file TestModuleCreate.cpp * \file TestModuleCreate.cpp
* \brief CalypModuleIf testing for YUV420p sequences * \brief CalypModuleIf testing create
*/ */
#include "CalypFrame.h"
#include "CalypModulesFactory.h"
#include "CalypStream.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "lib/CalypFrame.h"
#include "lib/CalypModuleIf.h"
#include "lib/CalypStream.h"
#include "modules/CalypModulesFactory.h"
class TestModuleCreate : public ::testing::Test class TestModuleCreate : public ::testing::Test
{ {
@@ -35,6 +36,8 @@ protected:
// Can be omitted if not needed. // Can be omitted if not needed.
static void SetUpTestCase() static void SetUpTestCase()
{ {
ClpString moduleName = CALYP_TEST_MODULE_NAME;
pcStream = new CalypStream; pcStream = new CalypStream;
pcStream->open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8, pcStream->open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
CLP_BIG_ENDIAN, 1, true ); CLP_BIG_ENDIAN, 1, true );
@@ -50,66 +53,65 @@ protected:
pcStream = NULL; pcStream = NULL;
} }
// Some expensive resource shared by all tests. // Called before each test
static CalypStream* pcStream; void SetUp()
static CalypFrame* pcFrame;
static CalypModuleIf* pcModule;
static ClpString sModuleName;
};
CalypStream* TestModuleCreate::pcStream = NULL;
CalypFrame* TestModuleCreate::pcFrame = NULL;
ClpString TestModuleCreate::sModuleName = CALYP_TEST_MODULE_NAME;
TEST_F( TestModuleCreate, FIND_MODULE )
{
CalypModuleIf* module;
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ )
{ {
if( strcmp( it->first, sModuleName.c_str() ) == 0 ) ClpString moduleName = CALYP_TEST_MODULE_NAME;
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ )
{ {
module = it->second(); if( strcmp( it->first, moduleName.c_str() ) == 0 )
break; {
pcModule = it->second();
break;
}
} }
} }
EXPECT_NE( module, nullptr ); void TearDown()
module->Delete(); {
pcModule->Delete();
}
CalypModuleIf* pcModule;
// Some expensive resource shared by all tests.
static CalypStream* pcStream;
};
CalypStream* TestModuleCreate::pcStream = NULL;
TEST_F( TestModuleCreate, FIND_MODULE )
{
EXPECT_NE( pcModule, nullptr );
} }
TEST_F( TestModuleCreate, CREATE_OK ) TEST_F( TestModuleCreate, CREATE_OK )
{ {
CalypModuleIf* module; bool moduleRequireOptions = false;
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap(); if( pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_OPTIONS )
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ )
{ {
if( strcmp( it->first, sModuleName.c_str() ) == 0 ) moduleRequireOptions = true;
{
module = it->second();
break;
}
} }
EXPECT_NE( module, nullptr );
bool moduleCreated = false; bool moduleCreated = false;
std::vector<CalypFrame*> apcFrameList; std::vector<CalypFrame*> apcFrameList;
apcFrameList.clear(); apcFrameList.clear();
for( unsigned int i = 0; i < module->m_uiNumberOfFrames; i++ ) for( unsigned int i = 0; i < pcModule->m_uiNumberOfFrames; i++ )
{ {
apcFrameList.push_back( pcStream->getCurrFrame() ); apcFrameList.push_back( pcStream->getCurrFrame() );
pcStream->setNextFrame(); pcStream->setNextFrame();
pcStream->readNextFrame(); pcStream->readNextFrame();
} }
if( module->m_iModuleAPI >= CLP_MODULE_API_2 ) if( pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
{ {
moduleCreated = module->create( apcFrameList ); moduleCreated = pcModule->create( apcFrameList ) | moduleRequireOptions;
} }
else if( module->m_iModuleAPI == CLP_MODULE_API_1 ) else if( pcModule->m_iModuleAPI == CLP_MODULE_API_1 )
{ {
module->create( pcStream->getCurrFrame() ); pcModule->create( pcStream->getCurrFrame() );
moduleCreated = true; moduleCreated = true;
} }
EXPECT_EQ( moduleCreated, true ); EXPECT_EQ( moduleCreated, true );
@@ -117,72 +119,47 @@ TEST_F( TestModuleCreate, CREATE_OK )
TEST_F( TestModuleCreate, CREATE_FAIL_LESS_ONE ) TEST_F( TestModuleCreate, CREATE_FAIL_LESS_ONE )
{ {
CalypModuleIf* module; if( pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ )
{ {
if( strcmp( it->first, sModuleName.c_str() ) == 0 ) std::vector<CalypFrame*> apcFrameList;
apcFrameList.clear();
for( unsigned int i = 0; i < pcModule->m_uiNumberOfFrames - 1; i++ )
{ {
module = it->second(); apcFrameList.push_back( pcStream->getCurrFrame() );
break; pcStream->setNextFrame();
pcStream->readNextFrame();
} }
bool moduleCreated = pcModule->create( apcFrameList );
EXPECT_NE( moduleCreated, true );
} }
EXPECT_NE( module, nullptr );
bool moduleCreated = false;
std::vector<CalypFrame*> apcFrameList;
apcFrameList.clear();
for( unsigned int i = 0; i < module->m_uiNumberOfFrames - 1; i++ )
{
apcFrameList.push_back( pcStream->getCurrFrame() );
pcStream->setNextFrame();
pcStream->readNextFrame();
}
if( module->m_iModuleAPI >= CLP_MODULE_API_2 )
{
moduleCreated = module->create( apcFrameList );
}
else if( module->m_iModuleAPI == CLP_MODULE_API_1 )
{
module->create( pcStream->getCurrFrame() );
moduleCreated = true;
}
EXPECT_NE( moduleCreated, true );
} }
TEST_F( TestModuleCreate, CREATE_FAIL_PLUS_ONE ) TEST_F( TestModuleCreate, CREATE_FAIL_PLUS_ONE )
{ {
CalypModuleIf* module; if( pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ )
{ {
if( strcmp( it->first, sModuleName.c_str() ) == 0 ) std::vector<CalypFrame*> apcFrameList;
apcFrameList.clear();
for( unsigned int i = 0; i < pcModule->m_uiNumberOfFrames + 1; i++ )
{ {
module = it->second(); apcFrameList.push_back( NULL );
break;
} }
bool moduleCreated = pcModule->create( apcFrameList );
EXPECT_NE( moduleCreated, true );
} }
EXPECT_NE( module, nullptr ); }
bool moduleCreated = false; TEST_F( TestModuleCreate, CREATE_FAIL_NULL_FRAME )
std::vector<CalypFrame*> apcFrameList; {
apcFrameList.clear(); if( pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
for( unsigned int i = 0; i < module->m_uiNumberOfFrames + 1; i++ )
{ {
apcFrameList.push_back( pcStream->getCurrFrame() ); std::vector<CalypFrame*> apcFrameList;
pcStream->setNextFrame(); apcFrameList.clear();
pcStream->readNextFrame(); for( unsigned int i = 0; i < pcModule->m_uiNumberOfFrames - 1; i++ )
{
apcFrameList.push_back( NULL );
}
bool moduleCreated = pcModule->create( apcFrameList );
EXPECT_NE( moduleCreated, true );
} }
if( module->m_iModuleAPI >= CLP_MODULE_API_2 ) }
{
moduleCreated = module->create( apcFrameList );
}
else if( module->m_iModuleAPI == CLP_MODULE_API_1 )
{
module->create( pcStream->getCurrFrame() );
moduleCreated = true;
}
EXPECT_NE( moduleCreated, true );
}
@@ -0,0 +1,110 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file TestModuleCreate.cpp
* \brief CalypModuleIf testing for YUV420p sequences
*/
#include "gtest/gtest.h"
#include "lib/CalypFrame.h"
#include "lib/CalypModuleIf.h"
#include "lib/CalypStream.h"
#include "modules/CalypModulesFactory.h"
class TestModuleProcessNumberOfFrames : public ::testing::Test
{
protected:
// Per-test-case set-up.
// Called before the first test in this test case.
// Can be omitted if not needed.
static void SetUpTestCase()
{
ClpString moduleName = CALYP_TEST_MODULE_NAME;
pcStream = new CalypStream;
pcStream->open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
CLP_BIG_ENDIAN, 1, true );
}
// Per-test-case tear-down.
// Called after the last test in this test case.
// Can be omitted if not needed.
static void TearDownTestCase()
{
pcStream->close();
delete pcStream;
pcStream = NULL;
}
// Called before each test
void SetUp()
{
ClpString moduleName = CALYP_TEST_MODULE_NAME;
pcStream = new CalypStream;
pcStream->open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
CLP_BIG_ENDIAN, 1, true );
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ )
{
if( strcmp( it->first, moduleName.c_str() ) == 0 )
{
pcModule = it->second();
break;
}
}
}
void TearDown()
{
pcModule->Delete();
}
CalypModuleIf* pcModule;
// Some expensive resource shared by all tests.
static CalypStream* pcStream;
};
CalypStream* TestModuleProcessNumberOfFrames::pcStream = NULL;
TEST_F( TestModuleProcessNumberOfFrames, PROCESS_OK )
{
if( pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
{
std::vector<CalypFrame*> apcFrameList;
apcFrameList.clear();
for( unsigned int i = 0; i < pcModule->m_uiNumberOfFrames; i++ )
{
apcFrameList.push_back( pcStream->getCurrFrame() );
pcStream->setNextFrame();
pcStream->readNextFrame();
}
// Let's not test the modules that are not able to be created
if( pcModule->create( apcFrameList ) )
{
CalypFrame* frame = pcModule->process( apcFrameList );
EXPECT_NE( frame, nullptr );
}
}
}
-10
View File
@@ -1,10 +0,0 @@
#!/usr/bin/env bash
git checkout upstream
git pull https://github.com/pixlra/calyp.git master
git push origin upstream
git checkout master
git pull origin master
git merge upstream
git push origin master