1 # Copyright (C) 2021-2024 Free Software Foundation, Inc.
3 # This file is part of the GNU Binutils.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 # This script tests the -a option for "profng archive".
23 global srcdir CC CLOCK_GETTIME_LINK
24 set gprofng $::env(GPROFNG)
25 set tdir "tmpdir/gp-archive"
27 proc check_gp_archive { a_opt } {
29 set cmd "$gprofng archive -a $a_opt $tdir/exp.er"
30 set output [run_native_host_cmd "$cmd"]
31 if { [lindex $output 0] != 0 } then {
32 set out [lindex $output 1]
33 send_log "'$cmd' failed\n"
38 run_native_host_cmd "mv $tdir/t.c $tdir/t.c.1"
39 set output [run_native_host_cmd "$gprofng display text -source main $tdir/exp.er"]
40 set out [lindex $output 1]
41 if { [string first "CORRECTSOURCE" [lindex $output 1]] < 0 } then {
42 set out [lindex $output 1]
43 send_log "CORRECTSOURCE is not found aafter '$cmd'\n"
49 run_native_host_cmd "mkdir -p $tdir"
51 # Build test, create experiment:
52 set output [run_native_host_cmd "cd $tdir && \
53 cat $srcdir/lib/smalltest.c | sed '1 i /* CORRECTSOURCE */' > t.c && \
54 $CC -g t.c $CLOCK_GETTIME_LINK && \
55 $gprofng collect app -p on -a off -O exp.er ./a.out"]
57 if { [lindex $output 0] != 0 } then {
58 set out [lindex $output 1]
59 send_log "Experiment is not created in $tdir\n"
67 run_native_host_cmd "rm -rf $tdir/exp.er/archives/*; mv $tdir/t.c.1 $tdir/t.c"
68 check_gp_archive usedsrc