1 /* 2 * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <CppUTest/TestHarness.h> 8 #include <app/ts-demo/ts-demo.h> 9 #include <protocols/rpc/common/packed-c/encoding.h> 10 #include <service/crypto/client/cpp/crypto_client.h> 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> 14 TEST_GROUP(TsDemoTests)15TEST_GROUP(TsDemoTests) 16 { 17 void setup() 18 { 19 m_rpc_session = NULL; 20 m_crypto_service_context = NULL; 21 m_crypto_client = NULL; 22 23 service_locator_init(); 24 25 m_crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0"); 26 CHECK(m_crypto_service_context); 27 28 m_rpc_session = service_context_open(m_crypto_service_context); 29 CHECK(m_rpc_session); 30 31 (void)psa_crypto_client_init(m_rpc_session); 32 33 m_crypto_client = new packedc_crypto_client(m_rpc_session); 34 } 35 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; 56 }; 57 TEST(TsDemoTests,runTsDemo)58TEST(TsDemoTests, runTsDemo) 59 { 60 int status = run_ts_demo(false); 61 CHECK_EQUAL(0, status); 62 } 63