11 if (len(sys
.argv
) < 3):
12 print 'Usage:', sys
.argv
[0], 'source.c source.c.scop [clay_path] [clay options...]'
16 source_filename
= sys
.argv
[1]
17 scop_filename
= sys
.argv
[2]
20 print sys
.argv
[0], source_filename
, scop_filename
22 # Check if source_filename and scop_filename exist
23 if (os
.path
.exists(source_filename
) == False):
24 print 'Error:', source_filename
, ' file does not exist'
26 if (os
.path
.exists(scop_filename
) == False):
27 print 'Error:', scop_filename
, ' file does not exist'
32 if (len(sys
.argv
) >= 4):# and os.path.exists(sys.argv[3]) and os.access(sys.argv[3], os.X_OK)):
37 clay_options
= ["--readc"]
38 if (len(sys
.argv
) > 4):
40 while (i
< len(sys
.argv
)):
41 clay_options
+= [sys
.argv
[i
]]
44 print "clay =", clay
, clay_options
48 clay_output
,clay_error_output
= subprocess
.Popen([clay
, source_filename
] + clay_options
, stdout
= subprocess
.PIPE
, stderr
= subprocess
.PIPE
).communicate()
49 clay_output
+= clay_error_output
53 scop_file
= open(scop_filename
, 'r')
55 for line
in scop_file
:
56 #sys.stdout.write(line)
61 # Compare clay_output and scop
65 skip_next_line
= False
66 for line
in string
.split(clay_output
, '\n'):
68 skip_next_line
= False
70 if (line
== '# File name'): skip_next_line
= True
71 if line
!= '' and (string
.find(line
, 'enerated by') == -1): s0
+= line
+ '\n'
72 for line
in string
.split(scop
, '\n'):
74 skip_next_line
= False
76 if (line
== '# File name'): skip_next_line
= True
77 if line
!= '' and (string
.find(line
, 'enerated by') == -1): s1
+= line
+ '\n'
83 print 'Result:', '"clay', source_filename
+ '"', 'and', '"' + scop_filename
+ '"', 'are different'
86 print 'Result:', '"clay', source_filename
+ '"', 'and', '"' + scop_filename
+ '"', 'have no difference'