@@ -1,2 +1,4 | |||||
1 | #include "FuzzingDefs.h" |
|
1 | #include "FuzzingDefs.h" | |
2 |
|
2 | |||
|
3 | const QString NB_MAX_OPERATIONS_PROPERTY = QStringLiteral("component"); | |||
|
4 | const QString NB_MAX_VARIABLES_PROPERTY = QStringLiteral("nbMaxVariables"); |
@@ -1,10 +1,21 | |||||
1 | #ifndef SCIQLOP_FUZZINGDEFS_H |
|
1 | #ifndef SCIQLOP_FUZZINGDEFS_H | |
2 | #define SCIQLOP_FUZZINGDEFS_H |
|
2 | #define SCIQLOP_FUZZINGDEFS_H | |
3 |
|
3 | |||
|
4 | #include <QString> | |||
4 | // /////// // |
|
5 | // /////// // | |
5 | // Aliases // |
|
6 | // Aliases // | |
6 | // /////// // |
|
7 | // /////// // | |
7 |
|
8 | |||
8 | using Properties = QVariantHash; |
|
9 | using Properties = QVariantHash; | |
9 |
|
10 | |||
|
11 | // ///////// // | |||
|
12 | // Constants // | |||
|
13 | // ///////// // | |||
|
14 | ||||
|
15 | /// Max number of operations to generate | |||
|
16 | extern const QString NB_MAX_OPERATIONS_PROPERTY; | |||
|
17 | ||||
|
18 | /// Max number of variables to manipulate through operations | |||
|
19 | extern const QString NB_MAX_VARIABLES_PROPERTY; | |||
|
20 | ||||
10 | #endif // SCIQLOP_FUZZINGDEFS_H |
|
21 | #endif // SCIQLOP_FUZZINGDEFS_H |
@@ -1,91 +1,117 | |||||
|
1 | #include "FuzzingDefs.h" | |||
1 | #include <Network/NetworkController.h> |
|
2 | #include <Network/NetworkController.h> | |
2 | #include <SqpApplication.h> |
|
3 | #include <SqpApplication.h> | |
3 | #include <Time/TimeController.h> |
|
4 | #include <Time/TimeController.h> | |
4 | #include <Variable/VariableController.h> |
|
5 | #include <Variable/VariableController.h> | |
5 |
|
6 | |||
6 | #include <QLoggingCategory> |
|
7 | #include <QLoggingCategory> | |
7 | #include <QObject> |
|
8 | #include <QObject> | |
8 | #include <QtTest> |
|
9 | #include <QtTest> | |
9 |
|
10 | |||
10 | #include <memory> |
|
11 | #include <memory> | |
11 |
|
12 | |||
12 | Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing") |
|
13 | Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing") | |
13 |
|
14 | |||
14 | namespace { |
|
15 | namespace { | |
15 |
|
16 | |||
|
17 | // ///////// // | |||
|
18 | // Constants // | |||
|
19 | // ///////// // | |||
|
20 | ||||
|
21 | // Defaults values used when the associated properties have not been set for the test | |||
|
22 | const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100; | |||
|
23 | const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1; | |||
16 | /** |
|
24 | /** | |
17 | * Class to run random tests |
|
25 | * Class to run random tests | |
18 | */ |
|
26 | */ | |
19 | class FuzzingTest { |
|
27 | class FuzzingTest { | |
20 | public: |
|
28 | public: | |
21 | explicit FuzzingTest(VariableController &variableController, Properties properties) |
|
29 | explicit FuzzingTest(VariableController &variableController, Properties properties) | |
22 | : m_VariableController{variableController}, |
|
30 | : m_VariableController{variableController}, | |
23 | m_Properties{std::move(properties)}, |
|
31 | m_Properties{std::move(properties)}, | |
24 | { |
|
32 | { | |
25 | } |
|
33 | } | |
26 |
|
34 | |||
27 | void execute() |
|
35 | void execute() | |
28 | { |
|
36 | { | |
29 | /// @todo: complete |
|
37 | /// @todo: complete | |
|
38 | qCInfo(LOG_TestAmdaFuzzing()) << "Running" << nbMaxOperations() << "operations on" | |||
|
39 | << nbMaxVariables() << "variables..."; | |||
|
40 | ||||
30 | qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed."; |
|
41 | qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed."; | |
31 | } |
|
42 | } | |
32 |
|
43 | |||
33 | private: |
|
44 | private: | |
|
45 | int nbMaxOperations() const | |||
|
46 | { | |||
|
47 | static auto result | |||
|
48 | = m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE) | |||
|
49 | .toInt(); | |||
|
50 | return result; | |||
|
51 | } | |||
|
52 | ||||
|
53 | int nbMaxVariables() const | |||
|
54 | { | |||
|
55 | static auto result | |||
|
56 | = m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt(); | |||
|
57 | return result; | |||
|
58 | } | |||
|
59 | ||||
34 | VariableController &m_VariableController; |
|
60 | VariableController &m_VariableController; | |
35 | Properties m_Properties; |
|
61 | Properties m_Properties; | |
36 | }; |
|
62 | }; | |
37 |
|
63 | |||
38 | } // namespace |
|
64 | } // namespace | |
39 |
|
65 | |||
40 | class TestAmdaFuzzing : public QObject { |
|
66 | class TestAmdaFuzzing : public QObject { | |
41 | Q_OBJECT |
|
67 | Q_OBJECT | |
42 |
|
68 | |||
43 | private slots: |
|
69 | private slots: | |
44 | /// Input data for @sa testFuzzing() |
|
70 | /// Input data for @sa testFuzzing() | |
45 | void testFuzzing_data(); |
|
71 | void testFuzzing_data(); | |
46 | void testFuzzing(); |
|
72 | void testFuzzing(); | |
47 | }; |
|
73 | }; | |
48 |
|
74 | |||
49 | void TestAmdaFuzzing::testFuzzing_data() |
|
75 | void TestAmdaFuzzing::testFuzzing_data() | |
50 | { |
|
76 | { | |
51 | // ////////////// // |
|
77 | // ////////////// // | |
52 | // Test structure // |
|
78 | // Test structure // | |
53 | // ////////////// // |
|
79 | // ////////////// // | |
54 |
|
80 | |||
55 | QTest::addColumn<Properties>("properties"); // Properties for random test |
|
81 | QTest::addColumn<Properties>("properties"); // Properties for random test | |
56 |
|
82 | |||
57 | // ////////// // |
|
83 | // ////////// // | |
58 | // Test cases // |
|
84 | // Test cases // | |
59 | // ////////// // |
|
85 | // ////////// // | |
60 |
|
86 | |||
61 | ///@todo: complete |
|
87 | ///@todo: complete | |
62 | } |
|
88 | } | |
63 |
|
89 | |||
64 | void TestAmdaFuzzing::testFuzzing() |
|
90 | void TestAmdaFuzzing::testFuzzing() | |
65 | { |
|
91 | { | |
66 | QFETCH(Properties, properties); |
|
92 | QFETCH(Properties, properties); | |
67 |
|
93 | |||
68 | auto &variableController = sqpApp->variableController(); |
|
94 | auto &variableController = sqpApp->variableController(); | |
69 | auto &timeController = sqpApp->timeController(); |
|
95 | auto &timeController = sqpApp->timeController(); | |
70 |
|
96 | |||
71 | FuzzingTest test{variableController, properties}; |
|
97 | FuzzingTest test{variableController, properties}; | |
72 | test.execute(); |
|
98 | test.execute(); | |
73 | } |
|
99 | } | |
74 |
|
100 | |||
75 | int main(int argc, char *argv[]) |
|
101 | int main(int argc, char *argv[]) | |
76 | { |
|
102 | { | |
77 | QLoggingCategory::setFilterRules( |
|
103 | QLoggingCategory::setFilterRules( | |
78 | "*.warning=false\n" |
|
104 | "*.warning=false\n" | |
79 | "*.info=false\n" |
|
105 | "*.info=false\n" | |
80 | "*.debug=false\n" |
|
106 | "*.debug=false\n" | |
81 | "FuzzingOperations.info=true\n" |
|
107 | "FuzzingOperations.info=true\n" | |
82 | "TestAmdaFuzzing.info=true\n"); |
|
108 | "TestAmdaFuzzing.info=true\n"); | |
83 |
|
109 | |||
84 | SqpApplication app{argc, argv}; |
|
110 | SqpApplication app{argc, argv}; | |
85 | app.setAttribute(Qt::AA_Use96Dpi, true); |
|
111 | app.setAttribute(Qt::AA_Use96Dpi, true); | |
86 | TestAmdaFuzzing testObject{}; |
|
112 | TestAmdaFuzzing testObject{}; | |
87 | QTEST_SET_MAIN_SOURCE_PATH |
|
113 | QTEST_SET_MAIN_SOURCE_PATH | |
88 | return QTest::qExec(&testObject, argc, argv); |
|
114 | return QTest::qExec(&testObject, argc, argv); | |
89 | } |
|
115 | } | |
90 |
|
116 | |||
91 | #include "TestAmdaFuzzing.moc" |
|
117 | #include "TestAmdaFuzzing.moc" |
General Comments 0
You need to be logged in to leave comments.
Login now