File tree 3 files changed +25
-0
lines changed
3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,13 @@ Result<const void*> Program::get_constant_buffer_data(
373
373
}
374
374
}
375
375
376
+ Result<const NamedDataMap*> Program::get_named_data_map () const {
377
+ if (pte_data_map_.has_value ()) {
378
+ return &pte_data_map_.value ();
379
+ }
380
+ return Error::NotFound;
381
+ }
382
+
376
383
Result<const char *> Program::get_output_flattening_encoding (
377
384
const char * method_name) const {
378
385
auto plan = get_execution_plan (internal_program_, method_name);
Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ class Program final {
107
107
Result<const void *> get_constant_buffer_data (size_t buffer_idx, size_t nbytes)
108
108
const ;
109
109
110
+ /* *
111
+ * Get the named data map from the program.
112
+ * @return The named data map.
113
+ */
114
+ Result<const NamedDataMap*> get_named_data_map () const ;
115
+
110
116
/* *
111
117
* Returns the number of methods in the program.
112
118
*/
Original file line number Diff line number Diff line change @@ -371,6 +371,18 @@ TEST_F(ProgramTest, getMethods) {
371
371
EXPECT_EQ (strcmp (res2.get (), " forward2" ), 0 );
372
372
}
373
373
374
+ TEST_F (ProgramTest, GetNamedDataMap_Fail) {
375
+ Result<Program> program =
376
+ Program::load (add_loader_.get (), kDefaultVerification );
377
+ ASSERT_EQ (program.error (), Error::Ok);
378
+
379
+ // Get the named data map. Expect to fail, as add.pte does not have any
380
+ // named data segments.
381
+ Result<const executorch::runtime::NamedDataMap*> named_data_map =
382
+ program->get_named_data_map ();
383
+ EXPECT_EQ (named_data_map.error (), Error::NotFound);
384
+ }
385
+
374
386
// Test that the deprecated Load method (capital 'L') still works.
375
387
TEST_F (ProgramTest, DEPRECATEDLoad) {
376
388
// Parse the Program from the data.
You can’t perform that action at this time.
0 commit comments