Test saving compilation traces. (flutter/engine#8618)

This commit is contained in:
Chinmay Garde 2019-04-17 19:42:33 -07:00 committed by GitHub
parent bc238390cc
commit 24ee83dbde
2 changed files with 39 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#include "flutter/runtime/runtime_test.h"
#include "flutter/testing/testing.h"
#include "flutter/testing/thread_test.h"
#include "third_party/tonic/converter/dart_converter.h"
#include "third_party/tonic/scopes/dart_isolate_scope.h"
namespace flutter {
@ -320,5 +321,29 @@ TEST_F(DartIsolateTest, CanRegisterNativeCallback) {
latch.Wait();
}
TEST_F(DartIsolateTest, CanSaveCompilationTrace) {
if (DartVM::IsRunningPrecompiledCode()) {
// Can only save compilation traces in JIT modes.
GTEST_SKIP();
return;
}
fml::AutoResetWaitableEvent latch;
AddNativeCallback("NotifyNative",
CREATE_NATIVE_ENTRY(([&latch](Dart_NativeArguments args) {
ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(
Dart_GetNativeArgument(args, 0)));
latch.Signal();
})));
const auto settings = CreateSettingsForFixture();
auto vm_ref = DartVMRef::Create(settings);
auto isolate = RunDartCodeInIsolate(vm_ref, settings, GetThreadTaskRunner(),
"testCanSaveCompilationTrace");
ASSERT_TRUE(isolate);
ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
latch.Wait();
}
} // namespace testing
} // namespace flutter

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:isolate';
import 'dart:ui';
void main() {
}
@ -26,6 +27,18 @@ void canRegisterNativeCallback() async {
void NotifyNative() native "NotifyNative";
@pragma('vm:entry-point')
void testIsolateShutdown() { }
@pragma('vm:entry-point')
void testCanSaveCompilationTrace() {
List<int> trace = null;
try {
trace = saveCompilationTrace();
} catch (exception) {
print("Could not save compilation trace: " + exception);
}
NotifyResult(trace != null && trace.length > 0);
}
void NotifyResult(bool success) native "NotifyNative";