xref: /curl/tests/libtest/test1013.pl (revision 5b87b4ed)
1#!/usr/bin/env perl
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24###########################################################################
25# Determine if curl-config --protocols/--features matches the
26# curl --version protocols/features
27if ( $#ARGV != 2 )
28{
29    print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n";
30    exit 3;
31}
32
33my $what=$ARGV[2];
34
35# Read the output of curl --version
36my $curl_protocols="";
37open(CURL, "$ARGV[1]") || die "Can't get curl $what list\n";
38while( <CURL> )
39{
40    $curl_protocols = $_ if ( /$what:/i );
41}
42close CURL;
43
44$curl_protocols =~ s/\r//;
45$curl_protocols =~ /\w+: (.*)$/;
46@curl = split / /,$1;
47
48# Read the output of curl-config
49my @curl_config;
50open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config $what list\n";
51while( <CURLCONFIG> )
52{
53    chomp;
54    $_ = lc($_) if($what eq "protocols");  # accept uppercase protocols in curl-config
55    push @curl_config, $_;
56}
57close CURLCONFIG;
58
59# allow order mismatch to handle autotools builds with no 'sort -f' available
60if($what eq "features") {
61    @curl = sort @curl;
62    @curl_config = sort @curl_config;
63}
64
65my $curlproto = join ' ', @curl;
66my $curlconfigproto = join ' ', @curl_config;
67
68my $different = $curlproto ne $curlconfigproto;
69if ($different) {
70    print "Mismatch in $what lists:\n";
71    print "curl:        $curlproto\n";
72    print "curl-config: $curlconfigproto\n";
73}
74exit $different;
75