Skip to content

Commit 09cbda0

Browse files
Stew Benedictmwichmann
authored andcommitted
Fix journal output (bug 1782), use tetj.py from misc-test
1 parent 9af6106 commit 09cbda0

File tree

4 files changed

+56
-108
lines changed

4 files changed

+56
-108
lines changed

scripts/package/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RPM_BINARY_NAME=$(FULL_PACKAGE_NAME)-$(RELEASE).$(RPM_BUILD_ARCH).rpm
1515
RPM_SOURCE_NAME=$(FULL_PACKAGE_NAME)-$(RELEASE).src.rpm
1616

1717
SOURCE1 = $(PACKAGE)-$(VERSION).tar.gz
18+
TETJ = tetj.py
1819

1920
# Temporary build directory
2021
TMP_BUILD_DIR=/tmp/$(FULL_PACKAGE_NAME)
@@ -53,6 +54,7 @@ RPM_SRPM_DIR=$(RPM_TMP_BUILD_DIR)/SRPMS
5354
# Override this on the command line to use a different repo
5455
BZRTREES?=http://bzr.freestandards.org/lsb/devel
5556
BZR_MODULE=$(PACKAGE)
57+
TETJ_MODULE=misc-test
5658

5759
# Default target
5860
ifndef BUILD_NO_DEB
@@ -62,9 +64,9 @@ all: rpm_package
6264
endif
6365

6466
clean:
65-
@rm -f *.rpm *.deb *.tar.gz perldeps.pl
67+
@rm -f *.rpm *.deb *.tar.gz tetj.py
6668

67-
tarball: $(SOURCE1)
69+
tarball: $(SOURCE1) $(TETJ)
6870

6971
deb_package: rpm_package
7072
@fakeroot alien -cdk $(RPM_BINARY_NAME)
@@ -77,7 +79,7 @@ ifndef BUILD_NO_DEB
7779
@ls *.deb
7880
endif
7981

80-
$(RPM_BINARY_NAME) $(RPM_SOURCE_NAME): $(PACKAGE).spec $(SOURCE1) $(SOURCE2)
82+
$(RPM_BINARY_NAME) $(RPM_SOURCE_NAME): $(PACKAGE).spec $(SOURCE1) $(TETJ)
8183
@mkdir -p $(RPM_TMP_BUILD_DIR)/BUILD
8284
@mkdir -p $(RPM_TMP_BUILD_DIR)/RPMS
8385
@mkdir -p $(RPM_TMP_BUILD_DIR)/SRPMS
@@ -93,4 +95,7 @@ endif
9395
$(SOURCE1):
9496
bzr export $(SOURCE1) $(BZRTREES)/$(BZR_MODULE)
9597

98+
$(TETJ):
99+
bzr cat $(BZRTREES)/$(TETJ_MODULE)/tetj/tetj.py > tetj.py
100+
96101
.PHONY : tarball rpm_package

scripts/package/lsbappchk-python.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Release: %{rel}
77
License: GPL
88
Group: Development/Tools
99
Source: %{name}-%{version}.tar.gz
10+
Source1: tetj.py
1011
URL: http://www.linuxbase.org/test
1112
#Prefix: %{_prefix}
1213
BuildRoot: %{_tmppath}/%{name}-root
@@ -35,7 +36,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{basedir}/bin
3536
mkdir -p ${RPM_BUILD_ROOT}%{basedir}/lib/appchk
3637
mkdir -p ${RPM_BUILD_ROOT}%{basedir}/share/appchk
3738
cp -p source/lsbappchk.py ${RPM_BUILD_ROOT}%{basedir}/bin
38-
cp -p source/tet.py ${RPM_BUILD_ROOT}%{basedir}/lib/appchk
39+
cp -p %{SOURCE1} ${RPM_BUILD_ROOT}%{basedir}/lib/appchk
3940
cp -p lists/lsb-python-modules.list ${RPM_BUILD_ROOT}%{basedir}/share/appchk
4041

4142
# VERSION file for the journal
@@ -62,6 +63,10 @@ fi
6263

6364
#==================================================
6465
%changelog
66+
* Tue Nov 27 2007 Stew Benedict <stewb@linux-foundation.org>
67+
- fix journal issues (bug 1782)
68+
- use tetj.py from misc-test
69+
6570
* Tue Jul 10 2007 Stew Benedict <stewb@linux-foundation.org>
6671
- _foo -> foo, add os, re, string
6772
- bump to release 2

