copy code from test_full.c