@@ -55,7 +55,7 @@ class StubBackend final : public BackendInterface {
5555 using InitFn = std::function<Result<DelegateHandle*>(
5656 FreeableBuffer*,
5757 ArrayRef<CompileSpec>,
58- MemoryAllocator* )>;
58+ BackendInitContext )>;
5959 using ExecuteFn = std::function<Error(DelegateHandle*, EValue**)>;
6060 using DestroyFn = std::function<void (DelegateHandle*)>;
6161
@@ -83,8 +83,7 @@ class StubBackend final : public BackendInterface {
8383 FreeableBuffer* processed,
8484 ArrayRef<CompileSpec> compile_specs) const override {
8585 if (init_fn_) {
86- return init_fn_.value ()(
87- processed, compile_specs, context.get_runtime_allocator ());
86+ return init_fn_.value ()(processed, compile_specs, context);
8887 }
8988 // Return a benign value otherwise.
9089 return nullptr ;
@@ -351,7 +350,7 @@ TEST_P(BackendIntegrationTest, FreeingProcessedBufferSucceeds) {
351350 StubBackend::singleton ().install_init (
352351 [&](FreeableBuffer* processed,
353352 ET_UNUSED ArrayRef<CompileSpec> compile_specs,
354- ET_UNUSED MemoryAllocator* runtime_allocator )
353+ ET_UNUSED BackendInitContext backend_init_context )
355354 -> Result<DelegateHandle*> {
356355 init_called = true ;
357356 processed_data = processed->data ();
@@ -395,7 +394,7 @@ TEST_P(BackendIntegrationTest, EndToEndTestWithProcessedAsHandle) {
395394 StubBackend::singleton ().install_init (
396395 [&](FreeableBuffer* processed,
397396 ET_UNUSED ArrayRef<CompileSpec> compile_specs,
398- ET_UNUSED MemoryAllocator* runtime_allocator )
397+ ET_UNUSED BackendInitContext backend_init_context )
399398 -> Result<DelegateHandle*> {
400399 init_processed = processed;
401400 return processed;
@@ -492,7 +491,7 @@ TEST_P(BackendIntegrationTest, SegmentInfoIsPassedIntoDataLoader) {
492491 StubBackend::singleton ().install_init (
493492 [&](FreeableBuffer* processed,
494493 ET_UNUSED ArrayRef<CompileSpec> compile_specs,
495- ET_UNUSED MemoryAllocator* runtime_allocator )
494+ ET_UNUSED BackendInitContext backend_init_context )
496495 -> Result<DelegateHandle*> {
497496 processed_data = processed->data ();
498497 processed->Free ();
@@ -528,6 +527,24 @@ TEST_P(BackendIntegrationTest, SegmentInfoIsPassedIntoDataLoader) {
528527 EXPECT_EQ (backend_load_was_called, using_segments ());
529528}
530529
530+ TEST_P (BackendIntegrationTest, GetMethodNameSuccess) {
531+ Result<FileDataLoader> loader = FileDataLoader::from (program_path ());
532+ ASSERT_EQ (loader.error (), Error::Ok);
533+ const void * processed_data = nullptr ;
534+ StubBackend::singleton ().install_init (
535+ [&](FreeableBuffer* processed,
536+ ET_UNUSED ArrayRef<CompileSpec> compile_specs,
537+ ET_UNUSED BackendInitContext backend_init_context)
538+ -> Result<DelegateHandle*> {
539+ auto method_name = backend_init_context.get_method_name ();
540+ EXPECT_EQ (method_name, " forward" );
541+ processed_data = processed->data ();
542+ return nullptr ;
543+ });
544+ Result<Program> program = Program::load (&loader.get ());
545+ ASSERT_EQ (program.error (), Error::Ok);
546+ }
547+
531548// TODO: Add more tests for the runtime-to-backend interface. E.g.:
532549// - Errors during init() or execute() result in runtime init/execution failures
533550// - Correct values are passed to init()/execute()
@@ -606,7 +623,7 @@ TEST_P(DelegateDataAlignmentTest, ExpectedDataAlignment) {
606623 StubBackend::singleton ().install_init (
607624 [&](FreeableBuffer* processed,
608625 ET_UNUSED ArrayRef<CompileSpec> compile_specs,
609- ET_UNUSED MemoryAllocator* runtime_allocator )
626+ ET_UNUSED BackendInitContext backend_init_context )
610627 -> Result<DelegateHandle*> {
611628 processed_data = processed->data ();
612629 return nullptr ;
0 commit comments