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

Replace std::string pointer by reference and remove unused function DLSym #193

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SAtacker
Copy link
Contributor

  • Add test for DLOpen

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

unittests/CppInterOp/DynamicLibraryManagerTest.cpp Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.87%. Comparing base (e61e7ca) to head (2315dea).
Report is 11 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #193      +/-   ##
==========================================
+ Coverage   78.83%   78.87%   +0.03%     
==========================================
  Files           8        8              
  Lines        3048     3048              
==========================================
+ Hits         2403     2404       +1     
+ Misses        645      644       -1     
Files Coverage Δ
lib/Interpreter/DynamicLibraryManager.cpp 75.12% <100.00%> (ø)
lib/Interpreter/Paths.cpp 37.75% <100.00%> (+2.34%) ⬆️

... and 2 files with indirect coverage changes

Files Coverage Δ
lib/Interpreter/DynamicLibraryManager.cpp 75.12% <100.00%> (ø)
lib/Interpreter/Paths.cpp 37.75% <100.00%> (+2.34%) ⬆️

... and 2 files with indirect coverage changes

Copy link

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

github-actions bot commented Feb 3, 2024

clang-tidy review says "All clean, LGTM! 👍"

2 similar comments
Copy link

github-actions bot commented Feb 3, 2024

clang-tidy review says "All clean, LGTM! 👍"

Copy link

github-actions bot commented Feb 4, 2024

clang-tidy review says "All clean, LGTM! 👍"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -5,6 +5,11 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"

#include "../../lib/Interpreter/Paths.h"

#define XCPP_INTEROP_STRINGIFY(x) #x
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function-like macro 'XCPP_INTEROP_STRINGIFY' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]

#define XCPP_INTEROP_STRINGIFY(x) #x
        ^

#include "../../lib/Interpreter/Paths.h"

#define XCPP_INTEROP_STRINGIFY(x) #x
#define CPP_INTEROP_STRINGIFY(x) XCPP_INTEROP_STRINGIFY(x)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function-like macro 'CPP_INTEROP_STRINGIFY' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]

#define CPP_INTEROP_STRINGIFY(x) XCPP_INTEROP_STRINGIFY(x)
        ^

@SAtacker SAtacker force-pushed the codecov-inc branch 3 times, most recently from 1905eb3 to 1976d0c Compare February 4, 2024 06:08
Comment on lines 86 to 87
EXPECT_TRUE(err.find("no such file") != std::string::npos ||
err.find("No such file") != std::string::npos);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EXPECT_TRUE(err.find("no such file") != std::string::npos ||
err.find("No such file") != std::string::npos);
EXPECT_FALSE(err.empty());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel no such file is more verbose and the exact error we expect.


TEST(UtilsPlatform, DLTest) {
std::string err = "";
// CPPINTEROP_LIB_TestSharedLib_DIR_PREFIX specified by cmake though target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that supposed to compute the full path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that supposed to compute the full path?

That depends what ${CMAKE_BINARY_DIR}/unittests/bin/$<CONFIG>/ gives, we can assume that it gives the full path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Can't we get the fullpath to the test executable and find back the library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do it but it seemed to vary across arch and platform and configurations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do not want macros in that we can have a config.h.in file and have cmake configure it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to avoid that but not at the cost of introducing config.h.in. I was wondering if we should not try to look for these files in a few places. Like check if the file exists in these couple of places and pass it to the system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to avoid that but not at the cost of introducing config.h.in. I was wondering if we should not try to look for these files in a few places. Like check if the file exists in these couple of places and pass it to the system.

We can have a small utility program that uses c++ 17's filesystem and searches for it. Would that work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, however, no need to C++ 17 to implement that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, I shall do it for POSIX and windows separately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use llvm facilities from llvm::fs and llvm::sys that would avoid this.

Copy link

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

unittests/CppInterOp/DynamicLibraryManagerTest.cpp Outdated Show resolved Hide resolved
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

clang-tidy review says "All clean, LGTM! 👍"

@@ -22,7 +22,7 @@ export_executable_symbols(CppInterOpTests)

unset(LLVM_LINK_COMPONENTS)

add_cppinterop_unittest(DynamicLibraryManagerTests DynamicLibraryManagerTest.cpp)
add_cppinterop_unittest(DynamicLibraryManagerTests DynamicLibraryManagerTest.cpp ${CMAKE_SOURCE_DIR}/lib/Interpreter/Paths.cpp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we add this here? That should be provided by the shared object file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was because it wasn't getting linked on one of the platforms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

clang-tidy review says "All clean, LGTM! 👍"

DLErr(Err);
return Lib;
void DLClose(void* Lib, std::string& Err) {
auto dl = llvm::sys::DynamicLibrary(Lib);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test where we dlopen a library with standard dlopen and not DLOpen and try to close it with DLClose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants