ADD_EXECUTABLE( ProgressData ProgressData_test.cc )
TARGET_LINK_LIBRARIES( ProgressData zypp boost_unit_test_framework )
+ADD_EXECUTABLE(Vendor1 Vendor1.cc)
+TARGET_LINK_LIBRARIES(Vendor1 zypp boost_unit_test_framework )
+
ADD_TEST(ArchTest ${CMAKE_CURRENT_BINARY_DIR}/Arch)
ADD_TEST(UrlTest ${CMAKE_CURRENT_BINARY_DIR}/Url)
ADD_TEST(Edition ${CMAKE_CURRENT_BINARY_DIR}/Edition)
ADD_TEST(RepoInfoTest ${CMAKE_CURRENT_BINARY_DIR}/RepoInfo ${CMAKE_CURRENT_SOURCE_DIR}/data/RepoInfo)
ADD_TEST(FetcherTest ${CMAKE_CURRENT_BINARY_DIR}/Fetcher)
ADD_TEST(ProgressData_test ${CMAKE_CURRENT_BINARY_DIR}/ProgressData)
+ADD_TEST(Vendor1Test ${CMAKE_CURRENT_BINARY_DIR}/Vendor1)
--- /dev/null
+
+#include <iostream>
+#include <list>
+#include <string>
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+// parameterized test
+// http://www.boost.org/libs/test/example/unit_test_example4.cpp
+
+#include "zypp/base/LogControl.h"
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/ZYpp.h"
+#include "zypp/VendorAttr.h"
+
+using namespace std;
+using namespace zypp;
+
+
+// most frequently you implement test cases as a free functions
+void vendor_test()
+{
+ // No vendor definition files has been readed. So only suse,opensuse vendors are
+ // equivalent
+ BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") );
+ BOOST_REQUIRE( VendorAttr::instance().equivalent("equal", "equal") );
+ BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") );
+ BOOST_REQUIRE( VendorAttr::instance().equivalent("opensuse", "SuSE") );
+ BOOST_REQUIRE( !VendorAttr::instance().equivalent("open", "SuSE") );
+ BOOST_REQUIRE( !VendorAttr::instance().equivalent("nothing", "SuSE") );
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+ setenv("ZYPP_CONF", "./../../tests/zypp/data/Vendor/zypp1.conf", 1 );
+ zypp::base::LogControl::instance().logfile( "-" );
+ test_suite* test= BOOST_TEST_SUITE( "VendorTest" );
+ test->add( BOOST_TEST_CASE( &vendor_test ), 5 /* expected zero error */ , 0);
+ return test;
+}
+
--- /dev/null
+## Configuration file for software management
+## /etc/zypp/zypp.conf
+##
+## Boolean values are 0 1 yes no on off true false
+
+
+[main]
+
+
+##
+## Override the detected architecture
+##
+## Valid values: i586, i686, x86_64, ppc, ppc64, ia64, s390, s390x, ..
+## Default value: Autodetected
+##
+## ** CAUTION: Only set if you know what you're doing !
+## ** Changing this needs a full refresh (incl. download)
+## ** of all repository data.
+##
+# arch = s390
+
+
+##
+## Path where the repo metadata is downloaded and kept.
+##
+## Valid values: A directory
+## Default value: /var/cache/zypp/raw
+##
+## Changing this needs a full refresh (incl. download) of all repository data
+##
+# metadatadir = /var/cache/zypp/raw
+
+
+##
+## Path where the known repositories .repo files are kept
+##
+## Valid values: A directory
+## Default value: /etc/zypp/repos.d
+##
+## Changing this invalidates all known repositories
+##
+# reposdir = /etc/zypp/repos.d
+
+
+##
+## Path where the processed cache is kept (this is where zypp.db is located)
+##
+## Valid values: A directory
+## Default value: /var/cache/zypp
+##
+## Changing this needs a full refresh (except download) of all repository data
+##
+# cachedir = /var/cache/zypp
+
+
+##
+## Whether repository urls should be probed when added
+##
+## Valid values: boolean
+## Default value: false
+##
+## If true, accessability of repositories is checked immediately (when added)
+## (e.g. 'zypper ar' will check immediately)
+## If false, accessability of repositories is checked when refreshed
+## (e.g. 'zypper ar' will delay the check until the next refresh)
+##
+# repo.add.probe = false
+
+
+##
+## Amount of time in minutes that must pass before another refresh.
+##
+## Valid values: Integer
+## Default value: 10
+##
+## If you have autorefresh enabled for a repository, it is checked for
+## up-to-date metadata not more often than every <repo.refresh.delay>
+## minutes. If an automatic request for refresh comes before <repo.refresh.delay>
+## minutes passed since the last check, the request is ignored.
+##
+## A value of 0 means the repository will always be checked. To get the oposite
+## effect, disable autorefresh for your repositories.
+##
+## This option has no effect for repositories with autorefresh disabled, nor for
+## user-requested refresh.
+##
+# repo.refresh.delay = 10
+
+
+##
+## Whether to consider using a .patch.rpm when downloading a package
+##
+## Valid values: boolean
+## Default value: true
+##
+## Using a patch rpm will decrease the download size for package updates
+## since it does not contain all files of the package but only the changed
+## ones. The .patch.rpm is ready to be installed immediately after download.
+## There is no further processing needed, as it is for a .delta.rpm.
+##
+# download.use_patchrpm = true
+
+
+##
+## Whether to consider using a .delta.rpm when downloading a package
+##
+## Valid values: boolean
+## Default value: true
+##
+## Using a delta rpm will decrease the download size for package updates
+## since it does not contain all files of the package but only the binary
+## diff of changed ones. Recreating the rpm package on the local machine
+## is an expensive operation (memory,CPU). If your network connection is
+## not too slow, you benefit from disabling .delta.rpm.
+##
+# download.use_deltarpm = true
+
+
+##
+## Defining directory for equivalent vendors
+##
+## Valid values: A directory
+## Default value: /etc/zypp/vondors.d
+##
+vendordir = data/Vendor/notExist
+
VendorAttr::VendorAttr ()
{
vendorGroupCounter = 1;
-
+ Pathname xxx = ZConfig::instance().repoCachePath();
Pathname vendorPath (ZConfig::instance().vendorPath());
try
{
//checking if suse,opensuse has been defined. If not create entries
if (_vendorMap.find("suse") != _vendorMap.end()) {
if (_vendorMap.find("opensuse") == _vendorMap.end()) {
- _vendorMap["opensuse"] = ++vendorGroupCounter;
+ _vendorMap["opensuse"] = vendorGroupCounter;
}
} else {
if (_vendorMap.find("opensuse") == _vendorMap.end()) {
// both are not available. Create one group with suse,opensuse
- _vendorMap["opensuse"] = ++vendorGroupCounter;
+ _vendorMap["opensuse"] = vendorGroupCounter;
_vendorMap["suse"] = vendorGroupCounter;
} else {
- _vendorMap["suse"] = ++vendorGroupCounter;
+ _vendorMap["suse"] = vendorGroupCounter;
}
}
-
+
+ MIL << "Equivalent vendors:" << endl;
+ for (VendorMap::iterator it = _vendorMap.begin();
+ it != _vendorMap.end();
+ it ++) {
+ MIL << " " << it->first << " (group " << it->second << ")" << endl;
+ }
}
bool VendorAttr::addVendorFile( const Pathname & filename ) const
}
}
}
-
- MIL << "Equivalent vendors:" << endl;
- for (VendorMap::iterator it = _vendorMap.begin();
- it != _vendorMap.end();
- it ++) {
- MIL << " " << it->first << "(group " << it->second << ")" << endl;
- }
return true;
}
}
- bool VendorAttr::equivalent( const Vendor & lhs, const Vendor & rhs ) const
+ bool VendorAttr::equivalent( const Vendor & lVendor, const Vendor & rVendor ) const
{
- if ( lhs == rhs )
- return true;
-
unsigned int lhsID = 0;
unsigned int rhsID = 0;
+ Vendor lhs = str::toLower (lVendor);
+ Vendor rhs = str::toLower (rVendor);
+
+ if ( lhs == rhs )
+ return true;
if (_matchMap.find(lhs) != _matchMap.end()) {
lhsID = _matchMap[lhs];
}
}
}
-
- return( lhsID == lhsID );
+
+ return( lhsID && rhsID && lhsID == lhsID );
}
/////////////////////////////////////////////////////////////////
* equivalent vendor when updating. Replacing a package with one of a
* different vendor usually must be confirmed by the user.
*/
- bool equivalent( const Vendor & lhs, const Vendor & rhs ) const;
+ bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
private:
VendorAttr();
// ZYPP_CONF might override /etc/zypp/zypp.conf
const char *env_confpath = getenv( "ZYPP_CONF" );
+
Pathname confpath( env_confpath ? env_confpath : "/etc/zypp/zypp.conf" );
if ( PathInfo(confpath).isExist())
{
{
download_use_patchrpm = str::strToBool( value, download_use_patchrpm );
}
- else if ( entry == "download.use_deltarpm" )
- {
+ else if ( entry == "download.use_deltarpm" )
+ {
download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
- }
- }
- else if ( section == "vendordir" )
- {
- cfg_vendor_path = Pathname(value);
+ }
+ else if ( entry == "vendordir" )
+ {
+ cfg_vendor_path = Pathname(value);
+ }
}
-
}
}
-
}
~Impl()