From: Tomasz Swierczek Date: Tue, 28 Nov 2017 17:29:44 +0000 (+0100) Subject: Fix tests to properly recognize "tef-dummy" environment X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bcaea11e5b8408ade550cadab8f95232ef8eea77;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Fix tests to properly recognize "tef-dummy" environment * Initialize TA only if security.tee feature is enabled * Change security.tee feature recognition to be old-device-proof * Change expected tef-dummy return value to NOT_IMPLEMENTED (following GP API spec) Change-Id: I2918ea4bc5952de9adb7e19c48ca163a79adb4fa --- diff --git a/src/libteec-tests/test_cases.cpp b/src/libteec-tests/test_cases.cpp index 4449a6d1..78859ab9 100644 --- a/src/libteec-tests/test_cases.cpp +++ b/src/libteec-tests/test_cases.cpp @@ -209,8 +209,14 @@ bool checkIfTeeEnabled() if (!isChecked) { int ret = system_info_get_platform_bool("tizen.org/feature/security.tee", &isEnabled); - RUNNER_ASSERT_MSG(ret == SYSTEM_INFO_ERROR_NONE, - "Failed to get system info. Error: " << systemInfoErrToString(ret)); + if (ret == SYSTEM_INFO_ERROR_INVALID_PARAMETER) + { + // device may be so old it does not have the security.tee setting in config at all + isEnabled = false; + } else { + RUNNER_ASSERT_MSG(ret == SYSTEM_INFO_ERROR_NONE, + "Failed to get system info. Error: " << systemInfoErrToString(ret)); + } isChecked = true; } return isEnabled; @@ -221,7 +227,7 @@ RUNNER_TEST_GROUP_INIT(LIBTEEC) RUNNER_CHILD_TEST(libteec_01_load_TA_as_app) { - Ta ta(taUuid); + auto taPtr = std::unique_ptr(nullptr); TemporaryTestUser tmpUser("libteec_01_test_user", GUM_USERTYPE_NORMAL); tmpUser.create(); @@ -233,6 +239,11 @@ RUNNER_CHILD_TEST(libteec_01_load_TA_as_app) bool isTeeEnabled = checkIfTeeEnabled(); + if (isTeeEnabled) + { + taPtr.reset(new Ta(taUuid)); + } + auto fun = [&]() { auto contextPtr = std::unique_ptr @@ -251,7 +262,7 @@ RUNNER_CHILD_TEST(libteec_01_load_TA_as_app) TEEC_Result res = TEEC_InitializeContext(NULL, &context); contextPtr.reset(&context); - TEEC_Result desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_SUPPORTED; + TEEC_Result desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_IMPLEMENTED; RUNNER_ASSERT_MSG(res == desiredResult, "Failed to initialize context. Error code: " << errToString(res) << ", expected: " << errToString(desiredResult)); @@ -261,7 +272,7 @@ RUNNER_CHILD_TEST(libteec_01_load_TA_as_app) &session, &taUuid, TEEC_LOGIN_PUBLIC, NULL, NULL, &returnOrigin); sessionPtr.reset(&session); - desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_SUPPORTED; + desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_IMPLEMENTED; RUNNER_ASSERT_MSG(res == desiredResult, "Opening libteec session returned wrong value: " << errToString(res) << ", expected: " << errToString(desiredResult)); @@ -277,10 +288,15 @@ RUNNER_CHILD_TEST(libteec_01_load_TA_as_app) RUNNER_CHILD_TEST(libteec_02_load_TA_as_system) { - Ta ta(taUuid); + auto taPtr = std::unique_ptr(nullptr); bool isTeeEnabled = checkIfTeeEnabled(); + if (isTeeEnabled) + { + taPtr.reset(new Ta(taUuid)); + } + auto fun = [&]() { auto contextPtr = std::unique_ptr @@ -297,7 +313,7 @@ RUNNER_CHILD_TEST(libteec_02_load_TA_as_system) TEEC_Result res = TEEC_InitializeContext(NULL, &context); contextPtr.reset(&context); - TEEC_Result desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_SUPPORTED; + TEEC_Result desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_IMPLEMENTED; RUNNER_ASSERT_MSG(res == desiredResult, "Failed to initialize context. Error code: " << errToString(res) << ", expected: " << errToString(desiredResult)); @@ -307,7 +323,7 @@ RUNNER_CHILD_TEST(libteec_02_load_TA_as_system) &session, &taUuid, TEEC_LOGIN_PUBLIC, NULL, NULL, &returnOrigin); sessionPtr.reset(&session); - desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_SUPPORTED; + desiredResult = isTeeEnabled ? TEEC_SUCCESS : TEEC_ERROR_NOT_IMPLEMENTED; RUNNER_ASSERT_MSG(res == desiredResult, "Opening libteec session returned wrong value: " << errToString(res) << ", expected: " << errToString(desiredResult)); @@ -378,7 +394,7 @@ RUNNER_CHILD_TEST(libteec_03_try_use_libteec_with_no_cynara_perm_as_app) contextPtr.reset(&context); // OpTEE return TEEC_ERROR_ITEM_NOT_FOUND, when cannot access to /dev/tee - TEEC_Result desiredResult = isTeeEnabled ? TEEC_ERROR_ACCESS_DENIED : TEEC_ERROR_NOT_SUPPORTED; + TEEC_Result desiredResult = isTeeEnabled ? TEEC_ERROR_ACCESS_DENIED : TEEC_ERROR_NOT_IMPLEMENTED; RUNNER_ASSERT_MSG(res == desiredResult, "Initializing context returned wrong error code: " << errToString(res) << ", expected: " << errToString(desiredResult)); @@ -413,7 +429,7 @@ RUNNER_CHILD_TEST(libteec_04_invalid_context_name) TEEC_Result res = TEEC_InitializeContext("Invalid context name", &context); contextPtr.reset(&context); - TEEC_Result desiredResult = isTeeEnabled ? TEEC_ERROR_ITEM_NOT_FOUND : TEEC_ERROR_NOT_SUPPORTED; + TEEC_Result desiredResult = isTeeEnabled ? TEEC_ERROR_ITEM_NOT_FOUND : TEEC_ERROR_NOT_IMPLEMENTED; RUNNER_ASSERT_MSG(res == desiredResult, "Initializing context returned wrong error code: " << errToString(res) << ", expected: " << errToString(desiredResult));