Create a utility library (LIBBU) API unit test ... for vlb.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/vlb.c
  • src/libbu/tests/*.c

Code:

  • src/libbu/tests/bu_vlb.c
  • src/libbu/tests/CMakeLists.txt
Uploaded Work
File name/URLFile sizeDate submitted
test_bu_vlb.patch5.4 KBJanuary 03 2013 04:56 UTC
test_bu_vlb.patch6.6 KBJanuary 03 2013 08:23 UTC
test_bu_vlb.patch8.1 KBJanuary 04 2013 00:42 UTC
test_bu_vlb.patch8.8 KBJanuary 04 2013 07:58 UTC
Comments
Arjun Govindjeeon December 30 2012 18:43 UTCTask Claimed

I would like to work on this task.

Daniel Rossberg on December 30 2012 18:56 UTCTask Assigned

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

Melange on January 1 2013 18:56 UTCInitial Deadline passed

Melange has detected that the initial deadline has passed and it has set the task status to ActionNeeded. The student has 24 hours to submit the work before the task is reopened and sent back to the pool for other students to claim.

Melange on January 2 2013 18:56 UTCTask Reopened

Melange has detected that the final deadline has passed and it has reopened the task.

Arjun Govindjeeon January 2 2013 19:06 UTCTask Claimed

I would like to work on this task.

Arjun Govindjeeon January 2 2013 19:07 UTCForgot

Sorry, I forgot I had claimed this task and I've been busy that past 2 days. I am almost done,  just working out one segfault issue. I should be done in the next 10 minutes actually.

Harmanpreet Singh on January 3 2013 04:06 UTCTask Assigned

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

Arjun Govindjeeon January 3 2013 04:57 UTCReady for review

The work on this task is ready to be reviewed.

Sean on January 3 2013 05:20 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 January 3 2013 05:31 UTClooks good

Only noticed a few issues on quick inspection:



  • You should be using bu_malloc() and bu_free() instead of malloc() and free() directly.  See our HACKING file for a list of functions that are replaced by our libbu versions for portability.  

  • The open parenthesis on main() should be on a line by itself (functions are formatted differently).  The return type should be by itself too.

  • Your call to pipe() -- that block needs to be wrapped in HAVE_PIPE (see src/mged/mged.c for an example) as it's not portable.

  • Header is missing common.h (see HACKING)

  • Memory allocations are "unclean", must bu_free() before return/exit even in the error blocks (in case this main() ever turned into a non-main() function.  A goto is acceptable if you want to consolidate but make sure you still don't free a null pointer.

  • Use of // is no good (see HACKING).  Use /* comment */ instead.

  • The "documentation in the CMakeLists.txt file is great, but you should have some similar sort of summary comment in the source file as well.


 


 

Arjun Govindjeeon January 3 2013 08:23 UTCReady for review

The work on this task is ready to be reviewed.

Arjun Govindjeeon January 3 2013 08:25 UTCHACKING

I read the whole HACKING file and I noticed a few other things I could fix in my code, so I fixed those too. Hopefully in the future I will be more successful at doing things right the first time.

Daniel Rossberg on January 3 2013 14:06 UTCYour VLB_BLOCK_SIZE is fragile

At the moment it's the same as in vlb.c but you can't be sure that this is true in the future too.  Any idea how to solve this?  (Maybe with a bu_vlb_capacity() function?)


And why isn't one memset sufficient (line 73 74)?

Daniel Rossberg on January 3 2013 14:06 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.

Arjun Govindjeeon January 4 2013 00:10 UTCbu_vlb_capacity

The bu_vlb_capacity() function is an excellent idea, and I would have done something similar before, but I didn't think that as a unit test developer I should be modifying the code that I was writing a test for. However, it would appear that to prevent my unit test from containing bad code, I should just go ahead and do it.


Also with regard to the double memset, I first wrote all 1s to the bytes and then I set it back to all 0s, because bu_vlb_init, bu_vlb_initialize both use calloc, which zeroes the memory. I figured that just in case the calloc ever actually becomes essential to the operations of vlb (in the future), I should set the buffer back to 0s.


If you think that is a little overcautious/ridiculous (since vlb probably never will require zeroed memory to operate properly), I can remove it.

Arjun Govindjeeon January 4 2013 00:42 UTCReady for review

The work on this task is ready to be reviewed.

Andrei Popescu on January 4 2013 07:18 UTCCompiler Error

Hello !


The test looks great so far, but  ther are some issues we need to address:


bu_vlb.c:81:2: error: too few arguments to function ‘bu_vlb_capacity’


This is what causes the error : if (initialSize != bu_vlb_capacity()) {

 

Also, you should add brief comments in your code explaining key aspects. 

 

Goodluck with your Work!

 

 

Andrei Popescu on January 4 2013 07:18 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.

Arjun Govindjeeon January 4 2013 07:37 UTCCompile

Thats weird, not sure how that happened (I forgot to test it before I uploaded it), but everything is fine now.


Also I already have comments explaining things? I suppose I could add a few more.

Arjun Govindjeeon January 4 2013 07:58 UTCReady for review

The work on this task is ready to be reviewed.

Andrei Popescu on January 4 2013 09:20 UTCWell done !

Now it looks good.


Thanks for your effort!


If you wish, please leave your name so we can credit you in our authorship. 


 

Andrei Popescu on January 4 2013 09:20 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on January 14 2013 15:16 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!