Description
A YARPGen test is spread over three files:
-
driver.c
- declares: global variables; aninit
function that initializes them; achecksum
function for computing a checksum over the globals; a prototype for functiontest
; and amain
function that callsinit
, invokestest
and prints the result ofchecksum
. -
func.c
- declares thetest
function that is called fromdriver.c
-
init.h
- included fromfunc.c
and providesextern
declarations of all of the globals declared indriver.c
The reason for this separation is to prevent the compiler from having compile-time information about the initial values of global variables when it compiles func.c
. From personal communication with the YARPGen authors I understand this is an important feature.
When we test-case-reduce a YARPGen program, we want to simplify the code in all of driver.c
, func.c
and init.c
in sync. However, C-Reduce only works on a single file.
To allow this I propose the following:
-
Before reduction, put the contents of
init.h
intofunc.c
inline and get rid ofinit.h
. This should be fine becauseinit.h
is not included fromdriver.c
- its contents might as well be directly infunc.c
. -
Then, also before reduction, create a single file,
combined.c
, that has the form:- Contents of
driver.c
- A special sentinel comment line, e.g.
// SENTINEL
- Contents of
func.c
(after inlining the contents ofinit.h
intofunc.c
as above)
- Contents of
The interestingness test should then:
- Say "not interesting" if the sentinel comment line is not present
- Otherwise, extract the code before the sentinel comment into
driver.c
and the code after intofunc.c
and perform separate compilation of these files.
This should allow C-Reduce to shrink the program as if it were a single file, but have the compiler under test work on the split files.
At the end of reduction, it could be checked whether the split is still necessary - i.e., does the mutant still get killed if the minimised files are concatenated into a single file? If so, that would be an even better minimal test as it is self contained. But if not, a two file test is the result of reduction.