Merge lp:~javier.collado/utah/iso_validation_files_list into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Max Brustkern
Approved revision: 800
Merged at revision: 795
Proposed branch: lp:~javier.collado/utah/iso_validation_files_list
Merge into: lp:utah
Diff against target: 176 lines (+36/-20)
1 file modified
utah/isotest/iso_static_validation.py (+36/-20)
To merge this branch: bzr merge lp:~javier.collado/utah/iso_validation_files_list
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+139895@code.launchpad.net

Description of the change

This branch applies some refactoring to the `files_list` test case basically to
print a readable error in case of failure.

Aside from that, there are other small changes like moving the test case
comments to docstrings so that they can be used in the output to provide a
better description of the test case together with its id.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

I'm getting an error for:
AssertionError: 'isolinux/adtxt.cfg' not found in:
.
./.disk
...
./isolinux/adtxt.cfg
...

The same image passes with what's currently in the dev branch.

If I have time this week, I'll see if I can find a solution, otherwise, we can revisit it when Javier returns. The docstring changes and general principle of this are good.

review: Needs Fixing
798. By Javier Collado

Fixed typos

799. By Javier Collado

Added help to name parameter

800. By Javier Collado

Fixed matching problem using path normalization

Interestingly, the output of `bsdtar -t -f` using a desktop i386 image contains
a list of files prefixed with `./`. However, the output using a desktop amd64
image doesn't contain such a prefix. This turns out to be a problem when
matching the complete path (previously just a substring was matched). To fix
the problem `os.path.normpath` is used to get the same path regardless of the
output of `bsdtar -f -t`.

Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks for finding that bug. It was introduced when I decided to use a set with
all the file names in the image to match the ones in the `.list` file
(previously the file name was looked up using a string search in the whole
`bsdtar`). Using `os.path.normpath` as explained in the commit message works
fine (tested with desktop/server i386/amd64 images).

review: Needs Resubmitting
Revision history for this message
Max Brustkern (nuclearbob) wrote :

