From 840ad4ff1b98590bb1f0664a31408e50a01ba4b9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Tomaszewski Date: Tue, 4 Jul 2023 12:35:16 +0200 Subject: [PATCH] Enable functional tests (#6) * Enable to compile gna plugin (only) * add readme with BKM how to compile plugin * enable unit tests except deprecated subset * Fix compilation errors caused by update to OV master (it contains changes incompatible with release/2023/0) * remove dependency with redundant functionality * enable target ov_legacy_transformations_tests * enable to run ov_legacy_transformations_tests target using ctest * Apply build type information given by user correcly * enable to use specific gna library version * enabling functional tests * add gna lib location to path * update readme with functional tests enablement --- README.md | 99 +++++++++++++++++++++++---------- tests/CMakeLists.txt | 2 +- tests/functional/CMakeLists.txt | 33 +++++------ 3 files changed, 85 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 624367e9bc092c..7a4c4e5d3d9de2 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,131 @@ ## Plugin Compilation -#### Assumptions -- OpenVINO version used 2023.0 (**branch releases/2023/0**) +Assumptions +----------- +- OpenVINO version used is commit hash stored in `openvino_version.txt` +- The `openvino_version.txt` file located in plugin's source directory - Commands syntax is bash-based - There are following (environmental) variables defined: ````bash -export openvino_source_dir = -export developer_package_dir = -export build_type = -export gna_plugin_source_dir = -export gna_plugin_build_dir = +export OPENVINO_SOURCE_DIR = +export DEVELOPER_PACKAGE_DIR = +export BUILD_TYPE = +export GNA_PLUGIN_SOURCE_DIR = +export GNA_PLUGIN_BUILD_DIR = ```` -#### Prerequisties + +Prerequisties +------------- + +##### Prepare OpenVino Developer Package Switch to respective version of openvino ````bash -cd $openvino_source_dir -git checkout releases/2023/0 +cd $OPENVINO_SOURCE_DIR +git checkout ```` -Prepare openvino developer package (build openvino) +build it ````bash -cmake -S $openvino_source_dir -B $developer_package_dir -D CMAKE_BUILD_TYPE=$build_type -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON -cmake --build $developer_package_dir --target ov_dev_targets --config $build_type +cmake -S $OPENVINO_SOURCE_DIR -B $DEVELOPER_PACKAGE_DIR -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON +cmake --build $DEVELOPER_PACKAGE_DIR --target ov_dev_targets --config $BUILD_TYPE ```` > **Note** > - It's important to keep in mind that `CMAKE_BUILD_TYPE` has no effect for multi-configuration generators such as Visual Studio. Therefore in this case config type has to be provided to build command as above. > - There is yet another target `ie_dev_targets` can be used, but it seems to have identical result as `ov_dev_targets` +##### Get GNA local version of plugin source + Clone **gna.plugin** repository ````bash -git clone https://github.com/intel-innersource/frameworks.ai.gna.plugin.git $gna_plugin_source_dir +git clone https://github.com/intel-innersource/frameworks.ai.gna.plugin.git $GNA_PLUGIN_SOURCE_DIR +```` + + +##### Prepare configuration for functional tests +There is an additional step needed in order to run functional tests. You have create `plugins.xml` files (one for *Debug* and one for *Release*) with following content: +````xml + + + + + + ```` +and copy them respectively to `$OPENVINO_SOURCE_DIR/bin/intel64/$BUILD_TYPE/` + +> **Note** +> Remember that Windows build uses different names of gna plugin library depending onf build type: +> - `openvino_intel_gna_plugin.dll` for `Release` build type +> - `openvino_intel_gna_plugind.dll` for `Debug` build type + + -#### Plugin build +Plugin build +------------ Create **gna.plugin** solution ````bash -cmake -S $gna_plugin_source_dir -B $gna_plugin_build_dir -D OpenVINODeveloperPackage_DIR=$developer_package_dir -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON +cmake -S $GNA_PLUGIN_SOURCE_DIR -B $GNA_PLUGIN_BUILD_DIR -D OpenVINODeveloperPackage_DIR=$DEVELOPER_PACKAGE_DIR -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON ```` It happens often that for development purposes many versions of gna library exist in openvino `temp\` directory. Therefore it is possible to use specific version of the library by defining `GNA_LIB_VERSION` otherwise default version defined in main `CMakeLists.txt` will be applied ````bash -export gna_version= -cmake -S $gna_plugin_source_dir -B $gna_plugin_build_dir -D OpenVINODeveloperPackage_DIR=$developer_package_dir -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON -D GNA_LIB_VERSION=$gna_version +export GNA_VERSION= +cmake -S $GNA_PLUGIN_SOURCE_DIR -B $GNA_PLUGIN_BUILD_DIR -D OpenVINODeveloperPackage_DIR=$DEVELOPER_PACKAGE_DIR -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON -D GNA_LIB_VERSION=$GNA_VERSION ```` - Run build ````bash -cmake --build $gna_plugin_build_dir --config $build_type +cmake --build $GNA_PLUGIN_BUILD_DIR --config $BUILD_TYPE ```` > **Note** > Developer package has bo be built for respective configuration type otherwise gna plugin build will fail. -#### Plugin's tests build and run + + +Build and run plugin's tests +---------------------------- By default all tests are compiled during plugin build, however there is a possibility to selectively compile selected tests by using `--target` option. For example to compile unit tests use `ov_gna_unit_tests` target run ````bash -cmake --build $gna_plugin_build_dir --config $build_type --target ov_gna_unit_tests +cmake --build $GNA_PLUGIN_BUILD_DIR --config $BUILD_TYPE --target ov_gna_unit_tests ```` -In order to run tests do +and simply run ````bash -cd $gna_plugin_build_dir -ctest -C $build_type +cd $GNA_PLUGIN_BUILD_DIR +ctest -C $BUILD_TYPE ```` -> **Note** -> Currently only `ov_gna_unit_tests` are supported +In order to get detailed output use `-V` parameter of `ctest` +````bash +ctest -C $BUILD_TYPE -V +```` + + -#### Handy tips +Handy tips +---------- Sometimes it is handy to run cmake project generation in trace mode in order to figure out what happened. In order to do this add cmake's `--trace-source=` option. Besides option `--trace-expand` will expand variable into their values. For example command below will print out trace messsages from `libGNAConfig.cmake` file ````bash -cmake -S $gna_plugin_source_dir -B $gna_plugin_build_dir -D OpenVINODeveloperPackage_DIR=$developer_package_dir -D OV_ROOT_DIR=$openvino_source_dir --trace-source=libGNAConfig.cmake --trace-expand +cmake -S $GNA_PLUGIN_SOURCE_DIR -B $GNA_PLUGIN_BUILD_DIR -D OpenVINODeveloperPackage_DIR=$DEVELOPER_PACKAGE_DIR -D OV_ROOT_DIR=$OPENVINO_SOURCE_DIR --trace-source=libGNAConfig.cmake --trace-expand ```` -#### References + + +References +---------- https://docs.openvino.ai/2022.1/openvino_docs_ie_plugin_dg_plugin_build.html https://docs.openvino.ai/2022.3/openvino_docs_ie_plugin_dg_plugin_build.html diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f7edfb547fc8ab..d3c0801f02c046 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,5 +24,5 @@ endif() if(ENABLE_FUNCTIONAL_TESTS) # add_subdirectory(deprecated/functional) -# add_subdirectory(functional) + add_subdirectory(functional) endif() diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index da06dc85ee6545..efd7a8ec8b16aa 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -8,24 +8,21 @@ endif() set(TARGET_NAME ov_gna_func_tests) -addIeTargetTest( - NAME ${TARGET_NAME} - ROOT ${CMAKE_CURRENT_SOURCE_DIR} - INCLUDES - ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDENCIES - openvino_intel_gna_plugin - LINK_LIBRARIES - funcSharedTests - ADD_CLANG_FORMAT - LABELS - GNA +file(GLOB_RECURSE MODULE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) +file(GLOB_RECURSE MODULE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR} *.hpp) + +add_executable(${TARGET_NAME} ${MODULE_SOURCES} ${MODULE_HEADERS}) +target_link_libraries(${TARGET_NAME} + openvino::gmock + openvino::gtest + openvino::gtest_main + openvino::funcTestUtils + openvino::funcSharedTests + openvino::sharedTestClasses ) -target_compile_definitions(${TARGET_NAME} - PUBLIC ${ARGV} - GNA_DATA_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/data\") +set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${OpenVINO_SOURCE_DIR}/temp/tbb/bin;${OpenVINO_SOURCE_DIR}/${BIN_FOLDER}/$;${GNA_PATH}") -if (ENABLE_DATA) - add_dependencies(${TARGET_NAME} data) -endif() \ No newline at end of file +add_test(NAME ${TARGET_NAME}_run COMMAND ${TARGET_NAME}) +set_tests_properties(${TARGET_NAME}_run PROPERTIES ENVIRONMENT "PATH=${OpenVINO_SOURCE_DIR}/temp/tbb/bin") +set_tests_properties(${TARGET_NAME}_run PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_append:${OpenVINO_SOURCE_DIR}/${BIN_FOLDER}/$;PATH=path_list_append:${GNA_PATH}")