blob: 92f736939c641c54216f4a2a9e883ea56216c518 [file] [log] [blame]
Julian Hall38c729b2020-11-23 18:23:03 +01001/*
Imre Kisb059dfb2022-05-31 14:39:28 +02002 * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
Julian Hall38c729b2020-11-23 18:23:03 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <app/ts-demo/ts-demo.h>
Julian Hall7a703402021-08-04 09:20:43 +01008#include <service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h>
julhal01c3f4e9a2020-12-15 13:39:01 +00009#include <protocols/rpc/common/packed-c/encoding.h>
Julian Hall38c729b2020-11-23 18:23:03 +010010#include <CppUTest/TestHarness.h>
julhal01c3f4e9a2020-12-15 13:39:01 +000011#include <service_locator.h>
12#include <service/crypto/client/cpp/crypto_client.h>
13
Julian Hall38c729b2020-11-23 18:23:03 +010014
15TEST_GROUP(TsDemoTests) {
16
17 void setup()
18 {
julhal01c3f4e9a2020-12-15 13:39:01 +000019 struct rpc_caller *caller;
20 int status;
21
22 m_rpc_session_handle = NULL;
23 m_crypto_service_context = NULL;
24 m_crypto_client = NULL;
25
26 service_locator_init();
27
28 m_crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0", &status);
29 CHECK(m_crypto_service_context);
30
julhal01734dbad2020-12-21 10:27:41 +000031 m_rpc_session_handle = service_context_open(m_crypto_service_context, TS_RPC_ENCODING_PACKED_C, &caller);
julhal01c3f4e9a2020-12-15 13:39:01 +000032 CHECK(m_rpc_session_handle);
33
julhal01734dbad2020-12-21 10:27:41 +000034 m_crypto_client = new packedc_crypto_client(caller);
Julian Hall38c729b2020-11-23 18:23:03 +010035 }
36
37 void teardown()
38 {
Julian Hall38c729b2020-11-23 18:23:03 +010039 delete m_crypto_client;
40 m_crypto_client = NULL;
julhal01c3f4e9a2020-12-15 13:39:01 +000041
Imre Kisb059dfb2022-05-31 14:39:28 +020042 if (m_crypto_service_context) {
43 if (m_rpc_session_handle) {
44 service_context_close(m_crypto_service_context, m_rpc_session_handle);
45 m_rpc_session_handle = NULL;
46 }
julhal01c3f4e9a2020-12-15 13:39:01 +000047
Imre Kisb059dfb2022-05-31 14:39:28 +020048 service_context_relinquish(m_crypto_service_context);
49 m_crypto_service_context = NULL;
50 }
Julian Hall38c729b2020-11-23 18:23:03 +010051 }
52
julhal01c3f4e9a2020-12-15 13:39:01 +000053 rpc_session_handle m_rpc_session_handle;
54 struct service_context *m_crypto_service_context;
55 crypto_client *m_crypto_client;
Julian Hall38c729b2020-11-23 18:23:03 +010056};
57
58TEST(TsDemoTests, runTsDemo)
59{
60 int status = run_ts_demo(m_crypto_client, false);
61 CHECK_EQUAL(0, status);
62}