tools/bmap-tools.git
11 years agoPre-release 2.0-rc2
Artem Bityutskiy [Fri, 4 Jan 2013 07:57:54 +0000 (09:57 +0200)]
Pre-release 2.0-rc2

Change-Id: I43508315224221e42dbf149dd026b0636b17358e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: slight readability imporovement
Artem Bityutskiy [Fri, 4 Jan 2013 07:47:22 +0000 (09:47 +0200)]
bmaptool: slight readability imporovement

Full paths may be very long, so print only basenames in the informational
messages.

Change-Id: Iae2a1a35112f1da3f6d613b33d986d60ffe7c5e5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: add image_size parameter to BmapBdevCopy constructor
Mikko Ylinen [Fri, 4 Jan 2013 07:39:39 +0000 (09:39 +0200)]
bmaptool: add image_size parameter to BmapBdevCopy constructor

Align BmapBdevCopy class contructor parameters with BmapCopy
class consturctor parameters.

Change-Id: Idc941e0f4baaeee5c8f52772aa536e56848129fa
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: print auto-discovered bmap file correctly
Artem Bityutskiy [Fri, 4 Jan 2013 07:34:21 +0000 (09:34 +0200)]
bmaptool: print auto-discovered bmap file correctly

When the bmapfile was auto-discovered, we did not print its name correctly.

Change-Id: Ief4747ccc401219ac2cd546e6a0c2b00f5b020ff
Reported-by: Mikko Ylinen <mikko.ylinen@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPre-release 2.0-rc1
Artem Bityutskiy [Thu, 20 Dec 2012 08:52:10 +0000 (10:52 +0200)]
Pre-release 2.0-rc1

Change-Id: I0a46065988a14183ee33c49fc571974f4b09d188
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: implement progress wheel
Artem Bityutskiy [Thu, 20 Dec 2012 11:21:19 +0000 (13:21 +0200)]
BmapCopy: implement progress wheel

.. for the cases when the image size is not known.

Change-Id: I44a892aca1a34f1acc47aef396dfb4c27717bb1b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: do not discover bmap if --nobmap was given
Artem Bityutskiy [Thu, 20 Dec 2012 11:20:56 +0000 (13:20 +0200)]
bmaptool: do not discover bmap if --nobmap was given

Change-Id: Ia4dcfa3da319d079500b0849f07f52633534d464
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: prepare 2.0-rc1 release notes
Artem Bityutskiy [Thu, 20 Dec 2012 08:41:26 +0000 (10:41 +0200)]
RELEASE_NOTES: prepare 2.0-rc1 release notes

Change-Id: Ie7744bd4d0bbdac644dcf56b4870eb31e891bfeb
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: remove a done entry
Artem Bityutskiy [Thu, 20 Dec 2012 08:25:59 +0000 (10:25 +0200)]
TODO: remove a done entry

Change-Id: Ie27fe214f2d6668536b05e96b5596064dd6ae0a8
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: do not print progress bar when --quiet was used
Artem Bityutskiy [Thu, 20 Dec 2012 08:23:25 +0000 (10:23 +0200)]
bmaptool: do not print progress bar when --quiet was used

Change-Id: Ibffa68a2dd2d541b37e187cd81e50b9e4bad7bee
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: provied a link to the docs in help output
Artem Bityutskiy [Thu, 20 Dec 2012 08:21:19 +0000 (10:21 +0200)]
bmaptool: provied a link to the docs in help output

Change-Id: Id4d130ee29af411119ff5218ff99190f011f12a8
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: fix opening URLs
Artem Bityutskiy [Wed, 19 Dec 2012 16:25:57 +0000 (18:25 +0200)]
TransRead: fix opening URLs

Proxy did not work.

Change-Id: I0e7bf28bc7bf232a24aaa1a3898188a9c3207621
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: implement automatic bmap file discovery
Artem Bityutskiy [Wed, 19 Dec 2012 15:55:53 +0000 (17:55 +0200)]
bmaptool: implement automatic bmap file discovery

Change-Id: I25abad028cab641ab6a143562783d8cbe516ff1e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add another item
Artem Bityutskiy [Wed, 19 Dec 2012 14:28:12 +0000 (16:28 +0200)]
TODO: add another item

Change-Id: I766107ec1d93fed45f4e9dfa17623d0c1fae5f2d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: small documentation improvements
Artem Bityutskiy [Wed, 19 Dec 2012 14:13:06 +0000 (16:13 +0200)]
BmapCopy: small documentation improvements

