From 0170c6c7c34ce6e5b59d6ffd54cdba32527659fc Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome@forissier.org>
Date: Tue, 10 Nov 2020 17:24:05 +0100
Subject: [PATCH] Introduce BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS

Conditionally enable TA C++ tests in the optee_test_ext Buildroot package.
Some toolchains may not support this feature [1] so it is best to let
the user decide.

common.mk enables the tests by default when $(COMPILER) is not clang,
assuming that the default GCC toolchain from toolchain.mk is used (which
works fine with the C++ tests). The command line option is
'make WITH_CXX_TESTS=y|n'.

Link: https://github.com/OP-TEE/optee_test/issues/458
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
---
 br-ext/package/optee_test_ext/Config.in         | 6 ++++++
 br-ext/package/optee_test_ext/optee_test_ext.mk | 4 ++++
 common.mk                                       | 5 +++++
 3 files changed, 15 insertions(+)

diff --git a/br-ext/package/optee_test_ext/Config.in b/br-ext/package/optee_test_ext/Config.in
index e613185..dd4a4d7 100644
--- a/br-ext/package/optee_test_ext/Config.in
+++ b/br-ext/package/optee_test_ext/Config.in
@@ -43,4 +43,10 @@ config BR2_PACKAGE_OPTEE_TEST_EXT_WITH_TLS_TESTS
 	  Select Thread Local Storage tests in Trusted Applications. Some
 	  toolchains may not support this.
 
+config BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS
+	bool "with-cxx-tests"
+	help
+	  Select C++ tests in Trusted Applications. Some toolchains may not
+	  support this.
+
 endif
diff --git a/br-ext/package/optee_test_ext/optee_test_ext.mk b/br-ext/package/optee_test_ext/optee_test_ext.mk
index b05d0a0..5476fc8 100644
--- a/br-ext/package/optee_test_ext/optee_test_ext.mk
+++ b/br-ext/package/optee_test_ext/optee_test_ext.mk
@@ -19,6 +19,10 @@ ifneq ($(BR2_PACKAGE_OPTEE_TEST_EXT_WITH_TLS_TESTS),)
 TARGET_CONFIGURE_OPTS += WITH_TLS_TESTS=$(BR2_PACKAGE_OPTEE_TEST_EXT_WITH_TLS_TESTS)
 endif
 
+ifneq ($(BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS),)
+TARGET_CONFIGURE_OPTS += WITH_CXX_TESTS=$(BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS)
+endif
+
 define OPTEE_TEST_EXT_PREPARE_GP_SUITE
 	sh $(@D)/host/xtest/gp/prepare_suite.sh $(@D) \
 		$(BR2_PACKAGE_OPTEE_TEST_EXT_GP_PACKAGE)
diff --git a/common.mk b/common.mk
index 80d7e5c..28bbbd8 100644
--- a/common.mk
+++ b/common.mk
@@ -48,6 +48,10 @@ CFG_TEE_BENCHMARK		?= n
 
 # optee_test
 WITH_TLS_TESTS			?= y
+ifneq ($(COMPILER),clang)
+# assuming GCC toolchain from toolchain.mk
+WITH_CXX_TESTS			?= y
+endif
 
 CCACHE ?= $(shell which ccache) # Don't remove this comment (space is needed)
 
@@ -270,6 +274,7 @@ BR2_PACKAGE_OPTEE_TEST_EXT_SDK ?= $(OPTEE_OS_TA_DEV_KIT_DIR)
 BR2_PACKAGE_OPTEE_TEST_EXT_SITE ?= $(OPTEE_TEST_PATH)
 BR2_PACKAGE_OPTEE_TEST_EXT_GP_PACKAGE := $(GP_PACKAGE)
 BR2_PACKAGE_OPTEE_TEST_EXT_WITH_TLS_TESTS := $(WITH_TLS_TESTS)
+BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS := $(WITH_CXX_TESTS)
 BR2_PACKAGE_STRACE ?= y
 BR2_TARGET_GENERIC_GETTY_PORT ?= $(if $(CFG_NW_CONSOLE_UART),ttyAMA$(CFG_NW_CONSOLE_UART),ttyAMA0)
 
-- 
GitLab