2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-test-suite-utils.h>
19 #include <dali/integration-api/lockless-buffer.h>
20 #include <dali/public-api/dali-core.h>
29 static bool ReadTest(Integration::LocklessBuffer& buf, const unsigned char exp[], size_t size)
31 const unsigned char* res = buf.Read();
32 for(size_t i = 0; i < size; ++i, ++res)
36 tet_printf("FAIL: expected 0x%X result 0x%X\n", (int)exp[i], (int)*res);
42 } // anonymous namespace
44 // Simple write - read test
45 int UtcDaliLocklessBufferWriteRead01(void)
47 Integration::LocklessBuffer buf(10);
48 unsigned char data[10];
50 for(unsigned char i = 0; i < 10; ++i)
55 buf.Write(&data[0], 10);
57 if(ReadTest(buf, data, 10))
68 // test multiple writes, one read
69 int UtcDaliLocklessBufferMultipleWrites01(void)
71 Integration::LocklessBuffer buf(10);
72 unsigned char data[10];
74 for(unsigned char i = 0; i < 10; ++i)
80 buf.Write(&data[0], 10);
82 for(unsigned char i = 0; i < 10; ++i)
87 // No reads from buffer, so will overwrite contents of same buffer
88 buf.Write(&data[0], 10);
90 if(ReadTest(buf, data, 10))
101 // test one writes, multiple read
102 int UtcDaliLocklessBufferMultipleWrites02(void)
104 Integration::LocklessBuffer buf(10);
105 unsigned char data[10];
107 for(unsigned char i = 0; i < 10; ++i)
113 buf.Write(&data[0], 10);
115 if(ReadTest(buf, data, 10))
117 tet_result(TET_PASS);
121 tet_result(TET_FAIL);
124 // ReadTest one more time. for coverity.
125 if(ReadTest(buf, data, 10))
127 tet_result(TET_PASS);
131 tet_result(TET_FAIL);
134 for(unsigned char i = 0; i < 10; ++i)
139 // No reads from buffer, so will overwrite contents of same buffer
140 buf.Write(&data[0], 10);
142 if(ReadTest(buf, data, 10))
144 tet_result(TET_PASS);
148 tet_result(TET_FAIL);
151 // ReadTest one more time. for coverity.
152 if(ReadTest(buf, data, 10))
154 tet_result(TET_PASS);
158 tet_result(TET_FAIL);
165 int UtcDaliLocklessBufferGetSize01(void)
167 Integration::LocklessBuffer buf(10);
168 unsigned int size = buf.GetSize();
171 tet_result(TET_PASS);
175 tet_result(TET_FAIL);