blob: 7fd104f292e75816d9ccaa9c6365a3fdcbafe7a5 [file] [log] [blame]
Julian Hall38c729b2020-11-23 18:23:03 +01001/*
Gabor Toth70cb3c62023-05-10 12:40:24 +02002 * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
Julian Hall38c729b2020-11-23 18:23:03 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Julian Hall38c729b2020-11-23 18:23:03 +01007#include <CppUTest/TestHarness.h>
Gabor Toth70cb3c62023-05-10 12:40:24 +02008#include <app/ts-demo/ts-demo.h>
9#include <protocols/rpc/common/packed-c/encoding.h>
julhal01c3f4e9a2020-12-15 13:39:01 +000010#include <service/crypto/client/cpp/crypto_client.h>
Gabor Toth70cb3c62023-05-10 12:40:24 +020011#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>
julhal01c3f4e9a2020-12-15 13:39:01 +000014
Gabor Toth70cb3c62023-05-10 12:40:24 +020015TEST_GROUP(TsDemoTests)
16{
17 void setup()
18 {
19 m_rpc_session = NULL;
20 m_crypto_service_context = NULL;
21 m_crypto_client = NULL;
Julian Hall38c729b2020-11-23 18:23:03 +010022
Gabor Toth70cb3c62023-05-10 12:40:24 +020023 service_locator_init();
Julian Hall38c729b2020-11-23 18:23:03 +010024
Gabor Toth70cb3c62023-05-10 12:40:24 +020025 m_crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0");
26 CHECK(m_crypto_service_context);
julhal01c3f4e9a2020-12-15 13:39:01 +000027
Gabor Toth70cb3c62023-05-10 12:40:24 +020028 m_rpc_session = service_context_open(m_crypto_service_context);
29 CHECK(m_rpc_session);
julhal01c3f4e9a2020-12-15 13:39:01 +000030
Gabor Toth70cb3c62023-05-10 12:40:24 +020031 (void)psa_crypto_client_init(m_rpc_session);
julhal01c3f4e9a2020-12-15 13:39:01 +000032
Gabor Toth70cb3c62023-05-10 12:40:24 +020033 m_crypto_client = new packedc_crypto_client(m_rpc_session);
Imre Kisb059dfb2022-05-31 14:39:28 +020034 }
Julian Hall38c729b2020-11-23 18:23:03 +010035
Gabor Toth70cb3c62023-05-10 12:40:24 +020036 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 Hall38c729b2020-11-23 18:23:03 +010056};
57
58TEST(TsDemoTests, runTsDemo)
59{
Gabor Toth70cb3c62023-05-10 12:40:24 +020060 int status = run_ts_demo(false);
61 CHECK_EQUAL(0, status);
Julian Hall38c729b2020-11-23 18:23:03 +010062}