blob: 2cc8973f9207582df4f0a9e315ecd38688c97ecb [file] [log] [blame]
Julian Hall38c729b2020-11-23 18:23:03 +01001/*
julhal01c3f4e9a2020-12-15 13:39:01 +00002 * Copyright (c) 2020-2021, 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
42 service_context_close(m_crypto_service_context, m_rpc_session_handle);
43 m_rpc_session_handle = NULL;
44
45 service_context_relinquish(m_crypto_service_context);
46 m_crypto_service_context = NULL;
Julian Hall38c729b2020-11-23 18:23:03 +010047 }
48
julhal01c3f4e9a2020-12-15 13:39:01 +000049 rpc_session_handle m_rpc_session_handle;
50 struct service_context *m_crypto_service_context;
51 crypto_client *m_crypto_client;
Julian Hall38c729b2020-11-23 18:23:03 +010052};
53
54TEST(TsDemoTests, runTsDemo)
55{
56 int status = run_ts_demo(m_crypto_client, false);
57 CHECK_EQUAL(0, status);
58}