Friday, December 10, 2010

SBR600 Project "fedpkg Test Suite" -- release 0.3

Here we are: another semester comes to an end. If, three weeks ago, you were wondering if you could survive, now you don't have to worry any more. Live or die, you will be relived soon.

To be honest, SBR600 is a tough course. If you take it with OPS535 (I know quite a few of you do.), it's really a challenge. I, for one, failed in time management for the first time since I started Seneca. I submitted my OPS535 assignments late for both occasions. Right now, I still have two assignments not started yet (due next week). One for SEC520, another for NDD430. But I'm very glad I can wrap up release 0.3 and get a big weight out of my back. I try to make a summary of the whole project. I put it in a wiki page: Summary Document

In my release 0.3, I tested three more functions on top of my release 0.2. A big improvement is that I got the unittest functions into my test code. In my 0.2, I had a difficult time to use assertion from unittest framework. The simple reason is this: in fedpkg, the function _run_command doesn't return anything. So I can't compare the result from the fedpkg function and from the local os. Finally, I figure out a solution. I create a bash script on the fly and run the bash script. I redirect the output of the bash script to a file. Now I can extract data from the output file and compare it to the result from the fedpkg function. I clean up the temp files in the end.

One function I tested is _find_branch. This function is to find the current branch. An easy assertion is the default branch master (assertEqual). Then I use a bash script change the branch name (git branch and git checkout commands). When I run _find_branch again, I asserted that the branch is not master anymore (assertNotEqual).

Next function I tested is _hash_file. This function is to generate a hash for a file, with a providing hash type. I use a bash script to calculate the hash of a file and output to a local file. I extracted hash to a variable. Then I run _hash_file on the same file using the same hash type. The two hash values should be equal (assertEqual, again).

The third function I tested is _verify_file. The function will verity the hash value against a predetermined value. Return true is they are the same. I generate a hash for a file using a bash script. Then use the hash and the file as arguments in _verify_file. Assertion should be true (assertTrue).

To run my test, you can go to chile.proximity.on.ca. I have my test script and required packages in /var/www/html/fedpkg directory. Run ./test_fedpkg.py will go through 7 tests.

No comments:

Post a Comment