| 1 |
/* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only */ |
| 2 |
/* SPDX-FileCopyrightText: Copyright Amazon.com, Inc. or its affiliates. All rights reserved. */ |
| 3 |
|
| 4 |
#include "efa_unit_tests.h" |
| 5 |
|
| 6 |
/* |
| 7 |
* test the error handling path of efa_device_construct() |
| 8 |
*/ |
| 9 |
void test_efa_device_construct_error_handling() |
| 10 |
{ |
| 11 |
int ibv_err = 4242; |
| 12 |
struct ibv_device **ibv_device_list; |
| 13 |
struct efa_device efa_device = {0}; |
| 14 |
|
| 15 |
ibv_device_list = ibv_get_device_list(&g_device_cnt); |
| 16 |
if (ibv_device_list == NULL) { |
| 17 |
skip(); |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
g_efa_unit_test_mocks.efadv_query_device = &efa_mock_efadv_query_device_return_mock; |
| 22 |
will_return(efa_mock_efadv_query_device_return_mock, ibv_err); |
| 23 |
|
| 24 |
efa_device_construct(&efa_device, 0, ibv_device_list[0]); |
| 25 |
|
| 26 |
/* when error happend, resources in efa_device should be NULL */ |
| 27 |
assert_null(efa_device.ibv_ctx); |
| 28 |
assert_null(efa_device.rdm_info); |
| 29 |
assert_null(efa_device.dgram_info); |
| 30 |
} |
| 31 |
|