1 #include <zypp/media/MediaManager.h>
2 #include <zypp/base/String.h>
3 #include <zypp/base/Logger.h>
4 #include <zypp/Pathname.h>
13 #include "mymediaverifier.h"
15 #include <boost/test/unit_test.hpp>
17 using boost::unit_test::test_suite;
18 using boost::unit_test::test_case;
21 using namespace zypp::media;
35 #define ONE_STEP(MSG) \
37 DBG << "======================================" << std::endl; \
38 DBG << "==>> " << MSG << std::endl; \
39 DBG << "======================================" << std::endl; \
40 if( do_step) { pause(); if( do_quit) exit(0); } \
43 BOOST_AUTO_TEST_CASE(strange_test)
45 bool eject_src = false;
46 bool close_src = false;
49 sigemptyset(&sa.sa_mask);
52 sigaction(SIGINT, &sa, NULL);
54 sigaction(SIGTERM, &sa, NULL);
56 // std::cerr << "ARGS=" << argc << std::endl;
57 // for(int i=1; i < argc; i++)
59 // if( std::string(argv[i]) == "-i")
62 // if( std::string(argv[i]) == "-e")
65 // if( std::string(argv[i]) == "-c")
70 MediaVerifierRef verifier(
71 new MyMediaVerifier(/* "SUSE-Linux-CORE-i386 9" */)
74 media::MediaId src = 0;
79 src_url = "nfs://dist.suse.de/dist/install";
82 iso_url.setQueryParam("iso", "SUSE-10.1-Beta5/SUSE-Linux-10.1-beta5-i386-CD1.iso");
83 iso_url.setQueryParam("url", src_url.asString());
87 iso_url.setQueryParam("iso", "/space/tmp/iso/SUSE-Linux-10.1-beta7-i386-CD1.iso");
92 if( eject_src || close_src)
94 ONE_STEP("SRC: open " + src_url.asString());
95 src = mm.open(src_url);
97 ONE_STEP("SRC: attach")
101 ONE_STEP("ISO: open " + iso_url.asString());
102 iso = mm.open(iso_url);
104 ONE_STEP("ISO: add verifier")
105 mm.addVerifier(iso, verifier);
107 ONE_STEP("ISO: attach")
110 ONE_STEP("provideFile(/INDEX.gz)")
111 mm.provideFile(iso, Pathname("/INDEX.gz"));
117 ONE_STEP("SRC: release(eject=true)")
118 mm.release(src, true);
120 catch(const MediaException &e)
123 ERR << "ONE: HUH? Eject hasn't worked?!" << std::endl;
131 ONE_STEP("SRC: close()")
134 catch(const MediaException &e)
137 ERR << "SRC: HUH? Close hasn't worked?!" << std::endl;
141 ONE_STEP("ISO: RELEASE")
146 catch(const MediaException &e)
148 ERR << "Catched media exception..." << std::endl;
154 ERR << "Catched *unknown* exception" << std::endl;
158 // vim: set ts=2 sts=2 sw=2 ai et: