• 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 "c/deadline.h"
19 #include "internal_inc/osal.h"
20 #include "sched/interval.h"
21 #include "dm/dependence_manager.h"
22 #include "sched/frame_interval.h"
23 #include "dfx/log/ffrt_log_api.h"
24 #include "common.h"
25 
26 using namespace testing;
27 #ifdef HWTEST_TESTING_EXT_ENABLE
28 using namespace testing::ext;
29 #endif
30 using namespace ffrt;
31 
32 class DeadlineTest : public testing::Test {
33 protected:
SetUpTestCase()34     static void SetUpTestCase()
35     {
36     }
37 
TearDownTestCase()38     static void TearDownTestCase()
39     {
40     }
41 
SetUp()42     void SetUp() override
43     {
44     }
45 
TearDown()46     void TearDown() override
47     {
48     }
49 };
50 
51 /**
52  * @tc.name: qos_interval_create_test
53  * @tc.desc: Test whether the qos_interval_create interface are normal.
54  * @tc.type: FUNC
55  */
56 HWTEST_F(DeadlineTest, qos_interval_create_test, TestSize.Level0)
57 {
58     uint64_t deadline_us = 50000;
59     qos qos = qos_deadline_request;
60     interval qi = qos_interval_create(deadline_us, qos);
61     EXPECT_NE(qi, nullptr);
62     qos_interval_destroy(qi);
63 }
64 
65 /**
66  * @tc.name: qos_interval_destroy_test
67  * @tc.desc: Test whether the qos_interval_destroy interface are normal.
68  * @tc.type: FUNC
69  */
70 HWTEST_F(DeadlineTest, qos_interval_destroy_test, TestSize.Level0)
71 {
72     uint64_t deadline_us = 50000;
73     qos qos = qos_deadline_request;
74     interval qi = qos_interval_create(deadline_us, qos);
75     EXPECT_NE(qi, nullptr);
76     qos_interval_destroy(qi);
77 }
78 
79 /**
80  * @tc.name: qos_interval_begin_test
81  * @tc.desc: Test whether the qos_interval_begin interface are normal.
82  * @tc.type: FUNC
83  */
84 HWTEST_F(DeadlineTest, qos_interval_begin_test, TestSize.Level0)
85 {
86     uint64_t deadline_us = 50000;
87     qos qos = qos_deadline_request;
88     interval qi = qos_interval_create(deadline_us, qos);
89     qos_interval_begin(qi);
90     qos_interval_destroy(qi);
91 }
92 
93 /**
94  * @tc.name: qos_interval_update_test
95  * @tc.desc: Test whether the qos_interval_update interface are normal.
96  * @tc.type: FUNC
97  */
98 HWTEST_F(DeadlineTest, qos_interval_update_test, TestSize.Level0)
99 {
100     uint64_t new_deadline_us = 40000;
101     uint64_t deadline_us = 50000;
102     qos qos = qos_deadline_request;
103     interval qi = qos_interval_create(deadline_us, qos);
104     qos_interval_update(qi, new_deadline_us);
105     qos_interval_destroy(qi);
106 }
107 
108 /**
109  * @tc.name: qos_interval_end_test
110  * @tc.desc: Test whether the qos_interval_end interface are normal.
111  * @tc.type: FUNC
112  */
113 HWTEST_F(DeadlineTest, qos_interval_end_test, TestSize.Level0)
114 {
115     uint64_t deadline_us = 50000;
116     qos qos = qos_deadline_request;
117     interval qi = qos_interval_create(deadline_us, qos);
118     qos_interval_end(qi);
119     qos_interval_destroy(qi);
120 }
121 
122 /**
123  * @tc.name: qos_interval_join_test
124  * @tc.desc: Test whether the qos_interval_join interface are normal.
125  * @tc.type: FUNC
126  */
127 HWTEST_F(DeadlineTest, qos_interval_join_test, TestSize.Level0)
128 {
129     uint64_t deadline_us = 50000;
130     qos qos = qos_deadline_request;
131     interval ret = qos_interval_create(deadline_us, qos);
132     EXPECT_NE(ret, nullptr);
133     qos_interval_join(ret);
134     qos_interval_destroy(ret);
135 }
136 
137 /**
138  * @tc.name: qos_interval_leave_test
139  * @tc.desc: Test whether the qos_interval_leave interface are normal.
140  * @tc.type: FUNC
141  */
142 HWTEST_F(DeadlineTest, qos_interval_leave_test, TestSize.Level0)
143 {
144     uint64_t deadline_us = 50000;
145     qos qos = qos_deadline_request;
146     interval ret = qos_interval_create(deadline_us, qos);
147     EXPECT_NE(ret, nullptr);
148     qos_interval_leave(ret);
149     qos_interval_destroy(ret);
150 }
151