-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix/mistral-nemo-chat-template * chore: add unitest for file manager utils and yaml config utils * chore: add unitest for cuda toolkit utils and semantic version utils
- Loading branch information
1 parent
0a3c5da
commit 9032501
Showing
4 changed files
with
181 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <gtest/gtest.h> | ||
#include "utils/cuda_toolkit_utils.h" | ||
|
||
// Test fixture for cuda_toolkit_utils | ||
class CudaToolkitUtilsTest : public ::testing::Test {}; | ||
|
||
// Tests for cuda_toolkit_utils | ||
|
||
TEST_F(CudaToolkitUtilsTest, WindowsCompatibleVersions) { | ||
EXPECT_EQ("12.4", cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"527.41", "windows", "")); | ||
EXPECT_EQ("11.7", cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"452.39", "windows", "")); | ||
} | ||
|
||
TEST_F(CudaToolkitUtilsTest, LinuxCompatibleVersions) { | ||
EXPECT_EQ("12.4", cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"525.60.13", "linux", "")); | ||
EXPECT_EQ("11.7", cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"450.80.02", "linux", "")); | ||
} | ||
|
||
TEST_F(CudaToolkitUtilsTest, TensorRTLLMEngine) { | ||
EXPECT_EQ("12.4", cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"527.41", "windows", "cortex.tensorrt-llm")); | ||
EXPECT_EQ("12.4", cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"525.60.13", "linux", "cortex.tensorrt-llm")); | ||
} | ||
|
||
TEST_F(CudaToolkitUtilsTest, UnsupportedDriverVersion) { | ||
EXPECT_THROW(cuda_toolkit_utils::GetCompatibleCudaToolkitVersion( | ||
"450.00", "windows", ""), | ||
std::runtime_error); | ||
EXPECT_THROW(cuda_toolkit_utils::GetCompatibleCudaToolkitVersion("450.00", | ||
"linux", ""), | ||
std::runtime_error); | ||
} | ||
|
||
TEST_F(CudaToolkitUtilsTest, UnsupportedOS) { | ||
EXPECT_THROW(cuda_toolkit_utils::GetCompatibleCudaToolkitVersion("527.41", | ||
"macos", ""), | ||
std::runtime_error); | ||
} |
94 changes: 94 additions & 0 deletions
94
engine/test/components/test_file_manager_config_yaml_utils.cc
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,94 @@ | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
#include <filesystem> | ||
#include "utils/config_yaml_utils.h" | ||
#include "utils/file_manager_utils.h" | ||
|
||
// Mock for filesystem operations | ||
|
||
// Test fixture | ||
class FileManagerConfigTest : public ::testing::Test {}; | ||
|
||
// Tests for file_manager_utils | ||
|
||
TEST_F(FileManagerConfigTest, GetExecutableFolderContainerPath) { | ||
auto path = file_manager_utils::GetExecutableFolderContainerPath(); | ||
EXPECT_FALSE(path.empty()); | ||
EXPECT_TRUE(std::filesystem::is_directory(path)); | ||
} | ||
|
||
TEST_F(FileManagerConfigTest, GetHomeDirectoryPath) { | ||
auto path = file_manager_utils::GetHomeDirectoryPath(); | ||
EXPECT_FALSE(path.empty()); | ||
EXPECT_TRUE(std::filesystem::is_directory(path)); | ||
} | ||
|
||
TEST_F(FileManagerConfigTest, GetConfigurationPath) { | ||
auto path = file_manager_utils::GetConfigurationPath(); | ||
EXPECT_FALSE(path.empty()); | ||
EXPECT_TRUE(path.has_filename()); | ||
} | ||
|
||
TEST_F(FileManagerConfigTest, GetDefaultDataFolderName) { | ||
auto folder_name = file_manager_utils::GetDefaultDataFolderName(); | ||
EXPECT_FALSE(folder_name.empty()); | ||
EXPECT_TRUE(folder_name.find("cortexcpp") != std::string::npos); | ||
} | ||
|
||
TEST_F(FileManagerConfigTest, CreateConfigFileIfNotExist) { | ||
|
||
file_manager_utils::CreateConfigFileIfNotExist(); | ||
EXPECT_TRUE( | ||
std::filesystem::exists(file_manager_utils::GetConfigurationPath())); | ||
std::filesystem::remove(file_manager_utils::GetConfigurationPath()); | ||
} | ||
|
||
TEST_F(FileManagerConfigTest, GetCortexConfig) { | ||
file_manager_utils::CreateConfigFileIfNotExist(); | ||
auto config = file_manager_utils::GetCortexConfig(); | ||
EXPECT_FALSE(config.dataFolderPath.empty()); | ||
EXPECT_FALSE(config.logFolderPath.empty()); | ||
EXPECT_GT(config.maxLogLines, 0); | ||
} | ||
|
||
// Tests for config_yaml_utils | ||
|
||
TEST_F(FileManagerConfigTest, DumpYamlConfig) { | ||
config_yaml_utils::CortexConfig config{.logFolderPath = "/path/to/logs", | ||
.dataFolderPath = "/path/to/data", | ||
.maxLogLines = 1000, | ||
.apiServerHost = "localhost", | ||
.apiServerPort = "8080"}; | ||
|
||
std::string test_file = "test_config.yaml"; | ||
config_yaml_utils::DumpYamlConfig(config, test_file); | ||
|
||
EXPECT_TRUE(std::filesystem::exists(test_file)); | ||
|
||
// Clean up | ||
std::filesystem::remove(test_file); | ||
} | ||
|
||
TEST_F(FileManagerConfigTest, FromYaml) { | ||
// Create a test YAML file | ||
std::string test_file = "test_config.yaml"; | ||
std::ofstream out_file(test_file); | ||
out_file << "logFolderPath: /path/to/logs\n" | ||
<< "dataFolderPath: /path/to/data\n" | ||
<< "maxLogLines: 1000\n" | ||
<< "apiServerHost: localhost\n" | ||
<< "apiServerPort: '8080'\n"; | ||
out_file.close(); | ||
|
||
config_yaml_utils::CortexConfig default_config{}; | ||
auto config = config_yaml_utils::FromYaml(test_file, default_config); | ||
|
||
EXPECT_EQ(config.logFolderPath, "/path/to/logs"); | ||
EXPECT_EQ(config.dataFolderPath, "/path/to/data"); | ||
EXPECT_EQ(config.maxLogLines, 1000); | ||
EXPECT_EQ(config.apiServerHost, "localhost"); | ||
EXPECT_EQ(config.apiServerPort, "8080"); | ||
|
||
// Clean up | ||
std::filesystem::remove(test_file); | ||
} |
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,43 @@ | ||
#include <gtest/gtest.h> | ||
#include "utils/semantic_version_utils.h" | ||
|
||
class SemanticVersionUtilsTest : public ::testing::Test { | ||
protected: | ||
void SetUp() override { | ||
// Setup code if needed | ||
} | ||
|
||
void TearDown() override { | ||
// Teardown code if needed | ||
} | ||
}; | ||
|
||
// Tests for semantic_version_utils | ||
|
||
TEST_F(SemanticVersionUtilsTest, SplitVersion) { | ||
auto version = semantic_version_utils::SplitVersion("1.2.3"); | ||
EXPECT_EQ(1, version.major); | ||
EXPECT_EQ(2, version.minor); | ||
EXPECT_EQ(3, version.patch); | ||
} | ||
|
||
TEST_F(SemanticVersionUtilsTest, SplitVersionPartial) { | ||
auto version = semantic_version_utils::SplitVersion("1.2"); | ||
EXPECT_EQ(1, version.major); | ||
EXPECT_EQ(2, version.minor); | ||
EXPECT_EQ(0, version.patch); | ||
} | ||
|
||
TEST_F(SemanticVersionUtilsTest, SplitVersionEmpty) { | ||
auto version = semantic_version_utils::SplitVersion(""); | ||
EXPECT_EQ(0, version.major); | ||
EXPECT_EQ(0, version.minor); | ||
EXPECT_EQ(0, version.patch); | ||
} | ||
|
||
TEST_F(SemanticVersionUtilsTest, CompareSemanticVersion) { | ||
EXPECT_EQ(0, semantic_version_utils::CompareSemanticVersion("1.2.3", "1.2.3")); | ||
EXPECT_EQ(-1, semantic_version_utils::CompareSemanticVersion("1.2.3", "1.2.4")); | ||
EXPECT_EQ(1, semantic_version_utils::CompareSemanticVersion("1.3.0", "1.2.9")); | ||
EXPECT_EQ(-1, semantic_version_utils::CompareSemanticVersion("1.9.9", "2.0.0")); | ||
} |