This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit dc8183377cd3c7a7294af68b6bc5108fba354011
Author:     Soham Kute <[email protected]>
AuthorDate: Mon Mar 30 03:43:34 2026 +0530
Commit:     michaelni <[email protected]>
CommitDate: Sun Mar 29 23:01:39 2026 +0000

    avutil/tests/file: replace trivial test with error-path coverage
    
    The original test only mapped the source file and printed its content,
    exercising none of the error branches in av_file_map().
    
    Replace it with a test that maps a real file (path via argv[1] for
    out-of-tree builds) and verifies it is non-empty, then calls
    av_file_map() on a nonexistent file twice: once with log_offset=0 to
    confirm the error is logged at AV_LOG_ERROR, and once with log_offset=1
    to confirm the level is raised by one, covering the
    log_level_offset_offset path in av_vlog().  A custom av_log callback
    captures the emitted level independently of the global log level.
    The two error cases share a single for() loop to avoid duplication.
    
    Add a FATE entry in tests/fate/libavutil.mak with CMP=null since
    there is no fixed stdout to compare.
    
    Signed-off-by: Soham Kute <[email protected]>
---
 libavutil/tests/file.c   | 41 ++++++++++++++++++++++++++++++++++++-----
 tests/fate/libavutil.mak |  5 +++++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/libavutil/tests/file.c b/libavutil/tests/file.c
index 0b151de9a1..5fc3f0b8f1 100644
--- a/libavutil/tests/file.c
+++ b/libavutil/tests/file.c
@@ -16,17 +16,48 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdarg.h>
+#include <stdio.h>
+
 #include "libavutil/file.c"
+#include "libavutil/log.h"
+
+static int last_log_level = -1;
+
+static void log_callback(void *ctx, int level, const char *fmt, va_list args)
+{
+    (void)ctx; (void)fmt; (void)args;
+    last_log_level = level;
+}
 
-int main(void)
+int main(int argc, char **argv)
 {
+    const char *path = argc > 1 ? argv[1] : "file.c";
     uint8_t *buf;
     size_t size;
-    if (av_file_map("file.c", &buf, &size, 0, NULL) < 0)
-        return 1;
 
-    buf[0] = 's';
-    printf("%s", buf);
+    av_log_set_callback(log_callback);
+
+    /* map an existing file and verify it is non-empty and readable */
+    if (av_file_map(path, &buf, &size, 0, NULL) < 0)
+        return 1;
     av_file_unmap(buf, size);
+    if (size == 0)
+        return 1;
+
+    /* for offset i, error must be logged at AV_LOG_ERROR + i */
+    for (int i = 0; i < 2; i++) {
+        last_log_level = -1;
+        if (av_file_map("no_such_file_xyz", &buf, &size, i, NULL) >= 0) {
+            av_file_unmap(buf, size);
+            return 2;
+        }
+        if (last_log_level != AV_LOG_ERROR + i) {
+            fprintf(stderr, "expected level %d with offset=%d, got %d\n",
+                    AV_LOG_ERROR + i, i, last_log_level);
+            return 3;
+        }
+    }
+
     return 0;
 }
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index a93a83dc21..d69a4de863 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -187,6 +187,11 @@ fate-uuid: libavutil/tests/uuid$(EXESUF)
 fate-uuid: CMD = run libavutil/tests/uuid$(EXESUF)
 fate-uuid: CMP = null
 
+FATE_LIBAVUTIL += fate-file
+fate-file: libavutil/tests/file$(EXESUF)
+fate-file: CMD = run libavutil/tests/file$(EXESUF) 
$(SRC_PATH)/libavutil/tests/file.c
+fate-file: CMP = null
+
 FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
 FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
 fate-libavutil: $(FATE_LIBAVUTIL)

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to