Skip to content

Commit

Permalink
Add more error message for test
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms committed Apr 4, 2017
1 parent d4aa596 commit a3ae2ba
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/sonic-config-engine/tests/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from unittest import TestCase

class TestJ2Files(TestCase):
class TestAcl(TestCase):
def setUp(self):
self.test_dir = os.path.dirname(os.path.realpath(__file__))
self.script_file = os.path.join(self.test_dir, '..', 'sonic-cfggen')
Expand All @@ -16,11 +16,23 @@ def setUp(self):

def run_script(self, argument):
print 'CMD: sonic-cfggen ' + argument
return subprocess.check_output(self.script_file + ' ' + argument, shell=True)
output = ''
try:
output = subprocess.check_output(self.script_file + ' ' + argument, shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, (p):
print 'subprocess.CalledProcessError: cmd:%s returncode:%s' % (p.cmd, p.returncode)
print output
return output

def run_acl_script(self, argument):
print 'CMD: translate_acl ' + argument
return subprocess.check_output(self.acl_script_file + ' ' + argument, shell=True)
output = ''
try:
output = subprocess.check_output(self.acl_script_file + ' ' + argument, shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, (p):
print 'subprocess.CalledProcessError: cmd:%s returncode:%s' % (p.cmd, p.returncode)
print output
return output

def test_translate_acl(self):
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -o ' + self.test_dir + ' ' + self.t0_acl
Expand All @@ -30,7 +42,7 @@ def test_translate_acl(self):
output_file = os.path.join(self.test_dir, filename)
assert filecmp.cmp(sample_output_file, output_file)

def test_translate_everflor(self):
def test_translate_everflow(self):
argument = '-m ' + self.t0_minigraph_everflow + ' -p ' + self.t0_port_config + ' -o ' + self.test_dir + ' ' + self.t0_acl
self.run_acl_script(argument)
for filename in ['rules_for_everflow.json','table_everflow.json']:
Expand Down

0 comments on commit a3ae2ba

Please sign in to comment.