-
Notifications
You must be signed in to change notification settings - Fork 3
Improved code coverage #208
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2a73cb0
Began refactor for better code coverage
b94e039
Tests
b6fe558
tests
3feefee
Fixed workflow execution sequence
80b8507
Cleanup
90fd943
More tests
973dcaf
Added more tests
3e089c2
More tests
b00268c
Rename test
e1bc2ab
wip
1d26510
Improved test env
b6c0b24
Refactored structure of tests
4fca5d0
Extended test suite
ee8cc2a
cleanup
385bc00
cleanup
7df1a47
reverted changes from capio_server
f152c80
Fixed issue in running docker tests
f042a90
This commit disables the capio_syscall_unit_tests within the docker C…
b08ec2e
Fixed docker CI/CD tests
79c2059
resolved comments
335f98b
Moved from .hpp test files to .cpp test files
475ede7
Minor improvement to cmakelist
ba3c3c1
Apply suggestion from @GlassOfWhiskey
marcoSanti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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,62 @@ | ||
| #ifndef CAPIO_CLIENT_MANAGER_HPP | ||
| #define CAPIO_CLIENT_MANAGER_HPP | ||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <client-manager/client_manager.hpp> | ||
|
|
||
| extern ClientManager *client_manager; | ||
|
|
||
| TEST(ClientManagerTestEnvironment, testReplyToNonClient) { | ||
| char buffer[1024]; | ||
| EXPECT_THROW(client_manager->replyToClient(-1, 0, buffer, 0), std::runtime_error); | ||
| } | ||
|
|
||
| TEST(ClientManagerTestEnvironment, testGetNumberOfConnectedClients) { | ||
|
|
||
| EXPECT_EQ(client_manager->getConnectedPosixClients(), 0); | ||
|
|
||
| client_manager->registerClient(1234); | ||
| EXPECT_EQ(client_manager->getConnectedPosixClients(), 1); | ||
|
|
||
| client_manager->removeClient(1234); | ||
| EXPECT_EQ(client_manager->getConnectedPosixClients(), 0); | ||
| } | ||
|
|
||
| TEST(ClientManagerTestEnvironment, testFailedRequestCode) { | ||
|
|
||
| // NOTE: there is no need to delete this object as it is only attaching to the shm allocated by | ||
| // client_manager. Also calling delete on this raises std::terminate as an exception is thrown | ||
| // in the destructor | ||
| // TODO: change behaviour of ERR_EXIT to not throw exceptions but only print error and continue | ||
| const auto request_queue = | ||
| new CircularBuffer<char>(SHM_COMM_CHAN_NAME, CAPIO_REQ_BUFF_CNT, CAPIO_REQ_MAX_SIZE); | ||
|
|
||
| char req[CAPIO_REQ_MAX_SIZE], new_req[CAPIO_REQ_MAX_SIZE]; | ||
| constexpr int TEST_REQ_CODE = 123; | ||
| sprintf(req, "%04d aaaa bbbb cccc", TEST_REQ_CODE); | ||
| request_queue->write(req, CAPIO_REQ_MAX_SIZE); | ||
| const auto return_code = client_manager->readNextRequest(new_req); | ||
| std::cout << new_req << std::endl; | ||
| EXPECT_EQ(return_code, TEST_REQ_CODE); | ||
|
|
||
| sprintf(req, "abc aaaa bbbb cccc"); | ||
| request_queue->write(req, CAPIO_REQ_MAX_SIZE); | ||
|
|
||
| EXPECT_EQ(client_manager->readNextRequest(new_req), -1); | ||
| } | ||
|
|
||
| TEST(ClientManagerTestEnvironment, testAddAndRemoveProducedFiles) { | ||
|
|
||
| client_manager->registerClient(1234, "test_app"); | ||
| client_manager->registerProducedFile(1234, "test.txt"); | ||
|
|
||
| EXPECT_TRUE(client_manager->isProducer(1234, "test.txt")); | ||
|
|
||
| client_manager->removeProducedFile(1234, "test.txt"); | ||
| EXPECT_FALSE(client_manager->isProducer(1234, "test.txt")); | ||
|
|
||
| client_manager->registerProducedFile(1111, "test1.txt"); | ||
| EXPECT_FALSE(client_manager->isProducer(1111, "test1.txt")); | ||
| } | ||
|
|
||
| #endif // CAPIO_CLIENT_MANAGER_HPP |
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,45 @@ | ||
| #include <gtest/gtest.h> | ||
|
|
||
| char *node_name; | ||
|
|
||
| #include "capiocl.hpp" | ||
| #include "capiocl/engine.h" | ||
| #include "client-manager/client_manager.hpp" | ||
| #include "common/constants.hpp" | ||
| #include "storage/manager.hpp" | ||
| #include "utils/capiocl_adapter.hpp" | ||
| #include "utils/location.hpp" | ||
|
|
||
| capiocl::engine::Engine *capio_cl_engine = nullptr; | ||
| StorageManager *storage_manager = nullptr; | ||
| ClientManager *client_manager = nullptr; | ||
|
|
||
| const capiocl::engine::Engine &CapioCLEngine::get() { return *capio_cl_engine; } | ||
|
|
||
| class ServerUnitTestEnvironment : public testing::Environment { | ||
| public: | ||
| explicit ServerUnitTestEnvironment() = default; | ||
|
|
||
| void SetUp() override { | ||
| capio_cl_engine = new capiocl::engine::Engine(false); | ||
| node_name = new char[HOST_NAME_MAX]; | ||
| gethostname(node_name, HOST_NAME_MAX); | ||
| open_files_location(); | ||
|
|
||
| client_manager = new ClientManager(); | ||
| storage_manager = new StorageManager(); | ||
| } | ||
|
|
||
| void TearDown() override { | ||
| delete storage_manager; | ||
| delete client_manager; | ||
| delete capio_cl_engine; | ||
| } | ||
| }; | ||
|
|
||
| int main(int argc, char **argv, char **envp) { | ||
| testing::InitGoogleTest(&argc, argv); | ||
|
|
||
| testing::AddGlobalTestEnvironment(new ServerUnitTestEnvironment()); | ||
| return RUN_ALL_TESTS(); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.