This seems to be working well now for me. Good stuff.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/isotest/iso_static_validation.py'
2--- utah/isotest/iso_static_validation.py 2012-12-13 17:30:08 +0000
3+++ utah/isotest/iso_static_validation.py 2013-01-03 11:57:21 +0000
4@@ -25,7 +25,7 @@
5 # as published by the Free Software Foundation, either version 3 of
6 # the License, or (at your option) any later version.
7 #
8-# iso_satatic_validation is distributed in the hope that it will
9+# iso_static_validation is distributed in the hope that it will
10 # be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13@@ -76,7 +76,7 @@
14
15 #Read the iso name and initialise global variables
16 parser = argparse.ArgumentParser()
17-parser.add_argument('--name')
18+parser.add_argument('--name', help='Path to the ISO file to be tested')
19 args = parser.parse_args()
20
21
22@@ -137,8 +137,10 @@
23 unittest.fail("Setup error")
24
25 def setUp(self):
26- logging.info('\n{separator}\n{id}\n{separator}'
27- .format(separator='-' * 80, id=self.id()))
28+ logging.info('\n{separator}\n{id}\n{description}\n{separator}'
29+ .format(separator='-' * 80,
30+ id=self.id(),
31+ description=self.shortDescription() or ''))
32 self.block_size = ONE_MB_BLOCK
33 self.iso_location = iso_location
34 logging.debug('Using iso at: ' + self.iso_location)
35@@ -170,8 +172,8 @@
36 else:
37 self.fail("Image name be in the form of release-variant-arch.iso")
38
39- # Test if the sha check sum of the iso matches that is given in the server
40 def test_sha256_checksum(self):
41+ """Test if the ISO SHA checksum matches what is given in the server."""
42 current_iso_digest = {}
43 sha256sum_url = os.path.join(self.url, 'current', 'SHA256SUMS')
44 try:
45@@ -208,8 +210,8 @@
46 logging.debug("Local File Checksum: '%s'", sha256)
47 self.assertEqual(iso_sha256, sha256)
48
49- # Test if the list file in the repository matches the content of the iso
50 def test_files_list(self):
51+ """Test if the list repository file matches the content of the ISO."""
52 if self.st_variant == 'server':
53 list_url = os.path.join(self.url, 'current',
54 self.st_release + '-' + 'server' + '-' +
55@@ -233,13 +235,18 @@
56 self.assertEqual(stderr, '')
57
58 logging.debug('Checking that each list entry is in the iso')
59+ iso_files = set(os.path.normpath(path)
60+ for path in stdout.splitlines())
61 for list_entry in list_repository:
62- self.assertIn(list_entry[1:].rstrip(), stdout)
63+ fname = os.path.normpath(list_entry[1:].rstrip())
64+ self.assertIn(fname, iso_files,
65+ '{!r} not found in:\n{}'
66+ .format(fname, stdout))
67
68- # Test if the manfest is the same as that is given in the server
69 @unittest.skipUnless(ubiquity_image,
70 "manifest only for ubiquity based images")
71 def test_manifest(self):
72+ """Test if the ISO manifest matches the one in the server."""
73 manifest_url = os.path.join(self.url, 'current',
74 self.st_release + '-' +
75 self.st_variant + '-' +
76@@ -259,9 +266,12 @@
77 for manifest_entry in manifest:
78 self.assertIn(manifest_entry, manifest_local)
79
80- # Test if the buildid present in the download server is
81- # the same as that given in distro info
82 def test_build_id(self):
83+ """Test if the ISO buildid matches the one in the server.
84+
85+ The buildid is extracted from the distro info file.
86+
87+ """
88 logging.debug('Extract distro information of the image from the iso')
89 buildid_path = self.iso.extract("./.disk/info", self.temp_dir)
90 buildinfo = open(buildid_path)
91@@ -284,11 +294,11 @@
92 logging.debug('Checking buildids are the same in iso and repo')
93 self.assertIn(id_server, build_info_line)
94
95- # Test if wubi is present for desktop or dvd and it is a valid PE
96 @unittest.skipUnless(st_variant == 'desktop' and
97 st_arch != 'powerpc',
98 "Skipping images that aren't ubiquity-based.")
99 def test_wubi(self):
100+ """Test if wubi is present for desktop or dvd and it is a valid PE."""
101 logging.debug('Extracting wubi from the desktop images')
102 wubi_path = self.iso.extract('./wubi.exe', self.temp_dir)
103 cmd = ["file", wubi_path]
104@@ -299,10 +309,10 @@
105 self.assertEqual(stderr, '')
106 self.assertIn(" PE32 executable (GUI)", stdout)
107
108- # Test if the relevant files are present in the iso for desktop iso
109 @unittest.skipUnless(st_variant == 'desktop' and
110 st_arch != 'powerpc', "Skipping for non desktop iso")
111 def test_files_ubiquity(self):
112+ """Test if the relevant files are present in the ISO for desktop."""
113 (stdout, stderr) = self.iso.listfiles()
114 logging.debug('Check for error in extracting file list from the iso')
115 self.assertEqual(stderr, '')
116@@ -320,10 +330,10 @@
117 else:
118 self.assertIn(path, stdout)
119
120- # Test if the relevant important files are present in the iso for dvd iso
121 @unittest.skipUnless(st_variant == 'dvd',
122 "This file list test is only specific for dvd")
123 def test_files_ubiquity_dvd(self):
124+ """Test if the relevant important files are present in DVD ISO."""
125 (stdout, stderr) = self.iso.listfiles()
126 logging.debug('Check for error in extracting file list from the iso')
127 self.assertEqual(stderr, '')
128@@ -332,13 +342,16 @@
129 logging.debug('Check if relevant files are present in the iso')
130 self.assertIn(list_entry.rstrip(), stdout)
131
132- # Test if the relevant files are present in the iso for d-i based images,
133- # two list of files are used
134- # file_list_di for i386 and amd64
135- # file_list_di_powerpc for powerpc and amd64+mac
136 # Test is skipped for ubiquity based images
137 @unittest.skipIf(ubiquity_image, "Skipping for ubiquity images")
138 def test_files_di(self):
139+ """Test if the relevant files are present for d-i based images ISO.
140+
141+ Two list of files are used:
142+ file_list_di for i386 and amd64
143+ file_list_di_powerpc for powerpc and amd64+mac
144+
145+ """
146 (stdout, stderr) = self.iso.listfiles()
147 logging.debug('Check for error in extracting file list from the iso')
148 self.assertEqual(stderr, '')
149@@ -361,10 +374,10 @@
150 else:
151 self.assertIn(path, stdout)
152
153- # Test if vmlinuz is a valid executable
154 @unittest.skipUnless(st_arch != 'powerpc',
155 "vmlinuz is not present only for powerpc images")
156 def test_vmlinuz(self):
157+ """Test if vmlinuz is a valid executable."""
158 logging.debug('Extract kernel image from the iso')
159 path = iso.kernelpath()
160 vmlinuz_path = self.iso.extract(path, self.temp_dir)
161@@ -376,10 +389,13 @@
162 self.assertEqual(stderr, '')
163 self.assertIn('Linux kernel', stdout)
164
165- # Test if filesystem.squashfs is present and
166- # if that is a squash fs for ubiquity based images
167 @unittest.skipUnless(ubiquity_image, "Skipping for non ubiquity images")
168 def test_filesystem_squashfs(self):
169+ """Test if filesystem.squashfs is present and its contents.
170+
171+ The squash fs must be for ubiquity based images.
172+
173+ """
174 logging.debug('Extracting the filesystem.squashfs')
175 squashfs_path = self.iso.extract('casper/filesystem.squashfs',
176 self.temp_dir)

Subscribers

People subscribed via source and target branches