missing NULL terminator in set_config_x
[geda-gaf.git] / docs / wiki / pcb-unit_tests.html
blob1026ae4c275af1ee61b861f1d6f2aeee5dae3fb9
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <head>
5 <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />
6 <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />
7 <link rel="stylesheet" media="print" type="text/css" href="./print.css" />
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 </head>
11 <body>
13 <h2 class="sectionedit1" id="unit_testing_framework">Unit Testing Framework</h2>
14 <div class="level2">
16 <p>
17 I just figured this out, so, here&#039;s how it works, and I&#039;ll formalize this page later.
18 </p>
20 <p>
21 pcb uses the glib testing framework for unit tests: <a href="https://developer.gnome.org/glib/stable/glib-Testing.html" class="urlextern" title="https://developer.gnome.org/glib/stable/glib-Testing.html" rel="nofollow">https://developer.gnome.org/glib/stable/glib-Testing.html</a>
22 </p>
24 <p>
25 Look at main-test.c for examples.
26 </p>
28 <p>
29 In the actual code, you can wrap the unit test stuff in:
30 </p>
31 <pre class="code">#ifdef PCB_UNIT_TEST
32 #endif /* PCB_UNIT_TEST */</pre>
34 <p>
35 so that it doesn&#039;t bog things down when not testing. Does it really bog things down when not testing??
36 </p>
38 <p>
39 You need a “&lt;x&gt;_register_tests” function, and then how ever many functions you&#039;re going to use to execute your tests. Put prototypes in the header file. Include the header file in main-test.c, and add a call to the “&lt;x&gt;_register_tests” function in main.
40 </p>
42 <p>
43 In the register function, make a call to g_test_add_func to add whatever testing functions you want to call. It uses a /x/y naming convention, where x is the test module, and y are the individual tests.
44 </p>
46 <p>
47 You have to add the source file to the list of files to be compiled for testing in Makefile.am. Look for the TEST_SRCS variable, and add your files there, in addition to adding them wherever else you need so that pcb compiles them.
48 </p>
50 <p>
51 Finally, you can rerun configure (to regen the makefiles), and execute “make check” from the build directory. This will build and execute the tests without necessarily building all of pcb. I&#039;m not sure if this runs the pcb level tests or not.
52 </p>
54 </div>
55 </body>
56 </html>