@@ -25,27 +25,26 @@ def run_script(self, argument):
25
25
print 'CMD: sonic-cfggen ' + argument
26
26
return subprocess .check_output (self .script_file + ' ' + argument , shell = True )
27
27
28
- def run_diff (self , file1 , file2 , diff ):
29
- return subprocess .check_output ('diff {} {} >{} ' .format (file1 , file2 , diff ), shell = True )
28
+ def run_diff (self , file1 , file2 ):
29
+ return subprocess .check_output ('diff -u {} {} || true ' .format (file1 , file2 ), shell = True )
30
30
31
- def test_bgpd_t1 (self ):
31
+ def run_bgpd_test (self , minigraph , portconfig , valid_result_file ):
32
32
conf_template = os .path .join (self .test_dir , '..' , '..' , '..' , 'dockers' , 'docker-fpm-quagga' , 'bgpd.conf.j2' )
33
- argument = '-m ' + self . t1_minigraph + ' -p ' + self . dell_s6000_port_config + ' -t ' + conf_template + ' -y ' + self .deployment_id_asn_map + ' -j ' + self .device_metadata + ' > ' + self .output_file
33
+ argument = '-m ' + minigraph + ' -p ' + portconfig + ' -t ' + conf_template + ' -y ' + self .deployment_id_asn_map + ' -j ' + self .device_metadata + ' > ' + self .output_file
34
34
self .run_script (argument )
35
- self .assertTrue (filecmp .cmp (os .path .join (self .test_dir , 'sample_output' , 'CO4SCH04001AALF.bgpd.conf' ), self .output_file ))
35
+ original_filename = os .path .join (self .test_dir , 'sample_output' , valid_result_file )
36
+ r = filecmp .cmp (original_filename , self .output_file )
37
+ diff_output = self .run_diff (original_filename , self .output_file ) if not r else ""
38
+ self .assertTrue (r , "Diff:\n " + diff_output )
39
+
40
+ def test_bgpd_t1 (self ):
41
+ return self .run_bgpd_test (self .t1_minigraph , self .dell_s6000_port_config , 'CO4SCH04001AALF.bgpd.conf' )
36
42
37
43
def test_bgpd_tycoon_t1 (self ):
38
- conf_template = os .path .join (self .test_dir , '..' , '..' , '..' , 'dockers' , 'docker-fpm-quagga' , 'bgpd.conf.j2' )
39
- argument = '-m ' + self .tycoon_t1_minigraph + ' -p ' + self .a7060_port_config + ' -t ' + conf_template + ' -y ' + self .deployment_id_asn_map + ' -j ' + self .device_metadata + ' > ' + self .output_file
40
- self .run_script (argument )
41
- self .assertTrue (filecmp .cmp (os .path .join (self .test_dir , 'sample_output' , 'SN1-0102-0201-11T1.bgpd.conf' ), self .output_file ))
44
+ return self .run_bgpd_test (self .tycoon_t1_minigraph , self .a7060_port_config , 'SN1-0102-0201-11T1.bgpd.conf' )
42
45
43
46
def test_bgpd_m0 (self ):
44
- conf_template = os .path .join (self .test_dir , '..' , '..' , '..' , 'dockers' , 'docker-fpm-quagga' , 'bgpd.conf.j2' )
45
- argument = '-m ' + self .m0_minigraph + ' -p ' + self .hlx_port_config + ' -t ' + conf_template + ' -y ' + self .deployment_id_asn_map + ' -j ' + self .device_metadata + ' > ' + self .output_file
46
- self .run_script (argument )
47
- self .assertTrue (filecmp .cmp (os .path .join (self .test_dir , 'sample_output' , 'MWH01-0100-0202-01M0.bgpd.conf' ), self .output_file ))
48
-
47
+ return self .run_bgpd_test (self .m0_minigraph , self .hlx_port_config , 'MWH01-0100-0202-01M0.bgpd.conf' )
49
48
50
49
def tearDown (self ):
51
50
try :
0 commit comments