2
# vim: ai ts=4 sts=4 et sw=4
4
# Copyright (c) 2009 Intel Corporation
6
# This program is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by the Free
8
# Software Foundation; version 2 of the License
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
# You should have received a copy of the GNU General Public License along
16
# with this program; if not, write to the Free Software Foundation, Inc., 59
17
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
specify -N -o output.spec testpkg.yaml 1>output.1.o 2>output.2.o
21
mv output.spec output.orig.spec
23
specify -N -o output.spec testpkg.yaml 1>ouput.1 2>output.2
24
if [ ! -f output.no -a ! -f output.spec ]; then
25
mv output.2 output.error
28
if [ -f output.p ]; then
29
diff -upN output.orig.spec output.spec > newoutput.p
30
mv output.spec output.new.spec
31
patch < output.p >/dev/null
33
if [ -f output.1p ]; then
34
diff -upN output.1.o output.1 > newoutput.1p
35
mv output.1 output.1.n
36
patch < output.1p >/dev/null
38
if [ -f output.2p ]; then
39
diff -upN output.2.o output.2 > newoutput.2p
40
mv output.2 output.2.n
41
patch < output.2p >/dev/null
54
def prep_working_env(cases_dir, case, dst_dir):
55
shutil.copy(os.path.join(cases_dir, 'base', 'testpkg.yaml'), dst_dir)
56
for out in glob.glob(os.path.join(cases_dir, 'test-'+case, '*')):
58
if not os.path.isdir(out):
59
shutil.copy(out, dst_dir)
61
pass # ignore if file missing
63
def cleanup(work_dir):
64
shutil.rmtree(work_dir)
66
def run_and_check(work_dir):
71
if os.path.exists('output.error'):
72
# something wrong with tested tools
73
print >> sys.stderr, file(os.path.join(work_dir, 'output.error')).read()
79
def compare_outfile(work_dir):
81
#print glob.glob(os.path.join(work_dir, '*'))
82
desc = {'output.p': '*.spec',
83
'output.1p': 'STDOUT',
84
'output.2p': 'STDERR'}
85
orig = {'output.p': 'output.orig.spec',
86
'output.1p': 'output.1.o',
87
'output.2p': 'output.2.o'}
88
new = {'output.p': 'output.new.spec',
89
'output.1p': 'output.1.n',
90
'output.2p': 'output.2.n'}
91
for out in ('output.p', 'output.1p', 'output.2p'):
92
fp = os.path.join(work_dir, out)
93
if os.path.exists(fp):
94
if not filecmp.cmp(os.path.join(work_dir, orig[out]),\
95
os.path.join(work_dir, new[out])):
98
exp_output_diff = file(fp).read().strip()
99
output_diff = file(os.path.join(work_dir, 'new'+out)).read().strip()
102
output_diff = '<EMPTY>'
103
if not exp_output_diff:
104
exp_output_diff = '<EMPTY>'
106
print "%sExpected changes of %s:" % (BLUE,desc[out])
107
print '----------------------------------------------------------------------%s' % RESET
108
print exp_output_diff
109
print '%s----------------------------------------------------------------------%s' % (BLUE,RESET)
110
print "%sActual:" % RED
111
print '----------------------------------------------------------------------%s' % RESET
113
print '%s----------------------------------------------------------------------%s' % (RED,RESET)