20d181ba84ddf009a9acbf1d6d480785c9209cd4
[platform/upstream/libzypp.git] / zypp / misc / LoadTestcase.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/misc/LoadTestcase.h
10  *
11 */
12 #ifndef ZYPP_MISC_LOADTESTCASE_H
13 #define ZYPP_MISC_LOADTESTCASE_H
14
15 #include <zypp/Arch.h>
16 #include <zypp/Locale.h>
17 #include <zypp/Pathname.h>
18 #include <zypp/ResolverFocus.h>
19 #include <zypp/Url.h>
20 #include <zypp/base/PtrTypes.h>
21 #include <zypp/base/SetTracker.h>
22 #include <zypp/base/NonCopyable.h>
23 #include <zypp/sat/Queue.h>
24 #include <zypp/target/modalias/Modalias.h>
25
26 #include <optional>
27 #include <memory>
28
29 namespace zypp {
30   class RepoManager;
31 }
32
33 namespace zypp::misc::testcase {
34
35   enum class TestcaseRepoType {
36     Helix,
37     Testtags,
38     Url
39   };
40
41   struct RepoData {
42     TestcaseRepoType type;
43     std::string alias;
44     uint priority = 99;
45     std::string path;
46   };
47
48   struct ForceInstall {
49     std::string channel;
50     std::string package;
51     std::string kind;
52   };
53
54   struct TestcaseSetup
55   {
56     Arch architecture = Arch_noarch;
57
58     std::optional<RepoData> systemRepo;
59     std::vector<RepoData> repos;
60
61     // solver flags: default to false - set true if mentioned in <setup>
62     ResolverFocus resolverFocus  = ResolverFocus::Default;
63
64     Pathname globalPath;
65     Pathname hardwareInfoFile;
66     Pathname systemCheck;
67
68     target::Modalias::ModaliasList modaliasList;
69     base::SetTracker<LocaleSet> localesTracker;
70     sat::StringQueue autoinstalled;
71     std::set<std::string> multiversionSpec;
72     std::vector<ForceInstall> forceInstallTasks;
73
74     bool set_licence = false;
75     bool show_mediaid = false;
76
77     bool ignorealreadyrecommended   = false;
78     bool onlyRequires               = false;
79     bool forceResolve               = false;
80     bool cleandepsOnRemove          = false;
81
82     bool allowDowngrade     = false;
83     bool allowNameChange    = false;
84     bool allowArchChange    = false;
85     bool allowVendorChange  = false;
86
87     bool dupAllowDowngrade     = false;
88     bool dupAllowNameChange    = false;
89     bool dupAllowArchChange    = false;
90     bool dupAllowVendorChange  = false;
91
92     bool applySetup ( zypp::RepoManager &manager ) const;
93
94     static bool loadRepo (zypp::RepoManager &manager, const TestcaseSetup &setup, const RepoData &data );
95   };
96
97   struct TestcaseTrial
98   {
99     struct Node {
100       std::string name;
101       std::string value;
102
103       const std::string &getProp( const std::string &name, const std::string &def = std::string() ) const;
104
105       std::map<std::string, std::string> properties;
106       std::vector<std::shared_ptr<Node>> children;
107     };
108     std::vector<Node> nodes;
109   };
110
111   class LoadTestcase : private zypp::base::NonCopyable
112   {
113   public:
114     struct Impl;
115
116     enum Type {
117       None,
118       Helix,
119       Yaml
120     };
121
122     LoadTestcase();
123     ~LoadTestcase();
124
125     bool loadTestcaseAt ( const zypp::Pathname &path, std::string *err );
126     static Type testcaseTypeAt ( const zypp::Pathname &path );
127
128     const TestcaseSetup &setupInfo() const;
129     const std::vector<TestcaseTrial> &trialInfo() const;
130
131   private:
132     std::unique_ptr<Impl> _pimpl;
133   };
134
135 }
136
137
138 #endif // ZYPP_MISC_LOADTESTCASE_H