Imported Upstream version 17.22.1
[platform/upstream/libzypp.git] / tests / sat / SolvParsing_test.cc
1 #include <stdio.h>
2 #include <iostream>
3 #include <boost/test/unit_test.hpp>
4
5 #include "zypp/base/Logger.h"
6 #include "zypp/TmpPath.h"
7 #include "zypp/RepoManager.h"
8 #include "zypp/base/Easy.h"
9 #include "zypp/ZYppFactory.h"
10 #include "zypp/Package.h"
11 #include "zypp/sat/Solvable.h"
12
13 // allows us to control signature
14 // callbacks
15 #include "KeyRingTestReceiver.h"
16
17 #define BOOST_TEST_MODULE ResObject
18
19 using std::cout;
20 using std::endl;
21 using std::string;
22 using namespace zypp;
23 using namespace boost::unit_test;
24
25
26 /*
27  * this test test that the attributes
28  * from the metadata are preserved into
29  * the final object
30  *
31  * so the test covers both libsolv-tools
32  * right insertion and parsing
33  * and libzypp ResObject and friends data
34  * extraction from solv files
35  */
36
37
38 // init the solv
39 static void init_pool_yum()
40 {
41   Pathname dir(TESTS_SRC_DIR);
42   dir += "/repo/yum/data/10.2-updates-subset";
43
44   ZYpp::Ptr z = getZYpp();
45   ZConfig::instance().setSystemArchitecture(Arch("i586"));
46
47   filesystem::TmpDir tmp;
48   RepoManagerOptions opts = RepoManagerOptions::makeTestSetup(tmp.path());
49   RepoManager mgr(opts);
50
51   KeyRingTestReceiver keyring_callbacks;
52   KeyRingTestSignalReceiver receiver;
53
54   // disable sgnature checking
55   keyring_callbacks.answerAcceptKey(KeyRingReport::KEY_TRUST_TEMPORARILY);
56   keyring_callbacks.answerAcceptVerFailed(true);
57   keyring_callbacks.answerAcceptUnknownKey(true);
58
59   RepoInfo info;
60   info.setAlias("updates");
61   info.addBaseUrl(dir.asUrl());
62   mgr.buildCache(info);
63   mgr.loadFromCache(info);
64 }
65
66 BOOST_AUTO_TEST_CASE(attributes)
67 {
68     init_pool_yum();
69     MIL << sat::Pool::instance();
70     Repository r = sat::Pool::instance().reposFind("updates");
71
72     int c = 0;
73
74     for ( Repository::SolvableIterator it = r.solvablesBegin();
75           it != r.solvablesEnd();
76           ++it )
77     {
78         sat::Solvable s = *it;
79         //MIL << s.ident() << endl;
80         if ( s.ident() == "openssl-devel" )
81         {
82             c++;
83             Package::Ptr p = asKind<Package>(makeResObject(s));
84             BOOST_CHECK(p);
85
86             //solvable 5 (6):
87             //name: openssl-devel 0.9.8d-17.2 i586
88             BOOST_CHECK_EQUAL(p->name(), "openssl-devel");
89             //vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
90             BOOST_CHECK_EQUAL(p->vendor(), "SUSE LINUX Products GmbH, Nuernberg, Germany");
91             //solvable:checksum: 9f6a44015ad97680e9f93d0edefa1d533940479c
92             BOOST_CHECK_EQUAL(p->checksum(), CheckSum::sha1("9f6a44015ad97680e9f93d0edefa1d533940479c"));
93             //solvable:summary:
94             BOOST_CHECK_EQUAL(p->summary(), "Include Files and Libraries mandatory for Development.");
95             //solvable:description: This package contains all necessary include files and libraries needed
96             //to develop applications that require these.
97             BOOST_CHECK_EQUAL(p->description(), "This package contains all necessary include files and libraries needed\nto develop applications that require these.");
98             //solvable:authors: Mark J. Cox <mark@openssl.org>
99             //Ralf S. Engelschall <rse@openssl.org>
100             //Dr. Stephen <Henson steve@openssl.org>
101             //Ben Laurie <ben@openssl.org>
102             //Bodo Moeller <bodo@openssl.org>
103             //Ulf Moeller <ulf@openssl.org>
104             //Holger Reif <holger@openssl.org>
105             //Paul C. Sutton <paul@openssl.org>
106             //solvable:packager: http://bugs.opensuse.org
107             //solvable:url: http://www.openssl.org/
108             //solvable:buildtime: 1165493634
109             //solvable:installsize: 3845
110             BOOST_CHECK_EQUAL(p->installSize(), ByteCount(3937193));
111             //solvable:downloadsize: 909
112             BOOST_CHECK_EQUAL(p->downloadSize(), ByteCount(930588));
113             //solvable:mediadir: rpm/i586
114             //solvable:mediafile: openssl-devel-0.9.8d-17.2.i586.rpm
115             //solvable:license: BSD License and BSD-like, Other License(s), see package
116             //solvable:group: Development/Libraries/C and C++
117             BOOST_CHECK_EQUAL(p->group(), "Development/Libraries/C and C++");
118             //solvable:sourcearch: src
119             //solvable:sourceevr: (void)
120             //solvable:sourcename: openssl
121             //solvable:headerend: 34861
122
123         }
124     }
125
126     // check that we actually found all testeable
127     // resolvables
128     BOOST_CHECK_EQUAL(c, 1);
129
130
131 }