Made the scripts work from make distcheck
This commit is contained in:
parent
0d114c854b
commit
0248d3b668
|
@ -56,6 +56,7 @@ def test_config_atest(app_desc, config, run_test, verbose=True):
|
|||
|
||||
except IOError as se:
|
||||
print >> sys.stderr, "Failed to verify %s" % ' '.join(cmd)
|
||||
print >> sys.stderr, "Current directory: %s" % os.getcwd()
|
||||
print >> sys.stderr, "Error was %s" % se
|
||||
raise se
|
||||
|
||||
|
@ -147,7 +148,7 @@ def check_configs_tested(basedir, app_configs):
|
|||
|
||||
|
||||
def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True,
|
||||
rmtmp=False):
|
||||
confpath=".", rmtmp=False):
|
||||
check_configs_tested("doc/examples/", app_configs)
|
||||
errors = 0
|
||||
for app in apps:
|
||||
|
@ -157,9 +158,10 @@ def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True,
|
|||
|
||||
configs = app_configs[app[3]]
|
||||
for config in configs:
|
||||
config = os.path.join(confpath, config)
|
||||
errors |= test_config(app, config, tmpdir, verbose)
|
||||
|
||||
if rmtmp:
|
||||
if rmtmp or not errors:
|
||||
remove_tmpdir(tmpdir)
|
||||
|
||||
return errors
|
||||
|
@ -169,6 +171,7 @@ if __name__ == '__main__':
|
|||
import argparse
|
||||
|
||||
confpath = "."
|
||||
wordir = "."
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--e1nitb", action="store_true", dest="e1nitb")
|
||||
|
@ -176,11 +179,17 @@ if __name__ == '__main__':
|
|||
action="store_true", help="verbose mode")
|
||||
parser.add_argument("-p", "--pythonconfpath", dest="p",
|
||||
help="searchpath for config")
|
||||
parser.add_argument("-w", "--workdir", dest="w",
|
||||
help="Working directory to run in")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.p:
|
||||
confpath = args.p
|
||||
|
||||
if args.w:
|
||||
workdir = args.w
|
||||
|
||||
osmoappdesc = None
|
||||
try:
|
||||
osmoappdesc = osmoutil.importappconf(confpath, "osmoappdesc")
|
||||
|
@ -194,4 +203,6 @@ if __name__ == '__main__':
|
|||
if args.e1nitb:
|
||||
configs['nitb'].extend(osmoappdesc.nitb_e1_configs)
|
||||
|
||||
sys.exit(test_all_apps(apps, configs, verbose=args.verbose))
|
||||
os.chdir(workdir)
|
||||
sys.exit(test_all_apps(apps, configs, confpath=confpath,
|
||||
verbose=args.verbose))
|
||||
|
|
|
@ -14,23 +14,32 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import osmopy.obscvty as obscvty
|
||||
import osmopy.osmoutil as osmoutil
|
||||
|
||||
confpath = '.'
|
||||
|
||||
"""Test a VTY. Warning: osmoappdesc must be imported first."""
|
||||
|
||||
|
||||
class TestVTY(unittest.TestCase):
|
||||
def setUp(self):
|
||||
osmo_vty_cmd = osmoappdesc.vty_command
|
||||
osmo_vty_cmd = osmoappdesc.vty_command[:]
|
||||
config_index = osmo_vty_cmd.index('-c')
|
||||
if config_index:
|
||||
cfi = config_index + 1
|
||||
osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])
|
||||
|
||||
try:
|
||||
print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd())
|
||||
self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
|
||||
except OSError:
|
||||
print >> sys.stderr, "Current directory: %s" % os.getcwd()
|
||||
print >> sys.stderr, "Consider setting -w"
|
||||
print >> sys.stderr, "Consider setting -b"
|
||||
time.sleep(1)
|
||||
|
||||
appstring = osmoappdesc.vty_app[2]
|
||||
|
@ -61,8 +70,7 @@ if __name__ == '__main__':
|
|||
import os
|
||||
import sys
|
||||
|
||||
workdir = "."
|
||||
confpath = "."
|
||||
workdir = '.'
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-v", "--verbose", dest="verbose",
|
||||
|
@ -70,7 +78,7 @@ if __name__ == '__main__':
|
|||
parser.add_argument("-p", "--pythonconfpath", dest="p",
|
||||
help="searchpath for config")
|
||||
parser.add_argument("-w", "--workdir", dest="w",
|
||||
help="Working directory to run in")
|
||||
help="Working directory")
|
||||
args = parser.parse_args()
|
||||
|
||||
verbose_level = 1
|
||||
|
@ -89,6 +97,7 @@ if __name__ == '__main__':
|
|||
print >> sys.stderr, "osmoappdesc not found, set searchpath with -p"
|
||||
sys.exit(1)
|
||||
|
||||
print "confpath %s, workdir %s" % (confpath, workdir)
|
||||
os.chdir(workdir)
|
||||
print "Running tests for specific VTY commands"
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestVTY)
|
||||
|
|
Loading…
Reference in New Issue