1 /*
2 * Copyright (c) 2017, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 #include "cm_test.h"
24
25 using CMRT_UMD::CmQueue;
26 class QueueTest: public CmTest
27 {
28 public:
QueueTest()29 QueueTest(): m_queue(nullptr) {}
30
~QueueTest()31 ~QueueTest() {}
32
CreateTwice()33 int32_t CreateTwice()
34 {
35 int32_t result = m_mockDevice->CreateQueue(m_queue);
36 EXPECT_EQ(CM_SUCCESS, result);
37 CmQueue *another_queue = nullptr;
38 result = m_mockDevice->CreateQueue(another_queue);
39 EXPECT_EQ(CM_SUCCESS, result);
40 EXPECT_EQ(m_queue, another_queue);
41 return CM_SUCCESS;
42 }//===================
43
EnqueueWithoutTask()44 int32_t EnqueueWithoutTask()
45 {
46 int32_t result = m_mockDevice->CreateQueue(m_queue);
47 EXPECT_EQ(CM_SUCCESS, result);
48 CMRT_UMD::CmEvent *event = nullptr;
49 result = m_queue->Enqueue(nullptr, event, nullptr);
50 EXPECT_EQ(CM_INVALID_ARG_VALUE, result);
51 result = m_queue->DestroyEvent(event);
52 EXPECT_NE(CM_SUCCESS, result);
53 return CM_SUCCESS;
54 }//===================
55
56 private:
57 CmQueue *m_queue;
58 };//=================
59
TEST_F(QueueTest,CreateTwice)60 TEST_F(QueueTest, CreateTwice)
61 {
62 RunEach<int32_t>(CM_SUCCESS,
63 [this]() { return CreateTwice(); });
64 return;
65 }//========
66
TEST_F(QueueTest,EnqueueWithoutTask)67 TEST_F(QueueTest, EnqueueWithoutTask)
68 {
69 RunEach<int32_t>(CM_SUCCESS,
70 [this]() { return EnqueueWithoutTask(); });
71 return;
72 }//========
73