Skip to content

Commit 7112fd1

Browse files
authored
Update backend_integration_test.cpp
1 parent bf7f19a commit 7112fd1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

runtime/executor/test/backend_integration_test.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,35 @@ TEST_P(BackendIntegrationTest, BasicInitSucceeds) {
347347
EXPECT_EQ(method_res.error(), Error::Ok);
348348
}
349349

350+
TEST_P(BackendIntegrationTest, GetBackendNamesSuccess) {
351+
// Load the program from file.
352+
Result<FileDataLoader> loader = FileDataLoader::from(program_path());
353+
ASSERT_EQ(loader.error(), Error::Ok);
354+
355+
Result<Program> program = Program::load(&loader.get());
356+
ASSERT_EQ(program.error(), Error::Ok);
357+
358+
// Get method metadata for the "forward" method.
359+
auto method_meta = program->method_meta("forward");
360+
361+
// Ensure the StubBackend is used.
362+
EXPECT_TRUE(method_meta->uses_backend(StubBackend::kName));
363+
364+
// Retrieve the number of backends.
365+
size_t num_backends = method_meta->num_backends();
366+
EXPECT_GT(num_backends, 0u);
367+
368+
// Iterate through each backend and verify its name.
369+
for (size_t i = 0; i < num_backends; ++i) {
370+
const char* name = method_meta->get_backend_name(i);
371+
EXPECT_NE(name, nullptr);
372+
// For this test, we expect that the only backend is StubBackend.
373+
EXPECT_STREQ(name, StubBackend::kName);
374+
}
375+
// Check that an out-of-range index returns nullptr.
376+
EXPECT_EQ(method_meta->get_backend_name(num_backends), nullptr);
377+
}
378+
350379
TEST_P(BackendIntegrationTest, FreeingProcessedBufferSucceeds) {
351380
// Install an init() implementation that frees its processed buffer, and lets
352381
// us know that it was actually called by setting init_called.

0 commit comments

Comments
 (0)