Add gbs option to enable the TZ backend support
authorPawel Kowalski <p.kowalski2@partner.samsung.com>
Wed, 28 Nov 2018 10:51:13 +0000 (11:51 +0100)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 3 Dec 2018 14:28:50 +0000 (15:28 +0100)
To enable the TZ backend support add following option to the gbs build:
--define "tz_backend ON". If the option is not set or is set to value
different than ON, the TZ backend support is disabled (it is disabled by
default).
When the TZ backend is disabled, some tests (T6* and T7*) are not built.

The same option has been added to the key-manager (branch tizen).

The key-manager-ta requires the following gbs option for these tests to
work properly: --define "test_key ON".

Change-Id: If1c27d8ae556f6882f65c4ace8bb4c1759656893

packaging/security-tests.spec
src/ckm/privileged/CMakeLists.txt
src/ckm/privileged/ckm-privileged-common.h
src/ckm/privileged/initial-values.cpp

index 66e47ac..6b4955e 100644 (file)
@@ -36,6 +36,7 @@ Requires: diffutils
 
 %global ckm_test_dir %{?TZ_SYS_SHARE:%TZ_SYS_SHARE/ckm-test/}%{!?TZ_SYS_SHARE:/usr/share/ckm-test/}
 %global ckm_rw_data_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm/}%{!?TZ_SYS_DATA:/opt/data/ckm/}
+%global tz_backend_enabled %{?tz_backend:%tz_backend}%{!?tz_backend:OFF}
 
 %description
 Security tests repository - for tests that can't be kept together with code.
@@ -48,6 +49,9 @@ cp %{SOURCE1} .
 export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib"
 
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+%if %{tz_backend_enabled} == ON
+        -DTZ_BACKEND="ON"                 \
+%endif
         -DDPL_LOG="ON"                    \
         -DDPL_WITH_DLOG="ON"              \
         -DVERSION=%{version}              \
index a7ac264..e212862 100644 (file)
@@ -22,6 +22,11 @@ PKG_CHECK_MODULES(CKM_DEP
     dbus-1
 )
 
+OPTION("TZ_BACKEND" OFF)
+IF(TZ_BACKEND)
+    ADD_DEFINITIONS("-DTZ_BACKEND")
+ENDIF(TZ_BACKEND)
+
 SET(CKM_SOURCES
     access_provider2.cpp
     async-api.cpp
index f70168a..2cd62b0 100644 (file)
 #pragma once
 
 #include <string>
+#include <dpl/test/test_runner.h>
+
+#define RUNNER_TEST_DUMMY(Proc, ...) \
+    void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple DPL_UNUSED)
+
+#ifdef TZ_BACKEND
+#define RUNNER_TEST_TZ_BACKEND(...) RUNNER_TEST(__VA_ARGS__)
+#else
+#define RUNNER_TEST_TZ_BACKEND(...) RUNNER_TEST_DUMMY(__VA_ARGS__)
+#endif
 
 // service lifecycle management
 enum ServiceIdx {
index 168d5ca..ce2a76d 100644 (file)
@@ -130,7 +130,7 @@ CKM::RawBuffer hexToBin(std::string &hex) {
 
 RUNNER_TEST_GROUP_INIT(T60_INITIAL_VALUES);
 
-RUNNER_TEST(T6001_init)
+RUNNER_TEST_TZ_BACKEND(T6001_init)
 {
     // [prepare]
     // remove database 0
@@ -155,7 +155,7 @@ RUNNER_TEST(T6001_init)
     test_exists(format_dest_path(XML_3_wrong), false);
 }
 
-RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP)
+RUNNER_TEST_TZ_BACKEND(T6010_PARSE_XML_FILE_AT_STARTUP)
 {
     // [test1]
     // check items existence as system service
@@ -200,7 +200,7 @@ RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP)
     }
 }
 
-RUNNER_TEST(T6020_PARSE_TWO_XML_FILES_AT_STARTUP)
+RUNNER_TEST_TZ_BACKEND(T6020_PARSE_TWO_XML_FILES_AT_STARTUP)
 {
     // [test]
     // check items existence as system service
@@ -216,7 +216,7 @@ RUNNER_TEST(T6020_PARSE_TWO_XML_FILES_AT_STARTUP)
     check_read_allowed(XML_2_EXPECTED_DATA_1.c_str(), XML_2_EXPECTED_DATA_1_DATA);
 }
 
-RUNNER_TEST(T6030_PARSE_FAIL_XML_AT_STARTUP)
+RUNNER_TEST_TZ_BACKEND(T6030_PARSE_FAIL_XML_AT_STARTUP)
 {
     // [test]
     // check items existence as system service - nothing should be available
@@ -226,7 +226,7 @@ RUNNER_TEST(T6030_PARSE_FAIL_XML_AT_STARTUP)
     check_read_not_visible(XML_3_EXPECTED_DATA_1.c_str());
 }
 
-RUNNER_TEST(T6040_CHECK_KEYS_VALID)
+RUNNER_TEST_TZ_BACKEND(T6040_CHECK_KEYS_VALID)
 {
     // [test]
     // check if key can create & verify signature
@@ -270,7 +270,7 @@ RUNNER_TEST(T6040_CHECK_KEYS_VALID)
     ckmc_buffer_free(signature);
 }
 
-RUNNER_TEST(T6050_ENCRYPTED_KEY)
+RUNNER_TEST_TZ_BACKEND(T6050_ENCRYPTED_KEY)
 {
     // [prepare]
     // to encrypt using RSA OAEP:  openssl rsautl -encrypt -oaep -pubin -inkey pub.key -in input.txt -out cipher.out
@@ -318,7 +318,7 @@ RUNNER_TEST(T6050_ENCRYPTED_KEY)
     ckmc_buffer_free(signature);
 }
 
-RUNNER_TEST(T6060_ENCRYPTED_ASCII_DATA)
+RUNNER_TEST_TZ_BACKEND(T6060_ENCRYPTED_ASCII_DATA)
 {
     // [prepare]
     // to encrypt using RSA OAEP:  openssl rsautl -encrypt -oaep -pubin -inkey pub.key -in input.txt -out cipher.out
@@ -339,7 +339,7 @@ RUNNER_TEST(T6060_ENCRYPTED_ASCII_DATA)
     ckmc_buffer_free(testData1);
 }
 
-RUNNER_TEST(T6070_ENCRYPTED_BIG_DATA)
+RUNNER_TEST_TZ_BACKEND(T6070_ENCRYPTED_BIG_DATA)
 {
     // [prepare]
     // to encrypt using RSA OAEP:  openssl rsautl -encrypt -oaep -pubin -inkey pub.key -in input.txt -out cipher.out
@@ -358,12 +358,12 @@ RUNNER_TEST(T6070_ENCRYPTED_BIG_DATA)
     ckmc_buffer_free(testData1);
 }
 
-RUNNER_TEST(T6999_deinit)
+RUNNER_TEST_TZ_BACKEND(T6999_deinit)
 {
     remove_user_data(0);
 }
 
-RUNNER_TEST(T7000_Encrypted_initial_values)
+RUNNER_TEST_TZ_BACKEND(T7000_Encrypted_initial_values)
 {
     int temp;
     std::string message  = "16c9efbc342777c0e36d59019582d59be8385bdea5497cf092f99ce5430498e9";