Tim Retout's www presence

Sun, 20 Sep 2009

Escape Velocity

I am no longer going to tag my blog posts with Planet {WUGLUG,UWCS}.

As I don't even lurk in the IRC channels any more (or read the mailing lists), and as of recently don't even live near enough to campus to visit, I think it's time to stop imposing my ramblings on the respective groups. :)

You can still read my blog directly, or on Facebook, if you are so inclined.

Posted: 20 Sep 2009 14:28 | Tags: ,

Wed, 09 Sep 2009

Unit testing

I spent the last day and a half writing a vaguely interesting Perl module for testing some code which gives a subtly different answer each time (i.e. incorporates data from time() and /dev/urandom) and has side effects (i.e. writes to the file system).

By overriding Perl's built-in 'open' function, it is possible to prefix each filename with the location of a temporary directory, effectively emulating chroot(). I also replaced Perl's time() with one that always returned the same answer. This meant that the login code I was testing would return a reliable result.

You have to be careful with prototypes. Spot the difference:

my $result = gmtime(time+$seconds);
my $result = gmtime(time()+$seconds);

Without adding a prototype to the new time() function, these will give different answers. I now have to go back to work tomorrow and close a bug I mistakenly filed. :)

I'm hoping to finish off my evil hacky overriding module and release it to CPAN. I want to add some routines to set up and tear down temporary chroot directories. Obviously there are some limitations to my approach; I'm not currently handling relative paths very well, and system() calls will not be "chrooted". But it should be quite handy and reusable in any case.

Posted: 09 Sep 2009 19:16 | Tags: , ,

< September 2009 >
SuMoTuWeThFrSa
   1 2 3 4 5
6 7 8 9101112
13141516171819
20212223242526
27282930   

Contact

Tim Retout tim@retout.co.uk
JabberID: tim@retout.co.uk

Comments

I'm afraid I have turned off comments for this blog, because of all the spam. Let's face it, I didn't read them anyway. Feel free to email me.

Links

Copyright © 2007-2011 Tim Retout