Thread: [Compbench-devel] CompBenchmarks++/Benchmark Benchmark.cpp, 1.17, 1.18 Benchmark.h, 1.12, 1.13
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-01-03 21:58:42
|
Update of /cvsroot/compbench/CompBenchmarks++/Benchmark In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21777 Modified Files: Benchmark.cpp Benchmark.h Log Message: Splited to CBMPackage. Index: Benchmark.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Benchmark/Benchmark.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Benchmark.h 28 Dec 2006 18:17:36 -0000 1.12 --- Benchmark.h 3 Jan 2007 21:58:38 -0000 1.13 *************** *** 30,130 **** { public: ! /** Benchmark status ! * Defines typedef used to code internal status of a given benchmark ! */ ! typedef enum Status { Unknown, /*!< Unkown; benchmark/package probably ! * not yet installed */ ! Downloaded, /*!< Package has been downloaded and checksum ! * is Ok. */ ! Extracted, /*!< Package has been successfuly extracted */ ! Patched, /*!< Package has been patched (optional step) */ ! Preconfigured, /*!< Package is now preconfigured. Also ! * optionnal, but each package goes throught ! * that step */ ! Configured, /*!< Package is configured (./configure) */ ! Made, /*!< Package has been made (make) */ ! Tested, /*!< Package has been tested */ ! Benchmarked }; /*!< Benchmarked */ ! private: - /** Package or benchmark status - * \sa CBMBenchmark::Status - * \sa storeStatus() - * \sa getStatus() - * \sa readStatus() */ - Status status; - - /** Expected MD5 on downloaded package - * \return MD5 expected, as an std::string */ - virtual std::string expectedMD5(void) = 0; - - /** Benchmark's status - * Initialise the status from file in the directory defined by CBMSystem::Status. - * \sa CBMBenchmark::Status - * \return 1 if ok. */ - virtual int readStatus(void); - - /** Remove context. - * \sa storeContext() - */ - virtual int resetContext(void); - protected: ! /** Stores current compiler. */ ! CBMCompiler *currentCompiler; ! /** Stores current (compiler) options. */ ! CBMCompilerOptions *currentOptions; ! ! /** System used */ ! class CBMSystem *system; /** Constructor * Initialise the CBMBenchmark::system variable. */ ! CBMBenchmark(class CBMSystem *_system); ! ! /** Pure method to extract package ! \return 1 if ok ! \sa Extract() ! \sa localPackageAbsoluteDirectory() */ ! virtual int extract(int _force = 0) = 0; ! ! /** Indicates if the package needs patching ! * Must be overloaded if so. Returns 0 by default. ! * \return 0 by default, 1 if patch is needed. ! * \sa patch() ! * \sa Patch() ! */ ! virtual int hasPatch(void); ! ! /** Method to patch package ! * Must be overloaded to patch package. ! * \sa Patch() */ ! virtual int patch(int _force = 0); ! ! /** Method to test package. ! * Must be overloaded to test package using a method provided by package ! * maintainers. ! * \sa Test() */ ! virtual int test(int _force = 0); ! ! /** Pure virtual method to pre-configure package ! * Pre-configuration creates any needed elements (files or what ever) to benchmark ! * package. ! * \return 1 if ok. ! * \sa PreConfigure() ! */ ! virtual int preConfigure(int _force) = 0; ! ! /** Pure virtual method to configure package ! * Broadly speaking, this is ./configure ! * \sa Configure() ! * \return 1 if ok */ ! virtual int configure(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions) = 0; ! /** Pure virtual method to build package ! * This could be a simple make, for instance. ! * \return 1 if ok ! * \sa Make() */ ! virtual int make(void) = 0; /** Pure virtual method to run benchmark --- 30,46 ---- { public: ! class CBMPackage *Package(void); private: protected: ! class CBMPackage *package; /** Constructor * Initialise the CBMBenchmark::system variable. */ ! CBMBenchmark(class CBMPackage *_package); ! /** Give object for underlaying system. ! Use package pointer. ! \sa package ! */ ! virtual CBMSystem *System(void); /** Pure virtual method to run benchmark *************** *** 133,202 **** virtual std::string bench(void) = 0; - /** Pure virtual method to clean-up sources - * Useful bettween two Make() to get all sources compiled with same environment. - * \sa Release() - * \sa Configure() - * \sa Make() */ - virtual int release(void) = 0; - - /** Uninstall benchmark - * Removes information used by CompBenchmarks as well as any downloaded, extracted - * or built element. Default behaviour should be ok in most case. - * \return 1 if ok. */ - virtual int uninstall(void); - - /** Stores benchmark status - * Probably internal usage only. - * \return 1 if ok - * \sa readStatus() - */ - virtual int storeStatus(Status _status); - - /** Gets a context ID - * Give an unique ID according to compiler and options used. This can avoid useless - * recompilations. - * \return ID (MD5) as std::string - * \sa Make() - * \sa storeContext() - * \sa ContextMatches() - */ - virtual std::string contextID(CBMCompiler *_currentCompiler, - CBMCompilerOptions *_currentOptions); - - /** Stores (compilation) context ID - * Stores the context ID for the current benchmark. - * \sa contextID() - * \sa ContextMatches() - * \return 1 if ok - */ - virtual int storeContext(CBMCompiler *_currentCompiler, - CBMCompilerOptions *_currentOptions); public: - - /** Package name - * \return a std::string like 'gzip', without quotes */ - virtual std::string packageName(void); - - /** Package version - * \return a std::string like '1.2.4', without quotes */ - virtual std::string packageVersion(void) = 0; - - /** Package size, in bytes - * \return an integer coding the size of package's archive (to download) in bytes. - */ - virtual int packageSize(void) = 0; - - /** Package comments - * Gives comments about package. Short description, or what ever. - * \return comments, as std::string - */ - virtual std::string packageComments(void) = 0; - - /** Package local filename - * \return a relative filename containing the local name of the uncompressed - * package (like 'gzip-1.2.4.tar.Z', without quotes) */ - virtual std::string localPackageName(void) = 0; - - /** Benchmark name \return a std::string representing current benchmark's identification --- 49,53 ---- *************** *** 208,356 **** virtual std::string benchmarkComments(void) = 0; ! /** Benchmark's language ! * \return std::string (C or C++) */ ! virtual std::string language(void) = 0; ! ! /** Returns package or benchmark license ! \return a std::string describing license */ ! virtual std::string license(void) = 0; ! ! /** Returns package home page ! \return URL in std::string */ ! virtual std::string homePage(void) = 0; ! ! /** Author(s) of package ! \return std::string containing authors. */ ! virtual std::string author(void) = 0; ! ! /** Convenience method ! * \return local uncompressed absolute archive filename for benchmark. ! * \sa localPackageName() */ ! virtual std::string localPackageAbsoluteName(void); ! /** Convenience method ! * \return directory used for extracting package ! * \sa CBMSystem::Extract */ ! virtual std::string localPackageAbsoluteDirectory(void); ! ! /** Relative directory to extract package ! * \return relative directory to use (or used, depending) for package extraction ! * \sa CBMSystem::Extract */ ! virtual char* extractDirectory(void) = 0; ! ! /** Indicates if the package provides a test method. ! * Must be overloaded if so. Returns 0 by default. ! * \return 0 by default, 1 if patch is needed. ! * \sa test() ! * \sa Test() ! */ ! virtual int hasTest(void); ! ! /** URL used for downloading package. ! * \return std::string representing the URL of the package ! * \sa expectedMD5() */ ! virtual std::string downloadURL(void) = 0; ! ! ! /** Display informations about benchmark ! Used by compbenchmark-config. Format is strict, default behaviour must be ! kept. */ ! virtual void display(void); ! /** Total size of benchmark ! * \return Total size, in bytes, of the benchmark/package. This comprises data used ! * in pre-configuration step. ! * \sa preConfigure() ! * \sa packageSize() */ ! virtual int benchmarkSize(void) = 0; ! ! /** Compairs previous compilation context to current one ! * \return 1 if they match. ! * \sa contextID() ! * \sa storeContext() ! * \sa Make() ! */ ! virtual int ContextMatches(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions); ! /** Download package. ! * Gets downloadURL() object from Internet and verify checksum. ! * Uses download(). Overloading is unadvised. ! * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Downloaded. ! * \param _force sets to 1 to force operation. May changes status. ! * \return 1 if ok. ! * \sa status */ ! virtual int Download(int _force = 0); ! ! /** Extract package. ! * Extracts downloaded package. ! * Uses extract(). Overloading is unadvised. ! * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Extracted. ! * \param _force sets to 1 to force operation. May changes status. ! * \return 1 if ok. ! * \sa Download() ! * \sa status */ ! virtual int Extract(int _force = 0); ! ! /** Patch package. ! * Patches extracted package. ! * Overloading is unadvised, 1 is returned without any action, by default. ! * If hasPatch() returns 1, uses patch(). ! * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Patched. ! * \param _force sets to 1 to force operation. May changes status. ! * \return 1 if ok. ! * \sa Extract() ! * \sa status */ ! virtual int Patch(int _force = 0); ! ! /** Preconfigure package. ! * Preconfigure downloaded package. ! * Uses preConfigure(). Overloading is unadvised. ! * This step won't be done and'll return 1 if ! * getStatus()>=CBMPackage::PreConfigured. May changes status. ! * \param _force sets to 1 to force operation. ! * \return 1 if ok. ! * \sa Patch() ! * \sa status */ ! virtual int PreConfigure(int _force = 0); ! ! /** Configure package. ! * Configure downloaded package. ! * Uses configure(). Overloading is unadvised. Argument are used to keep ! * compiler and options used for current bench (context), even ! * if ./configure script is not present : they'll be used by Make(). ! * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Configured. May changes status. ! * \return 1 if ok. ! * \sa Download() ! * \sa Release() ! * \sa ContextMatches() ! * \sa Make(). ! * \sa status */ ! virtual int Configure(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions); ! ! ! /** Build package. ! * Builds package. ! * Uses make(). Overloading is unadvised. ! * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Made. ! * \param _force sets to 1 to force operation. May changes status. ! * \return 1 if ok. May changes status. ! * \sa Configure() ! * \sa Release() ! * \sa status ! * \sa ContextMatches() */ ! virtual int Make(int _force = 0); ! ! /** Test a package. ! * Test a built package. ! * Overloading is unadvised, 1 is returned without any action, by default. ! * If hasPatch() returns 1, uses patch(). ! * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Benchmarked. ! * \param _force sets to 1 to force operation. May changes status. ! * \return 1 if ok. ! * \sa Make() ! * \sa status */ ! virtual int Test(int _force = 0); ! ! ! /** Run benchmarks. * Uses bench(). Overloading is unadvised. * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Benchmarked. --- 59,63 ---- virtual std::string benchmarkComments(void) = 0; ! /** Run benchmark. * Uses bench(). Overloading is unadvised. * This step won't be done and'll return 1 if getStatus()>=CBMPackage::Benchmarked. *************** *** 360,411 **** virtual std::string Bench(void); - /** Clean objects. - * Uses release(). Overloading is unadvised. - * This step won't be done and'll return 0 if getStatus()<CBMPackage::Made. May changes status. - * \return 1 if ok. - * \sa Bench() */ - virtual int Release(void); - - /** Install package. - * Installs package, uses, in that order Download(), Extract(), Patch() (if needed) - * and PreConfigure(). Overloading is unadvised. - * This step won't be done and'll return 1 if getStatus()>=CBMPackage::PreConfigured. - * \param _force assign to 1 for forcing operation. - * \return 1 if ok. May changes status. - * \sa status */ - virtual int Install(int _force = 0); - - /** Copy a local archive. - * Copy package to directory defined by CBMSystem::Download. It'll be ready - * to be extracted using Install(). - * \param _source the archive file - * \param _force assign to 1 for forcing operation. - * \return 1 if ok. May changes status. - * \sa status - * \sa extract */ - virtual int Fetch(char *_source, int _force = 0); - - /** Uninstall package. - * Uses uninstall(). Overloading is unadvised. - * This step won't be done and'll return 1 if getStatus()==CBMPackage::Unknown. - * \return 1 if ok. May changes status. - * \sa status */ - virtual int Uninstall(void); - - /** Returns benchmark's status - * \return status (enum). - * \sa CBMBenchmark::Status */ - virtual Status getStatus(void); - /** Virtual destructor */ virtual ~CBMBenchmark(); - }; ! #define lib_declare() \ ! extern "C" int cbmlib_getBenchmarkNumber(void); \ ! extern "C" CBMBenchmark *cbmlib_getBenchmark(int idx, class CBMSystem *_system); \ ! extern "C" CBMBenchmark *cbmlib_getBenchmarkByName(char *bench_id, class CBMSystem *_system); \ ! extern "C" std::vector<std::string> cbmlib_getBenchmarks(void) #endif --- 67,80 ---- virtual std::string Bench(void); /** Virtual destructor */ virtual ~CBMBenchmark(); }; ! #define DLdeclare() \ ! extern "C" CBMPackage *cbmlib_getPackage(void) ! ! #define DLPackageWrapper_declare() \ ! BenchmarkVector& Benchmarks(void); \ ! CBMBenchmark *Benchmark(std::string bid) #endif Index: Benchmark.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Benchmark/Benchmark.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Benchmark.cpp 28 Dec 2006 13:19:47 -0000 1.17 --- Benchmark.cpp 3 Jan 2007 21:58:38 -0000 1.18 *************** *** 1,485 **** #include <Benchmark/Benchmark.h> ! ! #include <System/System.h> ! #include <UI/UI.h> #include <cloptions.h> ! #include <config.h> ! ! #include <fstream> ! #include <iostream> ! #include <string> ! ! CBMBenchmark::CBMBenchmark(CBMSystem *_system) ! { ! system=_system; ! status=Unknown; ! currentCompiler=0; ! currentOptions=0; ! } ! ! std::string CBMBenchmark::packageName(void) ! { ! return(""); ! } ! ! int CBMBenchmark::readStatus(void) ! { ! char s; ! std::string r; ! std::string id; ! ! id="bm-status-"; ! id+=packageName(); ! ! ! r=system->read((char*) id.c_str()); ! ! if (r!="") { ! s=r.c_str()[0]; ! status=(Status) ((int) s - (int) '0'); ! return(1); ! } else { ! /* !!! */ ! return(0); ! } ! } ! ! int CBMBenchmark::resetContext(void) ! { ! std::string contextFile; ! ! contextFile=system->temporaryDirectory(CBMSystem::Status); ! contextFile+="/"; ! ! contextFile+="bm-context-"; ! contextFile+=packageName(); ! ! return(system->unlink(contextFile)); ! } ! ! std::string CBMBenchmark::localPackageAbsoluteName(void) ! { ! std::string localFile = system->temporaryDirectory(CBMSystem::Download); ! ! localFile+="/"; ! localFile+=localPackageName(); ! ! return(localFile); ! } ! ! std::string CBMBenchmark::localPackageAbsoluteDirectory(void) ! { ! std::string cmd; ! ! cmd+=system->temporaryDirectory(CBMSystem::Extract); ! cmd+="/"; ! cmd+=extractDirectory(); ! ! return(cmd); ! } ! ! int CBMBenchmark::hasPatch(void) ! { ! return(0); ! } ! ! int CBMBenchmark::patch(int _force) ! { ! return(1); ! } ! ! int CBMBenchmark::hasTest(void) ! { ! return(0); ! } ! ! int CBMBenchmark::test(int _force) ! { ! return(1); ! } ! ! ! int CBMBenchmark::uninstall(void) ! { ! std::string where = localPackageAbsoluteDirectory(); ! std::string cmd; ! cmd+=CBM_PROG_RM; ! cmd+=" -rf "; ! std::string sstdout; ! ! cmd+=where; ! ! return(system->exec(cmd, sstdout)==0); ! ! } ! ! int CBMBenchmark::storeStatus(Status _status) ! { ! int r; ! char c[16] = { 0 }; ! std::string tmp; ! std::string id; ! ! id="bm-status-"; ! id+=packageName(); ! ! sprintf(c, "%d", (int) _status); ! tmp=c; ! r=system->store((char*) id.c_str(), ! tmp); ! ! status=_status; ! return(r); ! } ! ! std::string CBMBenchmark::contextID(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions) ! { ! std::string what = _currentCompiler->Binary(); ! what+="\n"; ! what+=_currentOptions->Options(); ! return(what); ! } ! ! int CBMBenchmark::storeContext(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions) ! { ! std::string context = contextID(_currentCompiler, ! _currentOptions); ! std::string id; ! int r; ! ! id="bm-context-"; ! id+=packageName(); ! ! r=system->store((char*) id.c_str(), ! context); ! ! return(r); ! } ! ! int CBMBenchmark::ContextMatches(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions) ! { ! std::string previousContext; ! std::string context; ! std::string id; ! ! id="bm-context-"; ! id+=packageName(); ! ! previousContext=system->read((char*) id.c_str()); ! context=contextID(_currentCompiler, ! _currentOptions); ! ! if (context==previousContext) { ! currentCompiler=_currentCompiler; ! currentOptions=_currentOptions; ! return(1); ! } else { ! return(0); ! } ! } ! ! void CBMBenchmark::display(void) ! { ! std::cout << "package::Name=" << packageName() << std::endl ! << "package::Url=" << downloadURL() << std::endl ! << "package::Size=" << packageSize() << std::endl ! << "package::Version=" << packageVersion() << std::endl ! << "package::Comments=" << packageComments() << std::endl ! << "package::License=" << license() << std::endl ! << "package::Homepage=" << homePage() << std::endl ! << "package::Author=" << author() << std::endl << std::endl ! << "benchmark::Name=" << benchmarkName() << std::endl ! << "benchmark::Package=" << packageName() << std::endl ! << "benchmark::Language=" << language() << std::endl ! << "benchmark::Size=" << benchmarkSize() << std::endl ! << "benchmark::Status=" << getStatus() << std::endl ! << "benchmark::Comments=" << benchmarkComments() << std::endl ! << std::endl; ! } ! ! int CBMBenchmark::Download(int _force) ! { ! std::string localFile = localPackageAbsoluteName(); ! std::string expected_md5; ! std::string md5; ! std::string info; ! ! if ((!_force) && ! (getStatus()>=Downloaded)) { ! return(1); ! } ! ! info=packageName(); ! info+=" "; ! info+=packageVersion(); ! ! UI->Information(CBMUI::BenchDownload, ! info); ! ! try { ! system->download(downloadURL(), ! (char*) localFile.c_str()); ! } ! ! catch (...) { ! } ! ! if (cbmSystem->fileExists(localFile)) { ! expected_md5=expectedMD5(); ! md5=system->md5File(localFile); ! ! if (expected_md5==md5) { ! UI->Information(CBMUI::ChecksumOK, ! localFile); ! ! storeStatus(Downloaded); ! return(1); ! } else { ! UI->Information(CBMUI::ChecksumFailed, ! localFile); ! ! system->unlink((char*) localFile.c_str()); ! info="Unsuccesfull download "; ! info+=downloadURL(); ! info+=" to "; ! info+=localFile; ! UI->Fatal(info); ! return(0); ! } ! } else { ! info="Can't download "; ! info+=downloadURL(); ! info+=" to "; ! info+=localFile; ! UI->Fatal(info); ! ! system->unlink((char*) localFile.c_str()); ! } ! return(0); ! } ! ! int CBMBenchmark::Extract(int _force) ! { ! int r; ! ! if ((!_force) && ! (getStatus()>=Extracted)) { ! return(1); ! } ! ! UI->Information(CBMUI::BenchExtract, ! packageName()); ! ! r=extract(_force); ! ! if (r) ! storeStatus(Extracted); ! else { ! std::string info; ! info="Error extracting "; ! info+=localPackageAbsoluteName(); ! info+=" into "; ! info+=system->temporaryDirectory(CBMSystem::Extract); ! UI->Fatal(info); ! } ! ! return(r); ! } ! ! int CBMBenchmark::Patch(int _force) ! { ! int r; ! ! if (!hasPatch()) ! return(1); ! ! if ((!_force) && ! (getStatus()>=Patched)) { ! return(1); ! } ! ! UI->Information(CBMUI::BenchPatch, ! packageName()); ! ! r=patch(_force); ! ! if (r) ! storeStatus(Patched); ! else { ! std::string info; ! info="Error patching "; ! info+=localPackageAbsoluteName(); ! UI->Fatal(info); ! } ! ! return(r); ! } ! ! int CBMBenchmark::PreConfigure(int _force) ! { ! int r; ! ! if ((!_force) && (getStatus()>=Preconfigured)) { ! return(1); ! } ! if ( ((!hasPatch()) && (getStatus()<Extracted)) || ! ((hasPatch()) && (getStatus()<Patched)) ) { ! return(0); ! } ! ! ! UI->Information(CBMUI::BenchPreconfigure, ! packageName()); ! ! r=preConfigure(_force); ! ! if (r) ! storeStatus(Preconfigured); ! else { ! std::string info; ! ! info="Error in "; ! info+=packageName(); ! info+="'s pre-configuration"; ! UI->Fatal(info); ! } ! return(r); ! } ! ! int CBMBenchmark::Configure(CBMCompiler *_currentCompiler, ! CBMCompilerOptions *_currentOptions) { ! int r; ! std::string info; ! ! if (getStatus()>=Configured) { ! currentCompiler=_currentCompiler; ! currentOptions=_currentOptions; ! return(1); ! } ! ! info=packageName(); ! info+=" with compiler "; ! info+=_currentCompiler->Binary(); ! if (_currentOptions->Options()=="") { ! info+=" without options"; ! } else { ! info+=" and options "; ! info+=_currentOptions->Options(); ! } ! ! if (language()!=_currentCompiler->language()) { ! ! storeContext(_currentCompiler, ! _currentOptions); ! info=_currentCompiler->Binary(); ! info+=" is a "; ! info+=_currentCompiler->language(); ! info+=" compiler, while benchmark is written is "; ! info+=language(); ! info+="."; ! UI->Fatal(info); ! } ! ! UI->Information(CBMUI::BenchConfigure, ! info); ! ! r=configure(_currentCompiler, ! _currentOptions); ! ! if (r) { ! storeStatus(Configured); ! currentCompiler=_currentCompiler; ! currentOptions=_currentOptions; ! } else { ! info="Configure failed for "; ! info+=packageName(); ! UI->Fatal(info); ! } ! ! return(r); } ! int CBMBenchmark::Make(int _force) { ! int r; ! std::string info; ! time_t beg; ! time_t end; ! ! if ((getStatus()>=Made) && (!_force)) { ! return(1); ! } ! ! UI->Information(CBMUI::BenchMake, ! packageName()); ! ! beg=system->Time(); ! r=make(); ! if (r) { ! end=system->Time(); ! std::cout << "Build time : " << (double) (end-beg) << std::endl; ! storeStatus(Made); ! storeContext(currentCompiler, ! currentOptions); ! } else { ! info="Make failed for "; ! info+=packageName(); ! UI->Fatal(info); ! ! } ! ! return(r); } ! int CBMBenchmark::Test(int _force) { ! int r; ! std::string dum; ! ! if (!hasTest()) ! return(1); ! ! if (getStatus()<Configured) { ! UI->Fatal("Package is not configured"); ! } ! ! if ((!_force) && ! (getStatus()>=Benchmarked)) { ! return(1); ! } ! ! if (getStatus()<Made) { return(0); - } - - if (UO_enableTestSuite) { - UI->Information(CBMUI::BenchTest, - packageName()); - - r=test(_force); - } else { - dum=packageName(); - dum+=" : passed (disabled by user option)."; - UI->Information(CBMUI::BenchTest, - dum); - r=1; - } - - if (r) - storeStatus(Tested); - else { - std::string info; - info="Error testing "; - info+=localPackageAbsoluteName(); - UI->Fatal(info); - } - - return(r); } --- 1,24 ---- #include <Benchmark/Benchmark.h> ! #include <Benchmark/Package.h> #include <cloptions.h> + #include <UI/UI.h> ! CBMBenchmark::CBMBenchmark(CBMPackage *_package) { ! package=_package; } ! CBMPackage *CBMBenchmark::Package(void) { ! return(package); } ! CBMSystem *CBMBenchmark::System(void) { ! if (package) ! return(package->System()); ! else return(0); } *************** *** 490,494 **** ! if (((getStatus()<Tested) && (hasTest())) && (UO_enableTestSuite)) { info=benchmarkName(); --- 29,33 ---- ! if (((Package()->getStatus()<CBMPackage::Tested) && (Package()->hasTest())) && (UO_enableTestSuite)) { info=benchmarkName(); *************** *** 504,516 **** r=bench(); ! system->Chomp(r); if (r!="0") { ! storeStatus(Benchmarked); UI->Information(CBMUI::BenchResult, r); } else { info="Benchmarking failed for "; ! info+=packageName(); UI->Fatal(info); } --- 43,55 ---- r=bench(); ! Package()->System()->Chomp(r); if (r!="0") { ! Package()->storeStatus(CBMPackage::Benchmarked); UI->Information(CBMUI::BenchResult, r); } else { info="Benchmarking failed for "; ! info+=Package()->packageName(); UI->Fatal(info); } *************** *** 519,649 **** } - int CBMBenchmark::Release(void) - { - int r; - std::string info; - - if (getStatus()<Configured) { - return(0); - } - - UI->Information(CBMUI::BenchClean, - packageName()); - - - r=release(); - if (r) { - resetContext(); - storeStatus(Preconfigured); - } else { - info="Clean failed for "; - info+=packageName(); - /* UI->Fatal(info); */ - } - - return(r); - } - - int CBMBenchmark::Install(int _force) - { - int r; - - if (downloadURL()=="") { - UI->Fatal("Package is not known to be hosted anymore on the Internet. Use --fetch option."); - } - - resetContext(); - - r=Download(_force); - if (!r) - return(0); - - r=Extract(_force); - if (!r) - return(0); - - if (hasPatch()) { - r=Patch(); - if (!r) - return(0); - } - - r=PreConfigure(_force); - return(r); - } - - int CBMBenchmark::Fetch(char *_source, int _force) - { - std::string dest = localPackageAbsoluteName(); - std::string source = _source; - std::string expected_md5; - std::string md5; - - if ((getStatus()>=Downloaded) && (!_force)) { - return(1); - } - - if (dest!=source) { - cbmSystem->copy(source, dest); - } - - if (cbmSystem->fileExists(dest)) { - expected_md5=expectedMD5(); - md5=system->md5File(dest); - - if (expected_md5==md5) { - UI->Information(CBMUI::ChecksumOK, - dest); - - storeStatus(Downloaded); - return(1); - } else { - UI->Information(CBMUI::ChecksumFailed, - dest); - } - } - - return(0); - } - - int CBMBenchmark::Uninstall(void) - { - std::string statusFile; - int r; - - UI->Information(CBMUI::BenchUninstall, - packageName()); - - statusFile=system->temporaryDirectory(CBMSystem::Status); - statusFile+="/"; - statusFile+="bm-status-"; - statusFile+=packageName(); - - - if (getStatus()!=Unknown) { - system->unlink(localPackageAbsoluteName().c_str()); - system->unlink(statusFile.c_str()); - resetContext(); - r=uninstall(); - storeStatus(Unknown); - currentCompiler=0; - currentOptions=0; - return(r); - } else - return(0); - } - - CBMBenchmark::Status CBMBenchmark::getStatus(void) - { - // Status result = Unknown; - std::string localFile = localPackageAbsoluteName(); - - if (status==Unknown) { - readStatus(); - return(status); - } else - return(status); - } - CBMBenchmark::~CBMBenchmark() { --- 58,61 ---- |