Author: mlandres Date: Tue Mar 4 18:12:36 2008 New Revision: 9007 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9007&view=rev Log: added testsuite backdoor Modified: trunk/libzypp/zypp/ZConfig.cc trunk/libzypp/zypp/ZConfig.h Modified: trunk/libzypp/zypp/ZConfig.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=9007&r1=9006&r2=9007&view=diff ============================================================================== --- trunk/libzypp/zypp/ZConfig.cc (original) +++ trunk/libzypp/zypp/ZConfig.cc Tue Mar 4 18:12:36 2008 @@ -141,7 +141,7 @@ class ZConfig::Impl { public: - Impl() + Impl( const Pathname & override_r = Pathname() ) : cfg_arch ( defaultSystemArchitecture() ) , cfg_textLocale ( defaultTextLocale() ) , repo_add_probe ( false ) @@ -152,9 +152,21 @@ { MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; - // 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" ); + // override_r has higest prio + // ZYPP_CONF might override /etc/zypp/zypp.conf + Pathname confpath( override_r ); + if ( confpath.empty() ) + { + const char *env_confpath = getenv( "ZYPP_CONF" ); + confpath = env_confpath ? env_confpath : "/etc/zypp/zypp.conf"; + } + else + { + // Inject this into ZConfig. Be shure this is + // allocated via new. See: reconfigureZConfig + INT << "Reconfigure to " << confpath << endl; + ZConfig::instance()._pimpl.reset( this ); + } if ( PathInfo(confpath).isExist() ) { parser::IniDict dict( confpath ); @@ -268,6 +280,14 @@ }; /////////////////////////////////////////////////////////////////// + // Backdoor to redirect ZConfig from within the running + // TEST-application. HANDLE WITH CARE! + void reconfigureZConfig( const Pathname & override_r ) + { + // ctor puts itself unter smart pointer control. + new ZConfig::Impl( override_r ); + } + /////////////////////////////////////////////////////////////////// // // METHOD NAME : ZConfig::instance Modified: trunk/libzypp/zypp/ZConfig.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=9007&r1=9006&r2=9007&view=diff ============================================================================== --- trunk/libzypp/zypp/ZConfig.h (original) +++ trunk/libzypp/zypp/ZConfig.h Tue Mar 4 18:12:36 2008 @@ -147,6 +147,7 @@ /** Dtor */ ~ZConfig(); private: + friend class Impl; /** Default ctor. */ ZConfig(); /** Pointer to implementation */ -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org