[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] Complicatedness limits might need a little tweaking

On Sat, May 7, 2011 at 12:38 AM, Arthur O'Dwyer
<arthur.j.odwyer@gmail.com> wrote:
> For the most part, Csmith generates pretty reasonable medium-sized
> test cases, but it is still possible for it to get carried away. I
> just ran across this unusual case where Csmith 2.0.0 was generating a
> main() function of more than 6000 lines --- thanks to hundreds of
> global variables, a surprising number of which were structs containing
> structs containing structs.

It occurs to me that another possibility would be to generate a
checksum-printing helper function for each struct type, and have
main() call that function for each global variable of struct type,
rather than generating code to print all the fields of each global
variable individually.  This would reduce the worst-case size of
main() from O(number-of-variables x fields-per-struct x
fields-per-nested-struct x ...) down to O(number-of-variables), plus
an additional O(fields-per-struct) in helper code.

> csmith --bitfields --packed-struct -s 785395829 >test.c
> wc test.c
>   9043  36116 839634 test.c

wc test-new.c
  4223  21760 505125 /tmp/test2.c

I threw together a patch this morning.  This is just a quick hack
(e.g. notice that I'm handling const and volatile global variables by
having the hash function take a "const volatile struct S1 *"), and
array variables are still done by the old method.  Dealing with those
"field variables" burned out my brain long before I got to "int
subfield names". ;)