Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 1 | /* |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 2 | * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved. |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 7 | #include <CppUTest/TestHarness.h> |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 8 | #include <app/ts-demo/ts-demo.h> |
| 9 | #include <protocols/rpc/common/packed-c/encoding.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 10 | #include <service/crypto/client/cpp/crypto_client.h> |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 11 | #include <service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h> |
| 12 | #include <service/crypto/client/psa/psa_crypto_client.h> |
| 13 | #include <service_locator.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 14 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 15 | TEST_GROUP(TsDemoTests) |
| 16 | { |
| 17 | void setup() |
| 18 | { |
| 19 | m_rpc_session = NULL; |
| 20 | m_crypto_service_context = NULL; |
| 21 | m_crypto_client = NULL; |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 22 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 23 | service_locator_init(); |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 24 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 25 | m_crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0"); |
| 26 | CHECK(m_crypto_service_context); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 27 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 28 | m_rpc_session = service_context_open(m_crypto_service_context); |
| 29 | CHECK(m_rpc_session); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 30 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 31 | (void)psa_crypto_client_init(m_rpc_session); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 32 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 33 | m_crypto_client = new packedc_crypto_client(m_rpc_session); |
Imre Kis | b059dfb | 2022-05-31 14:39:28 +0200 | [diff] [blame] | 34 | } |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 35 | |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 36 | void teardown() |
| 37 | { |
| 38 | delete m_crypto_client; |
| 39 | m_crypto_client = NULL; |
| 40 | |
| 41 | if (m_crypto_service_context) { |
| 42 | if (m_rpc_session) { |
| 43 | service_context_close(m_crypto_service_context, m_rpc_session); |
| 44 | m_rpc_session = NULL; |
| 45 | } |
| 46 | |
| 47 | psa_crypto_client_deinit(); |
| 48 | service_context_relinquish(m_crypto_service_context); |
| 49 | m_crypto_service_context = NULL; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | struct rpc_caller_session *m_rpc_session; |
| 54 | struct service_context *m_crypto_service_context; |
| 55 | crypto_client *m_crypto_client; |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | TEST(TsDemoTests, runTsDemo) |
| 59 | { |
Gabor Toth | 70cb3c6 | 2023-05-10 12:40:24 +0200 | [diff] [blame^] | 60 | int status = run_ts_demo(false); |
| 61 | CHECK_EQUAL(0, status); |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 62 | } |