[Compbench-devel] CompBenchmarks++ cloptions.cpp,1.17,1.18
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-02-06 19:32:00
|
Update of /cvsroot/compbench/CompBenchmarks++ In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18523 Modified Files: cloptions.cpp Log Message: -B option added. -q improved. Index: cloptions.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/cloptions.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** cloptions.cpp 6 Feb 2007 17:49:56 -0000 1.17 --- cloptions.cpp 6 Feb 2007 19:31:52 -0000 1.18 *************** *** 34,37 **** --- 34,40 ---- unsigned int package:1; unsigned int benchmark:1; + unsigned int host:1; + unsigned int compiler:1; + unsigned int external_programs:1; } OptFilter; *************** *** 191,194 **** --- 194,198 ---- OptFilter filter = { 0 }; /* <empty>/all/installed */ std::string object_t; /* package/benchmark/host/compiler */ + int not_done = 1; static const struct option long_options[] = { *************** *** 198,202 **** {"manage", no_argument, 0, 'm'}, {"low-level", no_argument, 0, 'M'}, ! {"bench", no_argument, 0, 'B'}, {"filter-installed", no_argument, 0, 'i'}, {"install", required_argument, 0, 'I' }, --- 202,206 ---- {"manage", no_argument, 0, 'm'}, {"low-level", no_argument, 0, 'M'}, ! {"bench", required_argument, 0, 'B'}, {"filter-installed", no_argument, 0, 'i'}, {"install", required_argument, 0, 'I' }, *************** *** 211,217 **** /* {"package-benchmarks-info", 1, 0, 'I' }, */ ! {"host-info", 0, 0, 'H' }, ! {"programs-info", 0, 0, 'P' }, ! {"compiler-info", 1, 0, 'c' }, {"bench", 1, 0, 'B'}, --- 215,221 ---- /* {"package-benchmarks-info", 1, 0, 'I' }, */ ! {"host", 0, 0, 'H' }, ! {"programs", no_argument, 0, 'P' }, ! {"compiler", required_argument, 0, 'c' }, {"bench", 1, 0, 'B'}, *************** *** 229,233 **** }; ! while (1) { int option_index = 0; --- 233,237 ---- }; ! while (not_done) { int option_index = 0; *************** *** 235,239 **** break; ! c = getopt_long (argc, argv, "hviI:F:U:qp::b::aMmD:E:P:C:T:R:S:f", // uLHPCFIB", /* :011000112", */ long_options, &option_index); if (c==-1) { --- 239,243 ---- break; ! c = getopt_long (argc, argv, "hvxiI:F:U:qHc:p::B:b::aMmD:E:P:C:T:R:S:f", // uLHPCFIB", /* :011000112", */ long_options, &option_index); if (c==-1) { *************** *** 331,351 **** break; case 'H': ! /* cbmSystem->display(); */ /* !!! */ parseExitValue=0; break; ! case 'c': ! C=SC.select((char*) optarg); ! if (C) { ! /* C->display(); */ /* !!! */ ! parseExitValue=0; ! } else ! parseExitValue=1; break; ! case 045: /* !!! */ ! B=cbmOptionsExpectBenchmark(optarg); ! if (B) { ! /* B->display(); */ /* !!! */ ! parseExitValue=0; ! } break; /* case 'f': !!! --- 335,349 ---- break; case 'H': ! filter.host=1; parseExitValue=0; break; ! case 'x': ! filter.external_programs=1; ! parseExitValue=0; break; ! case 'c': ! filter.compiler=1; ! if (optarg) ! C=SC.select((char*) optarg); break; /* case 'f': !!! *************** *** 388,396 **** break; case 'B': ! /* B=cbmOptionsExpectBenchmark(optarg); if (!B) break; optind++; if (optind<=argc) { compiler=argv[optind-1]; --- 386,395 ---- break; case 'B': ! domain=DomainBench; B=cbmOptionsExpectBenchmark(optarg); if (!B) break; optind++; + if (optind<=argc) { compiler=argv[optind-1]; *************** *** 400,410 **** break; } ! C=SC.select((char*) compiler.c_str()); ! if (!C) { ! std::cerr << "Compiler " << compiler.c_str() << " not found." << std::endl; ! parseExitValue=1; ! break; ! } ! optind++; if (optind<=argc) { --- 399,403 ---- break; } ! optind++; if (optind<=argc) { *************** *** 413,439 **** options=""; } ! O=new CBM::CompilerOptions(options); ! P=B->Package(); ! if (P->getStatus()<CBM::Package::Preconfigured) { ! std::cerr << "Package not properly installed" << std::endl; ! parseExitValue=1; ! break; ! } ! context=P->ContextMatches(C, O); ! ! status=P->getStatus(); ! if ((status>=CBM::Package::Configured) && (!context)) { ! P->Release(); ! } ! ! if (!context) { ! P->Configure(C, O); ! P->Make(UO_force); ! P->Test(UO_force); ! } ! B->Bench(); ! ! parseExitValue=0; ! */ break; case '?': --- 406,410 ---- options=""; } ! not_done=0; break; case '?': *************** *** 441,445 **** } } - switch(domain) { case DomainVersion: --- 412,415 ---- *************** *** 447,454 **** --- 417,431 ---- (!filter.installed) && (!filter.benchmark) && + (!filter.external_programs) && + (!filter.host) && (!filter.package) && + (!filter.external_programs) && + (!filter.compiler) && (action==ActionUndef)) { std::cout << VERSION << std::endl; parseExitValue=0; + } else { + std::cerr << "Invalid filter or action with -v" << std::endl; + parseExitValue=255; } break; *************** *** 458,462 **** --- 435,491 ---- break; case DomainQuery: + if ((!filter.all) && (!filter.installed)) { + if (filter.host) { + std::cout << "Architecture : " << cbmSystem->arch() << std::endl + << "Host ID : " << cbmSystem->hostid() << std::endl + << "Hostname : " << cbmSystem->hostname() << std::endl + << "OS : " << cbmSystem->os() << std::endl + << "OS Version : " << cbmSystem->os_version() << std::endl + << "Processor name : " << cbmSystem->processor_name() << std::endl + << "Processor speed (MHz) : " << cbmSystem->processor_mhz() << std::endl + << "Processor cache (Kb) : " << cbmSystem->processor_cache() << std::endl + << "Processor number : " << cbmSystem->processor_number() << std::endl; + parseExitValue=0; + break; + } + if (filter.compiler) { + std::cout << "Compiler name : " << C->Name() << std::endl + << "Version : " << C->Version() << std::endl + << "Language : " << C->language() << std::endl + << "Binary : " << C->Binary() << std::endl; + parseExitValue=0; + break; + } + + if (filter.external_programs) { + std::cout << "BZIP2:" << CBM_PROG_BZIP2 << std::endl + << "CUT:" << CBM_PROG_CUT << std::endl + << "DD:" << CBM_PROG_DD << std::endl + << "DIALOG:" << CBM_PROG_DIALOG << std::endl + << "GREP:" << CBM_PROG_GREP << std::endl + << "GZIP:" << CBM_PROG_GZIP << std::endl + << "HEAD:" << CBM_PROG_HEAD << std::endl + << "MAKE:" << CBM_PROG_MAKE << std::endl + << "MKDIR:" << CBM_PROG_MKDIR << std::endl + << "PATCH:" << CBM_PROG_PATCH << std::endl + << "RM:" << CBM_PROG_RM << std::endl + << "TAIL:" << CBM_PROG_TAIL << std::endl + << "TAR:" << CBM_PROG_TAR << std::endl + << "UNZIP:" << CBM_PROG_UNZIP << std::endl + << "WGET:" << CBM_PROG_WGET << std::endl + << "ZCAT:" << CBM_PROG_ZCAT << std::endl + << "CAT:" << CBM_PROG_CAT << std::endl + << "PERL:" << CBM_PROG_PERL << std::endl; + parseExitValue=0; + break; + } + } + if ((filter.all) || (filter.installed)) { + if (filter.host) { + std::cerr << "-H option incompatible in that query." << std::endl; + parseExitValue=255; + break; + } if ((filter.package) && (P)) { std::cerr << "-p must have no argument when -a or -i is used." << std::endl; *************** *** 584,591 **** --- 613,629 ---- } break; + default: case ActionUndef: std::cerr << "action not specified." << std::endl; + std::cerr << "Valid options are -I and -U." << std::endl; + break; } case DomainLowLevel: + if (filter.host) { + std::cerr << "-H and -M options not compatibles." << std::endl; + parseExitValue=1; + break; + } + switch(action) { case ActionLLDownload: *************** *** 593,599 **** parseExitValue=!P->Download(); } else { ! CBM::cbmUI->Fatal("Package is not known to be hosted anymore on the Internet. Use --fetch option"); } break; case ActionLLExtract: parseExitValue=!P->Extract(); --- 631,645 ---- parseExitValue=!P->Download(); } else { ! std::cerr << "Package is not known to be hosted anymore on the Internet. Use --fetch <tarball> option" << std::endl; ! parseExitValue=1; } break; + case ActionInstall: + case ActionUninstall: + std::cerr << "Incompatible option for action. You probably meant -m." << std::endl; + break; + case ActionLLFetch: + P->Fetch((char*) tarball.c_str(), UO_force); + break; case ActionLLExtract: parseExitValue=!P->Extract(); *************** *** 611,615 **** --- 657,699 ---- parseExitValue=!P->Test(); break; + default: + std::cerr << "Invalid or missing option for -M" << std::endl; + parseExitValue=255; + break; + } + break; + case DomainBench: + if (!B) { + std::cerr << "benchmark (BID) expected" << std::endl; + break; } + C=SC.select((char*) compiler.c_str()); + if (!C) { + std::cerr << "Compiler " << compiler.c_str() << " not found." << std::endl; + parseExitValue=1; + break; + } + O=new CBM::CompilerOptions(options); + P=B->Package(); + if (P->getStatus()<CBM::Package::Preconfigured) { + std::cerr << "Package not properly installed" << std::endl; + parseExitValue=1; + break; + } + context=P->ContextMatches(C, O); + + status=P->getStatus(); + if ((status>=CBM::Package::Configured) && (!context)) { + P->Release(); + } + + if (!context) { + P->Configure(C, O); + P->Make(UO_force); + P->Test(UO_force); + } + B->Bench(); + + parseExitValue=0; break; } |