7 #include <boost/test/auto_unit_test.hpp>
9 #include "zypp/base/Logger.h"
10 #include "zypp/base/Exception.h"
11 #include "zypp/ZYppFactory.h"
12 #include "zypp/ZYpp.h"
13 #include "zypp/ZYppFactory.h"
14 #include "zypp/TmpPath.h"
16 using boost::unit_test::test_case;
19 using namespace zypp::filesystem;
21 BOOST_AUTO_TEST_CASE(target_test)
24 filesystem::TmpDir tmp;
26 ZYpp::Ptr z = getZYpp();
28 // create the products.d directory
29 assert_dir(tmp.path() / "/etc/products.d" );
30 BOOST_CHECK( copy( Pathname(TESTS_SRC_DIR) / "/zypp/data/Target/product.prod", tmp.path() / "/etc/products.d/product.prod") == 0 );
32 // make it the base product
33 BOOST_CHECK( symlink(tmp.path() / "/etc/products.d/product.prod", tmp.path() / "/etc/products.d/baseproduct" ) == 0 );
35 z->initializeTarget( tmp.path() );
37 // bsc#1024741: Omit creating a new uid for chrooted systems (if it already has one, fine)
38 BOOST_CHECK( ! PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").isExist() );
39 // create an artificial one
41 Pathname f( tmp.path() / "/var/lib/zypp" );
42 filesystem::assert_dir( f );
43 std::ofstream o( (f/"AnonymousUniqueId").c_str() );
44 o << "AnonymousUniqueId";
46 BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").isExist() );
47 BOOST_CHECK_EQUAL( z->target()->anonymousUniqueId(), "AnonymousUniqueId" );
49 // now check the base product
50 BOOST_CHECK_EQUAL( z->target()->targetDistribution(), "sle-10-i586");
51 BOOST_CHECK_EQUAL( z->target()->targetDistributionRelease(), "special_edition");
52 BOOST_CHECK_EQUAL( z->target()->distributionVersion(), "10");
54 Target::DistributionLabel dlabel( z->target()->distributionLabel() );
55 BOOST_CHECK_EQUAL( dlabel.summary, "A cool distribution" );
56 BOOST_CHECK_EQUAL( dlabel.shortName, "" );