Create a utility library (LIBBU) API unit test ... for backtrace.cBRL-CAD
Status: ClosedTime to complete: 48 hrs Mentors: SeanTags: unit test, API, C, Tcl, Python, Ruby

There are more than 300 library functions in our core LIBBU library. As a core library used by nearly every one of BRL-CAD's tools, testing those functions for correct behavior is important.

This task involves implementing a new unit test for any of LIBBU's source files that do not already have a unit test defined. The test should run all of the public functions and be hooked into our build system (if written in C). We have lots of existing unit tests to follow as an example.

You can implement this task in any language you like, but you'll have to bind all of the functions you test.

References:

  • include/bu.h
  • src/libbu/backtrace.c
  • src/libbu/tests/*.c

Code:

  • src/libbu/tests/bu_backtrace.c
  • src/libbu/tests/CMakeLists.txt
Uploaded Work
File name/URLFile sizeDate submitted
my.patch3.6 KBDecember 14 2012 07:04 UTC
my.patch3.9 KBDecember 15 2012 08:57 UTC
Comments
Lachlan Pon December 12 2012 23:42 UTCWhat is required?

Hi,


What need I do to test this function (bu_backtrace)? Is the output of this function always standard (it says something about gdb), or does it vary from platform to platform?


Thanks,
Lachlan 

Lachlan Pon December 12 2012 23:42 UTCTask Claimed

I would like to work on this task.

Lachlan Pon December 13 2012 00:58 UTCRE: What is required?

I could test it to ensure when the FILE * parameter is null, it prints to stdout, and when it is not null, it actually writes some data.

Sean on December 13 2012 06:53 UTCTask Assigned

This task has been assigned to Lachlan P. You have 48 hours to complete this task, good luck!

Sean on December 13 2012 15:21 UTCtricky one

So this is a tricky one to test.  The output will vary because it is calling on gdb to help get the trace.


Your idea about testing the FILE pointer is a reasonable test.  Note the TEST_BACKTRACE section at the bottom of the file -- that may be a good starting point as well to pull into your test file.  Since you're creating a separate unit test file, your patch should incorporate that test and remove that section from backtrace.c; just include both in your patchfile.


 

Lachlan Pon December 14 2012 07:04 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 14 2012 15:32 UTCbuffer size

So this looks almost perfect. :)


The fixed buffer size is a bug report waiting to happen, especially since debug/crash output can vary.  Since you have a file handle, you can call fstat() to get the file size and allocate a buffer of the appropriate size.


 

Sean on December 14 2012 15:33 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Sean on December 14 2012 15:33 UTCDeadline extended

The deadline of the task has been extended with 1 days and 0 hours.

Lachlan Pon December 14 2012 22:24 UTCfstat

Thanks,


I had assumed that fstat was 'unportable', and I couldn't find anything about it in the code.


Will rewrite it :-)


Lachlan

Sean on December 15 2012 06:18 UTCnot the case

fstat is VERY portable.  It's part of c89 and 1988 POSIX.1 so it's pretty much supported everywhere.  When in doubt, look around the code for other instances and you'll see we use it in several other places:  grep fstat src/libbu/*


 

Lachlan Pon December 15 2012 08:57 UTCReady for review

The work on this task is ready to be reviewed.

Lachlan Pon December 15 2012 08:59 UTCRE: not the case

Thanks!


Next time I will try that!


Lachlan


 

Sean on December 16 2012 05:55 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on January 10 2013 06:19 UTCclose

Lachlan, I thought you might like to know that there's about 4 days remaining and you're currently about 4 tasks close to making our top five.

Sean on January 14 2013 14:59 UTCthank you

As GCI comes to a close, we wanted to take the time to say THANK YOU for all your efforts.  This comment interface closes after GCI is over, so you're encouraged to join our mailing list where we'll be announcing contributions from GCI participants like yourelf over the upcoming months: 


https://lists.sourceforge.net/lists/listinfo/brlcad-news


If you've provided your full name, we'll be sure to credit you in our authorship documentation and you'll see your name in a future announcement.  If you contact us at devs@brlcad.org or via IRC, we'll even let you know when your work is integrated and follow up with updates.  You're welcome and encouraged to contact us any time, especially if you have a question about how to continue participating in Open Source after GCI is over, but even if just to keep in touch.  Note that ongoing participation in Open Source is one of the most impressive skills to have on your resumé.  Take care, be well, and thank you again!