]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libsframe/testsuite/libsframe.decode/frecnt-2.c
1 /* frecnt-2.c -- Test for decoder in libsframe.
3 Copyright (C) 2022-2023 Free Software Foundation, Inc.
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, see <http://www.gnu.org/licenses/>. */
24 #include "sframe-api.h"
26 /* DejaGnu should not use gnulib's vsnprintf replacement here. */
31 * SFrame info from the following source (2 fde 8 fres):
33 * int foo() { return ++cnt; }
34 * int main() { return foo(); }
41 sframe_decoder_ctx
*dctx
= NULL
;
42 uint32_t nfres
, fsize
;
52 #define TEST(name, cond) \
62 fp
= fopen (DATA
, "r");
65 if (fstat (fileno (fp
), &st
) < 0)
71 sf_buf
= malloc (st
.st_size
);
79 sf_size
= fread (sf_buf
, 1, st
.st_size
, fp
);
81 TEST ("frecnt-2: Read data", sf_size
!= 0);
83 dctx
= sframe_decode (sf_buf
, sf_size
, &err
);
84 TEST ("frecnt-2: Decode setup", dctx
!= NULL
);
86 unsigned int fde_cnt
= sframe_decoder_get_num_fidx (dctx
);
87 TEST ("frecnt-2: Decode FDE count", fde_cnt
== 2);
89 for (i
= 0; i
< fde_cnt
; ++i
)
91 err
= sframe_decoder_get_funcdesc (dctx
, i
, &nfres
, &fsize
, &fstart
,
93 TEST ("frecnt-2: Decode get FDE", err
== 0);
94 TEST ("frecnt-2: Decode get FRE", nfres
== 4);
100 sframe_decoder_free (&dctx
);
104 sframe_decoder_free (&dctx
);
105 fail ("frecnt-2: Test setup");