Skip to content

Commit

Permalink
[sonic-cfggen]: Output differences for bgp configurations (#2768)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-shirshov authored and lguohan committed Apr 11, 2019
1 parent 6176018 commit 9b1663c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def run_script(self, argument):
print 'CMD: sonic-cfggen ' + argument
return subprocess.check_output(self.script_file + ' ' + argument, shell=True)

def run_diff(self, file1, file2, diff):
return subprocess.check_output('diff {} {} >{}'.format(file1, file2, diff), shell=True)
def run_diff(self, file1, file2):
return subprocess.check_output('diff -u {} {} || true'.format(file1, file2), shell=True)

def test_interfaces(self):
interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')
Expand Down Expand Up @@ -61,7 +61,10 @@ def test_bgpd_quagga(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'bgpd.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'bgpd_quagga.conf'), self.output_file))
original_filename = os.path.join(self.test_dir, 'sample_output', 'bgpd_quagga.conf')
r = filecmp.cmp(original_filename, self.output_file)
diff_output = self.run_diff(original_filename, self.output_file) if not r else ""
self.assertTrue(r, "Diff:\n" + diff_output)

def test_zebra_quagga(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'zebra.conf.j2')
Expand Down

0 comments on commit 9b1663c

Please sign in to comment.