##// END OF EJS Templates
Merge branch 'feature/FuzingTests' into develop
Alexandre Leroux -
r1181:2728fb97fd33 merge
parent child
Show More
@@ -0,0 +1,8
1 #include "FuzzingDefs.h"
2
3 const QString NB_MAX_OPERATIONS_PROPERTY = QStringLiteral("component");
4 const QString NB_MAX_VARIABLES_PROPERTY = QStringLiteral("nbMaxVariables");
5 const QString AVAILABLE_OPERATIONS_PROPERTY = QStringLiteral("availableOperations");
6 const QString MAX_RANGE_PROPERTY = QStringLiteral("maxRange");
7 const QString METADATA_POOL_PROPERTY = QStringLiteral("metadataPool");
8 const QString PROVIDER_PROPERTY = QStringLiteral("provider");
@@ -0,0 +1,38
1 #ifndef SCIQLOP_FUZZINGDEFS_H
2 #define SCIQLOP_FUZZINGDEFS_H
3
4 #include <QString>
5 #include <QVariantHash>
6
7 // /////// //
8 // Aliases //
9 // /////// //
10
11 using MetadataPool = std::vector<QVariantHash>;
12 Q_DECLARE_METATYPE(MetadataPool)
13
14 using Properties = QVariantHash;
15
16 // ///////// //
17 // Constants //
18 // ///////// //
19
20 /// Max number of operations to generate
21 extern const QString NB_MAX_OPERATIONS_PROPERTY;
22
23 /// Max number of variables to manipulate through operations
24 extern const QString NB_MAX_VARIABLES_PROPERTY;
25
26 /// Set of operations available for the test
27 extern const QString AVAILABLE_OPERATIONS_PROPERTY;
28
29 /// Max range that an operation can reach
30 extern const QString MAX_RANGE_PROPERTY;
31
32 /// Set of metadata that can be associated to a variable
33 extern const QString METADATA_POOL_PROPERTY;
34
35 /// Provider used to retrieve data
36 extern const QString PROVIDER_PROPERTY;
37
38 #endif // SCIQLOP_FUZZINGDEFS_H
@@ -0,0 +1,74
1 #include "FuzzingOperations.h"
2 #include "FuzzingUtils.h"
3
4 #include <Data/IDataProvider.h>
5
6 #include <Variable/Variable.h>
7 #include <Variable/VariableController.h>
8
9 #include <QUuid>
10
11 Q_LOGGING_CATEGORY(LOG_FuzzingOperations, "FuzzingOperations")
12
13 namespace {
14
15 struct CreateOperation : public IFuzzingOperation {
16 bool canExecute(std::shared_ptr<Variable> variable) const override
17 {
18 // A variable can be created only if it doesn't exist yet
19 return variable == nullptr;
20 }
21
22 void execute(std::shared_ptr<Variable> &variable, VariableController &variableController,
23 const Properties &properties) const override
24 {
25 // Retrieves metadata pool from properties, and choose one of the metadata entries to
26 // associate it with the variable
27 auto metaDataPool = properties.value(METADATA_POOL_PROPERTY).value<MetadataPool>();
28 auto variableMetadata = RandomGenerator::instance().randomChoice(metaDataPool);
29
30 // Retrieves provider
31 auto variableProvider
32 = properties.value(PROVIDER_PROPERTY).value<std::shared_ptr<IDataProvider> >();
33
34 auto variableName = QString{"Var_%1"}.arg(QUuid::createUuid().toString());
35 qCInfo(LOG_FuzzingOperations())
36 << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")";
37
38 auto newVariable
39 = variableController.createVariable(variableName, variableMetadata, variableProvider);
40 std::swap(variable, newVariable);
41 }
42 };
43
44 struct UnknownOperation : public IFuzzingOperation {
45 bool canExecute(std::shared_ptr<Variable> variable) const override
46 {
47 Q_UNUSED(variable);
48 return false;
49 }
50
51 void execute(std::shared_ptr<Variable> &variable, VariableController &variableController,
52 const Properties &properties) const override
53 {
54 Q_UNUSED(variable);
55 Q_UNUSED(variableController);
56 Q_UNUSED(properties);
57 // Does nothing
58 }
59 };
60
61 } // namespace
62
63 std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperationType type)
64 {
65 switch (type) {
66 case FuzzingOperationType::CREATE:
67 return std::make_unique<CreateOperation>();
68 default:
69 // Default case returns unknown operation
70 break;
71 }
72
73 return std::make_unique<UnknownOperation>();
74 }
@@ -0,0 +1,49
1 #ifndef SCIQLOP_FUZZINGOPERATIONS_H
2 #define SCIQLOP_FUZZINGOPERATIONS_H
3
4 #include "FuzzingDefs.h"
5
6 #include <memory>
7 #include <set>
8
9 #include <QLoggingCategory>
10 #include <QMetaType>
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingOperations)
13
14 class Variable;
15 class VariableController;
16
17 /**
18 * Enumeration of types of existing fuzzing operations
19 */
20 enum class FuzzingOperationType { CREATE };
21
22 /// Interface that represents an operation that can be executed during a fuzzing test
23 struct IFuzzingOperation {
24 virtual ~IFuzzingOperation() noexcept = default;
25
26 /// Checks if the operation can be executed according to the current state of the variable
27 /// passed in parameter
28 virtual bool canExecute(std::shared_ptr<Variable> variable) const = 0;
29 /// Executes the operation on the variable passed in parameter
30 /// @param variable the variable on which to execute the operation
31 /// @param variableController the controller associated to the operation
32 /// @param properties properties that can be used to configure the operation
33 /// @remarks variable is passed as a reference because, according to the operation, it can be
34 /// modified (in/out parameter)
35 virtual void execute(std::shared_ptr<Variable> &variable,
36 VariableController &variableController,
37 const Properties &properties = {}) const = 0;
38 };
39
40 /// Factory of @sa IFuzzingOperation
41 struct FuzzingOperationFactory {
42 /// Creates a fuzzing operation from a type
43 static std::unique_ptr<IFuzzingOperation> create(FuzzingOperationType type);
44 };
45
46 using OperationsTypes = std::set<FuzzingOperationType>;
47 Q_DECLARE_METATYPE(OperationsTypes)
48
49 #endif // SCIQLOP_FUZZINGOPERATIONS_H
@@ -0,0 +1,25
1 #include "FuzzingUtils.h"
2
3 RandomGenerator &RandomGenerator::instance()
4 {
5 static auto instance = RandomGenerator();
6 return instance;
7 }
8
9 double RandomGenerator::generateDouble(double min, double max)
10 {
11 std::uniform_real_distribution<double> dist{min, max};
12 return dist(m_Mt);
13 }
14
15 int RandomGenerator::generateInt(int min, int max)
16 {
17 std::uniform_int_distribution<int> dist{min, max};
18 return dist(m_Mt);
19 }
20
21 RandomGenerator::RandomGenerator()
22 {
23 std::random_device rd{};
24 m_Mt = std::mt19937{rd()};
25 }
@@ -0,0 +1,41
1 #ifndef SCIQLOP_FUZZINGUTILS_H
2 #define SCIQLOP_FUZZINGUTILS_H
3
4 #include <random>
5
6 /**
7 * Class that proposes random utility methods
8 */
9 class RandomGenerator {
10 public:
11 /// @return the unique instance of the random generator
12 static RandomGenerator &instance();
13
14 /// Generates a random double between [min, max]
15 double generateDouble(double min, double max);
16 /// Generates a random int between [min, max]
17 int generateInt(int min, int max);
18
19 /// Returns a random element among the elements of a container. If the container is empty,
20 /// returns an element built by default
21 template <typename T, typename ValueType = typename T::value_type>
22 ValueType randomChoice(const T &container);
23
24 private:
25 std::mt19937 m_Mt;
26
27 explicit RandomGenerator();
28 };
29
30 template <typename T, typename ValueType>
31 ValueType RandomGenerator::randomChoice(const T &container)
32 {
33 if (container.empty()) {
34 return ValueType{};
35 }
36
37 auto randomIndex = generateInt(0, container.size() - 1);
38 return container.at(randomIndex);
39 }
40
41 #endif // SCIQLOP_FUZZINGUTILS
@@ -0,0 +1,241
1 #include "FuzzingDefs.h"
2 #include "FuzzingOperations.h"
3 #include "FuzzingUtils.h"
4
5 #include "AmdaProvider.h"
6
7 #include <Network/NetworkController.h>
8 #include <SqpApplication.h>
9 #include <Time/TimeController.h>
10 #include <Variable/VariableController.h>
11
12 #include <QLoggingCategory>
13 #include <QObject>
14 #include <QtTest>
15
16 #include <memory>
17
18 Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
19
20 namespace {
21
22 // /////// //
23 // Aliases //
24 // /////// //
25
26 using VariableId = int;
27
28 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
29 using VariablesOperations = std::vector<VariableOperation>;
30
31 using OperationsPool = std::set<std::shared_ptr<IFuzzingOperation> >;
32 using VariablesPool = std::map<VariableId, std::shared_ptr<Variable> >;
33
34 // ///////// //
35 // Constants //
36 // ///////// //
37
38 // Defaults values used when the associated properties have not been set for the test
39 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
40 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
41 const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE
42 = QVariant::fromValue(OperationsTypes{FuzzingOperationType::CREATE});
43
44 // /////// //
45 // Methods //
46 // /////// //
47
48 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
49 /// pairs that are valid (i.e. operation that can be executed on variable)
50 VariablesOperations availableOperations(const VariablesPool &variablesPool,
51 const OperationsPool &operationsPool)
52 {
53 VariablesOperations result{};
54
55 for (const auto &variablesPoolEntry : variablesPool) {
56 auto variableId = variablesPoolEntry.first;
57 auto variable = variablesPoolEntry.second;
58
59 for (const auto &operation : operationsPool) {
60 // A pair is valid if the current operation can be executed on the current variable
61 if (operation->canExecute(variable)) {
62 result.push_back({variableId, operation});
63 }
64 }
65 }
66
67 return result;
68 }
69
70 OperationsPool createOperationsPool(const OperationsTypes &types)
71 {
72 OperationsPool result{};
73
74 std::transform(types.cbegin(), types.cend(), std::inserter(result, result.end()),
75 [](const auto &type) { return FuzzingOperationFactory::create(type); });
76
77 return result;
78 }
79
80 /**
81 * Class to run random tests
82 */
83 class FuzzingTest {
84 public:
85 explicit FuzzingTest(VariableController &variableController, Properties properties)
86 : m_VariableController{variableController},
87 m_Properties{std::move(properties)},
88 m_VariablesPool{}
89 {
90 // Inits variables pool: at init, all variables are null
91 for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
92 m_VariablesPool[variableId] = nullptr;
93 }
94 }
95
96 void execute()
97 {
98 qCInfo(LOG_TestAmdaFuzzing()) << "Running" << nbMaxOperations() << "operations on"
99 << nbMaxVariables() << "variable(s)...";
100
101 auto canExecute = true;
102 for (auto i = 0; i < nbMaxOperations() && canExecute; ++i) {
103 // Retrieves all operations that can be executed in the current context
104 auto variableOperations = availableOperations(m_VariablesPool, operationsPool());
105
106 canExecute = !variableOperations.empty();
107 if (canExecute) {
108 // Of the operations available, chooses a random operation and executes it
109 auto variableOperation
110 = RandomGenerator::instance().randomChoice(variableOperations);
111
112 auto variableId = variableOperation.first;
113 auto variable = m_VariablesPool.at(variableId);
114 auto fuzzingOperation = variableOperation.second;
115
116 fuzzingOperation->execute(variable, m_VariableController, m_Properties);
117
118 // Updates variable pool with the new state of the variable after operation
119 m_VariablesPool[variableId] = variable;
120 }
121 else {
122 qCInfo(LOG_TestAmdaFuzzing())
123 << "No more operations are available, the execution of the test will stop...";
124 }
125 }
126
127 qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed.";
128 }
129
130 private:
131 int nbMaxOperations() const
132 {
133 static auto result
134 = m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE)
135 .toInt();
136 return result;
137 }
138
139 int nbMaxVariables() const
140 {
141 static auto result
142 = m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt();
143 return result;
144 }
145
146 OperationsPool operationsPool() const
147 {
148 static auto result = createOperationsPool(
149 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
150 .value<OperationsTypes>());
151 return result;
152 }
153
154 VariableController &m_VariableController;
155 Properties m_Properties;
156 VariablesPool m_VariablesPool;
157 };
158
159 } // namespace
160
161 class TestAmdaFuzzing : public QObject {
162 Q_OBJECT
163
164 private slots:
165 /// Input data for @sa testFuzzing()
166 void testFuzzing_data();
167 void testFuzzing();
168 };
169
170 void TestAmdaFuzzing::testFuzzing_data()
171 {
172 // ////////////// //
173 // Test structure //
174 // ////////////// //
175
176 QTest::addColumn<Properties>("properties"); // Properties for random test
177
178 // ////////// //
179 // Test cases //
180 // ////////// //
181
182 auto maxRange = SqpRange::fromDateTime({2017, 1, 1}, {0, 0}, {2017, 1, 5}, {0, 0});
183 MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "imf"}}};
184
185 // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the
186 // QVariant
187 std::shared_ptr<IDataProvider> provider = std::make_shared<AmdaProvider>();
188
189 QTest::newRow("fuzzingTest") << Properties{
190 {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
191 {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
192 {PROVIDER_PROPERTY, QVariant::fromValue(provider)}};
193 }
194
195 void TestAmdaFuzzing::testFuzzing()
196 {
197 QFETCH(Properties, properties);
198
199 auto &variableController = sqpApp->variableController();
200 auto &timeController = sqpApp->timeController();
201
202 // Generates random initial range (bounded to max range)
203 auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE))
204 .value<SqpRange>();
205
206 QVERIFY(maxRange != INVALID_RANGE);
207
208 auto initialRangeStart
209 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
210 auto initialRangeEnd
211 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
212 if (initialRangeStart > initialRangeEnd) {
213 std::swap(initialRangeStart, initialRangeEnd);
214 }
215
216 // Sets initial range on time controller
217 SqpRange initialRange{initialRangeStart, initialRangeEnd};
218 qCInfo(LOG_TestAmdaFuzzing()) << "Setting initial range to" << initialRange << "...";
219 timeController.onTimeToUpdate(initialRange);
220
221 FuzzingTest test{variableController, properties};
222 test.execute();
223 }
224
225 int main(int argc, char *argv[])
226 {
227 QLoggingCategory::setFilterRules(
228 "*.warning=false\n"
229 "*.info=false\n"
230 "*.debug=false\n"
231 "FuzzingOperations.info=true\n"
232 "TestAmdaFuzzing.info=true\n");
233
234 SqpApplication app{argc, argv};
235 app.setAttribute(Qt::AA_Use96Dpi, true);
236 TestAmdaFuzzing testObject{};
237 QTEST_SET_MAIN_SOURCE_PATH
238 return QTest::qExec(&testObject, argc, argv);
239 }
240
241 #include "TestAmdaFuzzing.moc"
@@ -1,58 +1,66
1 1 #ifndef SCIQLOP_SQPRANGE_H
2 2 #define SCIQLOP_SQPRANGE_H
3 3
4 4 #include <QObject>
5 5
6 6 #include <QDebug>
7 7
8 8 #include <Common/DateUtils.h>
9 9 #include <Common/MetaTypes.h>
10 10
11 11 #include <cmath>
12 12
13 13 /**
14 14 * @brief The SqpRange struct holds the information of time parameters
15 15 */
16 16 struct SqpRange {
17 /// Creates SqpRange from dates and times
18 static SqpRange fromDateTime(const QDate &startDate, const QTime &startTime,
19 const QDate &endDate, const QTime &endTime)
20 {
21 return {DateUtils::secondsSinceEpoch(QDateTime{startDate, startTime}),
22 DateUtils::secondsSinceEpoch(QDateTime{endDate, endTime})};
23 }
24
17 25 /// Start time (UTC)
18 26 double m_TStart;
19 27 /// End time (UTC)
20 28 double m_TEnd;
21 29
22 30 bool contains(const SqpRange &dateTime) const noexcept
23 31 {
24 32 return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd);
25 33 }
26 34
27 35 bool intersect(const SqpRange &dateTime) const noexcept
28 36 {
29 37 return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd);
30 38 }
31 39
32 40 bool operator==(const SqpRange &other) const
33 41 {
34 42 auto equals = [](const auto &v1, const auto &v2) {
35 43 return (std::isnan(v1) && std::isnan(v2)) || v1 == v2;
36 44 };
37 45
38 46 return equals(m_TStart, other.m_TStart) && equals(m_TEnd, other.m_TEnd);
39 47 }
40 48 bool operator!=(const SqpRange &other) const { return !(*this == other); }
41 49 };
42 50
43 51 const auto INVALID_RANGE
44 52 = SqpRange{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
45 53
46 54 inline QDebug operator<<(QDebug d, SqpRange obj)
47 55 {
48 56 auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart);
49 57 auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd);
50 58
51 59 d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd;
52 60 return d;
53 61 }
54 62
55 63 // Required for using shared_ptr in signals/slots
56 64 SCIQLOP_REGISTER_META_TYPE(SQPRANGE_REGISTRY, SqpRange)
57 65
58 66 #endif // SCIQLOP_SQPRANGE_H
@@ -1,167 +1,168
1 1 ## amda - CMakeLists.txt
2 2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 3 SET(SQPAMDA_LIBRARY_NAME "${LIBRARY_PREFFIX}_amda${DEBUG_SUFFIX}")
4 4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
7 7 SET(TESTS_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests-resources")
8 8
9 9 # Include amda directory
10 10 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
11 11 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
12 12
13 13 #
14 14 # Find Qt modules
15 15 #
16 16 SCIQLOP_FIND_QT(Core Widgets Network)
17 17
18 18 #
19 19 # Find dependent libraries
20 20 # ========================
21 21
22 22 # sciqlop plugin
23 23 find_package(sciqlop-plugin)
24 24 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
25 25
26 26 # sciqlop core
27 27 find_package(sciqlop-core)
28 28 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
29 29 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
30 30
31 31 # sciqlop gui
32 32 find_package(sciqlop-gui)
33 33 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
34 34 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
35 35
36 36 # Description file
37 37 FILE (GLOB_RECURSE PLUGIN_FILE ${RESOURCES_DIR}/amda.json)
38 38
39 39 # Resources files
40 40 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.qrc)
41 41
42 42 #
43 43 # Compile the library
44 44 #
45 45
46 46 ADD_DEFINITIONS(-DAMDA_LIB)
47 47
48 48 FILE (GLOB_RECURSE MODULE_SOURCES
49 49 ${INCLUDES_DIR}/*.h
50 50 ${SOURCES_DIR}/*.c
51 51 ${SOURCES_DIR}/*.cpp
52 52 ${SOURCES_DIR}/*.h
53 53 ${PLUGIN_FILE})
54 54
55 55 QT5_ADD_RESOURCES(RCC_AMDA
56 56 ${PROJECT_RESOURCES}
57 57 )
58 58
59 59 ADD_LIBRARY(${SQPAMDA_LIBRARY_NAME} ${MODULE_SOURCES} ${RCC_AMDA})
60 60 set_property(TARGET ${SQPAMDA_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
61 61 set_property(TARGET ${SQPAMDA_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
62 62
63 63 INSTALL(TARGETS ${SQPAMDA_LIBRARY_NAME}
64 64 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
65 65 LIBRARY DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR}
66 66 ARCHIVE DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR}
67 67 )
68 68
69 69
70 70 TARGET_LINK_LIBRARIES(${SQPAMDA_LIBRARY_NAME} ${LIBRARIES})
71 71 qt5_use_modules(${SQPAMDA_LIBRARY_NAME} Core Widgets Network)
72 72
73 73 add_dependencies(${SQPAMDA_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
74 74
75 75 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
76 76 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
77 77 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
78 78 IF(BUILD_SHARED_LIBS)
79 79 SET_TARGET_PROPERTIES(${SQPAMDA_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
80 80 ELSE()
81 81 TARGET_COMPILE_DEFINITIONS(${SQPAMDA_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
82 82 ENDIF()
83 83
84 84 # Set the variable to parent scope so that the other projects can copy the
85 85 # dependent shared libraries
86 86 SCIQLOP_SET_TO_PARENT_SCOPE(SQPAMDA_LIBRARY_NAME)
87 87
88 88 # Copy extern shared libraries to the lib folder
89 89 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPAMDA_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
90 90
91 91 # Add the files to the list of files to be analyzed
92 92 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
93 93 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
94 94 # Vera++ exclusion files
95 95 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
96 96 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
97 97
98 98 #
99 99 # Compile the tests
100 100 #
101 101 IF(BUILD_TESTS)
102 102 INCLUDE_DIRECTORIES(${SOURCES_DIR})
103 103 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
104 104 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
105 105 SET( TEST_LIBRARIES ${SQPAMDA_LIBRARY_NAME})
106 106
107 107 FOREACH( testFile ${TESTS_SOURCES} )
108 108 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
109 109 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
110 110
111 111 # Add to the list of sources files all the sources in the same
112 112 # directory that aren't another test
113 113 FILE (GLOB currentTestSources
114 114 ${testDirectory}/*.c
115 115 ${testDirectory}/*.cpp
116 116 ${testDirectory}/*.h)
117 117 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
118 LIST(APPEND testFilesToFormat ${currentTestSources})
118 119 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
119 120
120 121 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
121 122 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
122 123 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
123 124 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
124 125 qt5_use_modules(${testName} Test)
125 126
126 127 ADD_TEST( NAME ${testName} COMMAND ${testName} )
127 128
128 129 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
129 130 ENDFOREACH( testFile )
130 131
131 132 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
132 133 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
133 134 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
134 135 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
135 136
136 137 ADD_DEFINITIONS(-DAMDA_TESTS_RESOURCES_DIR="${TESTS_RESOURCES_DIR}")
137 138 ENDIF(BUILD_TESTS)
138 139
139 140 #
140 141 # Set the files that must be formatted by clang-format.
141 142 #
142 143 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
143 144 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
144 145
145 146 #
146 147 # Set the directories that doxygen must browse to generate the
147 148 # documentation.
148 149 #
149 150 # Source directories:
150 151 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
151 152 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
152 153 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
153 154 # Source directories to exclude from the documentation generation
154 155 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
155 156 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
156 157
157 158 #
158 159 # Set the directories with the sources to analyze and propagate the
159 160 # modification to the parent scope
160 161 #
161 162 # Source directories to analyze:
162 163 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
163 164 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
164 165 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
165 166 # Source directories to exclude from the analysis
166 167 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
167 168 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,76 +1,87
1 1
2 2 amdaplugin_moc_headers = [
3 3 'include/AmdaPlugin.h',
4 4 'include/AmdaProvider.h'
5 5 ]
6 6
7 7 amdaplugin_sources = [
8 8 'src/AmdaDefs.cpp',
9 9 'src/AmdaParser.cpp',
10 10 'src/AmdaPlugin.cpp',
11 11 'src/AmdaProvider.cpp',
12 12 'src/AmdaResultParser.cpp',
13 13 'src/AmdaResultParserDefs.cpp',
14 14 'src/AmdaResultParserHelper.cpp',
15 15 'src/AmdaServer.cpp'
16 16 ]
17 17
18 18 amdaplugin_ui_files = []
19 19 amdaplugin_resources_files = [
20 20 'resources/amdaresources.qrc'
21 21 ]
22 22
23 23 amdaplugin_inc = include_directories(['include', '../../plugin/include'])
24 24
25 25 moc_gen = generator(moc,
26 26 output : 'moc_@BASENAME@.cpp',
27 27 arguments : ['@INPUT@',
28 28 '-DSCIQLOP_PLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/amda/resources/amda.json"',
29 29 '-I', meson.current_source_dir()+'/include',
30 30 '-I', meson.current_source_dir()+'/../../plugin/include',
31 31 '-o', '@OUTPUT@'])
32 32
33 33 rcc_gen = generator(rcc,
34 34 output : 'qrc_@BASENAME@.cpp',
35 35 arguments : ['--name=@BASENAME@"',
36 36 '--output',
37 37 '@OUTPUT@',
38 38 '@INPUT@'])
39 39
40 40 amdaplugin_moc_plugin_files = moc_gen.process(amdaplugin_moc_headers)
41 41
42 42 amdaplugin_rcc_plugin_files = rcc_gen.process(amdaplugin_resources_files)
43 43
44 44 #amdaplugin_rcc_plugin_files = qt5.preprocess(
45 45 # qresources : amdaplugin_resources_files)
46 46
47 47 amdaplugin_moc_files = qt5.preprocess(
48 48 ui_files : amdaplugin_ui_files)
49 49
50 50 sciqlop_amdaplugin = library('amdaplugin',
51 51 amdaplugin_sources,
52 52 amdaplugin_moc_files,
53 53 amdaplugin_rcc_plugin_files,
54 54 amdaplugin_moc_plugin_files,
55 55 cpp_args : ['-DAMDA_LIB','-DQT_PLUGIN'],
56 56 include_directories : [amdaplugin_inc],
57 57 dependencies : [sciqlop_core, sciqlop_gui],
58 58 install : true
59 59 )
60 60
61 61
62 62 tests = [
63 63 [['tests/TestAmdaParser.cpp'],'test_amda_parser','AMDA parser test'],
64 64 [['tests/TestAmdaResultParser.cpp'],'test_amda_result_parser','AMDA result parser test'],
65 [['tests/TestAmdaAcquisition.cpp'],'test_amda_acquisition','AMDA Acquisition test']
65 [['tests/TestAmdaAcquisition.cpp'],'test_amda_acquisition','AMDA Acquisition test'],
66 [['tests/TestAmdaFuzzing.cpp'],'test_amda_fuzzing','AMDA fuzzing test']
67 ]
68
69 tests_sources = [
70 'tests/FuzzingDefs.h',
71 'tests/FuzzingDefs.cpp',
72 'tests/FuzzingOperations.h',
73 'tests/FuzzingOperations.cpp',
74 'tests/FuzzingUtils.h',
75 'tests/FuzzingUtils.cpp'
66 76 ]
67 77
68 78 foreach unit_test : tests
69 79 test_moc_files = qt5.preprocess(moc_sources : unit_test[0])
70 80 test_exe = executable(unit_test[1],unit_test[0] , test_moc_files,
71 81 link_with : [sciqlop_amdaplugin],
72 82 include_directories : [amdaplugin_inc],
73 83 cpp_args : ['-DAMDA_TESTS_RESOURCES_DIR="'+meson.current_source_dir()+'/tests-resources"'],
84 sources : [tests_sources],
74 85 dependencies : [sciqlop_core, sciqlop_gui, qt5test])
75 86 test(unit_test[2], test_exe, args: ['-teamcity', '-o', '@0@.teamcity.txt'.format(unit_test[1])], timeout: 3 * 60)
76 87 endforeach
General Comments 0
You need to be logged in to leave comments. Login now