Skip to content

Commit

Permalink
Fix the html_ddd unit test so that it will pass. Fix the DOMCount and…
Browse files Browse the repository at this point in the history
… DDErrorReport unit tests so they will fail if there are errors. Fix unit tests test_rot, reg_ddcore, reg_ddparser so that they are run as intended. Add an attribute to the DDLSchema because it already exists in many geometry XML files and the DOMCount unit test will fail without it. We might or might not want to remove this attribute named pork in the future. Remove many schema files that have not been used for anything for years and also some unused test related files. Some other minor cleanup. All these changes should only affect the unit tests in the RegressionTest package.
  • Loading branch information
W.David Dagenhart committed Sep 27, 2010
1 parent 00dba0f commit 4cfc689
Show file tree
Hide file tree
Showing 28 changed files with 342 additions and 3,989 deletions.
3 changes: 3 additions & 0 deletions DetectorDescription/Parser/interface/FIPConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class FIPConfiguration : public DDLDocumentProvider {
/// Read in the configuration file.
int readConfig(const std::string& filename);

/// Read in the configuration file.
int readConfig(const std::string& filename, bool fullPath);

/// Return a list of files as a std::vector of strings.
virtual const std::vector < std::string >& getFileList(void) const;

Expand Down
19 changes: 14 additions & 5 deletions DetectorDescription/Parser/src/FIPConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,22 @@ void FIPConfiguration::dumpFileList(void) const {
// Here the Xerces parser is used to process the content of the
// configuration file.
//-----------------------------------------------------------------------
int FIPConfiguration::readConfig(const std::string& filename)

int FIPConfiguration::readConfig(const std::string& filename, bool fullPath)
{
std::string absoluteFileName (filename);
if (!fullPath) {
edm::FileInPath fp(filename);
// config file
absoluteFileName = fp.fullPath();
}

DCOUT('P', "FIPConfiguration::ReadConfig(): started");

// Set the parser to use the handler for the configuration file.
// This makes sure the Parser is initialized and gets a handle to it.
DDLParser ddlp(cpv_);
ddlp.getXMLParser()->setContentHandler(&configHandler_);
edm::FileInPath fp(filename);
// config file
std::string absoluteFileName (filename);
absoluteFileName = fp.fullPath();
ddlp.getXMLParser()->parse(absoluteFileName.c_str());
const std::vector<std::string>& vURLs = configHandler_.getURLs();
const std::vector<std::string>& vFiles = configHandler_.getFileNames();
Expand All @@ -106,3 +110,8 @@ int FIPConfiguration::readConfig(const std::string& filename)
// std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl;
return 0;
}

int FIPConfiguration::readConfig(const std::string& filename)
{
return readConfig(filename, false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class DDErrorDetection

void report(const DDCompactView& cpv, std::ostream & o);

bool noErrorsInTheReport(const DDCompactView& cpv);

private:
DDErrorDetection() { };

Expand Down
14 changes: 14 additions & 0 deletions DetectorDescription/RegressionTest/src/DDErrorDetection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,17 @@ void DDErrorDetection::report(const DDCompactView& cpv, ostream & o)
o << std::endl;
//nix();
}

bool DDErrorDetection::noErrorsInTheReport(const DDCompactView& cpv)
{
return lp_err::instance().empty() &&
ma_err::instance().empty() &&
so_err::instance().empty() &&
ro_err::instance().empty() &&
sp_err::instance().empty() &&
lp_cpv(cpv).empty() &&
ma().empty() &&
so().empty() &&
ma_lp().empty() &&
so_lp().empty();
}
54 changes: 30 additions & 24 deletions DetectorDescription/RegressionTest/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@

<use name="DetectorDescription/Core"/>
<use name="DetectorDescription/ExprAlgo"/>
<use name="DetectorDescription/Algorithm"/>
<use name="DetectorDescription/RegressionTest"/>
<use name="DetectorDescription/Parser"/>
<use name="xerces-c"/>

<bin file="TestIntegration.cpp" name="DetectorDescriptionRegressionTestDDDReport">
<flags TEST_RUNNER_ARGS=" /bin/bash DetectorDescription/RegressionTest/test run_dddreport.sh" />
<use name="FWCore/Utilities" />
</bin>

<bin file="TestIntegration.cpp" name="DetectorDescriptionRegressionTestDOMCount">
<flags TEST_RUNNER_ARGS=" /bin/bash DetectorDescription/RegressionTest/test run_domcount.sh" />
<use name="FWCore/Utilities" />
</bin>
<bin file="TestIntegration.cpp" name="DetectorDescriptionRegressionTestDDErrorReport">
<flags TEST_RUNNER_ARGS=" /bin/bash DetectorDescription/RegressionTest/test run_DDErrorReport.sh" />
<use name="FWCore/Utilities" />
</bin>

<bin file="TestIntegration.cpp" name="DetectorDescriptionRegressionTestDOMCount">
<flags TEST_RUNNER_ARGS=" /bin/bash DetectorDescription/RegressionTest/test run_DOMCount.sh" />
<use name="FWCore/Utilities" />
</bin>

<bin file="DDErrorReport.cpp">
<use name="FWCore/Utilities"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/PluginManager"/>
<use name="DetectorDescription/Core"/>
<use name="DetectorDescription/Parser"/>
<use name="boost_program_options"/>
<use name="DetectorDescription/RegressionTest"/>
</bin>

<bin file="html_ddd.cpp">
<use name="FWCore/Utilities"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/PluginManager"/>
<use name="DetectorDescription/Base"/>
<use name="DetectorDescription/Core"/>
<use name="DetectorDescription/Parser"/>
<use name="DetectorDescription/RegressionTest"/>
</bin>

<bin file="testrot.cpp">
<use name="DetectorDescription/RegressionTest"/>
</bin>

<bin file="reg_ddcore.cpp">
<use name="DetectorDescription/RegressionTest"/>
</bin>

# <bin file=DOMCount.cpp></bin>
<bin file="reg_ddparser.cpp">
<use name="DetectorDescription/RegressionTest"/>
</bin>

<bin name="test_DDD_rot file=testrot.cpp"></bin>
<bin name="test_DDD_reg_ddcore file=reg_ddcore.cpp"></bin>
<bin name="test_DDD_reg_ddparser file=reg_ddparser.cpp"></bin>
#<bin name=test_DDD_dump_const file=const_dump.cpp">
# <use name=DetectorDescription/Core>
# <use name=DetectorDescription/ExprAlgo>
Expand Down
101 changes: 63 additions & 38 deletions DetectorDescription/RegressionTest/test/DDErrorReport.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@
#include <iostream>
#include <fstream>

#include "FWCore/PluginManager/interface/PluginManager.h"
#include "FWCore/PluginManager/interface/standard.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Parser/interface/DDLParser.h"
#include "DetectorDescription/Parser/interface/DDLSAX2FileHandler.h"
#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
#include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
#include <boost/shared_ptr.hpp>
// #include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/PluginManager/interface/PluginManager.h"
#include "FWCore/PluginManager/interface/standard.h"
// #include "FWCore/Utilities/interface/Presence.h"
// #include "FWCore/PluginManager/interface/PresenceFactory.h"
// #include "FWCore/ParameterSet/interface/ParameterSet.h"
// #include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
// #include "FWCore/ServiceRegistry/interface/Service.h"

// #include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <boost/program_options.hpp>

namespace DD { } using namespace DD;
#include <string>
#include <iostream>

int main(int argc, char *argv[])
{
std::string const kProgramName = argv[0];
edmplugin::PluginManager::configure(edmplugin::standard::config());
std::cout << "initialize DDL parser" << std::endl;
edmplugin::PluginManager::configure(edmplugin::standard::config());

// Process the command line arguments
std::string descString("DDErrorReport");
descString += " [options] configurationFileName\n";
descString += "Allowed options";
boost::program_options::options_description desc(descString);
desc.add_options()
("help,h", "Print this help message")
("file,f", boost::program_options::value<std::string>(), "XML configuration file name. "
"Default is DetectorDescription/RegressionTest/test/configuration.xml")
("path,p", "Specifies filename is a full path and not to use FileInPath to find file. "
" This option is ignored if a filename is not specified");

boost::program_options::positional_options_description p;
p.add("file", -1);

boost::program_options::variables_map vm;
try {
store(boost::program_options::command_line_parser(argc,argv).options(desc).positional(p).run(),vm);
notify(vm);
} catch(boost::program_options::error const& iException) {
std::cerr << "Exception from command line processing: "
<< iException.what() << "\n";
std::cerr << desc << std::endl;
return 1;
}

if(vm.count("help")) {
std::cout << desc << std::endl;
return 0;
}

bool fullPath = false;
std::string configfile("DetectorDescription/RegressionTest/test/configuration.xml");
if (vm.count("file")) {
configfile = vm["file"].as<std::string>();
if (vm.count("path")) {
fullPath = true;
}
}

DDCompactView cpv;
DDLParser myP(cpv);// = DDLParser::instance();
DDLParser myP(cpv);
myP.getDDLSAX2FileHandler()->setUserNS(false);

// std::cout << "about to set configuration" << std::endl;
/* The configuration file tells the parser what to parse.
The sequence of files to be parsed does not matter but for one exception:
XML containing SpecPar-tags must be parsed AFTER all corresponding
Expand All @@ -36,33 +67,27 @@ int main(int argc, char *argv[])
will not suffer from this restriction).
*/

std::cout << "about to start parsing" << std::endl;
std::string configfile("DetectorDescription/RegressionTest/test/configuration.xml");
if (argc==2) {
configfile = argv[1];
} else {
std::cout << "running default " << configfile << std::endl;
}
// Use the File-In-Path configuration document provider.
// Use the File-In-Path configuration document provider.
FIPConfiguration fp(cpv);
fp.readConfig(configfile);
fp.readConfig(configfile, fullPath);
int parserResult = myP.parse(fp);
std::cout << "done parsing" << std::endl;
std::cout.flush();
if (parserResult != 0) {
std::cout << " problem encountered during parsing. exiting ... " << std::endl;
exit(1);
}
std::cout << " parsing completed" << std::endl;
std::cout << std::endl << std::endl << "Start checking!" << std::endl << std::endl;
std::cout.flush();
std::cout << "Parsing completed. Start checking for errors." << std::endl;

DDErrorDetection ed(cpv);
// maybe later ed.report(cpv,std::cout);
// DDErrorDetection ed;
// ed.scan();
ed.report(cpv, std::cout);

bool noErrors = ed.noErrorsInTheReport(cpv);
if (noErrors && fullPath) {
std::cout << "DDErrorReport did not find any errors and is finished." << std::endl;
}
else {
ed.report(cpv, std::cout);
if (!noErrors) {
return 1;
}
}
return 0;

}
39 changes: 20 additions & 19 deletions DetectorDescription/RegressionTest/test/html_ddd.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
#include <iostream>
#include <fstream>

#include "DetectorDescription/RegressionTest/interface/DDHtmlFormatter.h"

// required for main() in cmssw framework
#include "FWCore/PluginManager/interface/PluginManager.h"
#include "FWCore/PluginManager/interface/standard.h"

#include "DetectorDescription/Core/src/LogicalPart.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Parser/interface/DDLParser.h"
#include "DetectorDescription/Parser/interface/DDLSAX2FileHandler.h"
#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
#include "DetectorDescription/Core/src/DDCheck.h"
#include "DetectorDescription/Core/interface/DDRoot.h"
#include "DetectorDescription/Base/interface/DDException.h"
#include "DetectorDescription/Core/interface/DDFilter.h"
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/Core/interface/DDValue.h"
#include "DetectorDescription/Core/interface/DDQuery.h"
#include "DetectorDescription/Core/interface/DDSpecifics.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/RegressionTest/interface/DDHtmlFormatter.h"
#include "DetectorDescription/Core/src/LogicalPart.h"
#include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
#include "DetectorDescription/Base/interface/DDException.h"

#include <iostream>
#include <string>
#include <cstdlib>
#include <fstream>

int main(int argc, char *argv[])
{
if (argc < 2) {
std::cout << "This program does nothing unless it is given a command line argument.\n";
std::cout << "The argument should be the name of an xml configuration file.\n";
std::cout << "It is intentional this does nothing when run as part of the unit tests.\n";
std::cout << "It is not a test. We only put it in the test directory because it is\n";
std::cout << "not of general use and so does not belong in the bin directory.\n";
std::cout << "There is currently no other place to put it.\n";
return 0;
}

// required for main() in cmssw framework
std::string const kProgramName = argv[0];
edmplugin::PluginManager::configure(edmplugin::standard::config());

try {
Expand Down
36 changes: 36 additions & 0 deletions DetectorDescription/RegressionTest/test/run_DDErrorReport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /usr/bin/env python

import FWCore.ParameterSet.Config as cms
import sys
import os

if os.getenv('LOCAL_TOP_DIR') == None:
print "The environment variable LOCAL_TOP_DIR must be set to run this script"
print "Usually setting it equal to the value of CMSSW_BASE will do what you want"
print "In the context of a unit test this variable is always set automatically"
sys.exit(1)

# get the list of XML files from the cfi file
process = cms.Process("TEST")
cfiFile = 'Geometry/CMSCommonData/cmsIdealGeometryXML_cfi'
if len(sys.argv) > 1:
cfiFile = sys.argv[1]
process.load(cfiFile)
xmlFiles = process.es_sources['XMLIdealGeometryESSource'].geomXMLFiles.value()

# create an XML configuration file that contains the same list of XML files as the python cfi file
configXMLFile = open('dddreportconfig.xml', 'w')
configXMLFile.write('<?xml version="1.0"?>\n')
configXMLFile.write('<Configuration xmlns="." xmlns:xsi="." xsi:schemaLocation= "." name="CMSConfiguration" version="0">\n')
configXMLFile.write(' <Include>\n')
for name in xmlFiles:
configXMLFile.write(" <File name=\"" + name + "\" url=\".\"/>\n")
configXMLFile.write(' </Include>\n')
configXMLFile.write('<Root fileName="cms.xml" logicalPartName="OCMS"/>\n')
configXMLFile.write('</Configuration>\n')
configXMLFile.close()

command = os.getenv('LOCAL_TOP_DIR') + "/test/" + os.getenv('SCRAM_ARCH') + "/DDErrorReport dddreportconfig.xml -p"
status = os.system( command )
if (status != 0):
sys.exit(1)
22 changes: 22 additions & 0 deletions DetectorDescription/RegressionTest/test/run_DDErrorReport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

pushd ${LOCAL_TMP_DIR}

cfiFiles=Geometry/CMSCommonData/cmsIdealGeometryXML_cfi
cfiFiles="${cfiFiles} Geometry/CMSCommonData/cmsExtendedGeometryXML_cfi"
cfiFiles="${cfiFiles} Geometry/CMSCommonData/cmsExtendedGeometryLiMaxXML_cfi"

status=0

for cfiFile in ${cfiFiles}
do
echo "run_DDErrorReport.py $cfiFile"
${LOCAL_TEST_DIR}/run_DDErrorReport.py $cfiFile
if [ $? -ne 0 ]
then
status=1
fi
done

popd
exit $status
Loading

0 comments on commit 4cfc689

Please sign in to comment.