From 95f18aa83589353bda65bbcdc7edb8b5ffe9d2cc Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 15 Jan 2021 18:21:39 +0000 Subject: [PATCH] Ensuring test files match dali-core/adaptor Change-Id: I8810c5d6f07a22cdecc7235916287f6be0ddf406 --- .../dali-toolkit-test-utils/test-application.cpp | 19 +- .../dali-toolkit-test-utils/test-application.h | 54 +++--- .../test-graphics-controller.h | 61 ++++++ automated-tests/tcbuild | 216 ++++++++++++++++++++- 4 files changed, 314 insertions(+), 36 deletions(-) create mode 100644 automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h mode change 120000 => 100755 automated-tests/tcbuild diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp index 062276a..a2a1848 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,9 +55,7 @@ void TestApplication::CreateCore() mCore = Dali::Integration::Core::New(mRenderController, mPlatformAbstraction, - mGlAbstraction, - mGlSyncAbstraction, - mGlContextHelperAbstraction, + mGraphicsController, Integration::RenderToFrameBuffer::FALSE, Integration::DepthBufferAvailable::TRUE, Integration::StencilBufferAvailable::TRUE, @@ -141,19 +139,24 @@ TestRenderController& TestApplication::GetRenderController() return mRenderController; } +TestGraphicsController& TestApplication::GetGraphicsController() +{ + return mGraphicsController; +} + TestGlAbstraction& TestApplication::GetGlAbstraction() { - return mGlAbstraction; + return static_cast(mGraphicsController.GetGlAbstraction()); } TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction() { - return mGlSyncAbstraction; + return static_cast(mGraphicsController.GetGlSyncAbstraction()); } TestGlContextHelperAbstraction& TestApplication::GetGlContextHelperAbstraction() { - return mGlContextHelperAbstraction; + return static_cast(mGraphicsController.GetGlContextHelperAbstraction()); } void TestApplication::ProcessEvent(const Integration::Event& event) @@ -262,7 +265,7 @@ bool TestApplication::RenderOnly() void TestApplication::ResetContext() { mCore->ContextDestroyed(); - mGlAbstraction.Initialize(); + mGraphicsController.Initialize(); mCore->ContextCreated(); } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h index 7362505..e7d8c76 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h @@ -2,7 +2,7 @@ #define DALI_TEST_APPLICATION_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,11 @@ #include #include #include + #include #include -#include "test-gl-abstraction.h" -#include "test-gl-context-helper-abstraction.h" -#include "test-gl-sync-abstraction.h" +#include "test-graphics-controller.h" #include "test-render-controller.h" namespace Dali @@ -58,27 +57,30 @@ public: void CreateScene(); void InitializeCore(); ~TestApplication() override; - static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message); - static void LogContext(bool start, const char* tag); - Dali::Integration::Core& GetCore(); - TestPlatformAbstraction& GetPlatform(); - TestRenderController& GetRenderController(); + static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message); + static void LogContext(bool start, const char* tag); + Dali::Integration::Core& GetCore(); + TestPlatformAbstraction& GetPlatform(); + TestRenderController& GetRenderController(); + TestGraphicsController& GetGraphicsController(); + TestGlAbstraction& GetGlAbstraction(); TestGlSyncAbstraction& GetGlSyncAbstraction(); TestGlContextHelperAbstraction& GetGlContextHelperAbstraction(); - void ProcessEvent(const Integration::Event& event); - void SendNotification(); - bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL); - bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector>& damagedRects); - bool RenderWithPartialUpdate(std::vector>& damagedRects, Rect& clippingRect); - uint32_t GetUpdateStatus(); - bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL); - bool RenderOnly(); - void ResetContext(); - bool GetRenderNeedsUpdate(); - bool GetRenderNeedsPostRender(); - uint32_t Wait(uint32_t durationToWait); - static void EnableLogging(bool enabled) + + void ProcessEvent(const Integration::Event& event); + void SendNotification(); + bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL); + bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector>& damagedRects); + bool RenderWithPartialUpdate(std::vector>& damagedRects, Rect& clippingRect); + uint32_t GetUpdateStatus(); + bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL); + bool RenderOnly(); + void ResetContext(); + bool GetRenderNeedsUpdate(); + bool GetRenderNeedsPostRender(); + uint32_t Wait(uint32_t durationToWait); + static void EnableLogging(bool enabled) { mLoggingEnabled = enabled; } @@ -92,11 +94,9 @@ private: void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL); protected: - TestPlatformAbstraction mPlatformAbstraction; - TestRenderController mRenderController; - TestGlAbstraction mGlAbstraction; - TestGlSyncAbstraction mGlSyncAbstraction; - TestGlContextHelperAbstraction mGlContextHelperAbstraction; + TestPlatformAbstraction mPlatformAbstraction; + TestRenderController mRenderController; + TestGraphicsController mGraphicsController; Integration::UpdateStatus mStatus; Integration::RenderStatus mRenderStatus; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h new file mode 100644 index 0000000..f5ab764 --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h @@ -0,0 +1,61 @@ +#ifndef TEST_GRAPHICS_CONTROLLER_H +#define TEST_GRAPHICS_CONTROLLER_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "test-gl-abstraction.h" +#include "test-gl-context-helper-abstraction.h" +#include "test-gl-sync-abstraction.h" + +namespace Dali +{ +class TestGraphicsController : public Dali::Graphics::Controller +{ +public: + TestGraphicsController() = default; + virtual ~TestGraphicsController() = default; + + void Initialize() + { + mGlAbstraction.Initialize(); + } + + Integration::GlAbstraction& GetGlAbstraction() override + { + return mGlAbstraction; + } + + Integration::GlSyncAbstraction& GetGlSyncAbstraction() override + { + return mGlSyncAbstraction; + } + + Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override + { + return mGlContextHelperAbstraction; + } + +private: + TestGlAbstraction mGlAbstraction; + TestGlSyncAbstraction mGlSyncAbstraction; + TestGlContextHelperAbstraction mGlContextHelperAbstraction; +}; + +} // namespace Dali + +#endif //TEST_GRAPHICS_CONTROLLER_H diff --git a/automated-tests/tcbuild b/automated-tests/tcbuild deleted file mode 120000 index 89c2de7..0000000 --- a/automated-tests/tcbuild +++ /dev/null @@ -1 +0,0 @@ -scripts/tcbuild.sh \ No newline at end of file diff --git a/automated-tests/tcbuild b/automated-tests/tcbuild new file mode 100755 index 0000000..b604675 --- /dev/null +++ b/automated-tests/tcbuild @@ -0,0 +1,215 @@ +#!/bin/bash + +#---------- DEBUG_BEGIN ---------- +#ARG="-d" # debug-on flag, might be set as $1 +# keyprompt "introductory message" -- wait until any key pressed +function keyprompt { echo -ne "\n\e[1;31m$1 -- " && read -n 1 && echo -e "\n\e[0m"; } +# d_bp -- breakpoint at which user need to press any key to proceed +function d_bp { if [[ "$ARG" == "-d" ]]; then keyprompt "d >> Press any key"; fi } +# d_showVar VARNAME -- print bash variable name +function d_showVar { if [ "$ARG" == "-d" -a -n "$1" ]; then echo "d >> ${1} = ${!1}"; fi } +# d_print "message" -- print a debug message +function d_print { if [ "$ARG" == "-d" -a -n "$1" ]; then echo -e "d >> $1"; fi } +#---------- DEBUG_END ---------- + +PROJECT_DIR="$(cd "$(dirname $0)" && pwd)" +d_showVar PROJECT_DIR + +function gbs_profile { +perl -e " +use Config::Tiny; +my \$Config = Config::Tiny->read( \"\$ENV{HOME}/.gbs.conf\" ); +my \$profile = \$Config->{general}->{profile}; +\$profile =~ s/profile.//; +print \$profile;" +} + +PROFILE=`gbs_profile` +RPM_DIR="$HOME/GBS-ROOT/local/repos/$PROFILE/armv7l/RPMS" +d_showVar RPM_DIR + +function add_module { + # argument check + if [ -z "$1" ]; then echo "Usage: `basename $0` addmod [module_lib_name]"; exit 1; fi + + MODULE_NAME=$1 + d_showVar MODULE_NAME + MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/') + d_showVar MODULE_NAME_C + MODULE_NAME_U=$(echo $MODULE_NAME | sed -e 's/-/_/') + d_showVar MODULE_NAME_U +# MODULE_LIBNAME=${2:-capi-$MODULE_NAME} + MODULE_LIBNAME=$1 + d_showVar MODULE_LIBNAME + + echo "Adding $MODULE_NAME module to project..." + d_bp + cd $PROJECT_DIR + # prepare .spec file + echo "-- Generating packaging/core-$MODULE_NAME-tests.spec file" + if [ ! -d packaging ]; then mkdir packaging; fi + sed -e "s:\[MODULE_NAME\]:$MODULE_NAME:g" -e "s:\[MODULE_LIBNAME\]:$MODULE_LIBNAME:g" \ + templates/core-\[module_name\]-tests.spec > packaging/core-$MODULE_NAME-tests.spec + # prepare src directory + mkdir src/$MODULE_NAME + echo "-- Generating src/$MODULE_NAME/CMakeLists.txt file" + sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" -e "s:%{MODULE_LIBNAME}:$MODULE_LIBNAME:g" \ + templates/src-directory/CMakeLists.txt > src/$MODULE_NAME/CMakeLists.txt + echo "-- Generating src/$MODULE_NAME/tct-$MODULE_NAME-core.c file" + sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" \ + templates/src-directory/tct-\[module_name\]-core.c > src/$MODULE_NAME/tct-$MODULE_NAME-core.c + echo "-- Generating src/$MODULE_NAME/utc-$MODULE_NAME.c file" + sed -e "s:%{MODULE_NAME_U}:$MODULE_NAME_U:g" -e "s:%{MODULE_NAME_C}:$MODULE_NAME_C:g" \ + templates/src-directory/utc-\[module_name\].c > src/$MODULE_NAME/utc-$MODULE_NAME.c + echo "Task finished successfully" +} + +function rm_module { + # argument check + if [ -z "$1" ]; then echo "Usage: `basename $0` rmmod "; exit 1; fi + + MODULE_NAME=$1 + d_showVar MODULE_NAME + + echo "Removing $MODULE_NAME module from project..." + d_bp + echo "---- Updating /opt/tct/packages/package_list.xml" + scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/packages/package_list.xml 1 + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # echo "---- Updating test plans" + # scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/manager/plan/*.xml 1 + # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + + cd $PROJECT_DIR + echo "-- Removing packaging/core-$MODULE_NAME-tests.spec file" + rm packaging/core-$MODULE_NAME-tests.spec + echo "-- Removing src/$MODULE_NAME directory" + rm -r src/$MODULE_NAME + echo "Task finished successfully" +} + +function build { + if [ -n "$1" ]; then + (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h) + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + cp packaging/core-$1-tests.spec ../packaging + cp .gitignore-without-autogenerated-files .gitignore + gbs build -A armv7l --spec core-$1-tests.spec --include-all --keep-packs | \ + tee build.log | stdbuf -o0 sed -e 's/error:/\x1b[1;91m&\x1b[0m/' \ + -e 's/warning:/\x1b[93m&\x1b[0m/' + rm ../packaging/core-$1-tests.spec + cp .gitignore-with-autogenerated-files .gitignore + else + echo "Build requires a module name" + exit 1 + fi +} + +function inst { + if [ -z "$1" ] + then + for mod in `ls -1 src/ | grep -v CMakeLists` + do + + if [ $mod != 'common' ] && [ $mod != 'manual' ]; then + + PKG_NAME="core-$mod-tests" + d_showVar PKG_NAME + VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }') + d_showVar VER + PKG_VNAME="$PKG_NAME-$VER" + d_showVar PKG_VNAME + PKG_FNAME="$PKG_VNAME-0.armv7l.rpm" + d_showVar PKG_FNAME + + if [ -f "$RPM_DIR/$PKG_FNAME" ] + then + inst $mod + echo "" + fi + fi + done + else + cd $PROJECT_DIR + # setting variables + MOD_NAME="$1" + d_showVar MOD_NAME + PKG_NAME="core-$MOD_NAME-tests" + d_showVar PKG_NAME + VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }') + d_showVar VER + PKG_VNAME="$PKG_NAME-$VER" + d_showVar PKG_VNAME + PKG_FNAME="$PKG_VNAME-0.armv7l.rpm" + d_showVar PKG_FNAME + TCT_DIR="opt/tct-$MOD_NAME-core-tests" + d_showVar TCT_DIR + + echo "Deploying $MOD_NAME suite to tct-mgr..." + d_bp + # prepare tct directory and files + echo "-- Preparing suite .zip file..." + echo "---- Creating /tmp/$TCT_DIR directory" + rm -r /tmp/opt > /dev/null 2>&1 + mkdir -p /tmp/$TCT_DIR + # README + echo "---- Copying /tmp/$TCT_DIR" + cp templates/tct-package/README /tmp/$TCT_DIR + # rpm + echo "---- Copying /tmp/$TCT_DIR package" + cp $RPM_DIR/$PKG_FNAME /tmp/$TCT_DIR + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # inst.sh + echo "---- Generating /tmp/$TCT_DIR/inst.sh file" + sed -e "s:%{PKG_NAME}:\"$PKG_NAME\":g" -e "s:%{PKG_FULLNAME}:\"$PKG_FNAME\":g" \ + -e "s:%{PKG_DIR}:\"/opt/usr/media/tct/$TCT_DIR\":g" \ + templates/tct-package/inst.sh > /tmp/$TCT_DIR/inst.sh + chmod a+x /tmp/$TCT_DIR/inst.sh + # tests.xml + echo "---- Generating /tmp/$TCT_DIR" + scripts/tctestsgen.sh $MOD_NAME /tmp/$TCT_DIR target + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # zip + echo "---- Preparing /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip file" + # clear old zips + rm -r /tmp/tct/packages > /dev/null 2>&1 + mkdir -p /tmp/tct/packages + # create new zip + ( cd /tmp; zip -r /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip opt > /dev/null 2>&1; ) + # deployment + echo "-- Suite deployment..." + echo "---- Copying /opt/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip" + cp /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip /opt/tct/packages/ + echo "---- Updating /opt/tct/packages/package_list.xml" + scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/packages/package_list.xml 0 + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # echo "---- Updating test plans" + # for file in `grep -r tct-$MOD_NAME-core-tests /opt/tct/manager/plan/ | cut -d: -f1 | uniq` + # do + # scripts/tcpackageslistsgen.sh $MOD_NAME $file + # done + # scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/manager/plan/Full_test.xml + # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + echo "Task finished successfully" + fi +} + +if [ -z "$1" ]; then + # usage note + echo "Usage: `basename $0` [module_lib_name]" + exit 1 +elif [ "addmod" == "$1" ]; then + # add new module + add_module $2 $3 +elif [ "rmmod" == "$1" ]; then + # remove module + rm_module $2 +elif [ "build" == "$1" ]; then + # build the binary + build $2 +elif [ "install" == "$1" ]; then + # install + inst $2 +else + echo "Invalid subcommand: $1" +fi -- 2.7.4