Imre Kis | b272481 | 2021-11-12 17:02:24 +0100 | [diff] [blame^] | 1 | // SPDX-License-Identifier: BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include <CppUTestExt/MockSupport.h> |
| 7 | #include "mock_rpc_interface.h" |
| 8 | #include "call_req_comparator.h" |
| 9 | |
| 10 | static call_req_comparator req_comparator(call_req_comparator::mode_ignore_opstatus); |
| 11 | |
| 12 | void mock_rpc_interface_init(void) |
| 13 | { |
| 14 | mock().installComparator("call_req", req_comparator); |
| 15 | } |
| 16 | |
| 17 | void expect_mock_rpc_interface_receive(struct rpc_interface *iface, |
| 18 | const struct call_req *req, rpc_status_t result) |
| 19 | { |
| 20 | mock().expectOneCall("rpc_interface_receive"). |
| 21 | onObject(iface). |
| 22 | withOutputParameterReturning("opstatus", &req->opstatus, sizeof(req->opstatus)). |
| 23 | withOutputParameterReturning("resp_buf_data_len", &req->resp_buf.data_len, |
| 24 | sizeof(req->resp_buf.data_len)). |
| 25 | withParameterOfType("call_req", "req", req). |
| 26 | andReturnValue(result); |
| 27 | } |
| 28 | |
| 29 | rpc_status_t mock_rpc_interface_receive(struct rpc_interface *iface, |
| 30 | struct call_req *req) |
| 31 | { |
| 32 | return mock().actualCall("rpc_interface_receive"). |
| 33 | onObject(iface). |
| 34 | withOutputParameter("opstatus", &req->opstatus). |
| 35 | withOutputParameter("resp_buf_data_len", &req->resp_buf.data_len). |
| 36 | withParameterOfType("call_req", "req", req). |
| 37 | returnIntValue(); |
| 38 | } |