Debian Codegraph @

prov/efa/test/efa_unit_test_send.c

raw
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 #include "ofi_util.h"
6 #include "efa_rdm_ep.h"
7
8 #define MSG_SIZE 10
9
10 void test_efa_rdm_msg_send_to_local_peer_with_null_desc(struct efa_resource **state)
11 {
12 struct efa_resource *resource = *state;
13 char buf[MSG_SIZE];
14 int i;
15 struct iovec iov;
16 struct efa_ep_addr raw_addr;
17 size_t raw_addr_len = sizeof(raw_addr);
18 fi_addr_t addr;
19 int ret;
20 struct fi_msg msg = {0};
21 struct fi_msg_tagged tmsg = {0};
22
23 efa_unit_test_resource_construct(resource, FI_EP_RDM, EFA_FABRIC_NAME);
24
25 ret = fi_getname(&resource->ep->fid, &raw_addr, &raw_addr_len);
26 assert_int_equal(ret, 0);
27
28 raw_addr.qpn = 1;
29 raw_addr.qkey = 0x1234;
30 ret = fi_av_insert(resource->av, &raw_addr, 1, &addr, 0 /* flags */, NULL /* context */);
31 assert_int_equal(ret, 1);
32
33 for (i = 0; i < MSG_SIZE; i++)
34 buf[i] = 'a' + i;
35
36 iov.iov_base = buf;
37 iov.iov_len = MSG_SIZE;
38
39 efa_unit_test_construct_msg(&msg, &iov, 1, addr, NULL, 0, NULL);
40
41 efa_unit_test_construct_tmsg(&tmsg, &iov, 1, addr, NULL, 0, NULL, 0, 0);
42
43 /* The peer won't be verified by shm so it is expected that EAGAIN will be returned */
44 ret = fi_send(resource->ep, buf, MSG_SIZE, NULL, addr, NULL);
45 assert_int_equal(ret, -FI_EAGAIN);
46
47 ret = fi_sendv(resource->ep, &iov, NULL, 1, addr, NULL);
48 assert_int_equal(ret, -FI_EAGAIN);
49
50 ret = fi_senddata(resource->ep, buf, MSG_SIZE, NULL, 0, addr, NULL);
51 assert_int_equal(ret, -FI_EAGAIN);
52
53 ret = fi_sendmsg(resource->ep, &msg, 0);
54 assert_int_equal(ret, -FI_EAGAIN);
55
56 ret = fi_tsend(resource->ep, buf, MSG_SIZE, NULL, addr, 0, NULL);
57 assert_int_equal(ret, -FI_EAGAIN);
58
59 ret = fi_tsendv(resource->ep, &iov, NULL, 1, addr, 0, NULL);
60 assert_int_equal(ret, -FI_EAGAIN);
61
62 ret = fi_tsenddata(resource->ep, buf, MSG_SIZE, NULL, 0, addr, 0, NULL);
63 assert_int_equal(ret, -FI_EAGAIN);
64
65 ret = fi_tsendmsg(resource->ep, &tmsg, 0);
66 assert_int_equal(ret, -FI_EAGAIN);
67 }