Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 2/2] lavu/tests/opts: add tests for filepath options
Date: Fri,  4 Mar 2022 16:03:07 +0100
Message-ID: <20220304150307.61769-2-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20220304150307.61769-1-ffmpeg@haasn.xyz>

From: Niklas Haas <git@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

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-03-04 15:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 15:03 [FFmpeg-devel] [PATCH 1/2] lavu: add syntax for loading AV_OPT_TYPE_BINARY from files Niklas Haas
2022-03-04 15:03 ` Niklas Haas [this message]
2022-03-05 19:16   ` [FFmpeg-devel] [PATCH 2/2] lavu/tests/opts: add tests for filepath options Michael Niedermayer
2022-03-08  7:47     ` J. Dekker
2022-03-08 13:36       ` Michael Niedermayer
2022-03-08 11:48 ` [FFmpeg-devel] [PATCH 1/2] lavu: add syntax for loading AV_OPT_TYPE_BINARY from files Anton Khirnov
2022-03-08 12:53   ` Niklas Haas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220304150307.61769-2-ffmpeg@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git