diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dbe76ecc..157eebab8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(NULL_ENTROPY_WARNING "${WARNING_BORDER}" "${NULL_ENTROPY_WARN_L3}" "${WARNING_BORDER}") +find_package(PythonInterp) find_package(Perl) if(PERL_FOUND) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ab3f78fc8..e24bf4e6e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,8 +29,8 @@ function(add_test_suite suite_name) add_custom_command( OUTPUT test_suite_${data_name}.c - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/desktop_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --help-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o . - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/desktop_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --help-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o . + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/tests/Makefile b/tests/Makefile index c544c8e0b..5e1458a0e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,7 +2,7 @@ # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS -CFLAGS ?= -g3 #-O2 +CFLAGS ?= -O2 WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-value LDFLAGS ?= @@ -186,12 +186,12 @@ $(DEP): C_FILES := $(addsuffix .c,$(APPS)) .SECONDEXPANSION: -$(C_FILES): %.c: suites/$$(func.$$*).function suites/%.data scripts/generate_code.py suites/helpers.function suites/main_test.function suites/desktop_test.function +$(C_FILES): %.c: suites/$$(func.$$*).function suites/%.data scripts/generate_code.py suites/helpers.function suites/main_test.function suites/host_test.function echo " Gen $@" python scripts/generate_code.py -f suites/$(func.$*).function \ -d suites/$*.data \ -t suites/main_test.function \ - -p suites/desktop_test.function \ + -p suites/host_test.function \ -s suites \ --help-file suites/helpers.function \ -o . @@ -218,20 +218,15 @@ test: check # Create separate targets for generating embedded tests. EMBEDDED_TESTS := $(addprefix embedded_,$(APPS)) -# FIXME: description needs change -# Each test suite name is stripped off of prefix test_suite_. mbed-os test dir -# structure requires format TESTS/[/]/ -# Test app names are split on "." and end part is used as the test dir name. -# Prevous parts are used as the test group dirs. For tests without "." same -# name is used as the test group dir. +# Generate test code for target. .SECONDEXPANSION: -$(EMBEDDED_TESTS): embedded_%: suites/$$(func.$$*).function suites/%.data scripts/generate_code.py suites/helpers.function suites/main_test.function suites/embedded_test.function +$(EMBEDDED_TESTS): embedded_%: suites/$$(func.$$*).function suites/%.data scripts/generate_code.py suites/helpers.function suites/main_test.function suites/target_test.function echo " Gen ./TESTS/mbedtls/$*/$*.c" python scripts/generate_code.py -f suites/$(func.$*).function \ -d suites/$*.data \ -t suites/main_test.function \ - -p suites/embedded_test.function \ + -p suites/target_test.function \ -s suites \ --help-file suites/helpers.function \ -o ./TESTS/mbedtls/$* diff --git a/tests/scripts/generate_code.py b/tests/scripts/generate_code.py index 6554937ab..58020f100 100644 --- a/tests/scripts/generate_code.py +++ b/tests/scripts/generate_code.py @@ -1,18 +1,22 @@ """ -mbed TLS -Copyright (c) 2017 ARM Limited + Test suites code generator. -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 + Copyright (C) 2006-2017, ARM Limited, All Rights Reserved + SPDX-License-Identifier: Apache-2.0 - http://www.apache.org/licenses/LICENSE-2.0 + 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 -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. + 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. + + This file is part of mbed TLS (https://tls.mbed.org) """ import os diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py index b43e613ef..b8f8a3752 100644 --- a/tests/scripts/mbedtls_test.py +++ b/tests/scripts/mbedtls_test.py @@ -1,18 +1,22 @@ """ -mbed SDK -Copyright (c) 2017 ARM Limited + Greentea host test script for on-target tests. -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 + Copyright (C) 2006-2017, ARM Limited, All Rights Reserved + SPDX-License-Identifier: Apache-2.0 - http://www.apache.org/licenses/LICENSE-2.0 + 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 -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. + 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. + + This file is part of mbed TLS (https://tls.mbed.org) """ import re diff --git a/tests/suites/desktop_test.function b/tests/suites/host_test.function similarity index 99% rename from tests/suites/desktop_test.function rename to tests/suites/host_test.function index 4c790a85e..a4a5a8265 100644 --- a/tests/suites/desktop_test.function +++ b/tests/suites/host_test.function @@ -1,4 +1,4 @@ -#line 2 "suites/desktop_test.function" +#line 2 "suites/host_test.function" /** * \brief Varifies that string is in string parameter format i.e. "" diff --git a/tests/suites/embedded_test.function b/tests/suites/target_test.function similarity index 99% rename from tests/suites/embedded_test.function rename to tests/suites/target_test.function index 3f1e77add..0bafe454f 100644 --- a/tests/suites/embedded_test.function +++ b/tests/suites/target_test.function @@ -1,4 +1,4 @@ -#line 2 "embedded_test.function" +#line 2 "suites/target_test.function" #include "greentea-client/test_env.h"