• 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 
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::DebugOption debugOption = {DEBUGGER_TEST_LIBRARY, true};
41         JSNApi::StartDebugger(instance, debugOption);
42     }
43 
TearDown()44     void TearDown() override
45     {
46         JSNApi::StopDebugger(instance);
47         TestHelper::DestroyEcmaVMWithScope(instance, scope);
48     }
49 
50     EcmaVM *instance {nullptr};
51     EcmaHandleScope *scope {nullptr};
52     JSThread *thread {nullptr};
53 };
54 
HWTEST_P_L0(DebuggerEntryTest,DebuggerSuite)55 HWTEST_P_L0(DebuggerEntryTest, DebuggerSuite)
56 {
57     std::string testName = GetCurrentTestName();
58     std::cout << "Running " << testName << std::endl;
59     ASSERT_NE(instance, nullptr);
60     auto [pandaFile, entryPoint] = GetTestEntryPoint(testName);
61     auto res = JSNApi::Execute(instance, pandaFile.c_str(), entryPoint.c_str());
62     ASSERT_TRUE(res);
63 }
64 
65 INSTANTIATE_TEST_SUITE_P(DebugAbcTest, DebuggerEntryTest, testing::ValuesIn(GetTestList()));
66 }  // namespace panda::ecmascript::tooling::test
67