• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <exception>
16 #include <iostream>
17 #include <string>
18 #include <thread>
19 #include <gtest/gtest.h>
20 #include <unistd.h>
21 #include <cstring>
22 #include <cstdint>
23 #include <cstdio>
24 #include <functional>
25 #include "sp_utils.h"
26 #include "sp_log.h"
27 #include "sp_task.h"
28 #include "parameters.h"
29 #include "GPU.h"
30 #include "effective.h"
31 using namespace testing::ext;
32 using namespace std;
33 
34 namespace OHOS {
35 namespace SmartPerf {
36 class SPdaemonTaskTest : public testing::Test {
37 public:
SetUpTestCase()38     static void SetUpTestCase() {}
TearDownTestCase()39     static void TearDownTestCase() {}
SetUp()40     void SetUp() {}
TearDown()41     void TearDown() {}
42 };
43 
44 /**
45  * @tc.name: CheckTcpParamTestCase
46  * @tc.desc: Test CheckTcpParam
47  * @tc.type: FUNC
48  */
49 HWTEST_F(SPdaemonTaskTest, CheckTcpParamTestCase001, TestSize.Level1)
50 {
51     std::string str = "-SESSIONID 12345678 -INTERVAL 1000 -PKG ohos.samples.ecg -c -g -t -p -f -r -o";
52     std::string errorInfo = "";
53     SPTask &spTask = SPTask::GetInstance();
54     bool flag = spTask.CheckTcpParam(str, errorInfo);
55     EXPECT_TRUE(flag);
56 }
57 
58 HWTEST_F(SPdaemonTaskTest, CheckTcpParamTestCase002, TestSize.Level1)
59 {
60     std::string str = "";
61     std::string errorInfo = "";
62     SPTask &spTask = SPTask::GetInstance();
63     bool flag = spTask.CheckTcpParam(str, errorInfo);
64     EXPECT_FALSE(flag);
65 }
66 
67 HWTEST_F(SPdaemonTaskTest, CheckTcpParamTestCase003, TestSize.Level1)
68 {
69     std::string str = "";
70     std::string errorInfo = "";
71     SPTask &spTask = SPTask::GetInstance();
72     bool flag = spTask.CheckTcpParam(str, errorInfo);
73     EXPECT_FALSE(flag);
74 }
75 
76 /**
77  * @tc.name: GpuRkTestCase
78  * @tc.desc: Gpu rkflag is true
79  * @tc.type: FUNC
80  */
81 HWTEST_F(SPdaemonTaskTest, GpuRkTestCase, TestSize.Level1)
82 {
83     std::string str = "";
84     std::string errorInfo = "";
85     GPU &gpu = GPU::GetInstance();
86     gpu.SetRkFlag();
87     std::map<std::string, std::string> result = gpu.ItemData();
88     EXPECT_NE(result.size(), 0);
89 }
90 }
91 }