Merge lp:~pwlars/lava-test/build-id into lp:lava-test/0.0

Proposed by Paul Larson
Status: Merged
Merged at revision: 54
Proposed branch: lp:~pwlars/lava-test/build-id
Merge into: lp:lava-test/0.0
Diff against target: 64 lines (+21/-9)
2 files modified
abrek/swprofile.py (+10/-8)
tests/test_swprofile.py (+11/-1)
To merge this branch: bzr merge lp:~pwlars/lava-test/build-id
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+41346@code.launchpad.net

Description of the change

get the image description from /etc/buildstamp if it exists

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Looks good.

I wonder if the lsb_release information test should explicitly make
/etc/buildstamp a missing file, otherwise the tests may fail if run
on an image with that file?

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'abrek/swprofile.py'
2--- abrek/swprofile.py 2010-08-18 15:33:32 +0000
3+++ abrek/swprofile.py 2010-11-19 19:18:45 +0000
4@@ -15,6 +15,7 @@
5
6 import apt
7 import lsb_release
8+from utils import read_file
9
10 def get_packages(apt_cache=None):
11 """ Get information about the packages installed
12@@ -51,13 +52,14 @@
13 def get_sw_image(lsb_information=None):
14 """ Get information about the image we are running
15
16- For now, this just uses the description from lsb-release. This will
17- be extended to provide more detailed information about the image if
18- it becomes available
19-
20- lsb_information - if not provided, this will be read from the system
21+ If /etc/buildstamp exists, get the sw_image id from that. Otherwise
22+ just use the lsb-release description for a rough idea.
23 """
24- if lsb_information == None:
25- lsb_information = lsb_release.get_lsb_information()
26- desc = lsb_information['DESCRIPTION']
27+ try:
28+ buildstamp = read_file("/etc/buildstamp")
29+ desc = buildstamp.splitlines()[1]
30+ except IOError:
31+ if lsb_information == None:
32+ lsb_information = lsb_release.get_lsb_information()
33+ desc = lsb_information['DESCRIPTION']
34 return {"desc":desc}
35
36=== modified file 'tests/test_swprofile.py'
37--- tests/test_swprofile.py 2010-09-10 17:09:14 +0000
38+++ tests/test_swprofile.py 2010-11-19 19:18:45 +0000
39@@ -16,6 +16,7 @@
40 import unittest
41
42 import abrek.swprofile
43+from abrek.utils import fake_file, clear_fakes
44
45
46 class Version:
47@@ -60,7 +61,16 @@
48 for pkg in a['packages']:
49 self.assertEqual(self.testpackage.installed.version, pkg['version'])
50
51- def test_image_desc(self):
52+ def test_sw_image_desc_lsb(self):
53 a = self.make_profile()
54 self.assertEqual(self.lsb_desc, a['sw_image']['desc'])
55
56+ def test_sw_image_desc_buildstamp(self):
57+ BUILDSTAMP = "linaro-m-headless-20101101-0"
58+ BUILDSTAMPFILE = "lexbuild6 Mon, 01 Nov 2010 02:11:39 -0400\n%s" % (
59+ BUILDSTAMP)
60+ fake_file('/etc/buildstamp', BUILDSTAMPFILE)
61+ a = self.make_profile()
62+ clear_fakes()
63+ self.assertEqual(BUILDSTAMP, a['sw_image']['desc'])
64+

Subscribers

People subscribed via source and target branches