check_test_files.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2009, Willow Garage, Inc.
00006 # All rights reserved.
00007 #
00008 # Redistribution and use in source and binary forms, with or without
00009 # modification, are permitted provided that the following conditions
00010 # are met:
00011 #
00012 #  * Redistributions of source code must retain the above copyright
00013 #    notice, this list of conditions and the following disclaimer.
00014 #  * Redistributions in binary form must reproduce the above
00015 #    copyright notice, this list of conditions and the following
00016 #    disclaimer in the documentation and/or other materials provided
00017 #    with the distribution.
00018 #  * Neither the name of the Willow Garage nor the names of its
00019 #    contributors may be used to endorse or promote products derived
00020 #    from this software without specific prior written permission.
00021 #
00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 # POSSIBILITY OF SUCH DAMAGE.
00034 
00035 ##\author Kevin Watts
00036 
00037 PKG = 'qualification'
00038 
00039 import roslib; roslib.load_manifest(PKG)
00040 import rostest, unittest
00041 
00042 from qualification.test_loader import load_tests_from_map, load_configs_from_map, load_wg_station_map
00043 from qualification.test import Test
00044 
00045 import os, sys
00046 
00047 ##\brief Parses launch, tests.xml and configs.xml files in qualification
00048 class QualificationTestParser(unittest.TestCase):
00049     def setUp(self):
00050         self.test_files = {}
00051         self.tests_ok = load_tests_from_map(self.test_files)
00052 
00053         self.config_files = {}
00054         self.configs_ok = load_configs_from_map(self.config_files)
00055 
00056         self.wg_stations = {}
00057         self.wg_stations_ok = load_wg_station_map(self.wg_stations)
00058 
00059     def test_wg_station_map(self):
00060         self.assert_(self.wg_stations_ok, "Unable to load WG station map. Configuration file \"wg_map.xml\" is invalid")
00061         self.assert_(len(self.wg_stations.items()) > 0, "No WG stations loaded")
00062 
00063     ##\brief All test.xml files must load properly
00064     def test_check_tests_parsed(self):
00065         self.assert_(self.tests_ok, "Tests failed to load (tests.xml)")
00066         self.assert_(self.test_files is not None, "Tests list is None, nothing to load")
00067         self.assert_(len(self.test_files.items()) > 0, "No tests loaded")
00068 
00069         for sn, tsts in self.test_files.iteritems():
00070             for t in tsts:
00071                 self.assert_(t.validate(), "Test failed to validate. Serial number: %s" % sn)
00072 
00073      ##\brief All config files must load successfully
00074     def test_check_configs_parsed(self):
00075         self.assert_(self.configs_ok, "Configs failed to load (configs.xml)")
00076         self.assert_(self.config_files is not None, "Configs list is None, nothing to load")
00077         self.assert_(len(self.config_files.items()) > 0, "No config scripts loaded")
00078 
00079         for sn, tsts in self.config_files.iteritems():
00080             for t in tsts:
00081                 self.assert_(t.validate(), "Config file failed to validate. Serial number: %s" % sn)
00082 
00083 if __name__ == '__main__':
00084     if len(sys.argv) > 1 and sys.argv[1] == '-v':
00085         # Use to run tests verbosly
00086         suite = unittest.TestSuite()
00087         suite.addTest(QualificationTestParser('test_wg_station_map'))
00088         suite.addTest(QualificationTestParser('test_check_tests_parsed'))
00089         suite.addTest(QualificationTestParser('test_check_configs_parsed'))
00090         
00091         unittest.TextTestRunner(verbosity = 2).run(suite)
00092     else:
00093         rostest.unitrun(PKG, 'check_test_files', QualificationTestParser)
00094 
00095 


qualification
Author(s): Kevin Watts (watts@willowgarage.com), Josh Faust (jfaust@willowgarage.com)
autogenerated on Sat Dec 28 2013 17:57:34