mirror of
https://gitee.com/openharmony/arkcompiler_toolchain
synced 2024-11-23 23:49:50 +00:00
!25 Add tooling testcase
Merge pull request !25 from weng-changcheng/add_tooling_testcase
This commit is contained in:
commit
1f7b9b34f6
@ -11,6 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
|
||||
import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni")
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/toolchain/test/test_helper.gni")
|
||||
@ -47,7 +48,7 @@ test_js_files = [
|
||||
]
|
||||
|
||||
foreach(file, test_js_files) {
|
||||
ts2abc_gen_abc("gen_${file}_abc") {
|
||||
es2abc_gen_abc("gen_${file}_abc") {
|
||||
test_js = "${test_js_path}${file}.js"
|
||||
test_abc = "$target_out_dir/${file}.abc"
|
||||
|
||||
@ -112,16 +113,16 @@ source_set("jsdebugtest_set") {
|
||||
[ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ]
|
||||
}
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//arkcompiler/ets_runtime:libark_jsruntime_test",
|
||||
"//arkcompiler/toolchain/tooling:libark_ecma_debugger_test",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("jsdebugtest") {
|
||||
deps = [ ":jsdebugtest_set" ]
|
||||
|
||||
deps += [
|
||||
"//arkcompiler/ets_runtime:libark_jsruntime_test",
|
||||
"//arkcompiler/toolchain/tooling:libark_ecma_debugger_test",
|
||||
]
|
||||
|
||||
if (is_ohos && is_standard_system) {
|
||||
if (enable_hilog) {
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
@ -23,12 +23,6 @@ class JsBreakpointArrowTest : public TestEvents {
|
||||
public:
|
||||
JsBreakpointArrowTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -38,6 +32,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -23,12 +23,6 @@ class JsBreakpointAsyncTest : public TestEvents {
|
||||
public:
|
||||
JsBreakpointAsyncTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -38,6 +32,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -23,12 +23,6 @@ class JsBreakpointTest : public TestEvents {
|
||||
public:
|
||||
JsBreakpointTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -38,6 +32,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -23,12 +23,6 @@ class JsExceptionTest : public TestEvents {
|
||||
public:
|
||||
JsExceptionTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22:breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -61,6 +55,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22:breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -23,12 +23,6 @@ class JsRangeErrorTest : public TestEvents {
|
||||
public:
|
||||
JsRangeErrorTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(20, 0, pandaFile_.c_str()); // 20: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -61,6 +55,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(20, 0, pandaFile_.c_str()); // 20: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -23,12 +23,6 @@ class JsSingleStepTest : public TestEvents {
|
||||
public:
|
||||
JsSingleStepTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
locationStart_ = TestUtil::GetLocation(19, 0, pandaFile_.c_str()); // 19: line number
|
||||
locationEnd_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22: line number
|
||||
return true;
|
||||
};
|
||||
|
||||
vmDeath = [this]() {
|
||||
ASSERT_NE(stepCounter_, 0); // 0: step counter
|
||||
ASSERT_EQ(breakpointCounter_, 2); // 2: break point counter
|
||||
@ -36,6 +30,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
locationStart_ = TestUtil::GetLocation(19, 0, pandaFile_.c_str()); // 19: line number
|
||||
locationEnd_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22: line number
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
|
@ -23,18 +23,6 @@ class JsStepIntoTest : public TestEvents {
|
||||
public:
|
||||
JsStepIntoTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
// line number for breakpoint array
|
||||
size_t breakpoint[POINTER_SIZE][LINE_COLUMN] =
|
||||
{{84, 0}, {87, 0}, {27, 0}, {79, 0}, {42, 0}, {38, 0}, {56, 0}, {60, 0}, {96, 0}, {54, 0}};
|
||||
// line number for stepinto array
|
||||
size_t stepInto[STEP_SIZE][LINE_COLUMN] =
|
||||
{{85, 5}, {23, 0}, {73, 0}, {80, 0}, {36, 0}, {43, 0}, {50, 0}, {61, 0}, {97, 15}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepInto[0], STEP_SIZE, stepLocations_);
|
||||
return true;
|
||||
};
|
||||
|
||||
vmDeath = [this]() {
|
||||
ASSERT_EQ(breakpointCounter_, pointerLocations_.size());
|
||||
ASSERT_EQ(stepCompleteCounter_, stepLocations_.size());
|
||||
@ -42,6 +30,15 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
// line number for breakpoint array
|
||||
size_t breakpoint[POINTER_SIZE][LINE_COLUMN] =
|
||||
{{84, 0}, {87, 0}, {27, 0}, {79, 0}, {42, 0}, {38, 0}, {56, 0}, {60, 0}, {96, 0}, {54, 0}};
|
||||
// line number for stepinto array
|
||||
// 35 -> 36; 49 -> 50
|
||||
size_t stepInto[STEP_SIZE][LINE_COLUMN] =
|
||||
{{85, 5}, {23, 0}, {73, 0}, {80, 0}, {35, 0}, {43, 0}, {49, 0}, {61, 0}, {97, 15}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepInto[0], STEP_SIZE, stepLocations_);
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
debugger_->NotifyScriptParsed(0, moduleName.data());
|
||||
|
@ -23,16 +23,6 @@ class JsStepOutTest : public TestEvents {
|
||||
public:
|
||||
JsStepOutTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
// 74、36: line number for breakpoint array
|
||||
size_t breakpoint[5][2] = {{74, 0}, {36, 0}, {50, 0}, {61, 0}, {96, 0}};
|
||||
// 28: line number for stepinto array
|
||||
size_t stepOut[4][2] = {{28, 0}, {43, 0}, {57, 0}, {88, 5}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepOut[0], STEP_SIZE, stepLocations_);
|
||||
return true;
|
||||
};
|
||||
|
||||
vmDeath = [this]() {
|
||||
ASSERT_EQ(breakpointCounter_, pointerLocations_.size()); // size: break point counter
|
||||
ASSERT_EQ(stepCompleteCounter_, stepLocations_.size()); // size: step complete counter
|
||||
@ -40,6 +30,12 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
// 74、36: line number for breakpoint array
|
||||
size_t breakpoint[5][2] = {{74, 0}, {36, 0}, {50, 0}, {61, 0}, {96, 0}};
|
||||
// 28: line number for stepinto array
|
||||
size_t stepOut[4][2] = {{28, 0}, {43, 0}, {57, 0}, {88, 5}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepOut[0], STEP_SIZE, stepLocations_);
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
debugger_->NotifyScriptParsed(0, moduleName.data());
|
||||
|
@ -23,16 +23,6 @@ class JsStepOverTest : public TestEvents {
|
||||
public:
|
||||
JsStepOverTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
// 24、27: line number for breakpoint array
|
||||
size_t breakpoint[8][2] = {{24, 0}, {27, 0}, {36, 0}, {50, 0}, {60, 0}, {90, 0}, {96, 0}, {54, 0}};
|
||||
// 25、28: line number for stepinto array
|
||||
size_t stepOver[7][2] = {{25, 5}, {28, 0}, {37, 0}, {51, 0}, {61, 0}, {91, 5}, {97, 15}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepOver[0], STEP_SIZE, stepLocations_);
|
||||
return true;
|
||||
};
|
||||
|
||||
vmDeath = [this]() {
|
||||
ASSERT_EQ(breakpointCounter_, pointerLocations_.size()); // size: break point counter
|
||||
ASSERT_EQ(stepCompleteCounter_, stepLocations_.size()); // size: step complete counter
|
||||
@ -40,6 +30,12 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
// 24、27: line number for breakpoint array
|
||||
size_t breakpoint[8][2] = {{24, 0}, {27, 0}, {36, 0}, {50, 0}, {60, 0}, {90, 0}, {96, 0}, {54, 0}};
|
||||
// 25、28: line number for stepinto array
|
||||
size_t stepOver[7][2] = {{25, 5}, {28, 0}, {37, 0}, {51, 0}, {61, 0}, {91, 5}, {97, 15}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepOver[0], STEP_SIZE, stepLocations_);
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
debugger_->NotifyScriptParsed(0, moduleName.data());
|
||||
|
@ -23,12 +23,6 @@ class JsSyntaxExceptionTest : public TestEvents {
|
||||
public:
|
||||
JsSyntaxExceptionTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(27, 0, pandaFile_.c_str()); // 27: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -61,6 +55,8 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(27, 0, pandaFile_.c_str()); // 27: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -23,14 +23,6 @@ class JsThrowExceptionTest : public TestEvents {
|
||||
public:
|
||||
JsThrowExceptionTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation(28, 0, pandaFile_.c_str()); // 28: breakpointer line
|
||||
std::cout<<"vmStart1"<<std::endl;
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
std::cout<<"vmStart2"<<std::endl;
|
||||
return true;
|
||||
};
|
||||
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
@ -64,6 +56,10 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
location_ = TestUtil::GetLocation(28, 0, pandaFile_.c_str()); // 28: breakpointer line
|
||||
std::cout<<"vmStart1"<<std::endl;
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
std::cout<<"vmStart2"<<std::endl;
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
|
@ -35,13 +35,13 @@ std::pair<EntityId, uint32_t> TestExtractor::GetBreakpointAddress(const SourceLo
|
||||
retOffset = jsLocation.GetBytecodeOffset();
|
||||
return true;
|
||||
};
|
||||
MatchWithLocation(callbackFunc, sourceLocation.line, sourceLocation.column, sourceLocation.path);
|
||||
MatchWithLocation(callbackFunc, sourceLocation.line, sourceLocation.column, "");
|
||||
return {retId, retOffset};
|
||||
}
|
||||
|
||||
SourceLocation TestExtractor::GetSourceLocation(EntityId methodId, uint32_t bytecodeOffset)
|
||||
SourceLocation TestExtractor::GetSourceLocation(const JSPandaFile *file, EntityId methodId, uint32_t bytecodeOffset)
|
||||
{
|
||||
SourceLocation location {GetSourceFile(methodId), 0, 0};
|
||||
SourceLocation location {file, 0, 0};
|
||||
auto callbackLineFunc = [&location](int32_t line) -> bool {
|
||||
location.line = line;
|
||||
return true;
|
||||
|
@ -23,18 +23,13 @@ using EntityId = panda_file::File::EntityId;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
struct SourceLocation {
|
||||
std::string path; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
int32_t line; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
const JSPandaFile *file;
|
||||
int32_t line;
|
||||
int32_t column;
|
||||
|
||||
bool operator==(const SourceLocation &other) const
|
||||
{
|
||||
return path == other.path && line == other.line && column == other.column;
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return !path.empty();
|
||||
return file == other.file && line == other.line && column == other.column;
|
||||
}
|
||||
};
|
||||
|
||||
@ -45,7 +40,7 @@ public:
|
||||
|
||||
std::pair<EntityId, uint32_t> GetBreakpointAddress(const SourceLocation &sourceLocation);
|
||||
|
||||
SourceLocation GetSourceLocation(EntityId methodId, uint32_t bytecodeOffset);
|
||||
SourceLocation GetSourceLocation(const JSPandaFile *file, EntityId methodId, uint32_t bytecodeOffset);
|
||||
};
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
|
||||
void PendingJobEntry() override {}
|
||||
|
||||
void NativeCalling(const void *nativeAddress) override {}
|
||||
void NativeCalling([[maybe_unused]] const void *nativeAddress) override {}
|
||||
|
||||
void TerminateTest()
|
||||
{
|
||||
|
@ -131,23 +131,25 @@ public:
|
||||
|
||||
static JSPtLocation GetLocation(int32_t line, int32_t column, const char *pandaFile)
|
||||
{
|
||||
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->OpenJSPandaFile(pandaFile);
|
||||
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->FindJSPandaFile(pandaFile);
|
||||
if (jsPandaFile == nullptr) {
|
||||
return JSPtLocation(nullptr, EntityId(0), 0);
|
||||
LOG_DEBUGGER(FATAL) << "cannot find: " << pandaFile;
|
||||
UNREACHABLE();
|
||||
}
|
||||
TestExtractor extractor(jsPandaFile);
|
||||
auto [id, offset] = extractor.GetBreakpointAddress({nullptr, line, column});
|
||||
auto [id, offset] = extractor.GetBreakpointAddress({jsPandaFile, line, column});
|
||||
return JSPtLocation(jsPandaFile, id, offset);
|
||||
}
|
||||
|
||||
static SourceLocation GetSourceLocation(const JSPtLocation &location, const char *pandaFile)
|
||||
{
|
||||
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->OpenJSPandaFile(pandaFile);
|
||||
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->FindJSPandaFile(pandaFile);
|
||||
if (jsPandaFile == nullptr) {
|
||||
return SourceLocation();
|
||||
LOG_DEBUGGER(FATAL) << "cannot find: " << pandaFile;
|
||||
UNREACHABLE();
|
||||
}
|
||||
TestExtractor extractor(jsPandaFile);
|
||||
return extractor.GetSourceLocation(location.GetMethodId(), location.GetBytecodeOffset());
|
||||
return extractor.GetSourceLocation(jsPandaFile, location.GetMethodId(), location.GetBytecodeOffset());
|
||||
}
|
||||
|
||||
static bool SuspendUntilContinue(DebugEvent reason, JSPtLocation location = JSPtLocation(nullptr, EntityId(0), 0))
|
||||
|
Loading…
Reference in New Issue
Block a user