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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/lockless-buffer.h>
23 #include <dali-test-suite-utils.h>
30 static bool ReadTest(Integration::LocklessBuffer& buf, const unsigned char exp[], size_t size)
32 const unsigned char *res = buf.Read();
33 for (size_t i=0; i<size; ++i, ++res)
37 tet_printf("FAIL: expected 0x%X result 0x%X\n", (int)exp[i], (int)*res);
43 } // anonymous namespace
46 // Simple write - read test
47 int UtcDaliLocklessBufferWriteRead01(void)
49 Integration::LocklessBuffer buf(10);
50 unsigned char data[10];
52 for( unsigned char i=0; i<10; ++i )
57 buf.Write( &data[0], 10 );
59 if( ReadTest( buf, data, 10 ) )
70 // test multiple writes, one read
71 int UtcDaliLocklessBufferMultipleWrites01(void)
73 Integration::LocklessBuffer buf(10);
74 unsigned char data[10];
76 for( unsigned char i=0; i<10; ++i )
82 buf.Write( &data[0], 10 );
84 for (unsigned char i=0; i<10; ++i)
89 // No reads from buffer, so will overwrite contents of same buffer
90 buf.Write( &data[0], 10 );
92 if( ReadTest(buf, data, 10) )
104 int UtcDaliLocklessBufferGetSize01(void)
106 Integration::LocklessBuffer buf(10);
107 unsigned int size = buf.GetSize();
110 tet_result(TET_PASS);
114 tet_result(TET_FAIL);