Change-Id: I8e39c895d930ea8d9eeef1ff80cb45cc0e359819
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: fix few pylint warnings
Artem Bityutskiy [Wed, 19 Dec 2012 14:09:51 +0000 (16:09 +0200)]
TransRead: fix few pylint warnings

Change-Id: I19af8f035c3469fc4035a0f075100f230475e06b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: improve comments a bit
Artem Bityutskiy [Wed, 19 Dec 2012 14:08:43 +0000 (16:08 +0200)]
TransRead: improve comments a bit

Change-Id: I80ef9be8e7ab82935c2da26e902749c2ff74a18a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: test urllib2 as well
Artem Bityutskiy [Mon, 17 Dec 2012 15:07:13 +0000 (17:07 +0200)]
test_api_base: test urllib2 as well

Prepend "file:" to file names sometimes to make all the I/O go through urllib2.

Change-Id: I0ed499f33edb7b7c2ec43a69bec4ed781716a8b3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: cleanup fake seek
Artem Bityutskiy [Wed, 19 Dec 2012 13:47:37 +0000 (15:47 +0200)]
TransRead: cleanup fake seek

Instead of patching objects run-time, just add seek() and tell() methods
to classes we need to support and use a helper '_fake_seek_forward()' function
from there. This is cleaner.

Change-Id: Ib8ca83eb078322e5468206b4440051451eac70ab
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: make error message more verbose
Artem Bityutskiy [Wed, 19 Dec 2012 13:07:59 +0000 (15:07 +0200)]
BmapCopy: make error message more verbose

Print all file names in case of short read/write error.

Change-Id: If86e676541371d246f4202a736604d4024cbe6b6
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: print file name as well
Artem Bityutskiy [Wed, 19 Dec 2012 09:00:11 +0000 (11:00 +0200)]
BmapCopy: print file name as well

When printing about SHA1 mismatch, also print the image file name.

Change-Id: I5c5aeea63943e15dfecc8a00db92e620cb45c7f9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: switch to stream tar decompression
Artem Bityutskiy [Wed, 19 Dec 2012 11:05:41 +0000 (13:05 +0200)]
TransRead: switch to stream tar decompression

Unfortunatelly we lose the check for amount of members, because it is not
compatible with stream extraction as it generates random seeks.

Change-Id: I5b56d2283abeca298e90c212d460049fd06b4a4c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: switch to CompressedFile for gzip compression
Artem Bityutskiy [Wed, 19 Dec 2012 10:40:23 +0000 (12:40 +0200)]
TransRead: switch to CompressedFile for gzip compression

Switch to use the '_CompressedFile' class for gzip files as well. The benefit
is that it does not require 'seek()' in the underlying file object, which
urllib2 does not provide.

Change-Id: Id737374885b29cf162976cea4a249ded55f5978f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: get rid of the __getattr__ method
Artem Bityutskiy [Wed, 19 Dec 2012 09:41:08 +0000 (11:41 +0200)]
TransRead: get rid of the __getattr__ method

The TransRead class implements very limited file-like objects. It is safer
to explicitely specify all the methods it supports, instead of defaulting
to the methods of the underlying 'transfile_obj'.

Change-Id: I51c4ee16f0313e0b39741f10bc04d480e48d19dc
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: generalize the Bzip2Read class
Artem Bityutskiy [Wed, 19 Dec 2012 09:36:11 +0000 (11:36 +0200)]
TransRead: generalize the Bzip2Read class

Turn it into a '_CompressedFile' class which can transparently decompress any
compressed file-like object granted there is the 'decompress(buffer)' function
available.

Change-Id: I69e48052cccbd2ad7237456b1c49c4d9994522f1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add another entry
Artem Bityutskiy [Wed, 19 Dec 2012 09:35:53 +0000 (11:35 +0200)]
TODO: add another entry

Change-Id: Ifff6c1a61f502e7b39b4d2b4bd1471b9f32fcf6c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: use stdout for progress bar
Artem Bityutskiy [Mon, 17 Dec 2012 16:21:11 +0000 (18:21 +0200)]
test_api_base: use stdout for progress bar

Because otherwise the output is visible when runnint nosetest without -s.

Change-Id: Ifa9ec61f4fdf2679bab215b316e70afcf7a6ad15
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: code re-arrangement
Artem Bityutskiy [Wed, 19 Dec 2012 09:07:52 +0000 (11:07 +0200)]
TransRead: code re-arrangement

Move class Error a little bit up.

Change-Id: Ia5308ff3fbb3f4098bd9ca01d43a814a8c6475cf
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: implement better fake seek method
Artem Bityutskiy [Fri, 14 Dec 2012 14:16:01 +0000 (16:16 +0200)]
TransRead: implement better fake seek method

