---
libavutil/tests/file_open.c | 45 +++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/libavutil/tests/file_open.c b/libavutil/tests/file_open.c
index 4ddbfa21c5..b22fa1bd45 100644
--- a/libavutil/tests/file_open.c
+++ b/libavutil/tests/file_open.c
@@ -17,12 +17,53 @@
*/
#include <fcntl.h>
+#include <stdio.h>
#include "libavutil/file_open.h"
int main(void)
{
- int fd = avpriv_open("no_such_file_xyz", O_RDONLY);
+ FILE *f;
+ int fd;
+
+ /* avpriv_open: non-existent file must return negative fd */
+ fd = avpriv_open("no_such_file_xyz", O_RDONLY);
if (fd >= 0)
- return 1; /* should have failed */
+ return 1;
+
+ /* avpriv_fopen_utf8: invalid mode → default branch → must return NULL */
+ f = avpriv_fopen_utf8("no_such_file_xyz", "x");
+ if (f != NULL)
+ return 2;
+
+ /* avpriv_fopen_utf8: mode 'r' on non-existent file → fd==-1 branch */
+ f = avpriv_fopen_utf8("no_such_file_xyz", "r");
+ if (f != NULL)
+ return 3;
+
+ /* avpriv_fopen_utf8: mode 'w' → O_WRONLY|O_CREAT|O_TRUNC branch */
+ f = avpriv_fopen_utf8("fate_file_open_tmp", "w");
+ if (!f)
+ return 4;
+ fclose(f);
+
+ /* avpriv_fopen_utf8: mode 'a' → O_APPEND branch */
+ f = avpriv_fopen_utf8("fate_file_open_tmp", "a");
+ if (!f)
+ return 5;
+ fclose(f);
+
+ /* avpriv_fopen_utf8: mode 'r+' → while(*m) loop + '+' branch */
+ f = avpriv_fopen_utf8("fate_file_open_tmp", "r+");
+ if (!f)
+ return 6;
+ fclose(f);
+
+ /* avpriv_fopen_utf8: mode 'rb' → while(*m) loop + 'b' branch */
+ f = avpriv_fopen_utf8("fate_file_open_tmp", "rb");
+ if (!f)
+ return 7;
+ fclose(f);
+
+ remove("fate_file_open_tmp");
return 0;
}
--
2.51.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]