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