From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9423 invoked by alias); 28 Nov 2012 11:14:01 -0000 Received: (qmail 9413 invoked by uid 22791); 28 Nov 2012 11:14:00 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_KC,TW_LV X-Spam-Check-By: sourceware.org Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Nov 2012 11:13:38 +0000 Received: by mail-la0-f47.google.com with SMTP id u2so10448153lag.20 for ; Wed, 28 Nov 2012 03:13:35 -0800 (PST) Received: by 10.152.45.229 with SMTP id q5mr17211315lam.34.1354101215476; Wed, 28 Nov 2012 03:13:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.135.105 with HTTP; Wed, 28 Nov 2012 03:13:14 -0800 (PST) In-Reply-To: <20121128110327.GI2315@tucnak.redhat.com> References: <20121128102445.GH2315@tucnak.redhat.com> <20121128110327.GI2315@tucnak.redhat.com> From: Konstantin Serebryany Date: Wed, 28 Nov 2012 11:14:00 -0000 Message-ID: Subject: Re: [PATCH] asan unit tests from llvm lit-test To: Jakub Jelinek Cc: Wei Mi , GCC Patches , David Li , Diego Novillo , Kostya Serebryany , Dodji Seketeli Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg02310.txt.bz2 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 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(1, 0), uaf_string); > replace that with > DIE_IF(77, uaf_test(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