-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more unit tests to increase coverage (#355)
* update * update * increase coverage * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * Update * update --------- Co-authored-by: Officeyutong <[email protected]>
- Loading branch information
1 parent
327ba8d
commit 808ce59
Showing
11 changed files
with
163 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
attach/frida_uprobe_attach_impl/test/test_attach_private_data_parsing.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <cerrno> | ||
#include <memory> | ||
#include <frida_attach_private_data.hpp> | ||
using namespace bpftime; | ||
|
||
TEST_CASE("Test illegal parsing") | ||
{ | ||
SECTION("Test bad strings") | ||
{ | ||
auto priv = std::make_unique< | ||
bpftime::attach::frida_attach_private_data>(); | ||
REQUIRE(priv->initialize_from_string("aaa:") == -EINVAL); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
attach/frida_uprobe_attach_impl/test/test_base_attach_impl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "catch2/catch_test_macros.hpp" | ||
#include <base_attach_impl.hpp> | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <cstdint> | ||
|
||
using namespace bpftime::attach; | ||
using namespace bpftime; | ||
|
||
TEST_CASE("Test bpftime_set_retval") | ||
{ | ||
curr_thread_override_return_callback.reset(); | ||
REQUIRE_THROWS(bpftime_set_retval(0)); | ||
bool called = false; | ||
curr_thread_override_return_callback = [&](uint64_t, uint64_t) { | ||
called = true; | ||
}; | ||
bpftime_set_retval(0); | ||
REQUIRE(called); | ||
} | ||
|
||
TEST_CASE("Test bpftime_override_return") | ||
{ | ||
curr_thread_override_return_callback.reset(); | ||
REQUIRE_THROWS(bpftime_override_return(0, 0)); | ||
|
||
bool called = false; | ||
curr_thread_override_return_callback = [&](uint64_t, uint64_t) { | ||
called = true; | ||
}; | ||
bpftime_override_return(0, 0); | ||
REQUIRE(called); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters