FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/tests/error.c
Date: 2026-09-30 10:56:58
Exec Total Coverage
Lines: 9 14 64.3%
Functions: 1 1 100.0%
Branches: 6 8 75.0%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "libavutil/error.c"
20
21 /* errno descriptions depend on the C library, so those are only looked up */
22 static const struct {
23 int num;
24 const char *tag;
25 } ffmpeg_codes[] = {
26 #define ERROR_TAG(CODE, DESC) { AVERROR_ ## CODE, #CODE },
27 #define ERROR_TAG2(CODE, CODE2, DESC) { AVERROR_ ## CODE, #CODE },
28 AVERROR_LIST(ERROR_TAG, ERROR_TAG2)
29 };
30
31 static const int errno_codes[] = {
32 #define ERRNO_CODE(CODE, DESC) AVERROR(CODE),
33 STRERROR_LIST(ERRNO_CODE)
34 };
35
36 1 int main(void)
37 {
38 char buf[AV_ERROR_MAX_STRING_SIZE];
39 1 int ret = 0;
40
41
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1 times.
30 for (size_t i = 0; i < FF_ARRAY_ELEMS(ffmpeg_codes); i++) {
42 29 int num = ffmpeg_codes[i].num;
43
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
29 if (av_strerror(num, buf, sizeof(buf)) < 0) {
45 ✗ printf("%d: lookup failed [%s]\n", num, ffmpeg_codes[i].tag);
46 ✗ ret = 1;
47 ✗ continue;
48 }
49 29 printf("%d: %s [%s]\n", num, buf, ffmpeg_codes[i].tag);
50 }
51
52
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1 times.
39 for (size_t i = 0; i < FF_ARRAY_ELEMS(errno_codes); i++) {
53
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
38 if (av_strerror(errno_codes[i], buf, sizeof(buf)) < 0) {
54 ✗ printf("errno %d: lookup failed\n", AVUNERROR(errno_codes[i]));
55 ✗ ret = 1;
56 }
57 }
58
59 1 return ret;
60 }
61