• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
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 <gtest/gtest.h>
17 #include <thread>
18 #include <cstring>
19 #include <algorithm>
20 #include <sched.h>
21 #include <unistd.h>
22 #include <sys/syscall.h>
23 #include <sys/resource.h>
24 
25 #define private public
26 #include "eu/worker_thread.h"
27 #undef private
28 
29 using namespace testing;
30 using namespace testing::ext;
31 using namespace ffrt;
32 
33 class WorkerThreadTest : public testing::Test {
34 protected:
SetUpTestCase()35     static void SetUpTestCase()
36     {
37     }
38 
TearDownTestCase()39     static void TearDownTestCase()
40     {
41     }
42 
SetUp()43     virtual void SetUp()
44     {
45     }
46 
TearDown()47     virtual void TearDown()
48     {
49     }
50 };
51 
52 /**
53  * @tc.name: IdleTest
54  * @tc.desc: Test whether the Idle interface are normal.
55  * @tc.type: FUNC
56  */
57 HWTEST_F(WorkerThreadTest, IdleTest, TestSize.Level1)
58 {
59     WorkerThread* wt = new WorkerThread(6);
60     bool ret = wt->Idle();
61     EXPECT_FALSE(ret);
62 }
63 
64 /**
65  * @tc.name: SetIdleTest
66  * @tc.desc: Test whether the SetIdle interface are normal.
67  * @tc.type: FUNC
68  */
69 HWTEST_F(WorkerThreadTest, SetIdleTest, TestSize.Level1)
70 {
71     WorkerThread* wt = new WorkerThread(6);
72     bool var = false;
73     wt->SetIdle(var);
74     EXPECT_FALSE(wt->idle);
75 }
76 
77 /**
78  * @tc.name: ExitedTest
79  * @tc.desc: Test whether the Exited interface are normal.
80  * @tc.type: FUNC
81  */
82 HWTEST_F(WorkerThreadTest, ExitedTest, TestSize.Level1)
83 {
84     WorkerThread* wt = new WorkerThread(6);
85     bool ret = wt->Exited();
86     EXPECT_FALSE(ret);
87 }
88 
89 /**
90  * @tc.name: SetExitedTest
91  * @tc.desc: Test whether the SetExited interface are normal.
92  * @tc.type: FUNC
93  */
94 HWTEST_F(WorkerThreadTest, SetExitedTest, TestSize.Level1)
95 {
96     WorkerThread* wt = new WorkerThread(6);
97     bool var = false;
98     wt->SetExited(var);
99     EXPECT_FALSE(wt->exited);
100 }
101 
102 /**
103  * @tc.name: GetQosTest
104  * @tc.desc: Test whether the GetQos interface are normal.
105  * @tc.type: FUNC
106  */
107 HWTEST_F(WorkerThreadTest, GetQosTest, TestSize.Level1)
108 {
109     WorkerThread* wt = new WorkerThread(6);
110     QoS ret = wt->GetQos();
111 }
112 
113 /**
114  * @tc.name: JoinTest
115  * @tc.desc: Test whether the Join interface are normal.
116  * @tc.type: FUNC
117  */
118 HWTEST_F(WorkerThreadTest, JoinTest, TestSize.Level1)
119 {
120     WorkerThread* wt = new WorkerThread(6);
121     wt->Join();
122 }
123 
124 /**
125  * @tc.name: DetachTest
126  * @tc.desc: Test whether the Detach interface are normal.
127  * @tc.type: FUNC
128  */
129 HWTEST_F(WorkerThreadTest, DetachTest, TestSize.Level1)
130 {
131     WorkerThread* wt = new WorkerThread(6);
132     wt->Detach();
133 }
134