Description: Build Qualcomm forked xtest_qtee test-suite
Author: Abhinaba Rakshit <abhinaba.rakshit@oss.qualcomm.com>
Origin: other, Qualcomm forked mink specific changes over OPTEE-Test
Last-Update: 2026-07-11
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: optee_test/CMakeLists.txt
===================================================================
--- optee_test.orig/CMakeLists.txt
+++ optee_test/CMakeLists.txt
@@ -1,8 +1,8 @@
-cmake_minimum_required (VERSION 3.4)
-project (optee_test C)
+cmake_minimum_required(VERSION 3.10)
+project (xtest_qtee C)
 
-# Default cross compile settings
-set (CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt)
+option(CFG_WERROR "Build with -Werror" FALSE)
+option(CFG_PKCS11_TA "Build with PKCS11" TRUE)
 
 set (OPTEE_TEST_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 ################################################################################
@@ -18,10 +18,14 @@ add_compile_options (
 	-Wmissing-prototypes -Wnested-externs
 	-Wpointer-arith -Wshadow -Wstrict-prototypes
 	-Wswitch-default -Wunsafe-loop-optimizations
-	-Wwrite-strings -Werror -fPIC
+	-Wwrite-strings -fPIC
  	-Wno-missing-field-initializers
-	-Wno-unused-parameter
+	-Wno-unused-parameter -Wno-alloc-size
+	-Wno-unterminated-string-initialization
 )
+if(CFG_WERROR)
+    add_compile_options(-Werror)
+endif(CFG_WERROR)
 
 find_program(CCACHE_FOUND ccache)
 if(CCACHE_FOUND)
@@ -30,5 +34,125 @@ if(CCACHE_FOUND)
 endif(CCACHE_FOUND)
 
 add_subdirectory (ta)
-add_subdirectory (host/xtest)
-add_subdirectory (host/supp_plugin)
+
+################################################################################
+# Packages
+################################################################################
+find_package(Threads REQUIRED)
+if(NOT THREADS_FOUND)
+	message(FATAL_ERROR "Threads not found")
+endif()
+
+find_package(OpenSSL)
+if(OPENSSL_FOUND)
+	add_compile_options(-DOPENSSL_FOUND=1 -DOPENSSL_API_COMPAT=10100)
+	set (OPENSSL_PRIVATE_LINK OpenSSL::Crypto)
+endif()
+
+find_package(Python REQUIRED)
+
+include(GNUInstallDirs)
+
+macro(EMBED_8100FILE prefix infile)
+	add_custom_command(
+		OUTPUT  regression_8100_${prefix}.h
+		COMMAND ${Python_EXECUTABLE} ${OPTEE_TEST_ROOT_DIR}/scripts/file_to_c.py --inf ${infile}
+	--out ${CMAKE_CURRENT_BINARY_DIR}/regression_8100_${prefix}.h
+	--name regression_8100_${prefix}
+		DEPENDS ${OPTEE_TEST_ROOT_DIR}/scripts/file_to_c.py ${infile}
+	)
+
+	set_property(SOURCE host/xtest/regression_8100.c APPEND PROPERTY OBJECT_DEPENDS
+		     ${CMAKE_CURRENT_BINARY_DIR}/regression_8100_${prefix}.h)
+endmacro(EMBED_8100FILE)
+
+EMBED_8100FILE(ca_crt ${OPTEE_TEST_ROOT_DIR}/cert/ca.crt)
+EMBED_8100FILE(mid_crt ${OPTEE_TEST_ROOT_DIR}/cert/mid.crt)
+EMBED_8100FILE(my_crt ${OPTEE_TEST_ROOT_DIR}/cert/my.crt)
+EMBED_8100FILE(my_csr ${OPTEE_TEST_ROOT_DIR}/cert/my.csr)
+
+set (SRC
+	host/xtest/adbg/src/adbg_case.c
+	host/xtest/adbg/src/adbg_enum.c
+	host/xtest/adbg/src/adbg_expect.c
+	host/xtest/adbg/src/adbg_log.c
+	host/xtest/adbg/src/adbg_run.c
+	host/xtest/adbg/src/security_utils_hex.c
+	host/xtest/aes_perf.c
+	host/xtest/benchmark_1000.c
+	host/xtest/benchmark_2000.c
+	host/xtest/clear_storage.c
+	host/xtest/regression_1000.c
+	host/xtest/regression_4000.c
+	host/xtest/regression_4100.c
+	host/xtest/regression_5000.c
+	host/xtest/regression_6000.c
+	host/xtest/regression_8000.c
+	host/xtest/regression_8100.c
+	host/xtest/hash_perf.c
+	host/xtest/stats.c
+	host/xtest/xtest_helpers.c
+	host/xtest/xtest_main.c
+	host/xtest/xtest_test.c
+	host/xtest/xtest_uuid_helpers.c
+)
+
+if (WITH_GP_TESTS)
+	add_compile_options(-DWITH_GP_TESTS=1)
+
+	macro(__GEN_GP_FILE outfile xmldir name basedir)
+		add_custom_command(
+			OUTPUT	${outfile}
+			COMMAND	xalan -in ${basedir}/${name}.xml
+				      -xsl gp/${name}.xsl -out ${outfile}
+			DEPENDS ${basedir}/${name}.xml gp/${name}.xsl
+		)
+	endmacro(__GEN_GP_FILE)
+	macro(GEN_GP_FILE outfile xmldir name)
+		__GEN_GP_FILE(${outfile} ${xmldir} ${name}
+			      gp-suite/packages/${xmldir})
+		list (APPEND SRC ${outfile})
+	endmacro(GEN_GP_FILE)
+
+	GEN_GP_FILE(gp_10000.c ClientAPI/xmlstable TEE)
+	GEN_GP_FILE(gp_20000.c TrustedCoreFw/xmlstable TEE_Internal_API)
+	GEN_GP_FILE(gp_30000.c DataStorage/xmlstable TEE_DataStorage_API)
+	GEN_GP_FILE(gp_40000.c Time_Arithmetical/xmlstable TEE_TimeArithm_API)
+	GEN_GP_FILE(gp_50000.c Crypto/xmlstable TEE_Crypto_API)
+	set (GP_INCLUDES PRIVATE host/xtest/gp/include)
+endif()
+
+if (CFG_PKCS11_TA)
+	add_compile_options(-DCFG_PKCS11_TA)
+	list (APPEND SRC host/xtest/pkcs11_1000.c)
+endif()
+
+################################################################################
+# Built binary
+################################################################################
+add_executable (${PROJECT_NAME} ${SRC})
+
+target_include_directories(${PROJECT_NAME}
+	PRIVATE host/xtest
+	PRIVATE host/supp_plugin/include
+	PRIVATE host/xtest/adbg/include
+	PRIVATE ${TA_DEV_KIT_DIR}/host_include
+	PRIVATE libteec/include
+	PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+	${GP_INCLUDES}
+)
+
+target_link_libraries (${PROJECT_NAME}
+	PRIVATE m
+	PRIVATE xtest-ta-headers
+	PRIVATE ckqteec
+	PRIVATE minkteec
+	PRIVATE minkadaptor
+	PRIVATE ${CMAKE_THREAD_LIBS_INIT}
+	PRIVATE ${OPENSSL_PRIVATE_LINK}
+)
+
+################################################################################
+# Install targets
+################################################################################
+install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