source/lsbappchk.py

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,39 @@
66

77
import sys
88
import os
9+
import md5
910
# modulefinder does all the heavy lifting
1011
import modulefinder
1112
sys.path.append('/opt/lsb/lib/appchk')
12-
import tet
13+
import tetj
1314

1415
# re-define the report class for our needs
1516
class lsbmf(modulefinder.ModuleFinder):
1617
def report(self):
1718
return self.modules
1819

20+
def sumfile(fobj):
21+
m = md5.new()
22+
while True:
23+
d = fobj.read(8096)
24+
if not d:
25+
break
26+
m.update(d)
27+
return m.hexdigest()
28+
29+
def file_info(journal, tfile):
30+
fsize = os.path.getsize(tfile)
31+
wstr = "FILE_SIZE %d" % (fsize)
32+
journal.purpose_start('File information')
33+
journal.testcase_info(1,0,0,wstr)
34+
f = file(tfile, 'rb')
35+
md5sum = sumfile(f)
36+
f.close()
37+
wstr = "BINARY_MD5SUM %s" % (md5sum)
38+
journal.testcase_info(0,0,0,wstr)
39+
journal.result(tetj.TETJ_PASS)
40+
journal.purpose_end()
41+
1942
# compare the found modules to the LSB list and report
2043
# if the import uses a /opt path, just warn
2144
def check_modules(journal, modules, lsb_modules, syspath_org):
@@ -25,11 +48,11 @@ def check_modules(journal, modules, lsb_modules, syspath_org):
2548
keys.sort()
2649
tcount = 0;
2750
for key in keys:
28-
jresult = 'PASS'
51+
jresult = tetj.TETJ_PASS
2952
tcount = tcount + 1
3053
if journal:
31-
tet.istart(tcount)
32-
tet.info(tcount, 'Check ' + key)
54+
journal.purpose_start('Check ' + key)
55+
3356
if key not in lsb_modules:
3457
if key != '__main__' and key != '__builtin__':
3558
# warn if we're getting modules from outside sys.path
@@ -43,16 +66,17 @@ def check_modules(journal, modules, lsb_modules, syspath_org):
4366
mdir = syspath_org[0]
4467
if mdir not in syspath_org:
4568
tresult = key + twarn + mdir
46-
jresult = 'UNRESOLVED'
69+
jresult = tetj.TETJ_UNRESOLVED
4770
else:
4871
tresult = key + tfail
49-
jresult = 'FAIL'
72+
jresult = tetj.TETJ_FAIL
5073
print tresult
5174
if journal:
52-
tet.info(tcount, tresult)
75+
journal.testcase_info(0,0,0,tresult)
76+
5377
if journal:
54-
tet.result(tcount, jresult)
55-
tet.iend(tcount)
78+
journal.result(jresult)
79+
journal.purpose_end()
5680

5781
def main(argv):
5882
if len(argv) == 1:
@@ -82,11 +106,9 @@ def main(argv):
82106
# prep the journal header
83107
if journal:
84108
myname = os.path.basename(argv[0])
85-
journal_file = tet.open_journal('journal.' + myname + '.' + jsuffix)
86-
tet.write_header(journal_file)
87-
vfile = sharepath + '/VERSION.' + myname
88-
tet.write_version(journal_file,vfile)
89-
tet.file_info(journal_file, testapp)
109+
journal = tetj.Journal('journal.' + myname + '.' + jsuffix, testapp)
110+
journal.add_config("VSX_NAME=lsb-tetjtest.py 0.1 (%s)" % journal.machine)
111+
journal.config_end()
90112

91113
path = sys.path[:]
92114
debug = 0
@@ -116,9 +138,14 @@ def main(argv):
116138

117139
print testapp + ":"
118140
if journal:
119-
tet.tstart(testapp)
141+
journal.testcase_start(testapp)
142+
file_info(journal, testapp)
143+
120144
modules = mf.report()
121145
check_modules(journal, modules, lsb_modules, syspath_org)
146+
if journal:
147+
journal.testcase_end(testapp)
148+
journal.close()
122149

123150
if __name__=='__main__':
124151
main(sys.argv)

source/tet.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)