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 <csignal>
20 #include <string>
21 #include <vector>
22 #include <fcntl.h>
23 #include <unistd.h>
24 #include <malloc.h>
25 #include <arpa/inet.h>
26 #include <gtest/gtest.h>
27 #include <netinet/in.h>
28 #include <sys/stat.h>
29 #include <sys/mman.h>
30 #include <sys/socket.h>
31 #include <sys/types.h>
32 #include "securec.h"
33
34 using namespace testing::ext;
35
36 class HatsBrkTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp();
41 void TearDown();
42 private:
43 };
SetUp()44 void HatsBrkTest::SetUp()
45 {
46 }
47
TearDown()48 void HatsBrkTest::TearDown()
49 {
50 }
51
SetUpTestCase()52 void HatsBrkTest::SetUpTestCase()
53 {
54 }
55
TearDownTestCase()56 void HatsBrkTest::TearDownTestCase()
57 {
58 }
59
60 /*
61 * @tc.number : SUB_KERNEL_SYSCALL_BRK_0100
62 * @tc.name : BrkDataEndFailed_0001
63 * @tc.desc : brk data end always failed.
64 * @tc.size : MediumTest
65 * @tc.type : Function
66 * @tc.level : Level 2
67 */
HWTEST_F(HatsBrkTest, BrkDataEndFailed_0001, Function | MediumTest | Level2)68 HWTEST_F(HatsBrkTest, BrkDataEndFailed_0001, Function | MediumTest | Level2)
69 {
70 errno = 0;
71 int ret = brk(nullptr);
72 EXPECT_EQ(ret, -1);
73 EXPECT_EQ(errno, ENOMEM);
74 }
75