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
16 #include "test/utils/test_entry.h"
17
18 #include <thread>
19
20 #include "test/utils/test_hooks.h"
21 #include "test/utils/test_list.h"
22
23 namespace panda::ecmascript::tooling::test {
24 static std::thread g_debuggerThread;
25 static std::unique_ptr<TestHooks> g_hooks = nullptr;
26
StartDebuggerImpl(const std::string & name,EcmaVM * vm,bool isDebugMode)27 bool StartDebuggerImpl([[maybe_unused]] const std::string &name, EcmaVM *vm, [[maybe_unused]] bool isDebugMode)
28 {
29 std::string testName = GetCurrentTestName();
30 g_hooks = std::make_unique<TestHooks>(testName, vm);
31 g_debuggerThread = std::thread([] {
32 TestUtil::WaitForInit();
33 g_hooks->Run();
34 });
35 return true;
36 }
37
StopDebuggerImpl(const std::string & name)38 bool StopDebuggerImpl([[maybe_unused]] const std::string &name)
39 {
40 g_hooks->TerminateTest();
41 g_debuggerThread.join();
42 g_hooks.reset();
43 return true;
44 }
45 } // namespace panda::ecmascript::tooling::test
46