Squish/Calculating Checksums

From Qt Wiki
< Squish
Revision as of 14:58, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Calculating checksums

When you are testing e.g. a file transfer client, and you want to make sure the file transferred is the same on both the sender and the receiver side, one easy way of doing this is using checksums. And luckily for us, Python comes with a hashlib module, with support for exactly that! Problem? The Python code in your test script is being executed in the context of the squishrunner, which is a problem if your application (and hence your files) are being executed on another machine, e.g. an embedded system.

But as mentioned in the article on generating test data, Squish gives us access to most of the Qt API using the built-in Qt wrapper library. And whatever Qt code we put into our test script will be executed in the context of the AUT, even when the AUT is being executed on an embedded system. So combining the fact that the Qt code is being executed on the AUT side along with Python’s hashlib module, we can generate checksums!

Usage:

Another option would be using Squish’s testData.get() function, copying the test data from the remote system to our local system, and using Python’s hashlib module without combining it with the Qt API.

Categories: