Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display full path to each processed file. #14

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char** argv)
printf("%s\n", usage);
exit(1);
}
return fix_path_seperators(argv[i]);
return fix_path_separators(argv[i]);
};

while (i < argc)
Expand Down Expand Up @@ -97,7 +97,7 @@ int main(int argc, char** argv)
return 1;
}
else
files.push_back(fix_path_seperators(a));
files.push_back(fix_path_separators(a));
}

if (files.empty())
Expand Down
6 changes: 5 additions & 1 deletion parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Parser::Parser(
{
for (auto&& sp : searchpaths_)
{
f = sp + path_sep() + filename_;
f = fix_path_separators(sp + path_sep() + filename_);
if (_is_file(f))
break;
}
Expand Down 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
36 changes: 36 additions & 0 deletions test/import/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,39 @@ 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)

file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/import_dir3/x/y/z.edl"
IMPORTED_FILE_PATH)
# \ character becomes \\\\ in a regular expression.
# Convert \ to \\ in IMPORTED_FILE_PATH.
string(REGEX REPLACE "\\\\" "\\\\\\\\" IMPORTED_FILE_PATH ${IMPORTED_FILE_PATH})

set_tests_properties(
oeedger8r_import_print_processing
PROPERTIES PASS_REGULAR_EXPRESSION "Processing ${IMPORTED_FILE_PATH}.")
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"
};
2 changes: 1 addition & 1 deletion utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ inline const char* path_sep()
#endif
}

inline std::string fix_path_seperators(const std::string& path)
inline std::string fix_path_separators(const std::string& path)
{
#if _WIN32
return replace(path, "/", "\\");
Expand Down