diff --git a/parser.cpp b/parser.cpp index 8762684..e757fb3 100644 --- a/parser.cpp +++ b/parser.cpp @@ -77,6 +77,9 @@ Parser::Parser( t_ = lex_->next(); t1_ = lex_->next(); + + // Remember full path to file. + filename_ = f; } Parser::~Parser() @@ -145,6 +148,7 @@ Edl* Parser::parse() if (cache_.count(filename_)) return cache_[filename_]; + printf("Processing %s.\n", filename_.c_str()); stack_.push_back(filename_); expect("enclave"); expect("{"); diff --git a/test/import/CMakeLists.txt b/test/import/CMakeLists.txt index 2764da2..681e9a0 100644 --- a/test/import/CMakeLists.txt +++ b/test/import/CMakeLists.txt @@ -71,3 +71,34 @@ add_import_test(oeedger8r_import_diamond diamond_d.edl "Success." "Duplicate") # Importing an edl with same basename is allowed. add_import_test(oeedger8r_import_same_basename samename.edl "Success." "Recursive") + +# Ensure that a.edl is picked up from first search-path. Warning will be raised +# for function import_dir1_ecall. +add_test( + NAME oeedger8r_import_search_path_order1 + COMMAND oeedger8r a.edl --search-path ${CMAKE_CURRENT_SOURCE_DIR}/import_dir1 + --search-path ${CMAKE_CURRENT_SOURCE_DIR}/import_dir2) +set_tests_properties( + oeedger8r_import_search_path_order1 + PROPERTIES PASS_REGULAR_EXPRESSION "Warning: Function 'import_dir1_ecall'") + +# Ensure that a.edl is picked up from first search-path. Warning will be raised +# for function import_dir2_ecall. +add_test( + NAME oeedger8r_import_search_path_order2 + COMMAND oeedger8r a.edl --search-path ${CMAKE_CURRENT_SOURCE_DIR}/import_dir2 + --search-path ${CMAKE_CURRENT_SOURCE_DIR}/import_dir1) +set_tests_properties( + oeedger8r_import_search_path_order2 + PROPERTIES PASS_REGULAR_EXPRESSION "Warning: Function 'import_dir2_ecall'") + +# Lockdown printing of imported file being processed. +add_test( + NAME oeedger8r_import_print_processing + COMMAND oeedger8r processing.edl --search-path ${CMAKE_CURRENT_SOURCE_DIR} + --search-path ${CMAKE_CURRENT_SOURCE_DIR}/import_dir3/x) + +set_tests_properties( + oeedger8r_import_print_processing + PROPERTIES PASS_REGULAR_EXPRESSION + "Processing ${CMAKE_CURRENT_SOURCE_DIR}/import_dir3/x/y/z.edl") diff --git a/test/import/import_dir1/a.edl b/test/import/import_dir1/a.edl new file mode 100644 index 0000000..1061108 --- /dev/null +++ b/test/import/import_dir1/a.edl @@ -0,0 +1,9 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + // Use wchar_t so that a warning is raised with function name. + public void import_dir1_ecall([wstring, in] wchar_t* str); + }; +}; diff --git a/test/import/import_dir2/a.edl b/test/import/import_dir2/a.edl new file mode 100644 index 0000000..3af95f0 --- /dev/null +++ b/test/import/import_dir2/a.edl @@ -0,0 +1,9 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + // Use wchar_t so that a warning is raised with function name. + public void import_dir2_ecall([wstring, in] wchar_t* str); + }; +}; diff --git a/test/import/import_dir3/x/y/z.edl b/test/import/import_dir3/x/y/z.edl new file mode 100644 index 0000000..8d55ea2 --- /dev/null +++ b/test/import/import_dir3/x/y/z.edl @@ -0,0 +1,8 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + public void z_ecall1(void); + }; +}; diff --git a/test/import/processing.edl b/test/import/processing.edl new file mode 100644 index 0000000..0a245cb --- /dev/null +++ b/test/import/processing.edl @@ -0,0 +1,6 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + import "y/z.edl" +};