diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e24bf4e6e..7b66dcfe4 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/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 + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_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_test_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 8b2af476b..b3ab03665 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -195,9 +195,9 @@ $(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/host_test.function +$(C_FILES): %.c: suites/$$(func.$$*).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/host_test.function echo " Gen $@" - $(PYTHON) scripts/generate_code.py -f suites/$(func.$*).function \ + $(PYTHON) scripts/generate_test_code.py -f suites/$(func.$*).function \ -d suites/$*.data \ -t suites/main_test.function \ -p suites/host_test.function \ @@ -230,9 +230,9 @@ EMBEDDED_TESTS := $(addprefix embedded_,$(APPS)) # 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/target_test.function +$(EMBEDDED_TESTS): embedded_%: suites/$$(func.$$*).function suites/%.data scripts/generate_test_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 \ + $(PYTHON) scripts/generate_test_code.py -f suites/$(func.$*).function \ -d suites/$*.data \ -t suites/main_test.function \ -p suites/target_test.function \ diff --git a/tests/scripts/generate_code.py b/tests/scripts/generate_test_code.py similarity index 99% rename from tests/scripts/generate_code.py rename to tests/scripts/generate_test_code.py index b6ee968cf..38b0d7547 100644 --- a/tests/scripts/generate_code.py +++ b/tests/scripts/generate_test_code.py @@ -1,6 +1,6 @@ # Test suites code generator. # -# Copyright (C) 2006-2017, ARM Limited, All Rights Reserved +# Copyright (C) 2018, ARM Limited, All Rights Reserved # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py index 7dba1b2fb..b825f1359 100644 --- a/tests/scripts/mbedtls_test.py +++ b/tests/scripts/mbedtls_test.py @@ -1,6 +1,6 @@ # Greentea host test script for on-target tests. # -# Copyright (C) 2006-2017, ARM Limited, All Rights Reserved +# Copyright (C) 2018, ARM Limited, All Rights Reserved # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/tests/scripts/generate_code_ut.py b/tests/scripts/test_generate_test_code.py similarity index 97% rename from tests/scripts/generate_code_ut.py rename to tests/scripts/test_generate_test_code.py index 383f029ab..08b6fb3a6 100644 --- a/tests/scripts/generate_code_ut.py +++ b/tests/scripts/test_generate_test_code.py @@ -1,6 +1,6 @@ -# Unit test for generate_code.py +# Unit test for generate_test_code.py # -# Copyright (C) 2006-2017, ARM Limited, All Rights Reserved +# Copyright (C) 2018, ARM Limited, All Rights Reserved # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -20,11 +20,11 @@ from StringIO import StringIO from unittest import TestCase, main as unittest_main from mock import patch -from generate_code import * +from generate_test_code import * """ -Unit tests for generate_code.py +Unit tests for generate_test_code.py """ @@ -510,7 +510,7 @@ void test_func() s = StringIOWrapper('test_suite_ut.function', data) self.assertRaises(InvalidFileFormat, parse_function_code, s, [], []) - @patch("generate_code.parse_function_signature") + @patch("generate_test_code.parse_function_signature") def test_parse_function_signature_called(self, parse_function_signature_mock): """ Test parse_function_code() @@ -527,10 +527,10 @@ void test_func() self.assertTrue(parse_function_signature_mock.called) parse_function_signature_mock.assert_called_with('void test_func()\n') - @patch("generate_code.gen_dispatch") - @patch("generate_code.gen_deps") - @patch("generate_code.gen_function_wrapper") - @patch("generate_code.parse_function_signature") + @patch("generate_test_code.gen_dispatch") + @patch("generate_test_code.gen_deps") + @patch("generate_test_code.gen_function_wrapper") + @patch("generate_test_code.parse_function_signature") def test_return(self, parse_function_signature_mock, gen_function_wrapper_mock, gen_deps_mock, @@ -572,10 +572,10 @@ exit: self.assertEqual(code, expected) self.assertEqual(dispatch_code, "\n test_func_wrapper,\n") - @patch("generate_code.gen_dispatch") - @patch("generate_code.gen_deps") - @patch("generate_code.gen_function_wrapper") - @patch("generate_code.parse_function_signature") + @patch("generate_test_code.gen_dispatch") + @patch("generate_test_code.gen_deps") + @patch("generate_test_code.gen_function_wrapper") + @patch("generate_test_code.parse_function_signature") def test_with_exit_label(self, parse_function_signature_mock, gen_function_wrapper_mock, gen_deps_mock, @@ -620,7 +620,7 @@ class ParseFunction(TestCase): Test Suite for testing parse_functions() """ - @patch("generate_code.parse_until_pattern") + @patch("generate_test_code.parse_until_pattern") def test_begin_header(self, parse_until_pattern_mock): """ Test that begin header is checked and parse_until_pattern() is called. @@ -640,7 +640,7 @@ class ParseFunction(TestCase): parse_until_pattern_mock.assert_called_with(s, END_HEADER_REGEX) self.assertEqual(s.line_no, 2) - @patch("generate_code.parse_until_pattern") + @patch("generate_test_code.parse_until_pattern") def test_begin_helper(self, parse_until_pattern_mock): """ Test that begin helper is checked and parse_until_pattern() is called. @@ -661,7 +661,7 @@ void print_helloworld() parse_until_pattern_mock.assert_called_with(s, END_SUITE_HELPERS_REGEX) self.assertEqual(s.line_no, 2) - @patch("generate_code.parse_suite_deps") + @patch("generate_test_code.parse_suite_deps") def test_begin_dep(self, parse_suite_deps_mock): """ Test that begin dep is checked and parse_suite_deps() is called. @@ -680,7 +680,7 @@ void print_helloworld() parse_suite_deps_mock.assert_called_with(s) self.assertEqual(s.line_no, 2) - @patch("generate_code.parse_function_deps") + @patch("generate_test_code.parse_function_deps") def test_begin_function_dep(self, parse_function_deps_mock): """ Test that begin dep is checked and parse_function_deps() is called. @@ -700,8 +700,8 @@ void print_helloworld() parse_function_deps_mock.assert_called_with(deps_str) self.assertEqual(s.line_no, 2) - @patch("generate_code.parse_function_code") - @patch("generate_code.parse_function_deps") + @patch("generate_test_code.parse_function_code") + @patch("generate_test_code.parse_function_deps") def test_return(self, parse_function_deps_mock, parse_function_code_mock): """ Test that begin case is checked and parse_function_code() is called. @@ -1390,9 +1390,9 @@ class GenFromTestData(TestCase): Test suite for gen_from_test_data() """ - @patch("generate_code.write_deps") - @patch("generate_code.write_parameters") - @patch("generate_code.gen_suite_deps_checks") + @patch("generate_test_code.write_deps") + @patch("generate_test_code.write_parameters") + @patch("generate_test_code.gen_suite_deps_checks") def test_intermediate_data_file(self, gen_suite_deps_checks_mock, write_parameters_mock, write_deps_mock): """ Test that intermediate data file is written with expected data.