Implement a generic '_add_fake_seek()' function which adds fake seek support to
any file-like object.

Also add support of URLs - open them using urllib2.

Change-Id: I20467631136031f3471f8c7d3ee79927d3fc4719
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: add an extra assertion
Artem Bityutskiy [Mon, 17 Dec 2012 14:56:53 +0000 (16:56 +0200)]
test_api_base: add an extra assertion

Change-Id: Ic0aab643450b00a9d31444c2fc86102279f29ead
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: remove unnecessary truncation
Artem Bityutskiy [Mon, 17 Dec 2012 14:53:02 +0000 (16:53 +0200)]
tests: helpers: remove unnecessary truncation

Change-Id: I72737ea81032cd4b72324727a9e1ae2d74b1d5c3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_base_api: generate uncompressed files as well
Artem Bityutskiy [Mon, 17 Dec 2012 13:22:21 +0000 (15:22 +0200)]
test_base_api: generate uncompressed files as well

Improve the '_generate_compressed_files()' and make it generate uncompressed
vesion of the file as well.

Change-Id: Ie2d042180a152914d42340c01e48f5a887da4185
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: rework the test to match the changed API
Artem Bityutskiy [Mon, 17 Dec 2012 12:30:04 +0000 (14:30 +0200)]
test_api_base: rework the test to match the changed API

BmapCopy does not accept paths anymore - amend the tests.

Change-Id: Ib78dcceb959bce673c08bfb1dca0aa86b985c7d4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: drop the file opening functionality
Artem Bityutskiy [Mon, 17 Dec 2012 10:42:02 +0000 (12:42 +0200)]
BmapCopy: drop the file opening functionality

The BmapCopy class is getting too large and specialized. Improve the situation
by changing the API and removing the file opening functionality. Now it
requires file-like objects all the time. The bmaptool, in turn, now opens the
files itself.

Change-Id: Id62794dfcf21e422fb5e4b9a3a025b2beb25506f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: implement the 'name' attribute
Artem Bityutskiy [Mon, 17 Dec 2012 10:41:19 +0000 (12:41 +0200)]
TransRead: implement the 'name' attribute

The standare attribute for the file name in file objects is 'name', not
'fullpath' - rename it.

Change-Id: I4544bab07c185a730c351fcefd8ff19047162ee7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: document that BmapCopy objects are one-time usable
Artem Bityutskiy [Mon, 17 Dec 2012 07:52:14 +0000 (09:52 +0200)]
BmapCopy: document that BmapCopy objects are one-time usable

Change-Id: I92ce7cd9444491386ababa93e9b747b00891e29a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: implement reading from file object
Artem Bityutskiy [Fri, 14 Dec 2012 13:49:11 +0000 (15:49 +0200)]
TransRead: implement reading from file object

This patch changes the way we open the file: instead of opening by name, open
it by its file object. This is not needed right now, but one of the next
patches will implement reading from an URL, in which case we'll have to be able
to read and decompress from a urlib file-object. In other words, this is a
preparations.

The good thing is that both tarfile and gzip modules allow to open by file
objects. However, the bad news is that bzip2 module does not support this.
This is why we implement the '_Bzip2Read' class which is a simple wrapper over
bzip2's 'stream decompressor': we just read from the back-end file-like object,
stream the data trhough the bzip2 decompressor, and provide to the caller.

Change-Id: I241c1dad4a0bc9619af61f393e6834b9568545fc
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: add a /dev/null quirk
Artem Bityutskiy [Fri, 14 Dec 2012 16:12:07 +0000 (18:12 +0200)]
BmapCopy: add a /dev/null quirk

It is sometimes useful to copy to /dev/null, e.g., for benchmarking. Hoever,
the /dev/null character device does not support 'fsync()', so bmaptool dies.

Intorduce a quirk for this situation.

Change-Id: Ic61bf86ad5a4e112d7ccd82aa41114dc8b207361
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: improve file size detection
Artem Bityutskiy [Fri, 14 Dec 2012 09:38:43 +0000 (11:38 +0200)]
TransRead: improve file size detection

In case of a tar archive, we know the file size for 'TarInfo'. Propagate it to
the users via our 'size' attribute.

Change-Id: I11dc7daa1d788fe98769ba6537f4117d89d06b34
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add an entry about improving the progress bar
Artem Bityutskiy [Fri, 14 Dec 2012 15:44:52 +0000 (17:44 +0200)]
TODO: add an entry about improving the progress bar

Change-Id: Ib7b3ca6d63ff1d1fbe5d16f96080600f4f92ff39
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: make object one-time usable
Artem Bityutskiy [Fri, 14 Dec 2012 13:04:30 +0000 (15:04 +0200)]
BmapCopy: make object one-time usable

