Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DftValidatorTest.cpp
Go to the documentation of this file.
1#include <gmock/gmock.h>
2#include "storm-config.h"
3#include "test/storm_gtest.h"
4
5#include "storm-dft/api/io.h"
8
9namespace {
10
11TEST(DftValidatorTest, Cyclic) {
12 std::string file = STORM_TEST_RESOURCES_DIR "/dft/cyclic.dft";
13 STORM_SILENT_EXPECT_THROW(storm::dft::api::loadDFTGalileoFile<double>(file), storm::exceptions::WrongFormatException);
14}
15
16TEST(DftValidatorTest, NonBinaryDependency) {
17 std::string file = STORM_TEST_RESOURCES_DIR "/dft/fdep.dft";
18 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
19 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
20 auto result = storm::dft::api::isWellFormed(*dft, true);
21 EXPECT_FALSE(result.first);
22 EXPECT_THAT(result.second, ::testing::MatchesRegex("DFT has dependency with more than one dependent event."));
23}
24
25TEST(DftValidatorTest, MultipleConstantFailed) {
26 std::string file = STORM_TEST_RESOURCES_DIR "/dft/const_be_test.dft";
27 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
28 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
29 auto result = storm::dft::api::isWellFormed(*dft, true);
30 EXPECT_FALSE(result.first);
31 EXPECT_THAT(result.second, ::testing::MatchesRegex("DFT has more than one constant failed BE."));
32}
33
34TEST(DftValidatorTest, OverlappingSpareModules) {
35 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_overlapping.dft";
36 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
37 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
38 auto result = storm::dft::api::isWellFormed(*dft, true);
39 EXPECT_FALSE(result.first);
40 EXPECT_THAT(result.second, ::testing::MatchesRegex("Spare modules .* should not overlap."));
41}
42
43TEST(DftValidatorTest, SharedPrimaryModule) {
44 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_shared_primary.dft";
45 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
46 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
47 auto result = storm::dft::api::isWellFormed(*dft, true);
48 EXPECT_FALSE(result.first);
49 EXPECT_THAT(result.second, ::testing::HasSubstr("shared primary module"));
50}
51
52TEST(DftValidatorTest, SpareConstantFailed) {
53 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_const_failed.dft";
54 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
55 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
56 auto result = storm::dft::api::isWellFormed(*dft, true);
57 EXPECT_FALSE(result.first);
58 EXPECT_THAT(result.second, ::testing::MatchesRegex("Spare module of .* contains a constant failed BE .*"));
59}
60
61TEST(DftValidatorTest, NonExponential) {
62 std::string file = STORM_TEST_RESOURCES_DIR "/dft/all_be_distributions.dft";
63 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
64 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
65 auto result = storm::dft::api::isWellFormed(*dft, true);
66 EXPECT_FALSE(result.first);
67 EXPECT_THAT(result.second, ::testing::HasSubstr("DFT has BE distributions which are neither exponential nor constant failed/failsafe."));
68}
69
70TEST(DftValidatorTest, OverlappingWithTopModule) {
71 std::string file = STORM_TEST_RESOURCES_DIR "/dft/modules3.dft";
72 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
73 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
75 EXPECT_TRUE(result.first);
76 EXPECT_THAT(result.second, ::testing::HasSubstr(" All elements of this spare module will be activated from the beginning on."));
77}
78
79TEST(DftValidatorTest, SpareModuleContainsParent) {
80 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_contains_spare.dft";
81 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
82 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
84 EXPECT_TRUE(result.first);
85 EXPECT_THAT(result.second, ::testing::HasSubstr("also contains the parent SPARE-gate"));
86 EXPECT_THAT(result.second, ::testing::HasSubstr("This can prevent proper activation of the spare module."));
87}
88
89TEST(DftValidatorTest, NoModelingIssues) {
90 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare.dft");
91 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
92 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
93
94 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare2.dft");
95 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
96 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
97
98 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare3.dft");
99 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
100 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
101
102 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare4.dft");
103 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
104 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
105
106 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare5.dft");
107 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
108 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
109
110 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare6.dft");
111 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
112 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
113
114 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare7.dft");
115 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
116 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
117
118 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare8.dft");
119 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
120 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
121}
122
123} // namespace
TEST(OrderTest, Simple)
Definition OrderTest.cpp:15
std::shared_ptr< storm::dft::storage::DFT< ValueType > > loadDFTGalileoFile(std::string const &file)
Load DFT from Galileo file.
Definition io.cpp:14
std::pair< bool, std::string > isWellFormed(storm::dft::storage::DFT< ValueType > const &dft, bool validForMarkovianAnalysis)
Check whether the DFT is well-formed.
std::pair< bool, std::string > hasPotentialModelingIssues(storm::dft::storage::DFT< ValueType > const &dft)
Check whether the DFT has potential modeling issues.
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)
Definition storm_gtest.h:19