- Notifications
You must be signed in to change notification settings - Fork3
Assert Fatal thread behavior#206
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
5224262 Updated storage bad usage
coder137776ff73 Assert fatal uses std::exit instead of std::terminate
coder1377ff4fbe Updated assert_fatal implementation
coder13767a74af Added assert_fatal test
coder13785336a9 Removed assert_throw
coder1377cdadd1 Replaced assert_throw with assert_fatal
coder1371ecc00f Updated assert_fatal.h
coder1372f16a69 Updated assert_fatal
coder137File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
5 changes: 4 additions & 1 deletionbuildcc/lib/env/CMakeLists.txt
This file contains hidden or 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
6 changes: 5 additions & 1 deletionbuildcc/lib/env/include/env/assert_fatal.h
This file contains hidden or 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
69 changes: 0 additions & 69 deletionsbuildcc/lib/env/include/env/assert_throw.h
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
10 changes: 6 additions & 4 deletionsbuildcc/lib/env/include/env/storage.h
This file contains hidden or 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
23 changes: 22 additions & 1 deletionbuildcc/lib/env/src/assert_fatal.cpp
This file contains hidden or 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
6 changes: 6 additions & 0 deletionsbuildcc/lib/env/src/storage.cpp
This file contains hidden or 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
72 changes: 72 additions & 0 deletionsbuildcc/lib/env/test/test_assert_fatal.cpp
This file contains hidden or 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,72 @@ | ||
| #include <thread> | ||
| #include "taskflow/taskflow.hpp" | ||
| // NOTE, Make sure all these includes are AFTER the system and header includes | ||
| #include "CppUTest/CommandLineTestRunner.h" | ||
| #include "CppUTest/MemoryLeakDetectorNewMacros.h" | ||
| #include "CppUTest/TestHarness.h" | ||
| #include "CppUTest/Utest.h" | ||
| #include "CppUTestExt/MockSupport.h" | ||
| namespace { | ||
| std::thread::id my_main_thread = std::this_thread::get_id(); | ||
| bool IsRunningInThread() { | ||
| bool threaded = true; | ||
| if (std::this_thread::get_id() == my_main_thread) { | ||
| threaded = false; | ||
| } | ||
| return threaded; | ||
| } | ||
| void assert_handle_fatal() { | ||
| if (IsRunningInThread()) { | ||
| mock().actualCall("assert_handle_fatal_threaded"); | ||
| } else { | ||
| mock().actualCall("assert_handle_fatal_main"); | ||
| } | ||
| } | ||
| } // namespace | ||
| // clang-format off | ||
| TEST_GROUP(AssertFatalTestGroup) | ||
| { | ||
| void teardown() { | ||
| mock().clear(); | ||
| } | ||
| }; | ||
| // clang-format on | ||
| TEST(AssertFatalTestGroup, AssertFatal_IsThreadedCheck) { | ||
| CHECK_FALSE(IsRunningInThread()); | ||
| tf::Taskflow tf; | ||
| tf.emplace([]() { CHECK_TRUE(IsRunningInThread()); }); | ||
| tf::Executor ex(1); | ||
| ex.run(tf); | ||
| ex.wait_for_all(); | ||
| } | ||
| TEST(AssertFatalTestGroup, AssertFatal_Threaded) { | ||
| mock().expectOneCall("assert_handle_fatal_threaded"); | ||
| tf::Taskflow tf; | ||
| tf.emplace([]() { assert_handle_fatal(); }); | ||
| tf::Executor ex(1); | ||
| ex.run(tf); | ||
| ex.wait_for_all(); | ||
| } | ||
| TEST(AssertFatalTestGroup, AssertFatal_NotThreaded) { | ||
| mock().expectOneCall("assert_handle_fatal_main"); | ||
| assert_handle_fatal(); | ||
| } | ||
| int main(int ac, char **av) { | ||
| return CommandLineTestRunner::RunAllTests(ac, av); | ||
| } |
8 changes: 8 additions & 0 deletionsbuildcc/lib/env/test/test_storage.cpp
This file contains hidden or 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
4 changes: 2 additions & 2 deletionsbuildcc/lib/target/src/generator/task.cpp
This file contains hidden or 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
6 changes: 3 additions & 3 deletionsbuildcc/lib/target/src/target/friend/compile_pch.cpp
This file contains hidden or 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
2 changes: 1 addition & 1 deletionbuildcc/lib/target/src/target/friend/link_target.cpp
This file contains hidden or 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
4 changes: 2 additions & 2 deletionsbuildcc/lib/target/src/target/tasks.cpp
This file contains hidden or 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
4 changes: 2 additions & 2 deletionsbuildcc/schema/include/schema/path.h
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.