FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/tests/mkdir.c
Date: 2026-08-31 11:24:46
Exec Total Coverage
Lines: 8 18 44.4%
Functions: 1 1 100.0%
Branches: 4 8 50.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2026 Jun Zhao
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "config.h"
22
23 #include <errno.h>
24 #include <stdio.h>
25
26 #if HAVE_UNISTD_H
27 #include <unistd.h>
28 #endif
29
30 #include "libavutil/random_seed.h"
31
32 #include "libavformat/internal.h"
33 #include "libavformat/os_support.h"
34
35 1 int main(void)
36 {
37 char parent[64];
38 char child[80];
39
40 1 snprintf(parent, sizeof(parent), "ff-mkdir-test-%08x", av_get_random_seed());
41 1 snprintf(child, sizeof(child), "%s/child", parent);
42
43
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (mkdir(parent, 0755) < 0) {
44 perror("mkdir parent");
45 return 1;
46 }
47
48
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (ff_mkdir_p(child) < 0) {
49 perror("ff_mkdir_p");
50 rmdir(parent);
51 return 1;
52 }
53
54
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (rmdir(child) < 0) {
55 perror("rmdir child");
56 rmdir(parent);
57 return 1;
58 }
59
60
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (rmdir(parent) < 0) {
61 perror("rmdir parent");
62 return 1;
63 }
64
65 1 return 0;
66 }
67