Make the 'BmapCopy' objects usable only once, just like many other
complex objects like Bzip2File.

The reason for this is that it is too complex to make them re-usable,
because this requires seeking image file and the destination file to the
beginning, and not all files are easily seekable.

In fact, some files are not seekable at all. So remove the unneeded
complexity.

Change-Id: I30ecdd44dead485ae9d187e3487b0efa548c15d5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: introduce a TransRead module
Artem Bityutskiy [Thu, 13 Dec 2012 17:32:16 +0000 (19:32 +0200)]
TransRead: introduce a TransRead module

Separate out the transparent file reading functionality to a module.
We'll add reading from an URL soon, so the module will become more complex.

Change-Id: I7bd45fba5c6265f10f1a41ba109e3662a8f50d7b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: include set_image_size testing
Artem Bityutskiy [Fri, 14 Dec 2012 08:29:54 +0000 (10:29 +0200)]
test_api_base: include set_image_size testing

Improve test coverage by also testing the 'set_image_size()' interface of
'BmapCopy'.

Change-Id: I86d8541a127a8ea514cad8a666bc49da52b29435
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: change generate_test_files's interface a bit
Artem Bityutskiy [Fri, 14 Dec 2012 08:24:34 +0000 (10:24 +0200)]
tests: helpers: change generate_test_files's interface a bit

Improve the API of the 'generate_test_files()' helper and teach it to return
file size. This allow testing the 'BmapCopy' module a bit better in the next
patch.

Also propagate the size to the 'do_test()' method of the 'test_api_base' test.

Change-Id: Ib20f57bc6120d770d59dec5705f6f5ffae4300ca
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: allow users setting image size
Artem Bityutskiy [Fri, 14 Dec 2012 07:58:09 +0000 (09:58 +0200)]
BmapCopy.py: allow users setting image size

The user sometimes knows the size of compressed image, so let him/her set it
in order to enable the progress bar.

This patch essentially changes an internal method to a pulic method.

Change-Id: I91e8c5de8196b17ae6bb8cab963bdc11145ede3c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add another improvement idea
Artem Bityutskiy [Thu, 13 Dec 2012 12:43:24 +0000 (14:43 +0200)]
TODO: add another improvement idea

Change-Id: I86f91d1d157a2dfc26fefb9981e489142fc3c36d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: disable pylint recommendation
Artem Bityutskiy [Thu, 13 Dec 2012 11:59:05 +0000 (13:59 +0200)]
bmaptool: disable pylint recommendation

Disable the 'too many statements' recommendation.

Change-Id: I514038cb7c5c7e472f7da66aba2762160b3a92bf
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: refuse copying without bmap by default
Artem Bityutskiy [Thu, 13 Dec 2012 11:54:49 +0000 (13:54 +0200)]
bmaptool: refuse copying without bmap by default

Allow copying without bmap only when the --nobmap. This way users will for
sure notice when they copy without bmap.

Change-Id: If323e995a22df23b4365859c940e1717fa7e8d28
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add few new ideas to the list
Artem Bityutskiy [Thu, 13 Dec 2012 09:44:37 +0000 (11:44 +0200)]
TODO: add few new ideas to the list

Change-Id: I1272fadc84463a5b9fddc58706eda4756fcfada4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: remove an entry about magic sequences
Artem Bityutskiy [Wed, 12 Dec 2012 14:52:18 +0000 (16:52 +0200)]
TODO: remove an entry about magic sequences

I've tried this, it is not really eassy to do. For example, for tar.bz2
and .bz2 the magic sequence is the same. Lets' leave it as it is.

Change-Id: I4919b1c35104457b1aa42b367e227497f9fd1127
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoREADME: master branch points to the latest release
Artem Bityutskiy [Wed, 12 Dec 2012 14:20:10 +0000 (16:20 +0200)]
README: master branch points to the latest release

Update the documentaion and tell that the master branch points to the latest
release, not pre-release.

Change-Id: Icb51a71b36809097c84466f5d7cbbffdf9c4ffe0
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: improve warning message
Artem Bityutskiy [Wed, 12 Dec 2012 14:01:12 +0000 (16:01 +0200)]
bmaptool: improve warning message

The tool tries to be generic and it is better to use word "copying" instead of
"flashing".

Change-Id: I85ac53a955da14a6acf4ef87cf72005b9d550ee4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: use progress indicator sometimes
Artem Bityutskiy [Wed, 12 Dec 2012 13:59:43 +0000 (15:59 +0200)]
test_api_base: use progress indicator sometimes

