I just thought of a clever (IMHO) trick to use gdb for writing white-box unit tests. I wanted to get opinions about it before merging into master.
The motivation: I wanted to write a regression test for the fix in http://github.com/gbarr/beanstalkd/commit/b9df37, but all_jobs_used is static in job.c, so there's no way to write an assert statement involving that value. On the other hand, I had just finished using gdb to inspect that variable and observe the bug -- gdb can easily access any part of the program, static or otherwise. The trick: use gdb's watchpoints feature to get a trace of every value taken on by a variable during the test, then compare that trace with a file of expected values. You can see an implementation at http://github.com/kr/beanstalkd/commit/d65d34. kr --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "beanstalk-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/beanstalk-talk?hl=en -~----------~----~----~----~------~----~------~--~---
