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 virtual void SetUp() 43 { 44 } 45 TearDown()46 virtual void TearDown() 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.Level1) 57 { 58 uint64_t deadline_us = 50000; 59 qos qos = qos_deadline_request; 60 61 interval qi = qos_interval_create(deadline_us, qos); 62 EXPECT_NE(&qi, nullptr); 63 64 qos = qos_max + 1; 65 interval qi1 = qos_interval_create(deadline_us, qos); 66 EXPECT_NE(&qi1, nullptr); 67 } 68 69 /** 70 * @tc.name: qos_interval_destroy_test 71 * @tc.desc: Test whether the qos_interval_destroy interface are normal. 72 * @tc.type: FUNC 73 */ 74 HWTEST_F(DeadlineTest, qos_interval_destroy_test, TestSize.Level1) 75 { 76 interval* qi = new interval(); 77 qos_interval_destroy(*qi); 78 79 uint64_t deadline_us = 50000; 80 qos qos = qos_max + 1; 81 82 interval qi1 = qos_interval_create(deadline_us, qos); 83 qos_interval_destroy(qi1); 84 } 85 86 /** 87 * @tc.name: qos_interval_begin_test 88 * @tc.desc: Test whether the qos_interval_begin interface are normal. 89 * @tc.type: FUNC 90 */ 91 HWTEST_F(DeadlineTest, qos_interval_begin_test, TestSize.Level1) 92 { 93 interval* qi = new interval(); 94 qos_interval_begin(*qi); 95 96 uint64_t deadline_us = 50000; 97 qos qos = qos_max + 1; 98 99 interval qi1 = qos_interval_create(deadline_us, qos); 100 qos_interval_begin(qi1); 101 } 102 103 /** 104 * @tc.name: qos_interval_update_test 105 * @tc.desc: Test whether the qos_interval_update interface are normal. 106 * @tc.type: FUNC 107 */ 108 HWTEST_F(DeadlineTest, qos_interval_update_test, TestSize.Level1) 109 { 110 uint64_t deadline_us = 50000; 111 qos qos = qos_max + 1; 112 uint64_t new_deadline_us = 40000; 113 interval* qi = new interval(); 114 qos_interval_update(*qi, new_deadline_us); 115 116 interval qi1 = qos_interval_create(deadline_us, qos); 117 qos_interval_update(qi1, new_deadline_us); 118 } 119 120 /** 121 * @tc.name: qos_interval_end_test 122 * @tc.desc: Test whether the qos_interval_end interface are normal. 123 * @tc.type: FUNC 124 */ 125 HWTEST_F(DeadlineTest, qos_interval_end_test, TestSize.Level1) 126 { 127 uint64_t deadline_us = 50000; 128 qos qos = qos_max + 1; 129 interval* qi = new interval(); 130 qos_interval_end(*qi); 131 132 interval qi1 = qos_interval_create(deadline_us, qos); 133 qos_interval_end(qi1); 134 } 135 136 /** 137 * @tc.name: qos_interval_join_test 138 * @tc.desc: Test whether the qos_interval_join interface are normal. 139 * @tc.type: FUNC 140 */ 141 HWTEST_F(DeadlineTest, qos_interval_join_test, TestSize.Level1) 142 { 143 uint64_t deadline_us = 50000; 144 qos qos = qos_deadline_request; 145 interval ret = qos_interval_create(deadline_us, qos); 146 qos_interval_join(ret); 147 148 qos = qos_max + 1; 149 interval ret1 = qos_interval_create(deadline_us, qos); 150 qos_interval_join(ret1); 151 } 152 153 /** 154 * @tc.name: qos_interval_leave_test 155 * @tc.desc: Test whether the qos_interval_leave interface are normal. 156 * @tc.type: FUNC 157 */ 158 HWTEST_F(DeadlineTest, qos_interval_leave_test, TestSize.Level1) 159 { 160 uint64_t deadline_us = 50000; 161 qos qos = qos_deadline_request; 162 interval ret = qos_interval_create(deadline_us, qos); 163 qos_interval_leave(ret); 164 165 qos = qos_max + 1; 166 interval ret1 = qos_interval_create(deadline_us, qos); 167 qos_interval_leave(ret1); 168 } 169