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
=== modified file 'utah/isotest/iso_static_validation.py'
--- utah/isotest/iso_static_validation.py 2012-12-13 17:30:08 +0000
+++ utah/isotest/iso_static_validation.py 2013-01-03 11:57:21 +0000
@@ -25,7 +25,7 @@
25# as published by the Free Software Foundation, either version 3 of25# as published by the Free Software Foundation, either version 3 of
26# the License, or (at your option) any later version.26# the License, or (at your option) any later version.
27#27#
28# iso_satatic_validation is distributed in the hope that it will28# iso_static_validation is distributed in the hope that it will
29# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty29# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
30# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the30# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31# GNU General Public License for more details.31# GNU General Public License for more details.
@@ -76,7 +76,7 @@
7676
77#Read the iso name and initialise global variables77#Read the iso name and initialise global variables
78parser = argparse.ArgumentParser()78parser = argparse.ArgumentParser()
79parser.add_argument('--name')79parser.add_argument('--name', help='Path to the ISO file to be tested')
80args = parser.parse_args()80args = parser.parse_args()
8181
8282
@@ -137,8 +137,10 @@
137 unittest.fail("Setup error")137 unittest.fail("Setup error")
138138
139 def setUp(self):139 def setUp(self):
140 logging.info('\n{separator}\n{id}\n{separator}'140 logging.info('\n{separator}\n{id}\n{description}\n{separator}'
141 .format(separator='-' * 80, id=self.id()))141 .format(separator='-' * 80,
142 id=self.id(),
143 description=self.shortDescription() or ''))
142 self.block_size = ONE_MB_BLOCK144 self.block_size = ONE_MB_BLOCK
143 self.iso_location = iso_location145 self.iso_location = iso_location
144 logging.debug('Using iso at: ' + self.iso_location)146 logging.debug('Using iso at: ' + self.iso_location)
@@ -170,8 +172,8 @@
170 else:172 else:
171 self.fail("Image name be in the form of release-variant-arch.iso")173 self.fail("Image name be in the form of release-variant-arch.iso")
172174
173 # Test if the sha check sum of the iso matches that is given in the server
174 def test_sha256_checksum(self):175 def test_sha256_checksum(self):
176 """Test if the ISO SHA checksum matches what is given in the server."""
175 current_iso_digest = {}177 current_iso_digest = {}
176 sha256sum_url = os.path.join(self.url, 'current', 'SHA256SUMS')178 sha256sum_url = os.path.join(self.url, 'current', 'SHA256SUMS')
177 try:179 try:
@@ -208,8 +210,8 @@
208 logging.debug("Local File Checksum: '%s'", sha256)210 logging.debug("Local File Checksum: '%s'", sha256)
209 self.assertEqual(iso_sha256, sha256)211 self.assertEqual(iso_sha256, sha256)
210212
211 # Test if the list file in the repository matches the content of the iso
212 def test_files_list(self):213 def test_files_list(self):
214 """Test if the list repository file matches the content of the ISO."""
213 if self.st_variant == 'server':215 if self.st_variant == 'server':
214 list_url = os.path.join(self.url, 'current',216 list_url = os.path.join(self.url, 'current',
215 self.st_release + '-' + 'server' + '-' +217 self.st_release + '-' + 'server' + '-' +
@@ -233,13 +235,18 @@
233 self.assertEqual(stderr, '')235 self.assertEqual(stderr, '')
234236
235 logging.debug('Checking that each list entry is in the iso')237 logging.debug('Checking that each list entry is in the iso')
238 iso_files = set(os.path.normpath(path)
239 for path in stdout.splitlines())
236 for list_entry in list_repository:240 for list_entry in list_repository:
237 self.assertIn(list_entry[1:].rstrip(), stdout)241 fname = os.path.normpath(list_entry[1:].rstrip())
242 self.assertIn(fname, iso_files,
243 '{!r} not found in:\n{}'
244 .format(fname, stdout))
238245
239 # Test if the manfest is the same as that is given in the server
240 @unittest.skipUnless(ubiquity_image,246 @unittest.skipUnless(ubiquity_image,
241 "manifest only for ubiquity based images")247 "manifest only for ubiquity based images")
242 def test_manifest(self):248 def test_manifest(self):
249 """Test if the ISO manifest matches the one in the server."""
243 manifest_url = os.path.join(self.url, 'current',250 manifest_url = os.path.join(self.url, 'current',
244 self.st_release + '-' +251 self.st_release + '-' +
245 self.st_variant + '-' +252 self.st_variant + '-' +
@@ -259,9 +266,12 @@
259 for manifest_entry in manifest:266 for manifest_entry in manifest:
260 self.assertIn(manifest_entry, manifest_local)267 self.assertIn(manifest_entry, manifest_local)
261268
262 # Test if the buildid present in the download server is
263 # the same as that given in distro info
264 def test_build_id(self):269 def test_build_id(self):
270 """Test if the ISO buildid matches the one in the server.
271
272 The buildid is extracted from the distro info file.
273
274 """
265 logging.debug('Extract distro information of the image from the iso')275 logging.debug('Extract distro information of the image from the iso')
266 buildid_path = self.iso.extract("./.disk/info", self.temp_dir)276 buildid_path = self.iso.extract("./.disk/info", self.temp_dir)
267 buildinfo = open(buildid_path)277 buildinfo = open(buildid_path)
@@ -284,11 +294,11 @@
284 logging.debug('Checking buildids are the same in iso and repo')294 logging.debug('Checking buildids are the same in iso and repo')
285 self.assertIn(id_server, build_info_line)295 self.assertIn(id_server, build_info_line)
286296
287 # Test if wubi is present for desktop or dvd and it is a valid PE
288 @unittest.skipUnless(st_variant == 'desktop' and297 @unittest.skipUnless(st_variant == 'desktop' and
289 st_arch != 'powerpc',298 st_arch != 'powerpc',
290 "Skipping images that aren't ubiquity-based.")299 "Skipping images that aren't ubiquity-based.")
291 def test_wubi(self):300 def test_wubi(self):
301 """Test if wubi is present for desktop or dvd and it is a valid PE."""
292 logging.debug('Extracting wubi from the desktop images')302 logging.debug('Extracting wubi from the desktop images')
293 wubi_path = self.iso.extract('./wubi.exe', self.temp_dir)303 wubi_path = self.iso.extract('./wubi.exe', self.temp_dir)
294 cmd = ["file", wubi_path]304 cmd = ["file", wubi_path]
@@ -299,10 +309,10 @@
299 self.assertEqual(stderr, '')309 self.assertEqual(stderr, '')
300 self.assertIn(" PE32 executable (GUI)", stdout)310 self.assertIn(" PE32 executable (GUI)", stdout)
301311
302 # Test if the relevant files are present in the iso for desktop iso
303 @unittest.skipUnless(st_variant == 'desktop' and312 @unittest.skipUnless(st_variant == 'desktop' and
304 st_arch != 'powerpc', "Skipping for non desktop iso")313 st_arch != 'powerpc', "Skipping for non desktop iso")
305 def test_files_ubiquity(self):314 def test_files_ubiquity(self):
315 """Test if the relevant files are present in the ISO for desktop."""
306 (stdout, stderr) = self.iso.listfiles()316 (stdout, stderr) = self.iso.listfiles()
307 logging.debug('Check for error in extracting file list from the iso')317 logging.debug('Check for error in extracting file list from the iso')
308 self.assertEqual(stderr, '')318 self.assertEqual(stderr, '')
@@ -320,10 +330,10 @@
320 else:330 else:
321 self.assertIn(path, stdout)331 self.assertIn(path, stdout)
322332
323 # Test if the relevant important files are present in the iso for dvd iso
324 @unittest.skipUnless(st_variant == 'dvd',333 @unittest.skipUnless(st_variant == 'dvd',
325 "This file list test is only specific for dvd")334 "This file list test is only specific for dvd")
326 def test_files_ubiquity_dvd(self):335 def test_files_ubiquity_dvd(self):
336 """Test if the relevant important files are present in DVD ISO."""
327 (stdout, stderr) = self.iso.listfiles()337 (stdout, stderr) = self.iso.listfiles()
328 logging.debug('Check for error in extracting file list from the iso')338 logging.debug('Check for error in extracting file list from the iso')
329 self.assertEqual(stderr, '')339 self.assertEqual(stderr, '')
@@ -332,13 +342,16 @@
332 logging.debug('Check if relevant files are present in the iso')342 logging.debug('Check if relevant files are present in the iso')
333 self.assertIn(list_entry.rstrip(), stdout)343 self.assertIn(list_entry.rstrip(), stdout)
334344
335 # Test if the relevant files are present in the iso for d-i based images,
336 # two list of files are used
337 # file_list_di for i386 and amd64
338 # file_list_di_powerpc for powerpc and amd64+mac
339 # Test is skipped for ubiquity based images345 # Test is skipped for ubiquity based images
340 @unittest.skipIf(ubiquity_image, "Skipping for ubiquity images")346 @unittest.skipIf(ubiquity_image, "Skipping for ubiquity images")
341 def test_files_di(self):347 def test_files_di(self):
348 """Test if the relevant files are present for d-i based images ISO.
349
350 Two list of files are used:
351 file_list_di for i386 and amd64
352 file_list_di_powerpc for powerpc and amd64+mac
353
354 """
342 (stdout, stderr) = self.iso.listfiles()355 (stdout, stderr) = self.iso.listfiles()
343 logging.debug('Check for error in extracting file list from the iso')356 logging.debug('Check for error in extracting file list from the iso')
344 self.assertEqual(stderr, '')357 self.assertEqual(stderr, '')
@@ -361,10 +374,10 @@
361 else:374 else:
362 self.assertIn(path, stdout)375 self.assertIn(path, stdout)
363376
364 # Test if vmlinuz is a valid executable
365 @unittest.skipUnless(st_arch != 'powerpc',377 @unittest.skipUnless(st_arch != 'powerpc',
366 "vmlinuz is not present only for powerpc images")378 "vmlinuz is not present only for powerpc images")
367 def test_vmlinuz(self):379 def test_vmlinuz(self):
380 """Test if vmlinuz is a valid executable."""
368 logging.debug('Extract kernel image from the iso')381 logging.debug('Extract kernel image from the iso')
369 path = iso.kernelpath()382 path = iso.kernelpath()
370 vmlinuz_path = self.iso.extract(path, self.temp_dir)383 vmlinuz_path = self.iso.extract(path, self.temp_dir)
@@ -376,10 +389,13 @@
376 self.assertEqual(stderr, '')389 self.assertEqual(stderr, '')
377 self.assertIn('Linux kernel', stdout)390 self.assertIn('Linux kernel', stdout)
378391
379 # Test if filesystem.squashfs is present and
380 # if that is a squash fs for ubiquity based images
381 @unittest.skipUnless(ubiquity_image, "Skipping for non ubiquity images")392 @unittest.skipUnless(ubiquity_image, "Skipping for non ubiquity images")
382 def test_filesystem_squashfs(self):393 def test_filesystem_squashfs(self):
394 """Test if filesystem.squashfs is present and its contents.
395
396 The squash fs must be for ubiquity based images.
397
398 """
383 logging.debug('Extracting the filesystem.squashfs')399 logging.debug('Extracting the filesystem.squashfs')
384 squashfs_path = self.iso.extract('casper/filesystem.squashfs',400 squashfs_path = self.iso.extract('casper/filesystem.squashfs',
385 self.temp_dir)401 self.temp_dir)

Subscribers

People subscribed via source and target branches