2 * Copyright (c) 2020 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/devel-api/threading/thread.h>
24 #include <type_traits>
30 volatile bool gRunThreadEntryFunc = false;
32 class TestThread : public Thread
36 gRunThreadEntryFunc = true;
41 int UtcDaliThreadP(void)
43 tet_infoline("Testing Dali::Thread");
45 gRunThreadEntryFunc = false;
50 // wait till the thread is terminated
51 while(!gRunThreadEntryFunc)
53 usleep(1); // 1 microsecond
55 DALI_TEST_EQUALS(true, gRunThreadEntryFunc, TEST_LOCATION);
59 // Restart the thread after joined
60 gRunThreadEntryFunc = false;
63 // wait till the thread is terminated
64 while(!gRunThreadEntryFunc)
66 usleep(1); // 1 microsecond
68 DALI_TEST_EQUALS(true, gRunThreadEntryFunc, TEST_LOCATION);
73 int UtcDaliThreadNonCopyable(void)
75 // we want to make sure that mutex is not copyable (its copy constructor is not defined)
76 // this test will stop compiling if Mutex has compiler generated copy constructor
77 static_assert(!__has_trivial_copy(Thread), "Thread should NOT be copyable");
79 DALI_TEST_CHECK(true);