Increase test coverage by using the progress indicator or the BmapCopy class
sometimes.

Change-Id: I2fd766de7d171965a2784e497b42ac358f75d4d9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: implement progress inicator
Artem Bityutskiy [Wed, 12 Dec 2012 13:51:25 +0000 (15:51 +0200)]
BmapCopy: implement progress inicator

I got a feature request from users to implement a progress bar in order to
show that the process is alive. This commit implements it.

I add a possibility to configure the BmapCopy class to print the progress
indicator to a user-defined file object with a user-defined pattern.

Change-Id: Ida0331a692163cbcf909ebf984917e2466eb0b70
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: make warnings and errors more visible
Artem Bityutskiy [Wed, 12 Dec 2012 08:20:01 +0000 (10:20 +0200)]
bmaptool: make warnings and errors more visible

People usually do not read docs and forget to use the --bmap option, and then
wonder why flashing is not fast enough. bmaptool prints some kind of warning
in this case, but it is not visible enough. Make it to be more visible:

1. Change the message to say that flashing will be slow.
2. Make the warning/error prefix to use capital letters.
3. Make the output to be coloured.

This should hopefully draw more attention and people will notice warnings
and errors more easily.

Change-Id: Iccf44430c5b9e671a5d540c2966fead3aa800337
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add an entry about progress indicator
Artem Bityutskiy [Tue, 11 Dec 2012 12:41:40 +0000 (14:41 +0200)]
TODO: add an entry about progress indicator

Change-Id: I05d16959ceec0dcfe800179a566ee82267233c00
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agopackaging: remove an internal URL release-1.0 v1.0
Artem Bityutskiy [Tue, 4 Dec 2012 09:54:34 +0000 (11:54 +0200)]
packaging: remove an internal URL

Change-Id: Ide9bf02a7ff0e02f1e7eaca6a2b46e98fffb0839
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRelease bmap-tools version 1.0
Artem Bityutskiy [Mon, 3 Dec 2012 08:08:23 +0000 (10:08 +0200)]
Release bmap-tools version 1.0

Change-Id: Ifa6e3142330bc2a082ed05a678a5c3a2dbf937b4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: turn into 1.0 notes
Artem Bityutskiy [Mon, 3 Dec 2012 07:57:34 +0000 (09:57 +0200)]
RELEASE_NOTES: turn into 1.0 notes

I am going to make release 1.0, and there are no differences between 1.0-rc7
and 1.0, so let's turn rc7 release notes into 1.0 release notes.

Change-Id: I01f69aae0103af7b96464efe6b0cd2d6d5126a38
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add an entry about a man page
Artem Bityutskiy [Mon, 3 Dec 2012 07:55:12 +0000 (09:55 +0200)]
TODO: add an entry about a man page

Change-Id: I33f3e2ae9e32373efb34f17124ac8fd75b1858a9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_fiemap: silence a pylint recommendation
Artem Bityutskiy [Thu, 29 Nov 2012 14:23:24 +0000 (16:23 +0200)]
test_fiemap: silence a pylint recommendation

Change-Id: I73fc76f957a2db8b8e51d2ebf9fefff5916548f2
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoSpelling fixes
Artem Bityutskiy [Thu, 29 Nov 2012 14:18:23 +0000 (16:18 +0200)]
Spelling fixes

Fix a number of mis-spelled words in comments. No functional changes.

Change-Id: I3667e141ecb7c5d24efb3ad83ef7b5fa5ea9f493
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: remove an item about temporary files
Artem Bityutskiy [Thu, 29 Nov 2012 14:09:11 +0000 (16:09 +0200)]
TODO: remove an item about temporary files

Well, we just do nt have them, so this item is useless. We only have them in
tests, and they get deleted on Ctrl-C because we use the NamedTemporaryFile
python function which deletes the files on close.

Change-Id: I9fce79088c8b66f6cc3a2d8889db941f7becda53
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPre-release 1.0-rc7
Artem Bityutskiy [Thu, 29 Nov 2012 10:42:17 +0000 (12:42 +0200)]
Pre-release 1.0-rc7

Change-Id: Id4ca03e5fc21632ad6a457ae9914446d886a041e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPlug RELEASE_NOTES to debian packages
Artem Bityutskiy [Thu, 29 Nov 2012 09:37:21 +0000 (11:37 +0200)]
Plug RELEASE_NOTES to debian packages

Change-Id: Id8d64cd4f2873100c95e92fbe8bbe43787506699
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPlug RELEASE notes to RPM packages
Artem Bityutskiy [Thu, 29 Nov 2012 09:03:55 +0000 (11:03 +0200)]
Plug RELEASE notes to RPM packages

