1/* 2 * Copyright (C) 2024 HiHope Open Source Organization. 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 <cerrno> 17#include <cstdio> 18#include <cstdlib> 19#include <string> 20#include <vector> 21#include <fcntl.h> 22#include <unistd.h> 23#include <arpa/inet.h> 24#include <gtest/gtest.h> 25#include <netinet/in.h> 26#include <sys/stat.h> 27#include <sys/socket.h> 28#include <sys/types.h> 29#include "securec.h" 30 31using namespace testing::ext; 32 33class HatsSchedgetprioritymaxTest : public testing::Test { 34public: 35static void SetUpTestCase(); 36static void TearDownTestCase(); 37void SetUp(); 38void TearDown(); 39private: 40}; 41void HatsSchedgetprioritymaxTest::SetUp() 42{ 43} 44void HatsSchedgetprioritymaxTest::TearDown() 45{ 46} 47void HatsSchedgetprioritymaxTest::SetUpTestCase() 48{ 49} 50void HatsSchedgetprioritymaxTest::TearDownTestCase() 51{ 52} 53 54/* 55 * @tc.number : SUB_KERNEL_SYSCALL_SCHEDGETPRIORITYMAX_0100 56 * @tc.name : SchedgetprioritymaxOfPolicySuccess_0001 57 * @tc.desc : sched_get_priority_max of scheduling policy success. 58 * @tc.size : MediumTest 59 * @tc.type : Function 60 * @tc.level : Level 1 61 */ 62HWTEST_F(HatsSchedgetprioritymaxTest, SchedgetprioritymaxOfPolicySuccess_0001, Function | MediumTest | Level1) 63{ 64 int ret = sched_get_priority_max(SCHED_OTHER); // SCHED_OTHER is 0 65 EXPECT_TRUE(ret >= 0); 66 67 ret = sched_get_priority_max(SCHED_FIFO); 68 EXPECT_TRUE(ret >= 0); 69 70 ret = sched_get_priority_max(SCHED_RR); 71 EXPECT_TRUE(ret >= 0); 72} 73 74/* 75 * @tc.number : SUB_KERNEL_SYSCALL_SCHEDGETPRIORITYMAX_0200 76 * @tc.name : SchedgetprioritymaxInvalidPolicyFail_0002 77 * @tc.desc : sched_get_priority_max use invalid policy fail, errno EINVAL. 78 * @tc.size : MediumTest 79 * @tc.type : Function 80 * @tc.level : Level 2 81 */ 82HWTEST_F(HatsSchedgetprioritymaxTest, SchedgetprioritymaxInvalidPolicyFail_0002, Function | MediumTest | Level2) 83{ 84 errno = 0; 85 int ret = sched_get_priority_max(-1); 86 EXPECT_EQ(ret, -1); 87 EXPECT_EQ(errno, EINVAL); 88}