Page 1 of 1

Unit testing and GPL

Posted: 2011-12-20 04:36am
by Number Theoretic
Suppose that there was a library containing an algorithm that i wanted to use in a program for which i intend to use MIT or BSD license, but this library has GPL license. Of course, i would then not use the library and implement the algorithm myself.

And here is where my question comes in:

As far as i know, the GPL is "contagious", so any code that uses GPL code also becomes GPL code automatically. If i wanted to write unit tests for my self-implemented version of the algorithm that use the GPL-ed library's version of the algorithm to check if my version's output is correct, would that mean that my implementation of the algorithm becomes GPL-ed? Or does this merely apply to the unit tests, because my algorithm per se doesn't use any GPL code anywhere?

Re: Unit testing and GPL

Posted: 2011-12-20 10:04am
by rapidsquirrel
Code that uses GPL doesn't become GPL'ed automatically, it's only if you wish to distributed said code to other people. If you are just using GPL code to test other code, then you have nothing to worry about. If your final product doesn't contain any GPL code then you are in the free and clear to license it how ever you wish.

Re: Unit testing and GPL

Posted: 2011-12-20 11:44am
by Sarevok
I thought algorithms are not covered under GPL ?

Re: Unit testing and GPL

Posted: 2011-12-20 11:59am
by Dave
Sarevok wrote:I thought algorithms are not covered under GPL ?
Well, no, the algorithm itself is not protected because it's just mathematics, but if you incorporate code (including code that implements the algorithm) that uses GPL copyrighted code, and distribute it, you have to make the rest of your source code available under the same license.

I believe that the GPL 2 code will let you use it for unit testing without forcing you to distribute (especially since you are not distributing your unit-testing code). I'm not sure if that's true for GPL 3 or the Affero General Public License.

I am not a lawyer, nor do I play one on TV.

Re: Unit testing and GPL

Posted: 2011-12-20 09:04pm
by TronPaul
As long as you don't distribute the GPL'd algorithm you should be ok. From my understanding your code doesn't become GPL if you work with GPL'd code, only if you package and distribute your code and the GPL'd code together. If you're using the GPL'd code for internal, private test cases you shouldn't have to worry.

Some links from a quick Google. It'd be best to ask a lawyer and the owner of the GPL'd software in question.
http://stackoverflow.com/questions/3332 ... test-cases
http://windyroad.org/2006/04/20/using-g ... tory-code/

Re: Unit testing and GPL

Posted: 2011-12-21 03:32am
by Number Theoretic
Thanks for all the replies. So, in a nutshell, i can use the GPL library to construct unit tests and verify my own implementations, but if i wanted to publish the unit tests, i should do so in a separate package, which then becomes GPL, while my own implementation can stay e.g. MIT as long as i don't include the unit tests in the same package. And, when in doubt, talk to a lawyer. Should work for me.

Re: Unit testing and GPL

Posted: 2011-12-21 08:41am
by Beowulf
When in doubt, talk to a lawyer. You may be able avoid having any of your code GPL though, if your test harness only uses staticly generated data in the test case, rather than hooking the GPL'd code into the harness.