@@ -0,0 +1,26 | |||
|
1 | #include "FuzzingValidators.h" | |
|
2 | ||
|
3 | #include <functional> | |
|
4 | ||
|
5 | Q_LOGGING_CATEGORY(LOG_FuzzingValidators, "FuzzingValidators") | |
|
6 | ||
|
7 | namespace { | |
|
8 | ||
|
9 | /** | |
|
10 | * Default implementation of @sa IFuzzingValidator. This validator takes as parameter of its | |
|
11 | * construction a function of validation which is called in the validate() method | |
|
12 | */ | |
|
13 | class FuzzingValidator : public IFuzzingValidator { | |
|
14 | public: | |
|
15 | /// Signature of a validation function | |
|
16 | using ValidationFunction = std::function<void(const VariableState &variableState)>; | |
|
17 | ||
|
18 | explicit FuzzingValidator(ValidationFunction fun) : m_Fun(std::move(fun)) {} | |
|
19 | ||
|
20 | void validate(const VariableState &variableState) const override { m_Fun(variableState); } | |
|
21 | ||
|
22 | private: | |
|
23 | ValidationFunction m_Fun; | |
|
24 | }; | |
|
25 | ||
|
26 | } // namespace |
@@ -0,0 +1,21 | |||
|
1 | #ifndef SCIQLOP_FUZZINGVALIDATORS_H | |
|
2 | #define SCIQLOP_FUZZINGVALIDATORS_H | |
|
3 | ||
|
4 | #include <QLoggingCategory> | |
|
5 | ||
|
6 | Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingValidators) | |
|
7 | ||
|
8 | class VariableState; | |
|
9 | ||
|
10 | /** | |
|
11 | * Struct that represents a validator. A validator checks if the state of a variable is valid at the | |
|
12 | * moment it is called during a fuzzing test | |
|
13 | */ | |
|
14 | struct IFuzzingValidator { | |
|
15 | virtual ~IFuzzingValidator() noexcept = default; | |
|
16 | ||
|
17 | /// Validates the variable's state passed in parameter | |
|
18 | virtual void validate(const VariableState &variableState) const = 0; | |
|
19 | }; | |
|
20 | ||
|
21 | #endif // SCIQLOP_FUZZINGVALIDATORS_H |
@@ -1,87 +1,89 | |||
|
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 | 65 | [['tests/TestAmdaAcquisition.cpp'],'test_amda_acquisition','AMDA Acquisition test'], |
|
66 | 66 | [['tests/TestAmdaFuzzing.cpp'],'test_amda_fuzzing','AMDA fuzzing test'] |
|
67 | 67 | ] |
|
68 | 68 | |
|
69 | 69 | tests_sources = [ |
|
70 | 70 | 'tests/FuzzingDefs.h', |
|
71 | 71 | 'tests/FuzzingDefs.cpp', |
|
72 | 72 | 'tests/FuzzingOperations.h', |
|
73 | 73 | 'tests/FuzzingOperations.cpp', |
|
74 | 74 | 'tests/FuzzingUtils.h', |
|
75 | 'tests/FuzzingUtils.cpp' | |
|
75 | 'tests/FuzzingUtils.cpp', | |
|
76 | 'tests/FuzzingValidators.h', | |
|
77 | 'tests/FuzzingValidators.cpp' | |
|
76 | 78 | ] |
|
77 | 79 | |
|
78 | 80 | foreach unit_test : tests |
|
79 | 81 | test_moc_files = qt5.preprocess(moc_sources : unit_test[0]) |
|
80 | 82 | test_exe = executable(unit_test[1],unit_test[0] , test_moc_files, |
|
81 | 83 | link_with : [sciqlop_amdaplugin], |
|
82 | 84 | include_directories : [amdaplugin_inc], |
|
83 | 85 | cpp_args : ['-DAMDA_TESTS_RESOURCES_DIR="'+meson.current_source_dir()+'/tests-resources"'], |
|
84 | 86 | sources : [tests_sources], |
|
85 | 87 | dependencies : [sciqlop_core, sciqlop_gui, qt5test]) |
|
86 | 88 | test(unit_test[2], test_exe, args: ['-teamcity', '-o', '@0@.teamcity.txt'.format(unit_test[1])], timeout: 3 * 60) |
|
87 | 89 | endforeach |
General Comments 0
You need to be logged in to leave comments.
Login now