Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter

- CitrineOS core extracted (CSMS OCPP 2.0.1)
- OpenOCPP extracted (firmware OCPP 1.6J/2.0.1)
- ShapeShifter library installed (pip install -e)
- ShapeShifter specification extracted
- EVerest extracted

TODO updated with progress
This commit is contained in:
Eric F
2026-06-08 00:38:27 -04:00
parent 468cfeaa50
commit d398a6ced2
7326 changed files with 1177561 additions and 7 deletions

View File

@@ -0,0 +1,37 @@
set(TEST_TARGET_NAME ${PROJECT_NAME}_EvManager_tests)
add_executable(${TEST_TARGET_NAME})
add_dependencies(${TEST_TARGET_NAME} ${MODULE_NAME})
get_target_property(GENERATED_INCLUDE_DIR generate_cpp_files EVEREST_GENERATED_INCLUDE_DIR)
target_include_directories(${TEST_TARGET_NAME}
PRIVATE
"$<TARGET_PROPERTY:generate_cpp_files,EVEREST_GENERATED_INCLUDE_DIR>"
)
target_sources(${TEST_TARGET_NAME}
PRIVATE
CommandRegistryTest.cpp
SimCommandTest.cpp
../main/simulation_command.cpp
)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE
BUILD_TESTING_MODULE_EV_MANAGER
)
target_link_libraries(${TEST_TARGET_NAME}
PRIVATE
everest::framework
everest::log
Catch2::Catch2WithMain
)
if (NOT DISABLE_EDM)
list(APPEND CMAKE_MODULE_PATH ${CPM_PACKAGE_catch2_SOURCE_DIR}/extras)
include(Catch)
catch_discover_tests(${TEST_TARGET_NAME})
endif ()
add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME})
ev_register_test_target(${TEST_TARGET_NAME})

View File

@@ -0,0 +1,129 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#include "../main/command_registry.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <string>
#include <vector>
SCENARIO("Commands can be registered", "[RegisteredCommand]") {
GIVEN("A command with 0 arguments") {
auto command_registry = CommandRegistry();
const auto command_name = std::string{"test_command0"};
const auto argument_count = 0;
const auto test_comand_0_function = [](const std::vector<std::string>& arguments) { return arguments.empty(); };
WHEN("The command is registered") {
command_registry.register_command(command_name, argument_count, test_comand_0_function);
THEN("The command can be retrieved") {
const auto& registered_command = command_registry.get_registered_command(command_name, 0);
THEN("The command can be executed") {
CHECK(registered_command({}) == true);
}
THEN("The command throws when the number of arguments is invalid") {
CHECK(registered_command({}) == true);
CHECK_THROWS_WITH(registered_command({"arg1"}),
"Invalid number of arguments for: test_command0 expected 0 got 1");
CHECK_THROWS_WITH(registered_command({"arg1", "arg2"}),
"Invalid number of arguments for: test_command0 expected 0 got 2");
CHECK_THROWS_WITH(registered_command({"arg1", "arg2", "arg3"}),
"Invalid number of arguments for: test_command0 expected 0 got 3");
}
}
}
}
GIVEN("A command with 1 argument") {
auto command_registry = CommandRegistry();
const auto command_name = std::string{"test_command1"};
const auto argument_count = 1;
const auto test_comand_1_function = [](const std::vector<std::string>& arguments) {
return arguments.size() == 1;
};
WHEN("The command is registered") {
command_registry.register_command(command_name, argument_count, test_comand_1_function);
THEN("The command can be retrieved") {
const auto& registered_command = command_registry.get_registered_command(command_name, 1);
THEN("The command can be executed") {
CHECK(registered_command({"arg1"}) == true);
}
THEN("The command throws when the number of arguments is invalid") {
CHECK_THROWS_WITH(registered_command({}),
"Invalid number of arguments for: test_command1 expected 1 got 0");
CHECK_THROWS_WITH(registered_command({"arg1", "arg2"}),
"Invalid number of arguments for: test_command1 expected 1 got 2");
}
}
}
}
GIVEN("A command with 2 arguments") {
auto command_registry = CommandRegistry();
const auto command_name = std::string{"test_command2"};
const auto argument_count = 2;
const auto test_comand_2_function = [](const std::vector<std::string>& arguments) {
return arguments.size() == 2;
};
WHEN("The command is registered") {
command_registry.register_command(command_name, argument_count, test_comand_2_function);
THEN("The command can be retrieved") {
const auto& registered_command = command_registry.get_registered_command(command_name, 2);
THEN("The command can be executed") {
CHECK(registered_command({"arg1", "arg2"}) == true);
}
THEN("The command throws when the number of arguments is invalid") {
CHECK_THROWS_WITH(registered_command({}),
"Invalid number of arguments for: test_command2 expected 2 got 0");
CHECK_THROWS_WITH(registered_command({"arg1"}),
"Invalid number of arguments for: test_command2 expected 2 got 1");
CHECK_THROWS_WITH(registered_command({"arg1", "arg2", "arg3"}),
"Invalid number of arguments for: test_command2 expected 2 got 3");
}
}
}
}
GIVEN("Two identical commands with different arguments") {
auto command_registry = CommandRegistry();
const std::string command_name = std::string{"test_command"};
const auto test_command_1_function = [](const std::vector<std::string>& arguments) {
return arguments.size() == 1;
};
const auto test_command_2_function = [](const std::vector<std::string>& arguments) {
return arguments.size() == 2;
};
WHEN("The command is registered") {
command_registry.register_command(command_name, 1, test_command_1_function);
command_registry.register_command(command_name, 2, test_command_2_function);
THEN("The command can be retrieved") {
const auto& registered_command1 = command_registry.get_registered_command(command_name, 1);
const auto& registered_command2 = command_registry.get_registered_command(command_name, 2);
THEN("The command can be executed") {
CHECK(registered_command1({"arg1"}) == true);
CHECK(registered_command2({"arg1", "arg2"}) == true);
}
THEN("The command throws when the number of arguments is invalid") {
CHECK_THROWS_WITH(registered_command1({}),
"Invalid number of arguments for: test_command expected 1 got 0");
CHECK_THROWS_WITH(registered_command1({"arg1", "arg2"}),
"Invalid number of arguments for: test_command expected 1 got 2");
}
}
THEN("The wrong commands can not be retrieved") {
CHECK_THROWS_WITH(command_registry.get_registered_command(command_name, 0),
"Command not found: test_command");
CHECK_THROWS_WITH(command_registry.get_registered_command(command_name, 4),
"Command not found: test_command");
}
}
}
}

View File

@@ -0,0 +1,118 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#include "../main/command_registry.hpp"
#include "../main/simulation_command.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <string>
#include <vector>
SCENARIO("SimCommands can be created", "[SimCommand]") {
GIVEN("A command with 0 arguments called test_command is registered") {
const auto command_name = std::string{"test_command"};
const auto argument_count = 0;
const auto test_command_function = [](const std::vector<std::string>& arguments) { return arguments.empty(); };
auto command_registry = CommandRegistry();
command_registry.register_command(command_name, argument_count, test_command_function);
WHEN("The SimCommand is created") {
const auto sim_command = SimulationCommand{&command_registry.get_registered_command(command_name, 0), {}};
THEN("The command can be executed") {
CHECK(sim_command.execute() == true);
}
}
WHEN("The SimCommand is created with the wrong number of arguments") {
const auto sim_command =
SimulationCommand{&command_registry.get_registered_command(command_name, 1), {"arg1"}};
THEN("The command throws") {
CHECK_THROWS_WITH(sim_command.execute(),
"Invalid number of arguments for: test_command expected 0 got 1");
}
}
}
}
SCENARIO("SimCommands can be parsed", "[SimCommand]") {
GIVEN("A few commands registered and a command string") {
auto command_registry = CommandRegistry();
const auto command_name_a = std::string{"commanda"};
const auto agrument_count_a = 0;
const auto command_function_a = [](const std::vector<std::string>& arguments) { return arguments.empty(); };
command_registry.register_command(command_name_a, agrument_count_a, command_function_a);
const auto command_name_b = std::string{"commandb"};
const auto argument_count_b = 1;
const auto command_function_b = [](const std::vector<std::string>& arguments) { return arguments.size() == 1; };
command_registry.register_command(command_name_b, argument_count_b, command_function_b);
const auto command_name_c = std::string{"commandc"};
const auto argument_count_c = 2;
const auto command_function_c = [](const std::vector<std::string>& arguments) { return arguments.size() == 2; };
command_registry.register_command(command_name_c, argument_count_c, command_function_c);
WHEN("A correct command string is to be parsed") {
const auto command_string = "commanda;commandb 0;commandc abc 0.0";
auto parsed_commands = SimulationCommand::parse_sim_commands(command_string, command_registry);
THEN("A queue of executable SimCommands exists.") {
CHECK(parsed_commands.front().execute());
parsed_commands.pop();
CHECK(parsed_commands.front().execute());
parsed_commands.pop();
CHECK(parsed_commands.front().execute());
parsed_commands.pop();
CHECK(parsed_commands.empty());
}
THEN("A queue of executable SimCommands exists.") {
CHECK(parsed_commands.front().execute());
parsed_commands.pop();
CHECK(parsed_commands.front().execute());
parsed_commands.pop();
CHECK(parsed_commands.front().execute());
parsed_commands.pop();
CHECK(parsed_commands.empty());
}
}
WHEN("A command string with wrong arguments is to be parsed") {
const auto command_string = "commanda 1;commandb;commandc abc 0.0 def";
auto parsed_commands = SimulationCommand::parse_sim_commands(command_string, command_registry);
THEN("The execution of the commands should fail.") {
CHECK_THROWS_WITH(parsed_commands.front().execute(),
"Invalid number of arguments for: commanda expected 0 got 1");
parsed_commands.pop();
CHECK_THROWS_WITH(parsed_commands.front().execute(),
"Invalid number of arguments for: commandb expected 1 got 0");
parsed_commands.pop();
CHECK_THROWS_WITH(parsed_commands.front().execute(),
"Invalid number of arguments for: commandc expected 2 got 3");
parsed_commands.pop();
CHECK(parsed_commands.empty());
}
}
WHEN("A command string with unregistered arguments is to be parsed") {
const auto command_string = "commandd;commande;commandf";
THEN("Parsing should fail") {
CHECK_THROWS_WITH(SimulationCommand::parse_sim_commands(command_string, command_registry),
"Command not found: commandd");
}
}
WHEN("An empty string is to be parsed") {
const auto command_string = "";
const auto parsed_commands = SimulationCommand::parse_sim_commands(command_string, command_registry);
THEN("It should create an empty queue") {
CHECK(parsed_commands.empty());
}
}
}
}