From b7597ae57977ff3d4ff359141a471acf22001f92 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 9 Aug 2016 23:03:39 +0200 Subject: [PATCH] Add tests for __gcov_dump and __gcov_reset * g++.dg/gcov/gcov-dump-1.C: New test. * g++.dg/gcov/gcov-dump-2.C: New test. From-SVN: r239308 --- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/gcov/gcov-dump-1.C | 23 ++++++++++++++++++ gcc/testsuite/g++.dg/gcov/gcov-dump-2.C | 32 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 gcc/testsuite/g++.dg/gcov/gcov-dump-1.C create mode 100644 gcc/testsuite/g++.dg/gcov/gcov-dump-2.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55ff0819c0d..f1465e878b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-09 Martin Liska + + * g++.dg/gcov/gcov-dump-1.C: New test. + * g++.dg/gcov/gcov-dump-2.C: New test. + 2016-08-09 Martin Liska * gcc.dg/tree-prof/val-prof-9.c: New test. diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C new file mode 100644 index 00000000000..f0e81e9b042 --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C @@ -0,0 +1,23 @@ +/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */ +/* { dg-do run { target native } } */ + +int value; + +extern "C" { void __gcov_dump(void); } + +int main(int argc, char **argv) +{ + value = 123; /* count(1) */ + + for (unsigned i = 0; i < 100; i++) + value += argc; /* count(100) */ + + __gcov_dump(); + + for (unsigned i = 0; i < 1000; i++) /* count(#####) */ + value += argc; + + return 0; /* count(#####) */ +} + +/* { dg-final { run-gcov gcov-dump-1.C } } */ diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C new file mode 100644 index 00000000000..6234a81a586 --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C @@ -0,0 +1,32 @@ +/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */ +/* { dg-do run { target native } } */ + +int value; + +extern "C" +{ + void __gcov_dump(void); + void __gcov_reset(void); +} + +int main(int argc, char **argv) +{ + value = 123; /* count(1) */ + + for (unsigned i = 0; i < 100; i++) + value += argc; /* count(100) */ + + __gcov_dump(); + + for (unsigned i = 0; i < 1000; i++) /* count(#####) */ + value += argc; + + __gcov_reset (); + + for (unsigned i = 0; i < 10000; i++) /* count(10001) */ + value += argc; + + return 0; /* count(1) */ +} + +/* { dg-final { run-gcov gcov-dump-2.C } } */ -- 2.30.2