Change-Id: I4863ca788c6b504eb931f00c71ddb17df6e17da2
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoLimit nosetests coverage to the bmap-tools project
Artem Bityutskiy [Thu, 29 Nov 2012 08:44:11 +0000 (10:44 +0200)]
Limit nosetests coverage to the bmap-tools project

... otherwise various libraries like 'bzip2' are included.

Change-Id: Iab43f8ba1c7d167ff8e924b3d592d4a602577fc1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoREADME: add more information
Artem Bityutskiy [Thu, 29 Nov 2012 07:43:16 +0000 (09:43 +0200)]
README: add more information

Add information about branches, releases, versioning, author, and the credits.

Change-Id: Icf0f8122f1e25048bffa84baa315d1a281c6867c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAmend comments: do not be confused about generators and iterators
Artem Bityutskiy [Thu, 29 Nov 2012 07:05:21 +0000 (09:05 +0200)]
Amend comments: do not be confused about generators and iterators

Iterators and generators are not the same things. Generators is a more narrow
concept. Generators are functions which yield elements.

Fix up commentaries where I mixed these terms. Call all my functions with
'yield' - generators. Also, prefer saying 'generator yields' to 'generators
generates' just to be more clear about what I am trying to say.

Fix a couple misspelled words and confusing sentences while on it.

No functional changes.

Change-Id: Ia87b1a6441c293aab2ad45e2cb762f388b49ea35
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAdd RELEASE_NOTES
Artem Bityutskiy [Wed, 28 Nov 2012 16:02:21 +0000 (18:02 +0200)]
Add RELEASE_NOTES

Not wired to the packaging so far - it needs some more work.

Change-Id: I82eae2e79acd55472f099a9178678f0aec4e452d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAdd a small README file
Artem Bityutskiy [Wed, 28 Nov 2012 15:38:33 +0000 (17:38 +0200)]
Add a small README file

Change-Id: I83285512d949bce6254d87091adc275e98d861c3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_fiemap: implement a test for part of the file
Artem Bityutskiy [Wed, 28 Nov 2012 13:01:43 +0000 (15:01 +0200)]
test_fiemap: implement a test for part of the file

Test no only the entire file, but also parts of the file.

Change-Id: I6a64199c371d8c343384d508856ea99a496a6c4a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFiemap: fix get_(un)mapped_ranges for file parts
Artem Bityutskiy [Wed, 28 Nov 2012 13:27:44 +0000 (15:27 +0200)]
Fiemap: fix get_(un)mapped_ranges for file parts

The functions worked incorrectly when the ranges were requested for part of the
file. Fix this.

Change-Id: Ib979c06a05dcbad1825b98199d23441d236fe5e4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_fiemap: code re-structuring
Artem Bityutskiy [Wed, 28 Nov 2012 12:28:57 +0000 (14:28 +0200)]
test_fiemap: code re-structuring

This patch re-structures the _do_test() function of the 'test_fiemap' unit
test. The re-structuring is needed because I am going to extend the test and
verify the 'get_(un)mapped_ranges()' finctions fro parts of the file, not only
for the entire file. Without the re-structuring there will be a lot of code
duplication.

So, this patch introduces a '_check_ranges()' helper function which verifies
the 'get_(un)mapped_ranges()' function for a given range of blocks.

Additinally, to make the code look uniform, this patch renames all the 'holes'
list variables into 'unmapped', to match the existing 'mapped' list.

Change-Id: Ie1a30941eea9004e742621e87bf325a7f464ab27
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_fiemap: test with different buffer sizes
Artem Bityutskiy [Wed, 28 Nov 2012 09:36:54 +0000 (11:36 +0200)]
test_fiemap: test with different buffer sizes

Test the 'Fiemap' class with several different buffer sizes.

Change-Id: I250f576c4804c02e3691197d8542430571fcb6d4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFiemap: amend things about the default buffer size
Artem Bityutskiy [Wed, 28 Nov 2012 09:35:24 +0000 (11:35 +0200)]
Fiemap: amend things about the default buffer size

Introduce a constant for the default buffer size.
Change the constructor interface - now None 'buf_size' means the default
buffer size, which is a nicer interface.

Change-Id: I1bc7dca57e9d36e4a9d6e8cc402b3f5038bcf460
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_fiemap: increase maximum file size to 16MiB
Artem Bityutskiy [Wed, 28 Nov 2012 09:26:39 +0000 (11:26 +0200)]
test_fiemap: increase maximum file size to 16MiB

The default 4MiB are probably too few because the internal ext4 extent size
seems to be 2MiB, so 4MiB are just 2 extents.

