xref: /aosp_15_r20/external/curl/tests/test1276.pl (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker#!/usr/bin/env perl
2*6236dae4SAndroid Build Coastguard Worker#***************************************************************************
3*6236dae4SAndroid Build Coastguard Worker#                                  _   _ ____  _
4*6236dae4SAndroid Build Coastguard Worker#  Project                     ___| | | |  _ \| |
5*6236dae4SAndroid Build Coastguard Worker#                             / __| | | | |_) | |
6*6236dae4SAndroid Build Coastguard Worker#                            | (__| |_| |  _ <| |___
7*6236dae4SAndroid Build Coastguard Worker#                             \___|\___/|_| \_\_____|
8*6236dae4SAndroid Build Coastguard Worker#
9*6236dae4SAndroid Build Coastguard Worker# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
10*6236dae4SAndroid Build Coastguard Worker#
11*6236dae4SAndroid Build Coastguard Worker# This software is licensed as described in the file COPYING, which
12*6236dae4SAndroid Build Coastguard Worker# you should have received as part of this distribution. The terms
13*6236dae4SAndroid Build Coastguard Worker# are also available at https://curl.se/docs/copyright.html.
14*6236dae4SAndroid Build Coastguard Worker#
15*6236dae4SAndroid Build Coastguard Worker# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16*6236dae4SAndroid Build Coastguard Worker# copies of the Software, and permit persons to whom the Software is
17*6236dae4SAndroid Build Coastguard Worker# furnished to do so, under the terms of the COPYING file.
18*6236dae4SAndroid Build Coastguard Worker#
19*6236dae4SAndroid Build Coastguard Worker# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20*6236dae4SAndroid Build Coastguard Worker# KIND, either express or implied.
21*6236dae4SAndroid Build Coastguard Worker#
22*6236dae4SAndroid Build Coastguard Worker# SPDX-License-Identifier: curl
23*6236dae4SAndroid Build Coastguard Worker#
24*6236dae4SAndroid Build Coastguard Worker###########################################################################
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard Workersub showline {
27*6236dae4SAndroid Build Coastguard Worker    my ($l) = @_;
28*6236dae4SAndroid Build Coastguard Worker    $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
29*6236dae4SAndroid Build Coastguard Worker    return $l;
30*6236dae4SAndroid Build Coastguard Worker}
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard Workermy $root = $ARGV[0];
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard Workeropen(my $fh, "-|", "perl $root/lib/optiontable.pl < $root/include/curl/curl.h");
35*6236dae4SAndroid Build Coastguard Workerbinmode $fh;
36*6236dae4SAndroid Build Coastguard Workermy @gen=<$fh>;
37*6236dae4SAndroid Build Coastguard Workerclose($fh);
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard Workeropen($fh, "<", "$root/lib/easyoptions.c");
40*6236dae4SAndroid Build Coastguard Workerbinmode $fh;
41*6236dae4SAndroid Build Coastguard Workermy @file=<$fh>;
42*6236dae4SAndroid Build Coastguard Workerclose($fh);
43*6236dae4SAndroid Build Coastguard Worker
44*6236dae4SAndroid Build Coastguard Workerif(join("", @gen) ne join("", @file)) {
45*6236dae4SAndroid Build Coastguard Worker    print "easyoptions.c need to be regenerated!\n";
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard Worker    printf "easyoptions.c is %u lines\n", scalar(@file);
48*6236dae4SAndroid Build Coastguard Worker    printf "generated file is %u lines\n", scalar(@gen);
49*6236dae4SAndroid Build Coastguard Worker    my $e = 0;
50*6236dae4SAndroid Build Coastguard Worker    for my $i (0 .. $#gen) {
51*6236dae4SAndroid Build Coastguard Worker        # strip CRLFs to unify
52*6236dae4SAndroid Build Coastguard Worker        $gen[$i] =~ s/[\r\n]//g;
53*6236dae4SAndroid Build Coastguard Worker        $file[$i] =~ s/[\r\n]//g;
54*6236dae4SAndroid Build Coastguard Worker        if($gen[$i] ne $file[$i]) {
55*6236dae4SAndroid Build Coastguard Worker            printf "File: %u:%s\nGen:  %u:%s\n",
56*6236dae4SAndroid Build Coastguard Worker                $i+1, showline($file[$i]),
57*6236dae4SAndroid Build Coastguard Worker                $i+1, showline($gen[$i]);
58*6236dae4SAndroid Build Coastguard Worker            $e++;
59*6236dae4SAndroid Build Coastguard Worker            if($e > 10) {
60*6236dae4SAndroid Build Coastguard Worker                # only show 10 lines diff
61*6236dae4SAndroid Build Coastguard Worker                last;
62*6236dae4SAndroid Build Coastguard Worker            }
63*6236dae4SAndroid Build Coastguard Worker        }
64*6236dae4SAndroid Build Coastguard Worker    }
65*6236dae4SAndroid Build Coastguard Worker    exit 1 if($e);
66*6236dae4SAndroid Build Coastguard Worker}
67