Skip to content

Commit

Permalink
Various improvements to ecFlow tests ECFLOW-1934
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento authored Dec 21, 2023
2 parents ec5841a + d1853c2 commit 21f37df
Show file tree
Hide file tree
Showing 220 changed files with 2,127 additions and 1,855 deletions.
13 changes: 3 additions & 10 deletions ACore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ set(test_srcs
test/TestSanitizerAS.cpp
test/TestSanitizerUB.cpp
test/TestSerialisation.cpp
test/TestStackTrace.cpp
test/TestStr.cpp
test/TestStringSplitPerf.cpp
test/TestStringSplitter.cpp
Expand All @@ -171,7 +170,7 @@ set(test_srcs

ecbuild_add_test(
TARGET
u_acore
u_core
LABELS
unit
nightly
Expand All @@ -181,14 +180,8 @@ ecbuild_add_test(
test_support
core
Boost::boost # Boost header-only libraries must be available (namely unit_test_framework)
#
# Important!
#
# Boost::timer, Boost::chrono are required when certain definitions are manually turned on, e.g.
# - FILE_PERF_CHECK_IMPLEMENTATIONS, at TestFile.cpp
# - STRING_SPLIT_IMPLEMENTATIONS_PERF_CHECK_, at TestStringSplitPerf.cpp
#
Boost::timer
)
target_clangformat(u_acore
target_clangformat(u_core
CONDITION ENABLE_TESTS
)
40 changes: 5 additions & 35 deletions ACore/test/TestCalendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,9 @@ using namespace ecf;
using namespace boost::posix_time;
using namespace boost::gregorian;

BOOST_AUTO_TEST_SUITE(CoreTestSuite)

// static boost::posix_time::time_duration diff_d(boost::posix_time::time_duration t1, boost::posix_time::time_duration
// t2)
//{
// // t2 > t1 otherwise assume we have gone over midnight
// if (t2 > t1) return t2 - t1;
//
// boost::posix_time::time_duration midnight(24,0,0);
// boost::posix_time::time_duration diff_from_midnight = midnight - t1;
// std::cout << to_simple_string(diff_from_midnight) << "\n";
//
// return diff_from_midnight + t2;
// }
//
// BOOST_AUTO_TEST_CASE( test_calendar_3 )
//{
// cout << "ACore:: ...test_calendar_3\n";
//
// Calendar calendar;
// BOOST_CHECK_MESSAGE(calendar.hybrid(),"Default calendar type should be hybrid");
//
// // init the calendar to 2009, Feb, 10th, 15 minutes past midnight
//
// boost::posix_time::time_duration t1(23,0,0);
// boost::posix_time::time_duration t2(1,0,0);
// boost::posix_time::time_duration expected(2,0,0);
//// std::cout << to_simple_string(t1) << "\n";
//// std::cout << to_simple_string(t2) << "\n";
//// std::cout << to_simple_string(t1 - t2) << "\n";
//// std::cout << to_simple_string(t2 - t1) << "\n";
//
// BOOST_CHECK_MESSAGE(diff_d(t1,t2) == expected," Expected " << to_simple_string(expected) << " but found " <<
// to_simple_string(diff_d(t1,t2)));
//}
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_Calendar)

BOOST_AUTO_TEST_CASE(test_calendar_default_ptime) {
cout << "ACore:: ...test_calendar_default_ptime \n";
Expand Down Expand Up @@ -548,3 +516,5 @@ BOOST_AUTO_TEST_CASE(test_calendar_julian) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestCereal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ std::ostream& operator<<(std::ostream& os, MyTop const& m) {

// =================================================================================

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_Cereal)

BOOST_AUTO_TEST_CASE(test_cereal_json) {
cout << "ACore:: ...test_cereal_json \n";
Expand Down Expand Up @@ -110,3 +112,5 @@ BOOST_AUTO_TEST_CASE(test_cereal_json2) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestCerealOptionalNVP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ std::ostream& operator<<(std::ostream& os, Base const& m) {

// =================================================================================

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_CerealOptionalNVP)

BOOST_AUTO_TEST_CASE(test_cereal_optional) {
cout << "ACore:: ...test_cereal_optional\n";
Expand Down Expand Up @@ -81,3 +83,5 @@ BOOST_AUTO_TEST_CASE(test_cereal_optional) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestCerealWithHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ CEREAL_REGISTER_TYPE(Derived1)

// =================================================================================

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_CerealWithHierarchy)

BOOST_AUTO_TEST_CASE(test_cereal_save_as_string_and_save_as_filename) {
cout << "ACore:: ...test_cereal_save_as_string_and_save_as_filename\n";
Expand Down Expand Up @@ -146,3 +148,5 @@ BOOST_AUTO_TEST_CASE(test_cereal_save_as_string_and_save_as_filename) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestClassDataMemberInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class MyType {
int* my_ptr_{nullptr}; // show be applied for all constructor types
};

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_ClassDataMemberInit)

BOOST_AUTO_TEST_CASE(test_class_data_member_init) {
cout << "ACore:: ...test_class_data_member_init \n";
Expand Down Expand Up @@ -107,3 +109,5 @@ BOOST_AUTO_TEST_CASE(test_class_data_member_init) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
using namespace boost;
using namespace std;

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_CommandLine)

static void doCheck(const std::vector<std::string>& theArgs) {
CommandLine cl(theArgs);
Expand Down Expand Up @@ -122,3 +124,5 @@ BOOST_AUTO_TEST_CASE(test_command_line_is_able_to_handle_single_quotes_in_double
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
4 changes: 2 additions & 2 deletions ACore/test/TestConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ struct ecf::converter_traits<Widget, Gizmo>
inline static Gizmo convert(const Widget&) { return Gizmo{}; }
};

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(Converter)
BOOST_AUTO_TEST_SUITE(T_Converter)

BOOST_AUTO_TEST_CASE(can_convert_from_numeric_to_string) {
BOOST_CHECK_EQUAL(ecf::convert_to<std::string>(0), "0");
Expand Down
2 changes: 1 addition & 1 deletion ACore/test/TestCore_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
* nor does it submit to any jurisdiction.
*/

#define BOOST_TEST_MODULE TestCore
#define BOOST_TEST_MODULE Test_Core
#include <boost/test/included/unit_test.hpp>
4 changes: 2 additions & 2 deletions ACore/test/TestExtract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "ecflow/core/Extract.hpp"

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(TestExtract)
BOOST_AUTO_TEST_SUITE(T_Extract)

BOOST_AUTO_TEST_CASE(can_extract_path_and_name) {
using namespace std::string_literals;
Expand Down
6 changes: 5 additions & 1 deletion ACore/test/TestFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ using namespace boost;
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_File)

BOOST_AUTO_TEST_CASE(test_splitFileIntoLines) {
// This is sanity test for splitFileIntoLines used extensively
Expand Down Expand Up @@ -550,3 +552,5 @@ BOOST_AUTO_TEST_CASE(test_get_all_files_by_extension) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
74 changes: 33 additions & 41 deletions ACore/test/TestGetUserDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,36 @@
* nor does it submit to any jurisdiction.
*/

// #include <boost/test/unit_test.hpp>
// #include <string>
// #include <iostream>
//
//
// #include <pwd.h> /* getpwdid */
// #include <sys/types.h>
// #include <unistd.h>
// #include <cstdio>
//
// using namespace std;
// using namespace ecf;
//
// BOOST_AUTO_TEST_SUITE( CoreTestSuite )

// BOOST_AUTO_TEST_CASE( test_get_user_details )
//{
// cout << "ACore:: ...test_get_user_details\n";
//
//
// struct passwd *passwd; /* man getpwuid */
//
// passwd = getpwuid ( getuid()); /* Get the uid of the running processand use it to get a record from /etc/passwd
//*/
//
// printf("\n The Real User Name is %s ", passwd->pw_gecos);
//
// printf("\n The Login Name is %s ", passwd->pw_name);
//
// printf("\n The Home Directory is %s", passwd->pw_dir);
//
// printf("\n The Login Shell is %s ", passwd->pw_shell);
//
// printf("\n The Passwd is %s ", getpwuid(getuid())->pw_passwd);
//
// printf("\n The uid is %lu ", (unsigned long) getpwuid(getuid())->pw_uid);
//
// printf("\n The gid is %lu \n\n", (unsigned long) getpwuid(getuid())->pw_gid);
// }

// BOOST_AUTO_TEST_SUITE_END()
#include <cstdio>
#include <iostream>
#include <pwd.h> /* getpwdid */
#include <string>
#include <unistd.h>

#include <boost/test/unit_test.hpp>
#include <sys/types.h>

using namespace std;

BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_GetUserDetails)

BOOST_AUTO_TEST_CASE(test_get_user_details, *boost::unit_test::disabled()) {
cout << "ACore:: ...test_get_user_details\n";

/* Get the uid of the running processand use it to get a record from /etc/passwd */
struct passwd* passwd = getpwuid(getuid());

printf("\n The Real User Name is %s ", passwd->pw_gecos);
printf("\n The Login Name is %s ", passwd->pw_name);
printf("\n The Home Directory is %s", passwd->pw_dir);
printf("\n The Login Shell is %s ", passwd->pw_shell);
printf("\n The Passwd is %s ", getpwuid(getuid())->pw_passwd);
printf("\n The uid is %lu ", (unsigned long)getpwuid(getuid())->pw_uid);
printf("\n The gid is %lu \n\n", (unsigned long)getpwuid(getuid())->pw_gid);
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ using namespace ecf;
using namespace std;
using namespace boost;

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_Log)

static std::string getLogPath() {

Expand Down Expand Up @@ -377,3 +379,5 @@ BOOST_AUTO_TEST_CASE(test_get_log_timing) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion ACore/test/TestMigration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ using namespace ecf;
using namespace boost::posix_time;
using namespace boost::gregorian;

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_Migration)

// If you are updating the tests, *MAKE SURE* to check out test/data/migration/* files
// #define UPDATE_TESTS 1
Expand Down Expand Up @@ -65,3 +67,5 @@ BOOST_AUTO_TEST_CASE(test_migration_restore_cereal) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
44 changes: 25 additions & 19 deletions ACore/test/TestNodePath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
#include <string>

#include <boost/test/unit_test.hpp>
#include <boost/timer/timer.hpp>

#include "ecflow/core/NodePath.hpp"

using namespace std;

BOOST_AUTO_TEST_SUITE(CoreTestSuite)
BOOST_AUTO_TEST_SUITE(U_Core)

BOOST_AUTO_TEST_SUITE(T_NodePath)

static void checkPath(const std::vector<std::string>& expectedPath, const std::string& path) {
std::vector<std::string> thePath;
Expand Down Expand Up @@ -116,23 +119,26 @@ BOOST_AUTO_TEST_CASE(test_extractHostPort) {
BOOST_CHECK_MESSAGE(host == "host" && port == "port", "expected 'host:port' found " << host << ":" << port);
}

// BOOST_AUTO_TEST_CASE( test_NodePath_perf )
//{
// cout << "ACore:: ...test_NodePath_perf \n";
//
// // Timing using:
// // StringSplitter : 6.35
// // Str::split : 8.64
// // See: Str::split -> define USE_STRINGSPLITTER
//
// boost::timer timer; // measures CPU, replace with cpu_timer with boost > 1.51, measures cpu & elapsed
// int n= 10000000 ;
// std::vector<std::string> thePath;thePath.reserve(20);
// for(int i = 0; i < n; i++) {
// thePath.clear();
// NodePath::split("/this/is/a/test/string/that/will/be/used/to/check/perf/of/node/path/extraction",thePath);
// }
// cout << "Timing for " << n << " NodePath is " << timer.elapsed() << endl;
// }
BOOST_AUTO_TEST_CASE(test_NodePath_perf, *boost::unit_test::disabled()) {
cout << "ACore:: ...test_NodePath_perf \n";

// Timing using:
// StringSplitter : 6.35
// Str::split : 8.64
// See: Str::split -> define USE_STRINGSPLITTER

// measures CPU, replace with cpu_timer with boost > 1.51, measures cpu & elapsed
boost::timer::auto_cpu_timer timer;
int n = 10000000;
std::vector<std::string> thePath;
thePath.reserve(20);
for (int i = 0; i < n; i++) {
thePath.clear();
NodePath::split("/this/is/a/test/string/that/will/be/used/to/check/perf/of/node/path/extraction", thePath);
}
cout << "Timing for " << n << " NodePath is " << timer.elapsed().wall << endl;
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
Loading

0 comments on commit 21f37df

Please sign in to comment.