Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 1 | /* |
Imre Kis | b059dfb | 2022-05-31 14:39:28 +0200 | [diff] [blame] | 2 | * Copyright (c) 2020-2022, 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 | |
| 7 | #include <app/ts-demo/ts-demo.h> |
Julian Hall | 7a70340 | 2021-08-04 09:20:43 +0100 | [diff] [blame] | 8 | #include <service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 9 | #include <protocols/rpc/common/packed-c/encoding.h> |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 10 | #include <CppUTest/TestHarness.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 11 | #include <service_locator.h> |
| 12 | #include <service/crypto/client/cpp/crypto_client.h> |
| 13 | |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 14 | |
| 15 | TEST_GROUP(TsDemoTests) { |
| 16 | |
| 17 | void setup() |
| 18 | { |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 19 | m_rpc_session = NULL; |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 20 | m_crypto_service_context = NULL; |
| 21 | m_crypto_client = NULL; |
| 22 | |
| 23 | service_locator_init(); |
| 24 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 25 | m_crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0"); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 26 | CHECK(m_crypto_service_context); |
| 27 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +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 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 31 | m_crypto_client = new packedc_crypto_client(m_rpc_session); |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | void teardown() |
| 35 | { |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 36 | delete m_crypto_client; |
| 37 | m_crypto_client = NULL; |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 38 | |
Imre Kis | b059dfb | 2022-05-31 14:39:28 +0200 | [diff] [blame] | 39 | if (m_crypto_service_context) { |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 40 | if (m_rpc_session) { |
| 41 | service_context_close(m_crypto_service_context, m_rpc_session); |
| 42 | m_rpc_session = NULL; |
Imre Kis | b059dfb | 2022-05-31 14:39:28 +0200 | [diff] [blame] | 43 | } |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 44 | |
Imre Kis | b059dfb | 2022-05-31 14:39:28 +0200 | [diff] [blame] | 45 | service_context_relinquish(m_crypto_service_context); |
| 46 | m_crypto_service_context = NULL; |
| 47 | } |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 50 | struct rpc_caller_session *m_rpc_session; |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 51 | struct service_context *m_crypto_service_context; |
| 52 | crypto_client *m_crypto_client; |
Julian Hall | 38c729b | 2020-11-23 18:23:03 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | TEST(TsDemoTests, runTsDemo) |
| 56 | { |
| 57 | int status = run_ts_demo(m_crypto_client, false); |
| 58 | CHECK_EQUAL(0, status); |
| 59 | } |