test_tle_udp_stream.cpp 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#include "test_tle_udp_stream.h"
17
18TEST_F(test_tle_udp_stream, stream_test_open)
19{
20	stream = tle_udp_stream_open(ctx,
21			(const struct tle_udp_stream_param *)&stream_prm);
22	EXPECT_NE(stream, nullptr);
23	ret = tle_udp_stream_close(stream);
24
25	EXPECT_EQ(ret, 0);
26}
27
28TEST_F(test_tle_udp_stream, stream_test_open_nullctx)
29{
30	stream = tle_udp_stream_open(nullptr,
31			(const struct tle_udp_stream_param *)&stream_prm);
32	EXPECT_EQ(stream, nullptr);
33	EXPECT_EQ(rte_errno, EINVAL);
34
35	ret = tle_udp_stream_close(stream);
36	EXPECT_EQ(ret, EINVAL);
37}
38
39TEST_F(test_tle_udp_stream, stream_test_open_null_stream_prm)
40{
41	stream = tle_udp_stream_open(ctx, nullptr);
42	EXPECT_EQ(stream, nullptr);
43	EXPECT_EQ(rte_errno, EINVAL);
44
45	ret = tle_udp_stream_close(stream);
46	EXPECT_EQ(ret, EINVAL);
47}
48
49
50TEST_F(test_tle_udp_stream, stream_test_open_close_open_close)
51{
52	stream = tle_udp_stream_open(ctx,
53			(const struct tle_udp_stream_param *)&stream_prm);
54	EXPECT_NE(stream, nullptr);
55
56	ret = tle_udp_stream_close(stream);
57	EXPECT_EQ(ret, 0);
58
59	stream = tle_udp_stream_open(ctx,
60			(const struct tle_udp_stream_param*)&stream_prm);
61	EXPECT_NE(stream, nullptr);
62
63	ret = tle_udp_stream_close(stream);
64	EXPECT_EQ(ret, 0);
65}
66
67TEST_F(test_tle_udp_stream, stream_test_close)
68{
69	stream = tle_udp_stream_open(ctx,
70			(const struct tle_udp_stream_param *)&stream_prm);
71	EXPECT_NE(stream, nullptr);
72
73	ret = tle_udp_stream_close(stream);
74	EXPECT_EQ(ret, 0);
75}
76
77TEST_F(test_tle_udp_stream, stream_test_close_null)
78{
79	ret = tle_udp_stream_close(nullptr);
80	EXPECT_EQ(ret, EINVAL);
81}
82
83
84TEST_F(test_tle_udp_stream, stream_test_close_already)
85{
86	stream = tle_udp_stream_open(ctx,
87			(const struct tle_udp_stream_param *)&stream_prm);
88	EXPECT_NE(stream, nullptr);
89
90	ret = tle_udp_stream_close(stream);
91	EXPECT_EQ(ret, 0);
92
93	ret = tle_udp_stream_close(stream);
94	EXPECT_NE(ret, 0);
95}
96
97TEST_F(test_tle_udp_stream, stream_get_param)
98{
99	struct tle_udp_stream_param prm;
100
101	stream = tle_udp_stream_open(ctx,
102			(const struct tle_udp_stream_param *)&stream_prm);
103	EXPECT_NE(stream, nullptr);
104
105	ret = tle_udp_stream_get_param(stream,&prm);
106	EXPECT_EQ(ret, 0);
107}
108
109TEST_F(test_tle_udp_stream, stream_get_param_streamnull)
110{
111	struct tle_udp_stream_param prm;
112
113	stream = tle_udp_stream_open(ctx,
114			(const struct tle_udp_stream_param *)&stream_prm);
115	EXPECT_NE(stream, nullptr);
116
117	ret = tle_udp_stream_get_param(nullptr, &prm);
118	EXPECT_EQ(ret, EINVAL);
119}
120
121TEST_F(test_tle_udp_stream, stream_get_param_prmnull)
122{
123	struct tle_udp_stream_param prm;
124
125	stream = tle_udp_stream_open(ctx,
126			(const struct tle_udp_stream_param *)&stream_prm);
127	EXPECT_NE(stream, nullptr);
128
129	ret = tle_udp_stream_get_param(stream, nullptr);
130	EXPECT_EQ(ret, EINVAL);
131}
132
133
134
135