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 "ecmascript/ecma_vm.h"
17 #include "ecmascript/napi/include/jsnapi.h"
18 #include "ecmascript/tests/test_helper.h"
19 #include "test/utils/test_list.h"
20
21 namespace panda::ecmascript::tooling::test {
22 using panda::test::TestHelper;
23
24 class DebuggerEntryTest : public testing::TestWithParam<const char *> {
25 public:
SetUpTestCase()26 static void SetUpTestCase()
27 {
28 GTEST_LOG_(INFO) << "SetUpTestCase";
29 }
30
TearDownTestCase()31 static void TearDownTestCase()
32 {
33 GTEST_LOG_(INFO) << "TearDownCase";
34 }
35
SetUp()36 void SetUp() override
37 {
38 SetCurrentTestName(GetParam());
39 TestHelper::CreateEcmaVMWithScope(instance, thread, scope);
40 JSNApi::StartDebugger(DEBUGGER_TEST_LIBRARY, instance, true);
41 }
42
TearDown()43 void TearDown() override
44 {
45 JSNApi::StopDebugger(instance);
46 TestHelper::DestroyEcmaVMWithScope(instance, scope);
47 }
48
49 EcmaVM *instance {nullptr};
50 EcmaHandleScope *scope {nullptr};
51 JSThread *thread {nullptr};
52 };
53
HWTEST_P_L0(DebuggerEntryTest,DebuggerSuite)54 HWTEST_P_L0(DebuggerEntryTest, DebuggerSuite)
55 {
56 std::string testName = GetCurrentTestName();
57 std::cout << "Running " << testName << std::endl;
58 ASSERT_NE(instance, nullptr);
59 auto [pandaFile, entryPoint] = GetTestEntryPoint(testName);
60 auto res = JSNApi::Execute(instance, pandaFile.c_str(), entryPoint.c_str());
61 ASSERT_TRUE(res);
62 }
63
64 INSTANTIATE_TEST_SUITE_P(DebugAbcTest, DebuggerEntryTest, testing::ValuesIn(GetTestList()));
65 } // namespace panda::ecmascript::tooling::test
66