Change-Id: If40f0ad70c6787659a01ebc6473ed4189069d81e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFiemap.py: implement new get_mapped_ranges
Artem Bityutskiy [Wed, 28 Nov 2012 07:02:22 +0000 (09:02 +0200)]
Fiemap.py: implement new get_mapped_ranges

Use full power of the FIEMAP ioctl and call it for large areas of the file,
instead of doing it block-after-block. This version is several times faster
than the old version.

The 'get_unmapped_ranges()' generator is build on top of 'get_mapped_ranges()'.

Change-Id: I8bbaf7ccb755904a2bcaef71ba53d82b4fa2c60b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: mark create_random_sparse_file as local
Artem Bityutskiy [Wed, 28 Nov 2012 09:07:42 +0000 (11:07 +0200)]
tests: helpers: mark create_random_sparse_file as local

Mark the 'create_random_sparse_file()' function as local by addin a leading
'_'.

Change-Id: Id17557c0c8b4268555d71610c1a12def8e8b64bc
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: correct tar.bz2 files extension
Artem Bityutskiy [Wed, 28 Nov 2012 09:05:54 +0000 (11:05 +0200)]
test_api_base: correct tar.bz2 files extension

This is just a copy-paste error - we gave .tar.bz2 files a '.tar.gz' extension.

Change-Id: Ic4a0fbb40c4519bb12c91c42b3e546b1952a82db
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: do not always write entire blocks
Artem Bityutskiy [Wed, 28 Nov 2012 08:57:46 +0000 (10:57 +0200)]
tests: helpers: do not always write entire blocks

In 'create_random_sparse_file()', when we have decided to map a block, we
always fill it entirely (write 4096 bytes). However, filling only part of this
block from a random offset withing a block is more realistic.

Change-Id: I825e9fb093e7c9c7be309b2563c2be6049783811
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: a small nicification
Artem Bityutskiy [Wed, 28 Nov 2012 08:37:02 +0000 (10:37 +0200)]
tests: helpers: a small nicification

getrandbits(1) is a bit more clever than randint(0, 1). Also, remove useless
bool().

Change-Id: I169c21f8e986dd6579a46d6eb0b214ec7e11611a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: use less random data
Artem Bityutskiy [Wed, 28 Nov 2012 08:30:07 +0000 (10:30 +0200)]
tests: helpers: use less random data

We do not need really random data in the files we generate - this only slows
the tests down a lot. Let's fill the files with semi-random data instead - just
pick a random byte and fill large regions with this byt. This also make
compression work faster, and it is good enough for our purposes.

Besides, this allows to reproduce tests by setting a known seed, which does not
work with os.urandom.

Change-Id: I0459ee44d271b8e19581e84cc33b7167e4ada166
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFiemap: fix internal buffer size calculations
Artem Bityutskiy [Wed, 28 Nov 2012 06:59:53 +0000 (08:59 +0200)]
Fiemap: fix internal buffer size calculations

... I used 'buf_size' instead of 'self._buf_size' by a mistake.

Change-Id: If92b92e4aa09653fe27e41e5a2cc236fce3042af
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFiemap: lower the default buffer size
Artem Bityutskiy [Wed, 28 Nov 2012 06:58:31 +0000 (08:58 +0200)]
Fiemap: lower the default buffer size

The default 1MiB buffer is a bit too large, make it 256KiB.

Change-Id: I7827889d6201f224033c77b5396901f65c766e8d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFiemap: introduce a constant for minimum buffer size
Artem Bityutskiy [Wed, 28 Nov 2012 06:56:58 +0000 (08:56 +0200)]
Fiemap: introduce a constant for minimum buffer size

Change-Id: Ic029ac27afa9c3994b9a59594ca52c280c3b24b9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoSuppress few pylint recommendations
Artem Bityutskiy [Tue, 27 Nov 2012 14:05:36 +0000 (16:05 +0200)]
Suppress few pylint recommendations

Change-Id: Ia757396ffe5d39b3ff5d35b9639417c662f74706
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: generate fully-mapped files as well
Artem Bityutskiy [Tue, 27 Nov 2012 13:58:34 +0000 (15:58 +0200)]
tests: helpers: generate fully-mapped files as well

Improve tests coverage by generating fully-mapped files as well.

Change-Id: Icf3a8a246efadd32a0dcbc28ccc279caaaced143
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_fiemap: add Fiemap module unit test
Artem Bityutskiy [Tue, 27 Nov 2012 13:11:21 +0000 (15:11 +0200)]
test_fiemap: add Fiemap module unit test

