From 8887364d8bf5081c5a539ca5bbaa31b3a6f62e40 Mon Sep 17 00:00:00 2001
From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Date: Mon, 11 Jun 2012 01:20:32 +0900
Subject: [PATCH 4/4] Added Metalink test case

---
 tests/FILEFORMAT       |    1 +
 tests/data/Makefile.am |    2 +-
 tests/data/test2005    |   65 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/runtests.pl      |   10 +++++++
 4 files changed, 77 insertions(+), 1 deletions(-)
 create mode 100644 tests/data/test2005

diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT
index 5432b43..66f0dfe 100644
--- a/tests/FILEFORMAT
+++ b/tests/FILEFORMAT
@@ -186,6 +186,7 @@ socks
 unittest
 debug
 TLS-SRP
+Metalink
 
 as well as each protocol that curl supports.  A protocol only needs to be
 specified if it is different from the server (useful when the server
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 7408547..6f098ba 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -92,7 +92,7 @@ test1371 test1372 test1373 test1374 test1375 test1376 test1377 test1378 \
 test1379 test1380 test1381 test1382 test1383 test1384 test1385 test1386 \
 test1387 test1388 test1389 test1390 test1391 test1392 test1393 \
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
-test2000 test2001 test2002 test2003 test2004
+test2000 test2001 test2002 test2003 test2004 test2005
 
 EXTRA_DIST = $(TESTCASES) DISABLED
 
diff --git a/tests/data/test2005 b/tests/data/test2005
new file mode 100644
index 0000000..8120458
--- /dev/null
+++ b/tests/data/test2005
@@ -0,0 +1,65 @@
+<testcase>
+<info>
+<keywords>
+Metalink
+HTTP
+HTTP GET
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data1 nocheck="yes">
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 35
+Connection: close
+Content-Type: application/metalink+xml
+Funny-head: yesyes
+
+All your metalink are belong to us
+</data1>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+<features>
+Metalink
+</features>
+ <name>
+Metalink XML file processing
+ </name>
+ <command option="no-include">
+--metalink file://%PWD/log/metalink2005
+</command>
+<file name="log/metalink2005">
+<?xml version="1.0" encoding="utf-8"?><metalink version="3.0" generator="Metalink Editor version 1.1.0" xmlns="http://www.metalinker.org/"><files><file name="log/file2005"><verification><hash type="sha256">f47557729497cc64ee4cd1eefc9709220800252ce045617c1b358608c7bc860a</hash></verification><resources maxconnections="1"><url type="http" preference="99">http://%HOSTIP:%HTTPPORT/20050001</url></resources></file></files></metalink>
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /20050001 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+<file name="log/file2005">
+All your metalink are belong to us
+</file>
+</verify>
+</testcase>
diff --git a/tests/runtests.pl b/tests/runtests.pl
index ed234be..a90d0ec 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -211,6 +211,7 @@ my $has_ntlm;    # set if libcurl is built with NTLM support
 my $has_ntlm_wb; # set if libcurl is built with NTLM delegation to winbind
 my $has_charconv;# set if libcurl is built with CharConv support
 my $has_tls_srp; # set if libcurl is built with TLS-SRP support
+my $has_metalink;# set if curl is build with libmetalink
 
 my $has_openssl; # built with a lib using an OpenSSL-like API
 my $has_gnutls;  # built with GnuTLS
@@ -2339,6 +2340,10 @@ sub checksystem {
                 # TLS-SRP enabled
                 $has_tls_srp=1;
             }
+            if($feat =~ /Metalink/i) {
+                # Metalink enabled
+                $has_metalink=1;
+            }
         }
         #
         # Test harness currently uses a non-stunnel server in order to
@@ -2749,6 +2754,11 @@ sub singletest {
                 next;
             }
         }
+        elsif($f eq "Metalink") {
+            if($has_metalink) {
+                next;
+            }
+        }
         elsif($f eq "socks") {
             next;
         }
-- 
1.7.9.1

