summaryrefslogtreecommitdiff
path: root/libavformat/tests
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2021-04-06 01:10:30 +0200
committerMarton Balint <cus@passwd.hu>2021-04-07 22:14:56 +0200
commitfb4da90fecdefa2508618ca835cd0250be940e04 (patch)
tree54858610d495c24ce27480a16a2a6c37cd4e48c1 /libavformat/tests
parent5dc5f289cefe67457bd16f1950c56911e926385f (diff)
downloadffmpeg-fb4da90fecdefa2508618ca835cd0250be940e04.tar.gz
avformat/url: add ff_make_absolulte_url2 to be able to test windows path cases
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/tests')
-rw-r--r--libavformat/tests/url.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c
index 2eb597bb5e..8644a3e826 100644
--- a/libavformat/tests/url.c
+++ b/libavformat/tests/url.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
#include "libavformat/url.h"
#include "libavformat/avformat.h"
@@ -48,19 +49,30 @@ static void test_decompose(const char *url)
static void test(const char *base, const char *rel)
{
- char buf[200], buf2[200];
+ char buf[200], buf2[200], buf_dos[200], buf_native[200];
int ret;
- ret = ff_make_absolute_url(buf, sizeof(buf), base, rel);
+ ret = ff_make_absolute_url2(buf, sizeof(buf), base, rel, 0);
if (ret < 0) {
printf("%50s %-20s => error %s\n", base, rel, av_err2str(ret));
return;
}
printf("%50s %-20s => %s\n", base, rel, buf);
+ ret = ff_make_absolute_url2(buf_dos, sizeof(buf_dos), base, rel, 1);
+ if (ret < 0)
+ snprintf(buf_dos, sizeof(buf_dos), "error %s", av_err2str(ret));
+ ret = ff_make_absolute_url(buf_native, sizeof(buf_native), base, rel);
+ if (ret < 0)
+ snprintf(buf_native, sizeof(buf_native), "error %s", av_err2str(ret));
+ if (strcmp(buf, buf_dos))
+ printf("%50s %-20sDOS %s\n", base, rel, buf_dos);
+ if (HAVE_DOS_PATHS && strcmp(buf_dos, buf_native) ||
+ !HAVE_DOS_PATHS && strcmp(buf, buf_native))
+ printf("Native mismatch\n");
if (base) {
/* Test in-buffer replacement */
snprintf(buf2, sizeof(buf2), "%s", base);
- ff_make_absolute_url(buf2, sizeof(buf2), buf2, rel);
+ ff_make_absolute_url2(buf2, sizeof(buf2), buf2, rel, 0);
if (strcmp(buf, buf2)) {
printf("In-place handling of %s + %s failed\n", base, rel);
exit(1);
@@ -121,6 +133,21 @@ int main(void)
test("http://server/foo/bar", "..doubledotfile");
test("http://server/foo/bar", "double..dotfile");
test("http://server/foo/bar", "doubledotfile..");
+ test("file1", "file2");
+ test("dir/file1", "file2");
+ test("dir/file1", "../file2");
+ test("dir\\file1", "file2");
+ test("\\\\srv\\shr\\file", "..\\..\\dummy");
+ test("\\\\srv\\shr\\file", "dummy");
+ test("\\\\srv\\shr\\file", "\\\\srv2\\shr2\\file2");
+ test("\\\\srv\\shr\\file", "d:/file");
+ test("C:\\dir\\a", "..\\file");
+ test("C:\\dir\\a", "\\\\srv\\shr\\file");
+ test("C:\\dir\\a", "d:\\file");
+ test("http://a/b", "\\\\srv\\shr\\file");
+ test("http://a/b", "//srv/shr/file");
+ test("http://a/b", "d:\\file");
+ test("http://a/b", "C:/file");
/* From https://tools.ietf.org/html/rfc3986#section-5.4 */
test("http://a/b/c/d;p?q", "g:h"); // g:h