• 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 #ifndef HDC_UT_RUNTIME_H
16 #define HDC_UT_RUNTIME_H
17 #include "ut_common.h"
18 
19 namespace HdcTest {
20 class Runtime {
21 public:
22     enum UtModType {
23         UT_MOD_BASE,
24         UT_MOD_SHELL,
25         UT_MOD_SHELL_INTERACTIVE,
26         UT_MOD_FILE,
27         UT_MOD_FORWARD,
28         UT_MOD_APP,
29     };
30     Runtime();
31     ~Runtime();
32     bool Initial(bool bConnectToDaemonIn);
33     bool CheckEntry(UtModType type);
34 
35     bool ResetUtTmpFolder();
36     bool ResetUtTmpFile(string file);
37     int InnerCall(int method);
GetRuntimeLoop()38     uv_loop_t *GetRuntimeLoop()
39     {
40         return &loopMain;
41     };
42 
43 private:
44     static void DoCheck(uv_timer_t *handle);
45     static void StartServer(uv_work_t *arg);
46     static void StartDaemon(uv_work_t *arg);
47     static void CheckStopServer(uv_idle_t *arg);
48     static void CheckStopDaemon(uv_idle_t *arg);
49     void WorkerPendding();
50     int CheckServerDaemonReady();
51 
52     bool serverRunning;
53     bool daemonRunning;
54     bool bCheckResult;
55     bool checkFinish;
56     bool hashInitialize;
57     UtModType checkType;
58     uv_loop_t loopMain;
59     uv_idle_t checkServerStop;
60     uv_idle_t checkDaemonStop;
61     Hdc::HdcServer *server;
62     void *daemon;  // Hdc::HdcDaemon *
63     uint8_t waitServerDaemonReadyCount = 0;
64     bool bConnectToDaemon = false;
65 };
66 }  // namespace HdcTest
67 #endif  // HDC_FUNC_TEST_H