Skip to content

Commit

Permalink
Display full path to each processed file.
Browse files Browse the repository at this point in the history
Displaying full path allows the user to figure out what file is being processed
in case an unintended file is being picked up from the specified search paths.
Add test for printed path.

Add tests to lock down the order in which search paths are processed.

Signed-off-by: Anand Krishnamoorthi <[email protected]>
  • Loading branch information
anakrish committed Jun 4, 2020
1 parent 24fc634 commit 1fae05c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Parser::Parser(

t_ = lex_->next();
t1_ = lex_->next();

// Remember full path to file.
filename_ = f;
}

Parser::~Parser()
Expand Down Expand Up @@ -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("{");
Expand Down
31 changes: 31 additions & 0 deletions test/import/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
9 changes: 9 additions & 0 deletions test/import/import_dir1/a.edl
Original file line number Diff line number Diff line change
@@ -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);
};
};
9 changes: 9 additions & 0 deletions test/import/import_dir2/a.edl
Original file line number Diff line number Diff line change
@@ -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);
};
};
8 changes: 8 additions & 0 deletions test/import/import_dir3/x/y/z.edl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Open Enclave SDK contributors.
// Licensed under the MIT License.

enclave {
trusted {
public void z_ecall1(void);
};
};
6 changes: 6 additions & 0 deletions test/import/processing.edl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Open Enclave SDK contributors.
// Licensed under the MIT License.

enclave {
import "y/z.edl"
};

0 comments on commit 1fae05c

Please sign in to comment.