void test_entry(val_api_t *val_api, psa_api_t *psa_api) { int32_t status = VAL_STATUS_SUCCESS; val = val_api; psa = psa_api; /* test init */ val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); if (!IS_TEST_START(val->get_status())) { goto test_exit; } /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ status = val->execute_non_secure_tests(TEST_NUM, test_c012_crypto_list, FALSE); if (VAL_ERROR(status)) { goto test_exit; } test_exit: val->crypto_function(VAL_CRYPTO_FREE); val->test_exit(); }
/** @brief - This function executes given list of tests from non-secure sequentially This covers non-secure to secure IPC API scenario @param - test_num : Test_num @param - tests_list : list of tests to be executed @param - server_hs : Initiate a server handshake @return - val_status_t **/ val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t *tests_list, bool_t server_hs) { val_status_t status = VAL_STATUS_SUCCESS; int32_t test_status = VAL_STATUS_SUCCESS; psa_handle_t handle; uint32_t i = 1; test_info_t test_info; char testcase_name[100] = ""; bool continue_test = true; test_info.test_num = test_num; mbed_val_print(PRINT_TEST, "[Info] Executing tests from non-secure\n", 0); while (tests_list[i] != NULL) { memset(testcase_name, 0, 100); sprintf(testcase_name, "Check%d", i); GREENTEA_TESTCASE_START(testcase_name); if (server_hs == TRUE) { /* Handshake with server tests */ test_info.block_num = i; status = mbed_val_execute_secure_test_func(&handle, test_info, SERVER_TEST_DISPATCHER_SID); if (VAL_ERROR(status)) { mbed_val_set_status(RESULT_FAIL(status)); mbed_val_print(PRINT_ERROR, "[Check%d] START\n", i); return status; } else { mbed_val_print(PRINT_DEBUG, "[Check%d] START\n", i); } } /* Execute client tests */ test_status = tests_list[i](NONSECURE); if (server_hs == TRUE) { /* Retrive Server test status */ status = mbed_val_get_secure_test_result(&handle); } if (test_status != VAL_STATUS_SUCCESS) { status = VAL_STATUS_ERROR; } if (IS_TEST_SKIP(status)) { mbed_val_set_status(status); mbed_val_print(PRINT_DEBUG, "[Check%d] SKIPPED\n", i); GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); continue_test = false; } else if (VAL_ERROR(status)) { mbed_val_set_status(RESULT_FAIL(status)); if (server_hs == TRUE) mbed_val_print(PRINT_ERROR, "[Check%d] FAILED\n", i); GREENTEA_TESTCASE_FINISH(testcase_name, 0, 1); continue_test = false; } else { if (server_hs == TRUE) mbed_val_print(PRINT_DEBUG, "[Check%d] PASSED\n", i); GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); continue_test = true; } if (!continue_test) { return status; } i++; } return status; }
int validate_UdiRootConfig(UdiRootConfig *config, int validateFlags) { if (config == NULL) return -1; #define VAL_ERROR(message, code) { \ fprintf(stderr, "%s\n", message); \ return code; \ } if (validateFlags & UDIROOT_VAL_PARSE) { if (config->udiMountPoint == NULL || strlen(config->udiMountPoint) == 0) { VAL_ERROR("Base mount point \"udiMount\" is not defined", UDIROOT_VAL_PARSE); } if (config->loopMountPoint == NULL || strlen(config->loopMountPoint) == 0) { VAL_ERROR("Loop mount mount \"loopMount\" is not defined", UDIROOT_VAL_PARSE); } if (config->imageBasePath == NULL || strlen(config->imageBasePath) == 0) { VAL_ERROR("\"imagePath\" is not defined", UDIROOT_VAL_PARSE); } if (config->udiRootPath == NULL || strlen(config->udiRootPath) == 0) { VAL_ERROR("\"udiRootPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->etcPath == NULL || strlen(config->etcPath) == 0) { VAL_ERROR("\"etcPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->modprobePath == NULL || strlen(config->modprobePath) == 0) { VAL_ERROR("\"modprobePath\" is not defined", UDIROOT_VAL_PARSE); } if (config->insmodPath == NULL || strlen(config->insmodPath) == 0) { VAL_ERROR("\"insmodPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->cpPath == NULL || strlen(config->cpPath) == 0) { VAL_ERROR("\"cpPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->mvPath == NULL || strlen(config->mvPath) == 0) { VAL_ERROR("\"mvPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->chmodPath == NULL || strlen(config->chmodPath) == 0) { VAL_ERROR("\"chmodPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->ddPath == NULL || strlen(config->ddPath) == 0) { VAL_ERROR("\"ddPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->mkfsXfsPath == NULL || strlen(config->mkfsXfsPath) == 0) { VAL_ERROR("\"mkfsXfsPath\" is not defined", UDIROOT_VAL_PARSE); } if (config->rootfsType == NULL || strlen(config->rootfsType) == 0) { VAL_ERROR("\"rootfsType\" is not defined", UDIROOT_VAL_PARSE); } } if (validateFlags & UDIROOT_VAL_FILEVAL) { struct stat statData; if (stat(config->modprobePath, &statData) != 0) { VAL_ERROR("Specified \"modprobePath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"modprobePath\" is not executable.", UDIROOT_VAL_FILEVAL); } if (stat(config->insmodPath, &statData) != 0) { VAL_ERROR("Specified \"insmodPath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"insmodPath\" is not executable.", UDIROOT_VAL_FILEVAL); } if (stat(config->cpPath, &statData) != 0) { VAL_ERROR("Specified \"cpPath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"cpPath\" is not executable.", UDIROOT_VAL_FILEVAL); } if (stat(config->mvPath, &statData) != 0) { VAL_ERROR("Specified \"mvPath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"mvPath\" is not executable.", UDIROOT_VAL_FILEVAL); } if (stat(config->chmodPath, &statData) != 0) { VAL_ERROR("Specified \"chmodPath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"chmodPath\" is not executable.", UDIROOT_VAL_FILEVAL); } if (stat(config->ddPath, &statData) != 0) { VAL_ERROR("Specified \"ddPath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"ddPath\" is not executable.", UDIROOT_VAL_FILEVAL); } if (stat(config->mkfsXfsPath, &statData) != 0) { VAL_ERROR("Specified \"mkfsXfsPath\" doesn't appear to exist.", UDIROOT_VAL_FILEVAL); } else if (!(statData.st_mode & S_IXUSR)) { VAL_ERROR("Specified \"mkfsXfsPath\" is not executable.", UDIROOT_VAL_FILEVAL); } } return 0; }