That's a bit scary (and will be slower than with gtest). But if we can limit the changes by replacing asan/tests/asan_test_config.h (and maybe some minimal other changes) that may work.
--kcc On Wed, Nov 28, 2012 at 3:03 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, Nov 28, 2012 at 02:40:55PM +0400, Konstantin Serebryany wrote: >> I fully agree about "minimal testsuite". >> But, for example, porting the asan's gtest test (2+ KLOC) to another >> harness is probably too much. > > Depends on how significant changes to the test body are actually needed, > and if we could e.g. write a script that transforms the gtest test into > dejagnu test. > Say something minimal, like for each > const char *uaf_string = "AddressSanitizer:.*heap-use-after-free"; > EXPECT_DEATH(uaf_test<U1>(1, 0), uaf_string); > replace that with > DIE_IF(77, uaf_test<U1>(1, 0)); /* { dg-final { asan-die-if 77 > "AddressSanitizer:.*heap-use-after-free" } } */ > which would be essnetially > int die_if; > and at the beginning of main > char *p = getenv ("ASAN_DIE_IF"); > if (p) > die_if = atoi (p); > or so, then > #define DIE_IF(id, what) if (die_if == id) { what; } > where the test would be run normally first, then asan-die-if would > run it again (see e.g. gdb-test in guality.exp how it invokes gdb on the > test) with setenv ASAN_DIE_IF 77 (environment only to cope with target > boards that don't pass arguments, perhaps we could just ignore bare metal > targets for these kind of tests), and scan the output for the given regexp. > Problem with that is that unfortunately the regexps are runtime constructed, > aren't present as literals. > Or even slighly more involved solution would be to define > #define EXPECT_DEATH(x, y) \ > if (die_if == 0) \ > { \ > fprintf (stderr, "EXPECT_DEATH%d %s EXPECT_DEATHEND%d\n", \ > die_if_counter, y, die_if_counter++); \ > } \ > else if (die_if_counter++ == die_if) \ > x > Then the test would be run once without ASAN_DIE_IF in environment (or =0), > that would produce output full of > EXPECT_DEATH1 AddressSanitizer:.*heap-use-after-free EXPECT_DEATHEND1 > ... > which tcl could parse, and figure from it that it should run the test > again 156 or how many times, with ASAN_DIE_IF from 1 to 156, and at each > iteration try to match the output against the regexp for that iteration. > Then you'd essentially just have to tweak a few lines at the start of the > test, includes, first few lines in main and that would be it. > > Jakub