Change-Id: I0da8bb80f8b15fd27695381324bb213726cfeca2
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: fix holes area for a 4097 bytes file
Artem Bityutskiy [Tue, 27 Nov 2012 13:44:05 +0000 (15:44 +0200)]
tests: helpers: fix holes area for a 4097 bytes file

... should be (0, 1), not (0, 0).

Change-Id: Ia611057680623360191973aa2691c9d35161bcef
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: teach generate_test_files to return mapped areas
Artem Bityutskiy [Tue, 27 Nov 2012 13:19:33 +0000 (15:19 +0200)]
tests: helpers: teach generate_test_files to return mapped areas

This is a preparation to the Fiemap test. In the Fiemap module we have 2
functions: get_mapped_ranges() and get_unmapped_ranges(). And to test both of
them it is convenient to have 2 lists from the
'tests.helpers.generate_test_files()' function: mapped list and unmapped list.

Thus, teach 'tests.helpers.generate_test_files()' to also generate the list of
mapped areas, not only the holes.

Change-Id: Id000ba0b278ccceb821f540755cdd94165eeecc9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: test .tar.gz and .tar.bz2 compression
Artem Bityutskiy [Tue, 27 Nov 2012 12:38:32 +0000 (14:38 +0200)]
test_api_base: test .tar.gz and .tar.bz2 compression

This actually revealed a bug...

Change-Id: Ife39862d4b9e71beea5b5150970da9066782145b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: fix tar.gz compression support
Artem Bityutskiy [Tue, 27 Nov 2012 12:39:40 +0000 (14:39 +0200)]
BmapCopy: fix tar.gz compression support

This is a nasty bug - I used 'if' instead of 'elif' ... Thanks to
'test_api_base' for revealing it.

Change-Id: I43e1954cb02c46ac27e9d9e7324e86ef9dec2974
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: add a possibility to avoid tmp files deletion
Artem Bityutskiy [Tue, 27 Nov 2012 10:06:29 +0000 (12:06 +0200)]
tests: add a possibility to avoid tmp files deletion

This is needed for debugging purposes. When there are issues, it is very handy
to be able to leave the temporary files and then investigate them. Do lets add
a simple way to do this. In the future, this may become a test parameter.

Change-Id: I067fc9d5a522057290c5c9ee190cf15ee7fa19f1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: introduce a possibility to change the directory for tmp files
Artem Bityutskiy [Tue, 27 Nov 2012 09:14:03 +0000 (11:14 +0200)]
tests: introduce a possibility to change the directory for tmp files

The default temporary directory is choosen by 'NamedTemporaryFile' and it is
usually '/tmp'. However, for debugging purposes it is nice to sometimes change
that to a different directory. In the future, this may be a test parameter.

Change-Id: I12428f99a14eb7467948e08048bd0108c8bf5bc1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: assign better names to temporary files
Artem Bityutskiy [Tue, 27 Nov 2012 08:52:54 +0000 (10:52 +0200)]
tests: assign better names to temporary files

When creating temporary files, add prefixes and suffixes which make it easy to
understand what is the file. This makes debugging a lot easier, although the
code becomes a bit more complex.

Change-Id: Ieba77821c3d97ed080fbc22b889d77cb640312c6
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add an entry about compression types detection
Artem Bityutskiy [Tue, 27 Nov 2012 07:21:54 +0000 (09:21 +0200)]
TODO: add an entry about compression types detection

Change-Id: I4a12477bd07a7b6d25be662929a0053cda170cb7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: helpers: move compress_test_file to test_api_base.py
Artem Bityutskiy [Tue, 27 Nov 2012 07:16:18 +0000 (09:16 +0200)]
tests: helpers: move compress_test_file to test_api_base.py

The 'compress_test_file()' function is only used by 'test_api_base' and I am
not planning any other tests which would need it. So let's move it to that
file.

While on this, also rename the function to '_generate_compressed_files()',
which is more consistent with the other iterator we have:
'generate_test_files()'.

Change-Id: I9191b413a82545facf9507d4c72ee070e0487be4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: make compare_holes local
Artem Bityutskiy [Tue, 27 Nov 2012 07:11:15 +0000 (09:11 +0200)]
test_api_base: make compare_holes local

The 'compare_holes()' function is only used in this test, so it is cleaner to
add a leading '_' to the name to show that it is a local function.

Change-Id: I8f2a446fefbc314640830e734db088e8ce39e05a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotest_api_base: also test compressed files
Artem Bityutskiy [Mon, 26 Nov 2012 15:58:48 +0000 (17:58 +0200)]
test_api_base: also test compressed files

Change-Id: Iae27bcea6fac825a2c6d1f82b125afda5db31859
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>