Introduce first version of TCP code.
[tldk.git] / test / gtest / test_tle_dring.cpp
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_dring.h"
17
18 TEST_F(dring, test_dring_st)
19 {
20         printf("%s started;\n", __func__);
21
22         tle_dring_reset(&dr);
23         r = init_drb_ring(OBJ_NUM);
24
25         ASSERT_NE(r, (void *) NULL) << "Out of memory";
26
27         tle_dring_dump(stdout, 1, &dr);
28
29         memset(&arg, 0, sizeof(arg));
30         arg[0].dr = &dr;
31         arg[0].r = r;
32         arg[0].iter = ITER_NUM;
33         arg[0].enq_type = SINGLE;
34         arg[0].deq_type = SINGLE;
35         rc = test_dring_enq_deq(&arg[0]);
36
37         rc = (rc != 0) ? rc : (arg[0].enq != arg[0].deq);
38         printf("%s finished with status: %s(%d);\n",
39                 __func__, strerror(-rc), rc);
40
41         tle_dring_dump(stdout, rc != 0, &dr);
42         fini_drb_ring(r);
43         EXPECT_EQ(rc, 0);
44 }
45
46
47 TEST_F(dring ,test_dring_mp_mc)
48 {
49         rc = test_dring_mt(MULTI, MULTI, MULTI, MULTI);
50         EXPECT_EQ(rc, 0);
51 }
52
53 TEST_F(dring, test_dring_mp_sc)
54 {
55         rc = test_dring_mt(MULTI, SINGLE, MULTI, NONE);
56         EXPECT_EQ(rc, 0);
57 }
58
59 TEST_F(dring, test_dring_sp_mc)
60 {
61         rc = test_dring_mt(SINGLE, MULTI, NONE, MULTI);
62         EXPECT_EQ(rc, 0);
63 }