Skip to content

Commit

Permalink
Test saving compilation traces. (flutter#8618)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde committed Apr 18, 2019
1 parent 7d3caf8 commit 8b5a50c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
25 changes: 25 additions & 0 deletions runtime/dart_isolate_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
15 changes: 14 additions & 1 deletion runtime/fixtures/simple_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

import 'dart:isolate';
import 'dart:ui';

void main() {
}
Expand All @@ -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";

0 comments on commit 8b5a50c

Please sign in to comment.