diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d8339e..7333b208 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,8 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) +add_definitions( -DDEV_ESSENTIAL_DISABLE_MAKE_RESULT_CHECK_RESERVED_ZERO=1 -DDEV_ESSENTIAL_DISABLE_DEPRECATED_WARNINGS=1) + file(STRINGS version QC4OPENX_VERSION LIMIT_COUNT 1) project(qc4openx VERSION ${QC4OPENX_VERSION}) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e3c848bc..5cb9aec3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -14,4 +14,4 @@ install( xosc_examples DESTINATION examples -) \ No newline at end of file +) diff --git a/include/common/xsd/c_osc_schema_checker.h b/include/common/xsd/c_osc_schema_checker.h deleted file mode 100644 index 998687fa..00000000 --- a/include/common/xsd/c_osc_schema_checker.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#ifndef cOSCSchemaChecker_h__ -#define cOSCSchemaChecker_h__ - -#include "c_parser_error_handler.h" -#include "common/qc4openx_filesystem.h" -#include "common/result_format/c_checker.h" -#include "common/result_format/c_checker_bundle.h" -#include "common/result_format/c_file_location.h" -#include "common/result_format/c_locations_container.h" -#include "common/result_format/c_result_container.h" -#include "common/util.h" - -#include -#include -#include -#include - -class OSCSchemaChecker -{ - private: - cResultContainer *pResultContainer; - cCheckerBundle *pXSDCheckerBundle; - std::string checkerBundleName; - cParameterContainer inputParams; - std::string xoscFilePath; - std::map> versionToXsdFile; - std::list unsupportedVersions; - - public: - OSCSchemaChecker() - { - } - OSCSchemaChecker(const std::string &name, cParameterContainer params, - std::map> versionMap) - : checkerBundleName(name), inputParams(params), versionToXsdFile(versionMap) - { - Init(); - } - ~OSCSchemaChecker() - { - } - void Init(); - bool RunChecks(); - bool ValidateXSD(const std::list &lSchemaFiles); - bool ExtractXOSCVersion(unsigned *i_uRevMajor, unsigned *i_uRevMinor); - void WriteEmptyReport(); -}; - -#endif diff --git a/include/common/xsd/c_parser_error_handler.h b/include/common/xsd/c_parser_error_handler.h deleted file mode 100644 index e62cc20b..00000000 --- a/include/common/xsd/c_parser_error_handler.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#ifndef cParserErrorHandler_h__ -#define cParserErrorHandler_h__ - -#include "common/util.h" - -#define SAX_EXPORT -#include "common/result_format/c_issue.h" - -#include -#include - -class cCheckerBundle; - -class cParserErrorHandler : public ErrorHandler -{ - private: - cCheckerBundle *myCheckerBundle; - const char *myFilePath; - - void reportParseException(const SAXParseException &ex); - - void reportParseIssue(const SAXParseException &ex, eIssueLevel issueLevel); - - public: - cParserErrorHandler() = default; - virtual ~cParserErrorHandler() = default; - - cParserErrorHandler(cCheckerBundle *myCheckerBundle, const char *filePath); - - void warning(const SAXParseException &ex); - void error(const SAXParseException &ex); - void fatalError(const SAXParseException &ex); - void resetErrors(); -}; - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8366fe4..7adab0b9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,45 +8,10 @@ set(CMAKE_INSTALL_RPATH $ORIGIN/../lib) add_subdirectory(common) add_subdirectory(report_modules) -add_subdirectory(checker_bundles) add_subdirectory(result_pooling) add_subdirectory(runtime) -if (WIN32) - ## copy batch scripts - install( - FILES - CheckXodr.bat - CheckXosc.bat - DESTINATION - ${CMAKE_INSTALL_PREFIX}/bin - ) -else(WIN32) - ## copy shell scripts - install( - FILES - CheckXodr.sh - CheckXosc.sh - DESTINATION - ${CMAKE_INSTALL_PREFIX}/bin - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_WRITE GROUP_READ - WORLD_EXECUTE WORLD_WRITE WORLD_READ - ) -endif(WIN32) - # FIXME: install()? -## copy default configs -file( - COPY "${CMAKE_CURRENT_SOURCE_DIR}/DefaultXoscConfiguration.xml" - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/ - ) -file( - COPY "${CMAKE_CURRENT_SOURCE_DIR}/DefaultXodrConfiguration.xml" - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/ - ) - ## copy common lib file( COPY "${PROJECT_SOURCE_DIR}/include" @@ -68,11 +33,6 @@ file( DESTINATION ${CMAKE_INSTALL_PREFIX}/src/common PATTERN "*.svn" EXCLUDE ) -file( - COPY "${CMAKE_CURRENT_SOURCE_DIR}/common/src/xsd" - DESTINATION ${CMAKE_INSTALL_PREFIX}/src/common - PATTERN "*.svn" EXCLUDE - ) # FIXME: No cpp file file( COPY "${CMAKE_CURRENT_SOURCE_DIR}/common/src/util.cpp" diff --git a/src/CheckXodr.bat b/src/CheckXodr.bat deleted file mode 100644 index ef17ba38..00000000 --- a/src/CheckXodr.bat +++ /dev/null @@ -1,93 +0,0 @@ -:: Copyright 2023 CARIAD SE. -:: -:: This Source Code Form is subject to the terms of the Mozilla -:: Public License, v. 2.0. If a copy of the MPL was not distributed -:: with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -@echo off - -REM Get current directory where script lies -set INSTALL_DIR=%~dp0 - -echo. -echo ============================= -echo QChecker for OpenX (QC4OpenX) -echo ============================= - -if "%~1" == "" ( - echo Syntax: - echo. - echo CheckXODR.bat myXodrFileToCheck.xodr - echo. - echo. - pause - exit -) - -set XODR_FILE=%1 -if not exist %XODR_FILE% ( - echo File %XODR_FILE% does not exist. - echo. - echo. - pause - exit -) - -set XODR_FILE_EXTENSION=%~x1 -if /I not %XODR_FILE_EXTENSION% == .xodr ( - echo File %XODR_FILE% is no XODR file. - echo. - echo. - pause - exit -) - -echo. -echo ========================================= -echo == Configuration -echo ========================================= -echo Check: %XODR_FILE% -echo. -echo Delete all .xqar Files: -del /s /q /f *.xqar -echo. -echo. - -echo ========================================= -echo == XODR schema check -echo ========================================= -%INSTALL_DIR%/XodrSchemaChecker.exe %XODR_FILE% -if ERRORLEVEL == 1 ( - echo Schema is not valid. Will skip any other checks. - pause - exit 1 -) -echo. -echo ========================================= -echo == Pool results -echo ========================================= -%INSTALL_DIR%/ResultPooling.exe / -echo. -echo. - -echo ========================================= -echo == Generate text report -echo ========================================= -%INSTALL_DIR%/TextReport.exe Result.xqar -echo. -echo. -echo ========================================= -echo == Open text report -echo ========================================= -start Report.txt -echo. -echo. -echo ========================================= -echo == Open text report with ui -echo ========================================= -%INSTALL_DIR%/ReportGUI.exe Result.xqar - -echo. -echo. -echo Finished all. -echo. \ No newline at end of file diff --git a/src/CheckXodr.sh b/src/CheckXodr.sh deleted file mode 100644 index a072fc16..00000000 --- a/src/CheckXodr.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - - -function pause(){ - read -p "Press [Enter] key to continue ..." -} - -# Get current directory where script lies -INSTALL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -echo -echo ============================= -echo QChecker for OpenX - QC4OpenX -echo ============================= - -if [ ! $1 ]; then - echo Syntax: - echo - echo CheckXODR.sh myXodrFileToCheck.xodr - echo - echo - pause - exit -fi - -XODR_FILE=$1 -if [ ! -f "$XODR_FILE" ]; then - echo File $XODR_FILE does not exist. - echo - echo - pause - exit -fi - -if [[ ! ${XODR_FILE,,} =~ \.xodr$ ]]; then - echo File $XODR_FILE is no XODR file. - echo - echo - pause - exit -fi - -echo -echo ========================================= -echo == Configuration -echo ========================================= -echo Check: $XODR_FILE -echo -echo Delete all .xqar Files: -find . -name "*.xqar" -type f -delete -print -echo -echo - -echo ========================================= -echo == XODR schema check -echo ========================================= -$INSTALL_DIR/XodrSchemaChecker $XODR_FILE -if [ $? != 0 ]; then - echo Schema is not valid. Will skip any other checks. - pause - exit 1 -fi -echo -echo - -echo ========================================= -echo == Pool results -echo ========================================= -$INSTALL_DIR/ResultPooling -echo -echo - -echo ========================================= -echo == Generate text report -echo ========================================= -$INSTALL_DIR/TextReport Result.xqar - -echo -echo -echo Finished all. -echo diff --git a/src/CheckXosc.bat b/src/CheckXosc.bat deleted file mode 100644 index ed8b200d..00000000 --- a/src/CheckXosc.bat +++ /dev/null @@ -1,93 +0,0 @@ -:: Copyright 2023 CARIAD SE. -:: -:: This Source Code Form is subject to the terms of the Mozilla -:: Public License, v. 2.0. If a copy of the MPL was not distributed -:: with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -@echo off - -REM Get current directory where script lies -set INSTALL_DIR=%~dp0 - -echo. -echo ============================= -echo QChecker for OpenX (QC4OpenX) -echo ============================= - -if "%~1" == "" ( - echo Syntax: - echo. - echo CheckXOSC.bat myXoscFileToCheck.xosc - echo. - echo. - pause - exit -) - -set XOSC_FILE=%1 -if not exist %XOSC_FILE% ( - echo File %XOSC_FILE% does not exist. - echo. - echo. - pause - exit -) - -set XOSC_FILE_EXTENSION=%~x1 -if /I not %XOSC_FILE_EXTENSION% == .xosc ( - echo File %XOSC_FILE% is no XOSC file. - echo. - echo. - pause - exit -) - -echo. -echo ========================================= -echo == Configuration -echo ========================================= -echo Check: %XOSC_FILE% -echo. -echo Delete all .xqar Files: -del /s /q /f *.xqar -echo. -echo. - -echo ========================================= -echo == XOSC schema check -echo ========================================= -%INSTALL_DIR%/XoscSchemaChecker.exe %XOSC_FILE% -if ERRORLEVEL == 1 ( - echo Schema is not valid. Will skip any other checks. - pause - exit 1 -) -echo. -echo ========================================= -echo == Pool results -echo ========================================= -%INSTALL_DIR%/ResultPooling.exe / -echo. -echo. - -echo ========================================= -echo == Generate text report -echo ========================================= -%INSTALL_DIR%/TextReport.exe Result.xqar -echo. -echo. -echo ========================================= -echo == Open text report -echo ========================================= -start Report.txt -echo. -echo. -echo ========================================= -echo == Open text report with ui -echo ========================================= -%INSTALL_DIR%/ReportGUI.exe Result.xqar - -echo. -echo. -echo Finished all. -echo. \ No newline at end of file diff --git a/src/CheckXosc.sh b/src/CheckXosc.sh deleted file mode 100644 index 8aec8c1a..00000000 --- a/src/CheckXosc.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - - -function pause(){ - read -p "Press [Enter] key to continue ..." -} - -# Get current directory where script lies -INSTALL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -echo ============================= -echo QChecker for OpenX - QC4OpenX -echo ============================= -echo - -if [ ! $1 ]; then - echo Syntax: - echo - echo CheckXOSC.sh myXoscFileToCheck.xosc - echo - echo - pause - exit -fi - -XOSC_FILE=$1 -if [ ! -f "$XOSC_FILE" ]; then - echo File $XOSC_FILE does not exist. - echo - echo - pause - exit -fi - -if [[ ! ${XOSC_FILE,,} =~ \.xosc$ ]]; then - echo File $XOSC_FILE is no XOSC file. - echo - echo - pause - exit -fi - -echo -echo ========================================= -echo == Configuration -echo ========================================= -echo Check: $XOSC_FILE -echo -echo Delete all .xqar Files: -find . -name "*.xqar" -type f -delete -print -echo -echo - -echo ========================================= -echo == XOSC schema check -echo ========================================= -$INSTALL_DIR/XoscSchemaChecker $XOSC_FILE -if [ $? != 0 ]; then - echo Schema is not valid. Will skip any other checks. - pause - exit 1 -fi -echo -echo ========================================= -echo == Pool results -echo ========================================= -$INSTALL_DIR/ResultPooling -echo -echo - -echo ========================================= -echo == Generate text report -echo ========================================= -$INSTALL_DIR/TextReport Result.xqar -echo -echo - -echo -echo -echo Finished all. -echo diff --git a/src/DefaultXodrConfiguration.xml b/src/DefaultXodrConfiguration.xml deleted file mode 100644 index 1eafe01c..00000000 --- a/src/DefaultXodrConfiguration.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/DefaultXoscConfiguration.xml b/src/DefaultXoscConfiguration.xml deleted file mode 100644 index 81333f53..00000000 --- a/src/DefaultXoscConfiguration.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/checker_bundles/CMakeLists.txt b/src/checker_bundles/CMakeLists.txt deleted file mode 100644 index 33982d90..00000000 --- a/src/checker_bundles/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -add_subdirectory(xodr_schema) -add_subdirectory(xosc_schema) \ No newline at end of file diff --git a/src/checker_bundles/xodr_schema/CMakeLists.txt b/src/checker_bundles/xodr_schema/CMakeLists.txt deleted file mode 100644 index 5510fe92..00000000 --- a/src/checker_bundles/xodr_schema/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -set(CHECKER_BUNDLE_XODR_SCHEMA "XodrSchemaChecker") -project(${CHECKER_BUNDLE_XODR_SCHEMA}) - -add_executable(${CHECKER_BUNDLE_XODR_SCHEMA} - src/stdafx.h - src/stdafx.cpp - src/static_odr_checks.h - src/static_odr_checks.cpp - src/xsd/c_parser_error_handler.h - src/xsd/c_parser_error_handler.cpp -) - -target_link_libraries(${CHECKER_BUNDLE_XODR_SCHEMA} PRIVATE qc4openx-common) - -install(TARGETS ${CHECKER_BUNDLE_XODR_SCHEMA} DESTINATION bin) -qc4openx_install_qt(bin ${CHECKER_BUNDLE_XODR_SCHEMA}${CMAKE_EXECUTABLE_SUFFIX}) - -#################################################################################################### -############################### Find supported opendrive schema files ############################## -#################################################################################################### -set(ASAM_OPENDRIVE_XSD_DIR "" CACHE PATH "Directory containing the ASAM OpenDRIVE schema files (*.xsd)") -if (NOT ASAM_OPENDRIVE_XSD_DIR) - message(FATAL_ERROR "ASAM_OPENDRIVE_XSD_DIR must be set!") -endif() - -file(GLOB_RECURSE schema_files "${ASAM_OPENDRIVE_XSD_DIR}/*.xsd") -if (NOT schema_files) - message(FATAL_ERROR "No OpenDRIVE schema files found in ASAM_OPENDRIVE_XSD_DIR: ${ASAM_OPENDRIVE_XSD_DIR}") -endif () - -set(found_schema_versions) -set(found_schema_files) -set(vires_xodr_version_regex - "^.*Definition for OpenDRIVE XML files \- Rev\. ([0-9]+\.[0-9]+[A-Z]*).*") -set(asam_xodr_version_regex "^.*ASAM OpenDRIVE V([0-9]+\.[0-9]+\.[0-9]+)") - -message("-- Finding OpenDRIVE schema files in ${ASAM_OPENDRIVE_XSD_DIR}") -list(APPEND CMAKE_MESSAGE_INDENT "-- ") -foreach(schema_file ${schema_files}) - file(STRINGS "${schema_file}" schema_file_content) - # Check each line for a matching version - foreach(line ${schema_file_content}) - # Vires xodr schema files are delivered as one file - string(REGEX MATCH "${vires_xodr_version_regex}" _ ${line}) - if(NOT CMAKE_MATCH_1) - # ASAM xodr schema files are delivered as multiple files - string(REGEX MATCH "${asam_xodr_version_regex}" _ ${line}) - endif() - - if(CMAKE_MATCH_1) - list(APPEND found_schema_versions ${CMAKE_MATCH_1}) - list(APPEND found_schema_files "${schema_file}") - message("Found version ${CMAKE_MATCH_1}: ${schema_file}") - install(FILES "${schema_file}" DESTINATION bin/xsd/xodr/${CMAKE_MATCH_1}) - break() - endif() - endforeach() -endforeach() - -list(POP_BACK CMAKE_MESSAGE_INDENT) -if (NOT found_schema_files) - message(FATAL_ERROR "No OpenDRIVE schema files found in ASAM_OPENDRIVE_XSD_DIR: ${ASAM_OPENDRIVE_XSD_DIR}") -endif () - -# Without the trailing slash, the parent dir would be copied as well (so leave it!) -set_target_properties(${CHECKER_BUNDLE_XODR_SCHEMA} PROPERTIES FOLDER checker_bundles) diff --git a/src/checker_bundles/xodr_schema/src/static_odr_checks.cpp b/src/checker_bundles/xodr_schema/src/static_odr_checks.cpp deleted file mode 100644 index 16b287e5..00000000 --- a/src/checker_bundles/xodr_schema/src/static_odr_checks.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "static_odr_checks.h" -#include "common/result_format/c_checker.h" -#include "common/result_format/c_checker_bundle.h" -#include "common/result_format/c_file_location.h" -#include "common/result_format/c_locations_container.h" -#include "common/result_format/c_parameter_container.h" -#include "common/result_format/c_result_container.h" -#include "stdafx.h" - -#include "common/config_format/c_configuration.h" -#include "common/config_format/c_configuration_checker.h" -#include "common/config_format/c_configuration_checker_bundle.h" -#include "xsd/c_parser_error_handler.h" - -XERCES_CPP_NAMESPACE_USE - -cResultContainer *pResultContainer; -cCheckerBundle *pXSDCheckerBundle; - -XERCES_CPP_NAMESPACE_USE - -// Main Programm -int main(int argc, char *argv[]) -{ - std::string strToolpath = argv[0]; - - if (argc != 2) - { - ShowHelp(strToolpath); - - if (argc < 2) - return 0; - else - return -1; - } - - QCoreApplication app(argc, argv); - - XMLPlatformUtils::Initialize(); - - std::string strFilepath = argv[1]; - - std::stringstream ssResultFile; - ssResultFile << CHECKER_BUNDLE_NAME << ".xqar"; - - cParameterContainer inputParams; - - // Default parameters - inputParams.SetParam("strResultFile", ssResultFile.str()); - - if (StringEndsWith(ToLower(strFilepath), ".xodr")) - { - inputParams.SetParam("XodrFile", strFilepath); - } - else if (StringEndsWith(ToLower(strFilepath), ".xml")) - { - cConfiguration configuration; - - std::cout << "Config: " << strFilepath << std::endl; - if (!cConfiguration::ParseFromXML(&configuration, strFilepath)) - { - std::cerr << "Could not read configuration! Abort." << std::endl; - return -1; - } - - inputParams.Overwrite(configuration.GetParams()); - - cConfigurationCheckerBundle *checkerBundleConfig = configuration.GetCheckerBundleByName(CHECKER_BUNDLE_NAME); - if (nullptr != checkerBundleConfig) - inputParams.Overwrite(checkerBundleConfig->GetParams()); - else - std::cerr << "No configuration for module '" << CHECKER_BUNDLE_NAME << "' found. Start with default params." - << std::endl; - - // We do no OpenSCENARIO validation - inputParams.DeleteParam("XoscFile"); - } - else if (StringEndsWith(ToLower(strFilepath), "--defaultconfig")) - { - WriteEmptyReport(); - return 0; - } - else if (strcmp(strFilepath.c_str(), "-h") == 0 || strcmp(strFilepath.c_str(), "--help") == 0) - { - ShowHelp(strToolpath); - return 0; - } - else - { - ShowHelp(strToolpath); - return -1; - } - - bool bXODRValid = RunChecks(inputParams); - exit(bXODRValid ? 0 : 1); -} - -void ShowHelp(const std::string &toolPath) -{ - std::string applicationName = toolPath; - std::string applicationNameWithoutExt = toolPath; - GetFileName(&applicationName, false); - GetFileName(&applicationNameWithoutExt, true); - - std::cout << "\n\nUsage of " << applicationNameWithoutExt << ":" << std::endl; - std::cout << "\nRun the application with xodr file: \n" << applicationName << " sample.xodr" << std::endl; - std::cout << "\nRun the application with dbqa configuration: \n" << applicationName << " config.xml" << std::endl; - std::cout << "\nRun the application and write empty report as default configuration: \n" - << applicationName << " --defaultconfig" << std::endl; - std::cout << "\n\n"; -} - -bool ValidateXSD(cCheckerBundle *pBundleSummary, const std::string &strSchemaFilePath, const char *strXodrFilePath, - unsigned int &numOfIdentityConstraintKeyErrors) -{ - // Remove xml namespace, if present, because the validation expects files without xml namespace - bool use_temp_file = true; - auto time_now = std::chrono::system_clock::now().time_since_epoch(); - auto millis = std::chrono::duration_cast(time_now).count(); - const std::string temp_file = "temp_" + std::to_string(millis) + ".xodr"; - std::ifstream input_file_stream(strXodrFilePath); - std::ofstream temp_file_stream(temp_file); - std::string line; - while (std::getline(input_file_stream, line) && use_temp_file) - { - if (line.find("CreateChecker("xsdSchemaChecker", "Checks the validity of an OpenDRIVE."); - - std::stringstream ssErrorDesc; - ssErrorDesc << "Schema file '" << strSchemaFilePath - << "'could not be loaded. Abort schema verifcation with error."; - - pXSDParserChecker->AddIssue(new cIssue(ssErrorDesc.str(), ERROR_LVL)); - pXSDParserChecker->UpdateSummary(); - - return false; - } - - cParserErrorHandler parserErrorHandler(pBundleSummary, strXodrFilePath); - - domParser.setErrorHandler(&parserErrorHandler); - domParser.setValidationScheme(XercesDOMParser::Val_Always); - domParser.setDoNamespaces(true); - domParser.setDoSchema(true); - domParser.setValidationSchemaFullChecking(true); - domParser.setExternalNoNamespaceSchemaLocation(strSchemaFilePath.c_str()); - - if (use_temp_file) - { - domParser.parse(temp_file.c_str()); - } - else - { - domParser.parse(strXodrFilePath); - } - std::remove(temp_file.c_str()); - - if (domParser.getErrorCount() != 0) - validationSuccessfull = false; - numOfIdentityConstraintKeyErrors = parserErrorHandler.GetNumberOfIdentityConstraintKeyError(); - - return validationSuccessfull; -} - -bool RunChecks(const cParameterContainer &inputParams) -{ - pResultContainer = new cResultContainer(); - // Use this constructor because it sets build date and build version - pXSDCheckerBundle = new cCheckerBundle(CHECKER_BUNDLE_NAME, "", ""); - - pXSDCheckerBundle->SetParam("strResultFile", inputParams.GetParam("strResultFile")); - pResultContainer->AddCheckerBundle(pXSDCheckerBundle); - - std::map versionToXSDFile = { - {"1.1", GetApplicationDir() + "/xsd/xodr/1.1/OpenDRIVE_1.1.xsd"}, - {"1.2", GetApplicationDir() + "/xsd/xodr/1.2/OpenDRIVE_1.2.xsd"}, - {"1.3", GetApplicationDir() + "/xsd/xodr/1.3D/OpenDRIVE_1.3.xsd"}, - {"1.4", GetApplicationDir() + "/xsd/xodr/1.4H/OpenDRIVE_1.4H.xsd"}, - {"1.5", GetApplicationDir() + "/xsd/xodr/1.5M/OpenDRIVE_1.5M.xsd"}, - {"1.6", GetApplicationDir() + "/xsd/xodr/1.6.1/opendrive_16_core.xsd"}, - {"1.7", GetApplicationDir() + "/xsd/xodr/1.7.0/opendrive_17_core.xsd"}}; - - bool bXODRValid = false; - std::string xodrFilePath = inputParams.GetParam("XodrFile"); - std::string xodrFileName = xodrFilePath; - GetFileName(&xodrFileName, false); - - try - { - unsigned revMinorHeader = 4; - unsigned revMajorHeader = 1; - std::stringstream ssVersionString; - std::string strVersionString; - - std::cout << "Check: '" << xodrFileName.c_str() << "'" << std::endl << std::endl; - - bXODRValid = ExtractXODRVersion(pXSDCheckerBundle, xodrFilePath.c_str(), &revMinorHeader, &revMajorHeader); - - ssVersionString << revMajorHeader << "." << revMinorHeader; - strVersionString = ssVersionString.str(); - - std::cout << "Found OpenDRIVE version: " << strVersionString << ". "; - - // Check if we have a xsd file for the version - if (versionToXSDFile.find(strVersionString.c_str()) != versionToXSDFile.end()) - { - std::string strVersionFileName = versionToXSDFile.at(strVersionString).filename().string(); - - std::cout << "Use schema file " << strVersionFileName << " for validation." << std::endl << std::endl; - std::cout << "Validate..." << std::endl; - unsigned int numOfIdentityConstraintKeyErrors = 0; - // Validate XML with schema file - ValidateXSD(pXSDCheckerBundle, versionToXSDFile.at(strVersionString).string(), xodrFilePath.c_str(), - numOfIdentityConstraintKeyErrors); - - cChecker *pXSDParserChecker = pXSDCheckerBundle->GetCheckerById("xsdSchemaChecker"); - - if (nullptr == pXSDParserChecker) - pXSDParserChecker = pXSDCheckerBundle->CreateChecker( - "xsdSchemaChecker", "Checks the validity of the xml schema of an OpenDRIVE."); - - std::string s_description = pXSDParserChecker->GetDescription(); - std::stringstream ssDescription; - ssDescription << s_description << " Found OpenDRIVE version: " << strVersionString << ". Used schema file " - << strVersionFileName << " for validation."; - pXSDParserChecker->SetDescription(ssDescription.str()); - - if (numOfIdentityConstraintKeyErrors) - { - std::stringstream errorStream; - errorStream << "Found " << numOfIdentityConstraintKeyErrors - << " issues: identity constraint key for element 'OpenDRIVE' not found, but cannot " - "determine the location in file."; - pXSDParserChecker->AddIssue(new cIssue(errorStream.str(), eIssueLevel::ERROR_LVL)); - } - - pXSDParserChecker->UpdateSummary(); - } - else - { - std::stringstream errMsg; - errMsg << "Got header version " << strVersionString << " from OpenDRIVE. This version is not supported."; - - std::cerr << errMsg.str(); - - cChecker *pXSDParserChecker = - pXSDCheckerBundle->CreateChecker("xodrVersionChecker", "Checks the validity of an OpenDRIVE."); - cLocationsContainer *loc = new cLocationsContainer( - "Version isn't supported.", (cExtendedInformation *)new cFileLocation(eFileType::XODR, 3, 5)); - pXSDParserChecker->AddIssue(new cIssue(errMsg.str(), ERROR_LVL, loc)); - pXSDParserChecker->UpdateSummary(); - bXODRValid = false; - } - - pXSDCheckerBundle->SetXODRFilePath(xodrFilePath); - } - catch (...) - { - std::cerr << "Unexpected exception occurred while parsing XODR." << std::endl; - XMLPlatformUtils::Terminate(); - exit(1); - } - - // pXSDCheckerBundle->DoProcessing(AddPrefixForDescriptionIssueProcessor); - pXSDCheckerBundle->SetDescription("Checks validity of the xml schema of a given xodr file."); - - std::stringstream ssSummaryString; - unsigned int issueCount = pXSDCheckerBundle->GetIssueCount(); - ssSummaryString << "Found " << issueCount << (issueCount == 1 ? " issue" : " issues"); - pXSDCheckerBundle->SetSummary(ssSummaryString.str()); - - std::cout << pXSDCheckerBundle->GetSummary() << std::endl << std::endl; - std::cout << "Write report: '" << inputParams.GetParam("strResultFile") << "'" << std::endl << std::endl; - pResultContainer->WriteResults(inputParams.GetParam("strResultFile")); - - std::cout << "Finished." << std::endl; - - pResultContainer->Clear(); - delete pResultContainer; - - XMLPlatformUtils::Terminate(); - - return bXODRValid; -} - -// Gets the xodr version from the header tag of a given xodr file. -bool ExtractXODRVersion(cCheckerBundle *ptrCheckerBundle, const char *i_cXodrPath, unsigned *i_uRevMinor, - unsigned *i_uRevMajor) -{ - bool b_valid = false; - try - { - XMLCh *i_pRevMinor = XMLString::transcode("revMinor"); - XMLCh *i_pRevMajor = XMLString::transcode("revMajor"); - - XercesDOMParser domParser; - cParserErrorHandler parserErrorHandler(ptrCheckerBundle, i_cXodrPath); - - domParser.setErrorHandler(&parserErrorHandler); - - domParser.parse(i_cXodrPath); - - DOMDocument *pInputDocument = domParser.getDocument(); - - if (nullptr == pInputDocument) - return false; - - XMLCh *i_pTagName = XMLString::transcode("header"); - DOMNodeList *i_lHeaderNodes = pInputDocument->getElementsByTagName(i_pTagName); - - if (i_lHeaderNodes->getLength() != 1) - { - std::stringstream errMsg; - errMsg << "Found " << (i_lHeaderNodes->getLength() == 0 ? "zero" : "multiple") - << " header tags in xml file. This is not supported."; - - cChecker *pXSDParserChecker = pXSDCheckerBundle->GetCheckerById("xsdSchemaChecker"); - - if (nullptr == pXSDParserChecker) - { - pXSDParserChecker = pXSDCheckerBundle->CreateChecker( - "xsdSchemaChecker", "Checks the validity of the header tag of an OpenDRIVE."); - } - - pXSDParserChecker->AddIssue(new cIssue(errMsg.str(), ERROR_LVL)); - pXSDParserChecker->UpdateSummary(); - } - else - { - b_valid = true; - } - - XMLSize_t i_sIdx = 0; - DOMElement *i_nHeaderNode = dynamic_cast(i_lHeaderNodes->item(i_sIdx)); - - std::string i_sRevMinor = XMLString::transcode(i_nHeaderNode->getAttribute(i_pRevMinor)); - std::string i_sRevMajor = XMLString::transcode(i_nHeaderNode->getAttribute(i_pRevMajor)); - - *i_uRevMajor = stoul(i_sRevMajor, nullptr, 0); - *i_uRevMinor = stoul(i_sRevMinor, nullptr, 0); - - XMLString::release(&i_pTagName); - XMLString::release(&i_pRevMajor); - XMLString::release(&i_pRevMinor); - } - catch (...) - { - std::stringstream errMsg; - errMsg << "Could not retrieve header version from xodr. Abort with error."; - - cChecker *pXSDParserChecker = pXSDCheckerBundle->CreateChecker( - "xsdSchemaChecker", "Checks the validity of the header tag of an OpenDRIVE"); - pXSDParserChecker->AddIssue(new cIssue(errMsg.str(), ERROR_LVL)); - pXSDParserChecker->UpdateSummary(); - } - - return b_valid; -} - -void WriteEmptyReport() -{ - cResultContainer emptyReport; - // Use this constructor because it sets build date and build version - cCheckerBundle *pCheckerBundle = new cCheckerBundle(CHECKER_BUNDLE_NAME, "", ""); - - emptyReport.AddCheckerBundle(pCheckerBundle); - - std::stringstream ssDefaultResultFile; - ssDefaultResultFile << CHECKER_BUNDLE_NAME << ".xqar"; - pCheckerBundle->SetParam("strResultFile", ssDefaultResultFile.str()); - - pCheckerBundle->CreateChecker("xodrVersionChecker"); - pCheckerBundle->CreateChecker("xsdSchemaChecker"); - - std::stringstream ssReportFile; - ssReportFile << CHECKER_BUNDLE_NAME << ".xqar"; - - std::cout << std::endl; - std::cout << "Write empty report: '" << ssReportFile.str() << "'" << std::endl << std::endl; - emptyReport.WriteResults(ssReportFile.str()); - - std::cout << "Finished." << std::endl; -} - -const std::string GetApplicationDir() -{ - return QCoreApplication::applicationDirPath().toStdString(); -} diff --git a/src/checker_bundles/xodr_schema/src/static_odr_checks.h b/src/checker_bundles/xodr_schema/src/static_odr_checks.h deleted file mode 100644 index 66cfe709..00000000 --- a/src/checker_bundles/xodr_schema/src/static_odr_checks.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef STATICODRCHECKS_H__ -#define STATICODRCHECKS_H__ - -#include "common/util.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "common/qc4openx_filesystem.h" - -#define CHECKER_BUNDLE_NAME "XodrSchemaChecker" - -class cParameterContainer; -class cCheckerBundle; - -/** - * Main function for application - * - * @param [in] argc Number of arguments in shell - * @param [in] argv Pointer to arguments - * - * @return The standard return value - */ -int main(int argc, char *argv[]); - -/** - * Shows the help for the application - * @param [in] applicationName The name of the application - */ -void ShowHelp(const std::string &applicationName); - -/** - * Runs the checks - */ -bool RunChecks(const cParameterContainer &inputParams); - -/** - * Validates an xml file with a schema file - * - * @param [in] pBundleSummary Pointer to the result container - * @param [in] strSchemaFilePath Pointer to the schema file (*.xsd) - * @param [in] strXodrFilePath Pointer to the xodr file - * - * @return True if XODR could be successfully validated - */ -bool ValidateXSD(cCheckerBundle *pBundleSummary, const std::string &strSchemaFilePath, const char *strXodrFilePath); - -/** - * Extracts version information from an xodr file - * - * @param [in] ptrCheckerBundle Pointer to the checkerBundle, in case issues need to be added to it - * @param [in] i_cXodrPath Pointer to the file path of the xodr - * @param [in] i_uRevMinor Pointer to the minor version number - * @param [in] i_uRevMajor Pointer to the major version number - */ -bool ExtractXODRVersion(cCheckerBundle *ptrCheckerBundle, const char *i_cXodrPath, unsigned *i_uRevMinor, - unsigned *i_uRevMajor); - -/* - * Writes an empty Report - */ -void WriteEmptyReport(); - -/** - * Get application directory - * - * @return directory, where the application is installed - */ -const std::string GetApplicationDir(); - -#endif diff --git a/src/checker_bundles/xodr_schema/src/stdafx.cpp b/src/checker_bundles/xodr_schema/src/stdafx.cpp deleted file mode 100644 index 75048a9a..00000000 --- a/src/checker_bundles/xodr_schema/src/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "stdafx.h" diff --git a/src/checker_bundles/xodr_schema/src/stdafx.h b/src/checker_bundles/xodr_schema/src/stdafx.h deleted file mode 100644 index 0f62588b..00000000 --- a/src/checker_bundles/xodr_schema/src/stdafx.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef _STD_AFX_ -#define _STD_AFX_ - -#include -#include -#include -#include -#include -#include - -#endif // _STD_INCLUDES_HEADER_FEP_XODR_MANIPULATION_ diff --git a/src/checker_bundles/xodr_schema/src/xsd/c_parser_error_handler.cpp b/src/checker_bundles/xodr_schema/src/xsd/c_parser_error_handler.cpp deleted file mode 100644 index ac8db7b6..00000000 --- a/src/checker_bundles/xodr_schema/src/xsd/c_parser_error_handler.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "c_parser_error_handler.h" - -#include "common/result_format/c_checker.h" -#include "common/result_format/c_checker_bundle.h" -#include "common/result_format/c_file_location.h" -#include "common/result_format/c_locations_container.h" -#include "common/result_format/c_result_container.h" - -cParserErrorHandler::cParserErrorHandler(cCheckerBundle *checkerBundle, const char *filePath) - : ErrorHandler(), myCheckerBundle(checkerBundle), myFilePath(filePath) -{ -} - -void cParserErrorHandler::reportParseException(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::WARNING_LVL); -} - -void cParserErrorHandler::reportParseIssue(const SAXParseException &ex, eIssueLevel issueLevel) -{ - if (myCheckerBundle != nullptr) - { - std::stringstream errorStr; - std::string message = XMLString::transcode(ex.getMessage()); - - errorStr << "Row:" << ex.getLineNumber() << " Column:" << ex.getColumnNumber() << " Message: " << message; - - cChecker *pXodrParserChecker = myCheckerBundle->GetCheckerById("xsdSchemaChecker"); - - if (nullptr == pXodrParserChecker) - { - pXodrParserChecker = - myCheckerBundle->CreateChecker("xsdSchemaChecker", "Checks the xsd validity of an xodr."); - } - - // The message "identity constraint key for element 'OpenDRIVE' not found" cannot be located. So we count them - if (message.find("identity constraint key for element 'OpenDRIVE' not found") != std::string::npos) - { - m_NumOfIdentityConstraintKeyErrors++; - return; - } - - pXodrParserChecker->AddIssue( - new cIssue(errorStr.str(), issueLevel, - new cLocationsContainer( - message, (cExtendedInformation *)new cFileLocation(eFileType::XODR, (int)ex.getLineNumber(), - (int)ex.getColumnNumber())))); - } -} - -void cParserErrorHandler::warning(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::WARNING_LVL); -} - -void cParserErrorHandler::error(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::ERROR_LVL); -} - -void cParserErrorHandler::fatalError(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::ERROR_LVL); -} - -void cParserErrorHandler::resetErrors() -{ -} - -unsigned int cParserErrorHandler::GetNumberOfIdentityConstraintKeyError() const -{ - return m_NumOfIdentityConstraintKeyErrors; -} diff --git a/src/checker_bundles/xodr_schema/src/xsd/c_parser_error_handler.h b/src/checker_bundles/xodr_schema/src/xsd/c_parser_error_handler.h deleted file mode 100644 index bc2b161d..00000000 --- a/src/checker_bundles/xodr_schema/src/xsd/c_parser_error_handler.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef cParserErrorHandler_h__ -#define cParserErrorHandler_h__ - -#include "common/util.h" - -#include "common/result_format/c_issue.h" - -#define SAX_EXPORT -#include -#include - -class cCheckerBundle; - -class cParserErrorHandler : public ErrorHandler -{ - private: - cCheckerBundle *myCheckerBundle{nullptr}; - const char *myFilePath{nullptr}; - - void reportParseException(const SAXParseException &ex); - - void reportParseIssue(const SAXParseException &ex, eIssueLevel issueLevel); - - unsigned int m_NumOfIdentityConstraintKeyErrors{0}; - - public: - cParserErrorHandler() = delete; - ~cParserErrorHandler() = default; - explicit cParserErrorHandler(cCheckerBundle *, const char *); - - void warning(const SAXParseException &ex); - void error(const SAXParseException &ex); - void fatalError(const SAXParseException &ex); - void resetErrors(); - unsigned int GetNumberOfIdentityConstraintKeyError() const; -}; - -#endif diff --git a/src/checker_bundles/xosc_schema/CMakeLists.txt b/src/checker_bundles/xosc_schema/CMakeLists.txt deleted file mode 100644 index c4fd18ac..00000000 --- a/src/checker_bundles/xosc_schema/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -set(CHECKER_BUNDLE_XOSC_SCHEMA "XoscSchemaChecker") -project(${CHECKER_BUNDLE_XOSC_SCHEMA}) - -add_executable(${CHECKER_BUNDLE_XOSC_SCHEMA} - src/stdafx.h - src/stdafx.cpp - src/static_osc_checks.h - src/static_osc_checks.cpp -) - -target_link_libraries(${CHECKER_BUNDLE_XOSC_SCHEMA} PRIVATE - qc4openx-common - Qt5::XmlPatterns -) - -install(TARGETS ${CHECKER_BUNDLE_XOSC_SCHEMA} DESTINATION bin) -qc4openx_install_qt(bin ${CHECKER_BUNDLE_XOSC_SCHEMA}${CMAKE_EXECUTABLE_SUFFIX}) - -#################################################################################################### -############################# Find supported openscenario schema files ############################# -#################################################################################################### -# find supported openscenario schema files -set(ASAM_OPENSCENARIO_XSD_DIR "" CACHE PATH "Directory containing the ASAM OpenSCENARIO schema files (*.xsd)") -if (NOT ASAM_OPENSCENARIO_XSD_DIR) - message(FATAL_ERROR "ASAM_OPENSCENARIO_XSD_DIR must be set!") -endif() - -file(GLOB_RECURSE schema_files "${ASAM_OPENSCENARIO_XSD_DIR}/*.xsd") -if (NOT schema_files) - message(FATAL_ERROR "No OpenSCENARIO schema files found in ASAM_OPENSCENARIO_XSD_DIR: ${ASAM_OPENSCENARIO_XSD_DIR}") -endif () - -set(found_schema_versions) -set(found_schema_files) -set(vires_xosc_version_regex - # non-capturing groups currently not supported in CMake (see: https://gitlab.kitware.com/cmake/cmake/-/issues/17686) - "^.*XML Schema .+ Version [D]*[r]*[a]*[f]*[t]*[ ]*([0-9]+\.[0-9]+\.[0-9]+).*") -set(asam_xosc_version_regex "^.*ASAM OpenSCENARIO V([0-9]+\.[0-9]+\.[0-9]+)") - -message("-- Finding OpenSCENARIO schema files in ${ASAM_OPENSCENARIO_XSD_DIR}") -list(APPEND CMAKE_MESSAGE_INDENT "-- ") -foreach(schema_file ${schema_files}) - file(STRINGS "${schema_file}" schema_file_content) - # Check each line for a matching version - foreach(line ${schema_file_content}) - # Vires xosc schema file? - string(REGEX MATCH "${vires_xosc_version_regex}" _ ${line}) - if(NOT CMAKE_MATCH_1) - # Maybe ASAM xosc schema file? - string(REGEX MATCH "${asam_xosc_version_regex}" _ ${line}) - endif() - - if(CMAKE_MATCH_1) - list(APPEND found_schema_versions ${CMAKE_MATCH_1}) - list(APPEND found_schema_files "${schema_file}") - message("Found version ${CMAKE_MATCH_1}: ${schema_file}") - install(FILES "${schema_file}" DESTINATION bin/xsd/xosc/${CMAKE_MATCH_1}) - break() - endif() - endforeach() -endforeach() - -list(POP_BACK CMAKE_MESSAGE_INDENT) -if (NOT found_schema_files) - message(FATAL_ERROR "No OpenSCENARIO schema files found in ASAM_OPENSCENARIO_XSD_DIR: ${ASAM_OPENSCENARIO_XSD_DIR}") -endif () - -set_target_properties(${CHECKER_BUNDLE_XOSC_SCHEMA} PROPERTIES FOLDER checker_bundles) diff --git a/src/checker_bundles/xosc_schema/src/static_osc_checks.cpp b/src/checker_bundles/xosc_schema/src/static_osc_checks.cpp deleted file mode 100644 index 31c40c15..00000000 --- a/src/checker_bundles/xosc_schema/src/static_osc_checks.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "static_osc_checks.h" - -int main(int argc, char *argv[]) -{ - std::string strToolpath = argv[0]; - - if (argc != 2) - { - ShowHelp(strToolpath); - if (argc < 2) - return 0; - else - return -1; - } - - QCoreApplication app(argc, argv); - - std::string strFilepath = argv[1]; - - cParameterContainer inputParams; - OSCSchemaChecker *schemaChecker; - - std::stringstream ssResultFile; - ssResultFile << CHECKER_BUNDLE_NAME << ".xqar"; - inputParams.SetParam("strResultFile", ssResultFile.str()); - - std::map> versionToXSDFile = { - {"0.9", - {GetApplicationDir() + "/xsd/xosc/0.9.1/OpenSCENARIO_TypeDefs.xsd", - GetApplicationDir() + "/xsd/xosc/0.9.1/OpenSCENARIO_v0.9.1.xsd"}}, - {"1.0", {GetApplicationDir() + "/xsd/xosc/1.0.0/OpenSCENARIO.xsd"}}, - {"1.1", {GetApplicationDir() + "/xsd/xosc/1.1.0/OpenSCENARIO.xsd"}}}; - - if (StringEndsWith(ToLower(strFilepath), ".xosc")) - { - inputParams.SetParam("XoscFile", strFilepath); - } - else if (StringEndsWith(ToLower(strFilepath), ".xml")) - { - cConfiguration configuration; - - std::cout << "Config: " << strFilepath << std::endl; - if (!cConfiguration::ParseFromXML(&configuration, strFilepath)) - { - std::cerr << "Could not read configuration! Abort." << std::endl; - return -1; - } - - inputParams.Overwrite(configuration.GetParams()); - - cConfigurationCheckerBundle *checkerBundleConfig = configuration.GetCheckerBundleByName(CHECKER_BUNDLE_NAME); - if (nullptr != checkerBundleConfig) - inputParams.Overwrite(checkerBundleConfig->GetParams()); - else - std::cerr << "No configuration for module '" << CHECKER_BUNDLE_NAME << "' found. Start with default params." - << std::endl; - - inputParams.DeleteParam("XodrFile"); - } - else if (StringEndsWith(ToLower(strFilepath), "--defaultconfig")) - { - schemaChecker = new OSCSchemaChecker(CHECKER_BUNDLE_NAME, inputParams, versionToXSDFile); - schemaChecker->WriteEmptyReport(); - return 0; - } - else if (strcmp(strFilepath.c_str(), "-h") == 0 || strcmp(strFilepath.c_str(), "--help") == 0) - { - ShowHelp(strToolpath); - return 0; - } - else - { - ShowHelp(strToolpath); - return -1; - } - - schemaChecker = new OSCSchemaChecker(CHECKER_BUNDLE_NAME, inputParams, versionToXSDFile); - - bool bXOSCValid = schemaChecker->RunChecks(); - exit(bXOSCValid ? 0 : 1); -} - -void ShowHelp(const std::string &toolPath) -{ - std::string applicationName = toolPath; - std::string applicationNameWithoutExt = toolPath; - GetFileName(&applicationName, false); - GetFileName(&applicationNameWithoutExt, true); - - std::cout << "\n\nUsage of " << applicationNameWithoutExt << ":" << std::endl; - std::cout << "\nRun the application with xosc file: \n" << applicationName << " sample.xosc" << std::endl; - std::cout << "\nRun the application with dbqa configuration: \n" << applicationName << " config.xml" << std::endl; - std::cout << "\nRun the application and write empty report as default configuration: \n" - << applicationName << " --defaultconfig" << std::endl; - std::cout << "\n\n"; -} - -const std::string GetApplicationDir() -{ - return QCoreApplication::applicationDirPath().toStdString(); -} diff --git a/src/checker_bundles/xosc_schema/src/static_osc_checks.h b/src/checker_bundles/xosc_schema/src/static_osc_checks.h deleted file mode 100644 index 0a5113a8..00000000 --- a/src/checker_bundles/xosc_schema/src/static_osc_checks.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#ifndef STATICOSCCHECKS_H__ -#define STATICOSCCHECKS_H__ - -#include "common/config_format/c_configuration.h" -#include "common/config_format/c_configuration_checker_bundle.h" -#include "common/config_format/c_configuration_report_module.h" -#include "common/qc4openx_filesystem.h" -#include "common/util.h" -#include "common/xsd/c_osc_schema_checker.h" -#include "common/xsd/c_parser_error_handler.h" -#include "stdafx.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define CHECKER_BUNDLE_NAME "XoscSchemaChecker" - -class cParameterContainer; -class cCheckerBundle; - -/** - * Main function for application - * - * @param [in] argc Number of arguments in shell - * @param [in] argv Pointer to arguments - * - * @return The standard return value - */ -int main(int argc, char *argv[]); - -/** - * Shows the help for the application - * @param [in] applicationName The name of the application - */ -void ShowHelp(const std::string &applicationName); - -/** - * Get application directory - * - * @return directory, where the application is installed - */ -const std::string GetApplicationDir(); - -#endif diff --git a/src/checker_bundles/xosc_schema/src/stdafx.cpp b/src/checker_bundles/xosc_schema/src/stdafx.cpp deleted file mode 100644 index 4a0e5a70..00000000 --- a/src/checker_bundles/xosc_schema/src/stdafx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "stdafx.h" diff --git a/src/checker_bundles/xosc_schema/src/stdafx.h b/src/checker_bundles/xosc_schema/src/stdafx.h deleted file mode 100644 index 4d65a490..00000000 --- a/src/checker_bundles/xosc_schema/src/stdafx.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#ifndef _STD_AFX_ -#define _STD_AFX_ - -#include -#include -#include -#include -#include -#include - -#endif // _STD_INCLUDES_HEADER_FEP_XODR_MANIPULATION_ diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d723aa9b..7f0f2589 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -29,9 +29,7 @@ add_library(qc4openx-common STATIC src/config_format/c_configuration_checker.cpp src/config_format/c_configuration_checker_bundle.cpp src/config_format/c_configuration_report_module.cpp - src/xsd/c_osc_schema_checker.cpp - src/xsd/c_parser_error_handler.cpp - src/xml/c_x_path_evaluator.cpp + src/xml/c_x_path_evaluator.cpp ) target_include_directories(qc4openx-common PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/common/src/xsd/c_osc_schema_checker.cpp b/src/common/src/xsd/c_osc_schema_checker.cpp deleted file mode 100644 index 2b1c9316..00000000 --- a/src/common/src/xsd/c_osc_schema_checker.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "common/xsd/c_osc_schema_checker.h" - -XERCES_CPP_NAMESPACE_USE - -void OSCSchemaChecker::Init() -{ - XMLPlatformUtils::Initialize(); - pResultContainer = new cResultContainer(); - pXSDCheckerBundle = new cCheckerBundle(checkerBundleName, "", ""); - pResultContainer->AddCheckerBundle(pXSDCheckerBundle); - xoscFilePath = inputParams.GetParam("XoscFile"); -} - -bool OSCSchemaChecker::RunChecks() -{ - bool bXOSCValid = false; - - try - { - unsigned revMajorHeader = 0; - unsigned revMinorHeader = 0; - std::stringstream ssVersionString; - - std::cout << "Check: '" << xoscFilePath.c_str() << "'" << std::endl << std::endl; - - bXOSCValid = ExtractXOSCVersion(&revMajorHeader, &revMinorHeader); - - ssVersionString << revMajorHeader << "." << revMinorHeader; - std::cout << "Found OpenSCENARIO version: " << ssVersionString.str() << ". "; - std::string strSchemaFilesUsedDesc = ""; - - if (versionToXsdFile.find(ssVersionString.str().c_str()) != versionToXsdFile.end()) - { - std::list schemaFiles = versionToXsdFile.at(ssVersionString.str().c_str()); - std::cout << "Use schema files:" << std::endl; - - std::list::iterator itSchemaFile; - for (itSchemaFile = schemaFiles.begin(); itSchemaFile != schemaFiles.end(); itSchemaFile++) - { - std::cout << "> " << itSchemaFile->filename() << std::endl; - strSchemaFilesUsedDesc += itSchemaFile->filename().string(); - strSchemaFilesUsedDesc += ", "; - } - std::cout << std::endl << "for validation." << std::endl << std::endl; - - if (strSchemaFilesUsedDesc.size() > 2) - strSchemaFilesUsedDesc = strSchemaFilesUsedDesc.substr(0, strSchemaFilesUsedDesc.size() - 2); - - ValidateXSD(schemaFiles); - - cChecker *pXSDParserChecker = pXSDCheckerBundle->GetCheckerById("xoscSchemaChecker"); - - if (nullptr == pXSDParserChecker) - pXSDParserChecker = pXSDCheckerBundle->CreateChecker( - "xoscSchemaChecker", "Checks the validity of the xml schema of an xosc."); - - std::string s_description = pXSDParserChecker->GetDescription(); - std::stringstream ssDescription; - ssDescription << s_description << " Found xosc version: " << ssVersionString.str() << ". Used schema file " - << strSchemaFilesUsedDesc << " for validation."; - pXSDParserChecker->SetDescription(ssDescription.str()); - - pXSDParserChecker->UpdateSummary(); - } - else - { - std::stringstream errMsg; - errMsg << "Got header version " << ssVersionString.str() - << " from OpenSCENARIO. This version is not supported."; - - std::cerr << errMsg.str(); - - cChecker *pXSDParserChecker = - pXSDCheckerBundle->CreateChecker("xoscVersionChecker", "Checks the validity of an xosc."); - cLocationsContainer *loc = new cLocationsContainer( - "Version isn't supported.", (cExtendedInformation *)new cFileLocation(eFileType::XOSC, 3, 5)); - pXSDParserChecker->AddIssue(new cIssue(errMsg.str(), ERROR_LVL, loc)); - pXSDParserChecker->UpdateSummary(); - bXOSCValid = false; - } - - pXSDCheckerBundle->SetXOSCFilePath(xoscFilePath); - } - catch (...) - { - std::cerr << "Unexpected exception occurred while parsing XOSC." << std::endl; - XMLPlatformUtils::Terminate(); - exit(1); - } - - pXSDCheckerBundle->SetDescription("Checks validity of the xml schema of a given xosc file."); - - std::stringstream ssSummaryString; - unsigned int issueCount = pXSDCheckerBundle->GetIssueCount(); - ssSummaryString << "Found " << issueCount << (issueCount == 1 ? " issue" : " issues"); - pXSDCheckerBundle->SetSummary(ssSummaryString.str()); - - std::cout << pXSDCheckerBundle->GetSummary() << std::endl << std::endl; - std::cout << "Write report: '" << inputParams.GetParam("strResultFile") << "'" << std::endl << std::endl; - pResultContainer->WriteResults(inputParams.GetParam("strResultFile")); - - std::cout << "Finished." << std::endl; - - pResultContainer->Clear(); - delete pResultContainer; - - XMLPlatformUtils::Terminate(); - - return bXOSCValid; -} - -bool OSCSchemaChecker::ValidateXSD(const std::list &lSchemaFiles) -{ - bool validationSuccessfull = true; - - XercesDOMParser domParser; - std::list::const_iterator itSchemaFile; - for (itSchemaFile = lSchemaFiles.begin(); itSchemaFile != lSchemaFiles.end(); itSchemaFile++) - { - std::string strSchemaFilePath = itSchemaFile->string(); - std::cout << "Load Grammar: " << strSchemaFilePath << std::endl; - - if (domParser.loadGrammar(strSchemaFilePath.c_str(), Grammar::SchemaGrammarType) == NULL) - { - validationSuccessfull = false; - - cChecker *pXSDParserChecker = - pXSDCheckerBundle->CreateChecker("xoscSchemaChecker", "Checks the validity of an xosc."); - - std::stringstream ssErrorDesc; - ssErrorDesc << "Schema file '" << strSchemaFilePath - << "'could not be loaded. Abort schema verifcation with error."; - - pXSDParserChecker->AddIssue(new cIssue(ssErrorDesc.str(), ERROR_LVL)); - pXSDParserChecker->UpdateSummary(); - - return false; - } - domParser.setExternalNoNamespaceSchemaLocation(strSchemaFilePath.c_str()); - } - - cParserErrorHandler parserErrorHandler(pXSDCheckerBundle, xoscFilePath.c_str()); - - domParser.setErrorHandler(&parserErrorHandler); - domParser.setValidationScheme(XercesDOMParser::Val_Always); - domParser.setDoNamespaces(true); - domParser.setDoSchema(true); - domParser.setValidationSchemaFullChecking(true); - - std::cout << "Validate..." << std::endl; - domParser.parse(xoscFilePath.c_str()); - - if (domParser.getErrorCount() != 0) - validationSuccessfull = false; - - return validationSuccessfull; -} - -bool OSCSchemaChecker::ExtractXOSCVersion(unsigned *i_uRevMajor, unsigned *i_uRevMinor) -{ - bool bValid = false; - - try - { - XMLCh *i_pRevMinor = XMLString::transcode("revMinor"); - XMLCh *i_pRevMajor = XMLString::transcode("revMajor"); - - XercesDOMParser domParser; - cParserErrorHandler parserErrorHandler(pXSDCheckerBundle, xoscFilePath.c_str()); - - domParser.setErrorHandler(&parserErrorHandler); - - domParser.parse(xoscFilePath.c_str()); - - DOMDocument *pInputDocument = domParser.getDocument(); - - if (nullptr == pInputDocument) - return false; - - XMLCh *pTagName = XMLString::transcode("FileHeader"); - DOMNodeList *lHeaderNodes = pInputDocument->getElementsByTagName(pTagName); - - if (lHeaderNodes->getLength() != 1) - { - std::stringstream errMsg; - errMsg << "Found " << (lHeaderNodes->getLength() == 0 ? "zero" : "multiple") - << " file header tags in xml file. This is not supported."; - - cChecker *pXSDParserChecker = pXSDCheckerBundle->GetCheckerById("xoscSchemaChecker"); - - if (nullptr == pXSDParserChecker) - { - pXSDParserChecker = pXSDCheckerBundle->CreateChecker( - "xoscSchemaChecker", "Checks the validity of the header tag of an xosc."); - } - - pXSDParserChecker->AddIssue(new cIssue(errMsg.str(), ERROR_LVL)); - pXSDParserChecker->UpdateSummary(); - } - else - { - bValid = true; - } - - XMLSize_t i_sIdx = 0; - DOMElement *i_nHeaderNode = dynamic_cast(lHeaderNodes->item(i_sIdx)); - - std::string i_sRevMinor = XMLString::transcode(i_nHeaderNode->getAttribute(i_pRevMinor)); - std::string i_sRevMajor = XMLString::transcode(i_nHeaderNode->getAttribute(i_pRevMajor)); - - *i_uRevMajor = stoul(i_sRevMajor, nullptr, 0); - *i_uRevMinor = stoul(i_sRevMinor, nullptr, 0); - - XMLString::release(&pTagName); - XMLString::release(&i_pRevMajor); - XMLString::release(&i_pRevMinor); - } - catch (...) - { - std::stringstream errMsg; - errMsg << "Could not retrieve header version from OpenSCENARIO. Abort with error."; - - cChecker *pXSDParserChecker = pXSDCheckerBundle->CreateChecker( - "xoscSchemaChecker", "Checks the validity of the header tag of an OpenSCENARIO."); - pXSDParserChecker->AddIssue(new cIssue(errMsg.str(), ERROR_LVL)); - pXSDParserChecker->UpdateSummary(); - } - - return bValid; -} - -void OSCSchemaChecker::WriteEmptyReport() -{ - cResultContainer emptyReport; - emptyReport.AddCheckerBundle(pXSDCheckerBundle); - - std::stringstream ssDefaultResultFile; - ssDefaultResultFile << checkerBundleName << ".xqar"; - pXSDCheckerBundle->SetParam("strResultFile", ssDefaultResultFile.str()); - - pXSDCheckerBundle->CreateChecker("xoscVersionChecker"); - pXSDCheckerBundle->CreateChecker("xoscSchemaChecker"); - - std::stringstream ssReportFile; - ssReportFile << checkerBundleName << ".xqar"; - - std::cout << std::endl; - std::cout << "Write empty report: '" << ssReportFile.str() << "'" << std::endl << std::endl; - emptyReport.WriteResults(ssReportFile.str()); - - std::cout << "Finished." << std::endl; -} diff --git a/src/common/src/xsd/c_parser_error_handler.cpp b/src/common/src/xsd/c_parser_error_handler.cpp deleted file mode 100644 index 68d2c06d..00000000 --- a/src/common/src/xsd/c_parser_error_handler.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "common/xsd/c_parser_error_handler.h" - -#include "common/result_format/c_checker.h" -#include "common/result_format/c_checker_bundle.h" -#include "common/result_format/c_file_location.h" -#include "common/result_format/c_locations_container.h" - -cParserErrorHandler::cParserErrorHandler(cCheckerBundle *checkerBundle, const char *filePath) : ErrorHandler() -{ - myCheckerBundle = checkerBundle; - myFilePath = filePath; -} - -void cParserErrorHandler::reportParseException(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::WARNING_LVL); -} - -void cParserErrorHandler::reportParseIssue(const SAXParseException &ex, eIssueLevel issueLevel) -{ - if (myCheckerBundle != nullptr) - { - std::stringstream errorStr; - std::string message = XMLString::transcode(ex.getMessage()); - - errorStr << "Row:" << ex.getLineNumber() << " Column:" << ex.getColumnNumber() << " Message: " << message; - - cChecker *pXodrParserChecker = myCheckerBundle->GetCheckerById("xoscSchemaChecker"); - - if (nullptr == pXodrParserChecker) - { - pXodrParserChecker = - myCheckerBundle->CreateChecker("xoscSchemaChecker", "Checks the xsd validity of an OpenSCENARIO."); - } - - cLocationsContainer *loc = - new cLocationsContainer(message, (cExtendedInformation *)new cFileLocation( - eFileType::XOSC, (int)ex.getLineNumber(), (int)ex.getColumnNumber())); - - pXodrParserChecker->AddIssue(new cIssue(errorStr.str(), issueLevel, loc)); - } -} - -void cParserErrorHandler::warning(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::WARNING_LVL); -} - -void cParserErrorHandler::error(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::ERROR_LVL); -} - -void cParserErrorHandler::fatalError(const SAXParseException &ex) -{ - reportParseIssue(ex, eIssueLevel::ERROR_LVL); -} - -void cParserErrorHandler::resetErrors() -{ -} diff --git a/test/function/CMakeLists.txt b/test/function/CMakeLists.txt index d94661d4..897bedf1 100644 --- a/test/function/CMakeLists.txt +++ b/test/function/CMakeLists.txt @@ -4,7 +4,6 @@ # Public License, v. 2.0. If a copy of the MPL was not distributed # with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -add_subdirectory(checker_bundles) add_subdirectory(examples) add_subdirectory(report_modules) add_subdirectory(result_pooling/src) @@ -18,15 +17,6 @@ add_custom_target(INSTALL_TEST_REFERENCES ALL) add_custom_command( TARGET INSTALL_TEST_REFERENCES PRE_BUILD - - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/checker_bundles/xodr_schema/files - ${REFERENCE_FILES_INSTALL_DIR}/function/checker_bundles/xodr_schema - - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/checker_bundles/xosc_schema/files - ${REFERENCE_FILES_INSTALL_DIR}/function/checker_bundles/xosc_schema - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/examples/example_checker_bundle/files ${REFERENCE_FILES_INSTALL_DIR}/function/examples/example_checker_bundle @@ -46,15 +36,4 @@ add_custom_command( COMMENT "Copying test reference files..." ) -configure_file ( - ${CMAKE_CURRENT_SOURCE_DIR}/checker_bundles/xodr_schema/files/XodrSchemaChecker.xqar.in - ${REFERENCE_FILES_INSTALL_DIR}/function/checker_bundles/xodr_schema/XodrSchemaChecker.xqar - @ONLY -) -configure_file ( - ${CMAKE_CURRENT_SOURCE_DIR}/checker_bundles/xosc_schema/files/XoscSchemaChecker.xqar.in - ${REFERENCE_FILES_INSTALL_DIR}/function/checker_bundles/xosc_schema/XoscSchemaChecker.xqar - @ONLY -) - set_target_properties(INSTALL_TEST_REFERENCES PROPERTIES FOLDER test/references) diff --git a/test/function/checker_bundles/CMakeLists.txt b/test/function/checker_bundles/CMakeLists.txt deleted file mode 100644 index 2847ba01..00000000 --- a/test/function/checker_bundles/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - - -add_subdirectory(xodr_schema/src) -add_subdirectory(xosc_schema/src) \ No newline at end of file diff --git a/test/function/checker_bundles/xodr_schema/files/XodrSchemaChecker.xqar.in b/test/function/checker_bundles/xodr_schema/files/XodrSchemaChecker.xqar.in deleted file mode 100644 index dc4d3dee..00000000 --- a/test/function/checker_bundles/xodr_schema/files/XodrSchemaChecker.xqar.in +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/test/function/checker_bundles/xodr_schema/files/XodrSchemaChecker_config.xml b/test/function/checker_bundles/xodr_schema/files/XodrSchemaChecker_config.xml deleted file mode 100644 index 971983f1..00000000 --- a/test/function/checker_bundles/xodr_schema/files/XodrSchemaChecker_config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/test/function/checker_bundles/xodr_schema/src/CMakeLists.txt b/test/function/checker_bundles/xodr_schema/src/CMakeLists.txt deleted file mode 100644 index 741e469d..00000000 --- a/test/function/checker_bundles/xodr_schema/src/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - - -set(TEST_NAME xodr_schema_tester) - -set_property(GLOBAL PROPERTY USE_FOLDERS true) - -include_directories(${TEST_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../../_common) - -add_executable(${TEST_NAME} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../_common/helper.cpp - ${TEST_NAME}.cpp) - -add_test(NAME ${TEST_NAME} - COMMAND ${TEST_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../../ -) - -target_link_libraries(${TEST_NAME} - PRIVATE - GTest::gtest_main - dev_essential::result - dev_essential::system -) - -target_compile_definitions(${TEST_NAME} - PRIVATE QC4OPENX_DBQA_BIN_DIR="${QC4OPENX_DBQA_DIR}/bin" - PRIVATE QC4OPENX_DBQA_XODR_SCHEMA_TEST_WORK_DIR="${CMAKE_CURRENT_BINARY_DIR}/../../../" - PRIVATE QC4OPENX_DBQA_XODR_SCHEMA_TEST_REF_DIR="${REFERENCE_FILES_INSTALL_DIR}/function/checker_bundles/xodr_schema") - -set_target_properties(${TEST_NAME} PROPERTIES FOLDER test/function) diff --git a/test/function/checker_bundles/xodr_schema/src/xodr_schema_tester.cpp b/test/function/checker_bundles/xodr_schema/src/xodr_schema_tester.cpp deleted file mode 100644 index 6d5ad161..00000000 --- a/test/function/checker_bundles/xodr_schema/src/xodr_schema_tester.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "gtest/gtest.h" - -#include "helper.h" - -#define MODULE_NAME "XodrSchemaChecker" - -class cTesterXodrSchema : public ::testing::Test -{ - public: - std::string strTestFilesDir = std::string(QC4OPENX_DBQA_XODR_SCHEMA_TEST_REF_DIR); - std::string strWorkingDir = std::string(QC4OPENX_DBQA_XODR_SCHEMA_TEST_WORK_DIR); -}; - -TEST_F(cTesterXodrSchema, CmdBasic) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); -} - -TEST_F(cTesterXodrSchema, CmdDefaultConfig) -{ - std::string strResultMessage; - - std::string strDefaultConfigFilePath = strWorkingDir + "/" + std::string(MODULE_NAME) + ".xqar"; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "--defaultconfig"); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFileExists(strResultMessage, strDefaultConfigFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); -} - -TEST_F(cTesterXodrSchema, CmdConfig) -{ - std::string strResultMessage; - - std::string strConfigFilePath = strTestFilesDir + "/" + std::string(MODULE_NAME) + "_config.xml"; - std::string strResultFilePath = strWorkingDir + "/" + std::string(MODULE_NAME) + ".xqar"; - std::string strExpectedResultFilePath = strTestFilesDir + "/" + std::string(MODULE_NAME) + ".xqar"; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, strConfigFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFileExists(strResultMessage, strResultFilePath, false); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFilesEqual(strResultMessage, strResultFilePath, strExpectedResultFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - a_util::filesystem::remove(strResultFilePath.c_str()); -} - -TEST_F(cTesterXodrSchema, CmdXodr) -{ - std::string strResultMessage; - - std::string strXodrFilePath = "../stimuli/xodr_examples/three_connected_roads_with_steps.xodr"; - std::string strResultFilePath = strWorkingDir + "/" + std::string(MODULE_NAME) + ".xqar"; - std::string strExpectedResultFilePath = strTestFilesDir + "/" + std::string(MODULE_NAME) + ".xqar"; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, strXodrFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFileExists(strResultMessage, strResultFilePath, false); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFilesEqual(strResultMessage, strResultFilePath, strExpectedResultFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - a_util::filesystem::remove(strResultFilePath.c_str()); -} - -TEST_F(cTesterXodrSchema, CmdConfigFileNotFound) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "error.xml"); - ASSERT_TRUE(nRes == qc4openx::ERR_FAILED); -} - -TEST_F(cTesterXodrSchema, CmdFirstArgumentWrong) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "error"); - ASSERT_TRUE(nRes == qc4openx::ERR_FAILED); -} - -TEST_F(cTesterXodrSchema, CmdTooMuchArguments) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "a b"); - ASSERT_TRUE(nRes == qc4openx::ERR_FAILED); -} diff --git a/test/function/checker_bundles/xosc_schema/files/XoscSchemaChecker.xqar.in b/test/function/checker_bundles/xosc_schema/files/XoscSchemaChecker.xqar.in deleted file mode 100644 index c916959a..00000000 --- a/test/function/checker_bundles/xosc_schema/files/XoscSchemaChecker.xqar.in +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/test/function/checker_bundles/xosc_schema/files/XoscSchemaChecker_config.xml b/test/function/checker_bundles/xosc_schema/files/XoscSchemaChecker_config.xml deleted file mode 100644 index 48f1f7b3..00000000 --- a/test/function/checker_bundles/xosc_schema/files/XoscSchemaChecker_config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/test/function/checker_bundles/xosc_schema/src/CMakeLists.txt b/test/function/checker_bundles/xosc_schema/src/CMakeLists.txt deleted file mode 100644 index c5100d62..00000000 --- a/test/function/checker_bundles/xosc_schema/src/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - - -set(TEST_NAME xosc_schema_tester) - -set_property(GLOBAL PROPERTY USE_FOLDERS true) - -include_directories(${TEST_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../../_common) - -add_executable(${TEST_NAME} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../_common/helper.cpp - ${TEST_NAME}.cpp) - -add_test(NAME ${TEST_NAME} - COMMAND ${TEST_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../../ -) - -target_link_libraries(${TEST_NAME} - PRIVATE - GTest::gtest_main - dev_essential::result - dev_essential::system -) - -target_compile_definitions(${TEST_NAME} - PRIVATE QC4OPENX_DBQA_BIN_DIR="${QC4OPENX_DBQA_DIR}/bin" - PRIVATE QC4OPENX_DBQA_XOSC_SCHEMA_TEST_WORK_DIR="${CMAKE_CURRENT_BINARY_DIR}/../../../" - PRIVATE QC4OPENX_DBQA_XOSC_SCHEMA_TEST_REF_DIR="${REFERENCE_FILES_INSTALL_DIR}/function/checker_bundles/xosc_schema") - -set_target_properties(${TEST_NAME} PROPERTIES FOLDER test/function) \ No newline at end of file diff --git a/test/function/checker_bundles/xosc_schema/src/xosc_schema_tester.cpp b/test/function/checker_bundles/xosc_schema/src/xosc_schema_tester.cpp deleted file mode 100644 index 39b1f57a..00000000 --- a/test/function/checker_bundles/xosc_schema/src/xosc_schema_tester.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "gtest/gtest.h" - -#include "helper.h" - -#define MODULE_NAME "XoscSchemaChecker" - -class cTesterXoscSchema : public ::testing::Test -{ - public: - std::string strTestFilesDir = std::string(QC4OPENX_DBQA_XOSC_SCHEMA_TEST_REF_DIR); - std::string strWorkingDir = std::string(QC4OPENX_DBQA_XOSC_SCHEMA_TEST_WORK_DIR); -}; - -TEST_F(cTesterXoscSchema, CmdBasic) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); -} - -TEST_F(cTesterXoscSchema, CmdDefaultConfig) -{ - std::string strResultMessage; - - std::string strDefaultConfigFilePath = strWorkingDir + "/" + std::string(MODULE_NAME) + ".xqar"; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "--defaultconfig"); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFileExists(strResultMessage, strDefaultConfigFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); -} - -TEST_F(cTesterXoscSchema, CmdConfig) -{ - std::string strResultMessage; - - std::string strConfigFilePath = strTestFilesDir + "/" + std::string(MODULE_NAME) + "_config.xml"; - std::string strResultFilePath = strWorkingDir + "/" + std::string(MODULE_NAME) + ".xqar"; - std::string strExpectedResultFilePath = strTestFilesDir + "/" + std::string(MODULE_NAME) + ".xqar"; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, strConfigFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFileExists(strResultMessage, strResultFilePath, false); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFilesEqual(strResultMessage, strResultFilePath, strExpectedResultFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - a_util::filesystem::remove(strResultFilePath.c_str()); -} - -TEST_F(cTesterXoscSchema, CmdXosc) -{ - std::string strResultMessage; - - std::string strXoscFilePath = "../stimuli/xosc_examples/test_ramp.xosc"; - std::string strResultFilePath = strWorkingDir + "/" + std::string(MODULE_NAME) + ".xqar"; - std::string strExpectedResultFilePath = strTestFilesDir + "/" + std::string(MODULE_NAME) + ".xqar"; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, strXoscFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFileExists(strResultMessage, strResultFilePath, false); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= CheckFilesEqual(strResultMessage, strResultFilePath, strExpectedResultFilePath); - ASSERT_TRUE_EXT(nRes == qc4openx::ERR_NOERROR, strResultMessage.c_str()); - - a_util::filesystem::remove(strResultFilePath.c_str()); -} - -TEST_F(cTesterXoscSchema, CmdConfigFileNotFound) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "error.xml"); - ASSERT_TRUE(nRes == qc4openx::ERR_FAILED); -} - -TEST_F(cTesterXoscSchema, CmdFirstArgumentWrong) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "error"); - ASSERT_TRUE(nRes == qc4openx::ERR_FAILED); -} - -TEST_F(cTesterXoscSchema, CmdTooMuchArguments) -{ - std::string strResultMessage; - - qc4openx::Result nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "a b"); - ASSERT_TRUE(nRes == qc4openx::ERR_FAILED); -}