Browse code

lavf: Add a fate test for the noproxy pattern matching

Signed-off-by: Martin Storsjö <martin@martin.st>

Martin Storsjö authored on 2013/02/27 18:45:16
Showing 4 changed files
... ...
@@ -380,7 +380,8 @@ SKIPHEADERS-$(CONFIG_NETWORK)            += network.h rtsp.h
380 380
 EXAMPLES  = metadata                                                    \
381 381
             output                                                      \
382 382
 
383
-TESTPROGS = seek                                                        \
383
+TESTPROGS = noproxy                                                     \
384
+            seek                                                        \
384 385
             srtp                                                        \
385 386
             url                                                         \
386 387
 
387 388
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+/*
1
+ * Copyright (c) 2013 Martin Storsjo
2
+ *
3
+ * This file is part of Libav.
4
+ *
5
+ * Libav is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * Libav is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with Libav; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#include "internal.h"
21
+
22
+static void test(const char *pattern, const char *host)
23
+{
24
+    int res = ff_http_match_no_proxy(pattern, host);
25
+    printf("The pattern \"%s\" %s the hostname %s\n",
26
+           pattern ? pattern : "(null)", res ? "matches" : "does not match",
27
+           host);
28
+}
29
+
30
+int main(void)
31
+{
32
+    test(NULL, "domain.com");
33
+    test("example.com domain.com", "domain.com");
34
+    test("example.com other.com", "domain.com");
35
+    test("example.com,domain.com", "domain.com");
36
+    test("example.com,domain.com", "otherdomain.com");
37
+    test("example.com, *.domain.com", "sub.domain.com");
38
+    test("example.com, *.domain.com", "domain.com");
39
+    test("example.com, .domain.com", "domain.com");
40
+    test("*", "domain.com");
41
+    return 0;
42
+}
... ...
@@ -1,3 +1,7 @@
1
+FATE_LIBAVFORMAT += fate-noproxy
2
+fate-noproxy: libavformat/noproxy-test$(EXESUF)
3
+fate-noproxy: CMD = run libavformat/noproxy-test
4
+
1 5
 FATE_LIBAVFORMAT += fate-srtp
2 6
 fate-srtp: libavformat/srtp-test$(EXESUF)
3 7
 fate-srtp: CMD = run libavformat/srtp-test
4 8
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+The pattern "(null)" does not match the hostname domain.com
1
+The pattern "example.com domain.com" matches the hostname domain.com
2
+The pattern "example.com other.com" does not match the hostname domain.com
3
+The pattern "example.com,domain.com" matches the hostname domain.com
4
+The pattern "example.com,domain.com" does not match the hostname otherdomain.com
5
+The pattern "example.com, *.domain.com" matches the hostname sub.domain.com
6
+The pattern "example.com, *.domain.com" matches the hostname domain.com
7
+The pattern "example.com, .domain.com" matches the hostname domain.com
8
+The pattern "*" matches the hostname domain.com