]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1276: verify lib/optiontable.pl
authorDaniel Stenberg <daniel@haxx.se>
Mon, 28 Nov 2022 15:34:01 +0000 (16:34 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 29 Nov 2022 13:45:27 +0000 (14:45 +0100)
Checks that it generates an output identical to the file.

tests/Makefile.am
tests/data/Makefile.inc
tests/data/test1276 [new file with mode: 0644]
tests/option-check.pl [new file with mode: 0755]

index 5da7423244afa9ebfe2d4b462997934a81088718..49d3911671fbd2bd1f9e966c6a5f293e616ef6a3 100644 (file)
@@ -32,10 +32,9 @@ EXTRA_DIST = ftpserver.pl httpserver.pl secureserver.pl runtests.pl           \
  serverhelp.pm tftpserver.pl rtspserver.pl directories.pm symbol-scan.pl      \
  CMakeLists.txt mem-include-scan.pl valgrind.supp extern-scan.pl              \
  manpage-scan.pl nroff-scan.pl http2-server.pl dictserver.py                  \
- negtelnetserver.py smbserver.py util.py                                      \
- disable-scan.pl manpage-syntax.pl error-codes.pl badsymbols.pl               \
- azure.pm appveyor.pm version-scan.pl options-scan.pl markdown-uppercase.pl   \
- check-deprecated.pl
+ negtelnetserver.py smbserver.py util.py disable-scan.pl manpage-syntax.pl    \
+ error-codes.pl badsymbols.pl azure.pm appveyor.pm version-scan.pl            \
+ options-scan.pl markdown-uppercase.pl check-deprecated.pl option-check.pl
 
 DISTCLEANFILES = configurehelp.pm
 
index 905e803e845c659a539f0676bc93f3a82c228f08..2f13f15ee5d5a54f621a164ef55892ebcf6c47c2 100644 (file)
@@ -153,14 +153,13 @@ test1191 test1192 test1193 test1194 test1195 test1196 test1197 test1198 \
 test1199 test1200 test1201 test1202 test1203 test1204 test1205 test1206 \
 test1207 test1208 test1209 test1210 test1211 test1212 test1213 test1214 \
 test1215 test1216 test1217 test1218 test1219 test1220 test1221 test1222 \
-test1223 \
-test1224 test1225 test1226 test1227 test1228 test1229 test1230 test1231 \
-test1232 test1233 test1234 test1235 test1236 test1237 test1238 test1239 \
-test1240 test1241 test1242 test1243 test1244 test1245 test1246 test1247 \
-test1248 test1249 test1250 test1251 test1252 test1253 test1254 test1255 \
-test1256 test1257 test1258 test1259 test1260 test1261 test1262 test1263 \
-test1264 test1265 test1266 test1267 test1268 test1269 test1270 test1271 \
-test1272 test1273 test1274 test1275 \
+test1223 test1224 test1225 test1226 test1227 test1228 test1229 test1230 \
+test1231 test1232 test1233 test1234 test1235 test1236 test1237 test1238 \
+test1239 test1240 test1241 test1242 test1243 test1244 test1245 test1246 \
+test1247 test1248 test1249 test1250 test1251 test1252 test1253 test1254 \
+test1255 test1256 test1257 test1258 test1259 test1260 test1261 test1262 \
+test1263 test1264 test1265 test1266 test1267 test1268 test1269 test1270 \
+test1271 test1272 test1273 test1274 test1275 test1276 \
 \
 test1280 test1281 test1282 test1283 test1284 test1285 test1286 test1287 \
 test1288 test1289 test1290 test1291 test1292 test1293 test1294 test1295 \
diff --git a/tests/data/test1276 b/tests/data/test1276
new file mode 100644 (file)
index 0000000..2526cdf
--- /dev/null
@@ -0,0 +1,25 @@
+<testcase>
+<info>
+<keywords>
+source analysis
+documentation
+</keywords>
+</info>
+
+#
+# Client-side
+<client>
+<server>
+none
+</server>
+
+ <name>
+Verify lib/optiontable.pl
+ </name>
+
+<command type="perl">
+%SRCDIR/option-check.pl %SRCDIR/..
+</command>
+</client>
+
+</testcase>
diff --git a/tests/option-check.pl b/tests/option-check.pl
new file mode 100755 (executable)
index 0000000..191b244
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/env perl
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) 2016 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+
+sub showline {
+    my ($l) = @_;
+    $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
+    return $l;
+}
+
+my $root = $ARGV[0];
+
+open(F, "perl $root/lib/optiontable.pl < $root/include/curl/curl.h|");
+binmode F;
+my @gen=<F>;
+close(F);
+
+open(F, "<$root/lib/easyoptions.c");
+binmode F;
+my @file=<F>;
+close(F);
+
+if(join("", @gen) ne join("", @file)) {
+    print "easyoptions.c need to be regenerated!\n";
+
+    printf "easyoptions.c is %u lines\n", scalar(@file);
+    printf "generated file is %u lines\n", scalar(@gen);
+    my $e = 0;
+    for my $i (0 .. $#gen) {
+        # strip CRLFs to unify
+        $gen[$i] =~ s/[\r\n]//g;
+        $file[$i] =~ s/[\r\n]//g;
+        if($gen[$i] ne $file[$i]) {
+            printf "File: %u:%s\nGen:  %u:%s\n",
+                $i+1, showline($file[$i]),
+                $i+1, showline($gen[$i]);
+            $e++;
+            if($e > 10) {
+                # only show 10 lines diff
+                last;
+            }
+        }
+    }
+    exit 1 if($e);
+}