From 9b1663ce8ac6499946e0d0a00be5e700b37a1490 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Wed, 10 Apr 2019 22:55:54 -0700 Subject: [PATCH] [sonic-cfggen]: Output differences for bgp configurations (#2768) --- src/sonic-config-engine/tests/test_j2files.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index d6066b628e61..ce7f56eccff6 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -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') @@ -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')