test_tle_udp_dev.h revision a152c68e
1/*
2 * Copyright (c) 2016  Intel Corporation.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef TEST_TLE_UDP_DEV_H_
17#define TEST_TLE_UDP_DEV_H_
18
19#include <arpa/inet.h>
20#include <gtest/gtest.h>
21#include <rte_errno.h>
22#include <tle_udp_impl.h>
23
24#define RX_NO_OFFLOAD 0
25#define TX_NO_OFFLOAD 0
26
27class udp_dev : public ::testing::Test {
28
29public:
30	struct tle_udp_ctx *ctx;
31	struct tle_udp_dev *dev;
32	struct tle_udp_ctx_param prm;
33	struct tle_udp_dev_param dev_prm;
34
35	virtual void SetUp(void)
36	{
37		rte_errno = 0;
38		memset(&prm, 0, sizeof(prm));
39		prm.socket_id = SOCKET_ID_ANY;
40		prm.max_streams = 0x1;
41		prm.max_stream_rbufs = 0x1;
42		prm.max_stream_sbufs = 0x1;
43
44		memset(&dev_prm, 0, sizeof(dev_prm));
45
46		/* Offload irrelevant in these tests, set to 0 */
47		dev_prm.rx_offload = RX_NO_OFFLOAD;
48		dev_prm.tx_offload = TX_NO_OFFLOAD;
49		inet_pton(AF_INET, "192.168.2.1", &(dev_prm).local_addr4);
50		inet_pton(AF_INET6, "fe80::21e:67ff:fec2:2568",
51				&(dev_prm).local_addr6);
52
53		ctx = tle_udp_create(&prm);
54		ASSERT_NE(ctx, (void *) NULL);
55	}
56
57	virtual void TearDown(void)
58	{
59		tle_udp_destroy(ctx);
60	}
61};
62
63#endif /* TEST_TLE_UDP_DEV_H_ */
64