1 /*
2 * Copyright (C) 2021 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 #include <gtest/gtest.h>
16
17 #include "dhcp_logger.h"
18 #include "dhcp_client_def.h"
19 #include "dhcp_function.h"
20 #include "securec.h"
21
22 DEFINE_DHCPLOG_DHCP_LABEL("DhcpClientTest");
23
24 using namespace testing::ext;
25
26 namespace OHOS {
27 class DhcpClientTest : public testing::Test {
28 public:
SetUpTestCase()29 static void SetUpTestCase()
30 {}
TearDownTestCase()31 static void TearDownTestCase()
32 {}
SetUp()33 virtual void SetUp()
34 {}
TearDown()35 virtual void TearDown()
36 {}
37 };
38
HWTEST_F(DhcpClientTest, GetProStatus_SUCCESS, TestSize.Level1)39 HWTEST_F(DhcpClientTest, GetProStatus_SUCCESS, TestSize.Level1)
40 {
41 DHCP_LOGE("enter GetProStatus_SUCCESS");
42 char workDir[DIR_MAX_LEN] = "./";
43 char pidFile[DIR_MAX_LEN] = "./wlan0.pid";
44 ASSERT_EQ(DHCP_OPT_SUCCESS, InitPidfile(workDir, pidFile, getpid()));
45 unlink(pidFile);
46 }
47
HWTEST_F(DhcpClientTest, StopProcess_SUCCESS, TestSize.Level1)48 HWTEST_F(DhcpClientTest, StopProcess_SUCCESS, TestSize.Level1)
49 {
50 char pidFile[DIR_MAX_LEN] = "./wlan0.pid";
51 char workDir[DIR_MAX_LEN] = "./";
52 pid_t testPid = 12345;
53 ASSERT_EQ(DHCP_OPT_SUCCESS, InitPidfile(workDir, pidFile, testPid));
54 unlink(pidFile);
55 }
56 } // namespace OHOS