Skip to content

Reducing YARPGen tests #15

Open
Open
@afd

Description

A YARPGen test is spread over three files:

  • driver.c - declares: global variables; an init function that initializes them; a checksum function for computing a checksum over the globals; a prototype for function test; and a main function that calls init, invokes test and prints the result of checksum.

  • func.c - declares the test function that is called from driver.c

  • init.h - included from func.c and provides extern declarations of all of the globals declared in driver.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 into func.c inline and get rid of init.h. This should be fine because init.h is not included from driver.c - its contents might as well be directly in func.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 of init.h into func.c as above)

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 into func.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.

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions