[FFmpeg-devel] [PATCH 2/2] lavu/tests/opts: add tests for filepath options
Niklas Haas
ffmpeg at haasn.xyz
Fri Mar 4 17:03:07 EET 2022
From: Niklas Haas <git at haasn.dev>
Using the venerable HEADER.txt as a small file to load.
---
libavutil/tests/opt.c | 38 +++++++++++++++++++++++++++++++++++++-
tests/fate/libavutil.mak | 2 +-
tests/ref/fate/opt | 4 ++++
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index e6ea892373..e3d4edee4e 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -113,7 +113,7 @@ static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
vfprintf(stdout, fmt, vl);
}
-int main(void)
+int main(int argc, const char **argv)
{
int i;
@@ -355,5 +355,41 @@ int main(void)
av_opt_free(&test_ctx);
}
+ printf("\nTesting av_opt_set_filepath()\n");
+ {
+ TestContext test_ctx = { 0 };
+ const char *samples;
+ char buf[256];
+ uint8_t *value;
+ int ret = AVERROR_BUG;
+
+ if (argc < 2)
+ return 1;
+ samples = argv[1];
+
+ test_ctx.class = &test_class;
+ av_opt_set_defaults(&test_ctx);
+ av_log_set_level(AV_LOG_QUIET);
+
+ if (snprintf(buf, sizeof(buf), "@%s/HEADER.txt", samples) >= sizeof(buf))
+ return 1;
+
+ ret = av_opt_set_filepath(&test_ctx, "bin", &buf[1], 0);
+ if (!ret)
+ ret = av_opt_get(&test_ctx, "bin", 0, &value);
+ printf("av_opt_set_filepath: bin='%s'\n",
+ ret ? av_err2str(ret) : (char *) value);
+ av_free(value);
+
+ ret = av_opt_set(&test_ctx, "bin", buf, 0);
+ if (!ret)
+ ret = av_opt_get(&test_ctx, "bin", 0, &value);
+ printf("av_opt_set: bin='%s'\n",
+ ret ? av_err2str(ret) : (char *) value);
+ av_free(value);
+
+ av_opt_free(&test_ctx);
+ }
+
return 0;
}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 1ec9ed00ad..587aa810cd 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -164,7 +164,7 @@ fate-tea: CMD = run libavutil/tests/tea$(EXESUF)
FATE_LIBAVUTIL += fate-opt
fate-opt: libavutil/tests/opt$(EXESUF)
-fate-opt: CMD = run libavutil/tests/opt$(EXESUF)
+fate-opt: CMD = run libavutil/tests/opt$(EXESUF) $(TARGET_SAMPLES)
FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index aac3fa0e7e..341693d097 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -417,3 +417,7 @@ Setting options string 'a_very_long_option_name_that_will_need_to_be_ellipsized_
Setting 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' to value '42'
Option 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' not found
Error 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42'
+
+Testing av_opt_set_filepath()
+av_opt_set_filepath: bin='46415445202D2046466D706567204175746F6D617465642054657374696E6720456E7669726F6E6D656E740A687474703A2F2F666174652E6D756C74696D656469612E63782F0A0A'
+av_opt_set: bin='46415445202D2046466D706567204175746F6D617465642054657374696E6720456E7669726F6E6D656E740A687474703A2F2F666174652E6D756C74696D656469612E63782F0A0A'
--
2.35.1
More information about the ffmpeg-devel
mailing list