randdisable (2003B)
1 #!/usr/bin/env perl 2 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 # 4 # SPDX-License-Identifier: curl 5 # 6 # This script makes a "random" build using configure and verifies that it 7 # builds curl correctly. It randomly adds a number of the available 8 # --disable-* flags to configure. When it detects a problem the script stops, 9 # otherwise it continues trying more combinations. 10 # 11 # 1. Figure out all existing configure --disable-* options 12 # 2. Generate random command line using supported options + random TLS 13 # 3. Run configure (exit if problem) 14 # 4. run "make -sj10" to build (exit if problem) 15 # 5. run curl -V (exit if problem) 16 # 6. GOTO 2 17 # 18 # Tips: 19 # 20 # - edit the @tls array to include all TLS backends you can build with 21 # - do a checkout in a ram-based filesystem 22 # 23 use List::Util qw/shuffle/; 24 25 sub getoptions { 26 my @all = `./configure --help`; 27 for my $o (@all) { 28 chomp $o; 29 if($o =~ /(--disable-[^ ]*)/) { 30 if($1 !~ /FEATURE/) { 31 push @disable, $1; 32 } 33 } 34 } 35 } 36 37 getoptions(); 38 39 # options to select a TLS 40 my @tls = ("--with-openssl", 41 "--with-wolfssl=/home/daniel/build-wolfssl", 42 "--with-gnutls", 43 "--with-mbedtls"); 44 45 do { 46 47 # get a random number of disable options 48 my $num = rand(scalar(@disable) - 2) + 2; 49 50 my $c = 0; 51 my $arg; 52 for my $d (shuffle @disable) { 53 $arg .= " $d"; 54 if(++$c >= $num) { 55 last; 56 } 57 } 58 59 my @stls = shuffle @tls; 60 $arg.= " ".$stls[0]; 61 62 system("make clean"); 63 if(system("./configure $arg")) { 64 print STDERR "configure problem\n"; 65 print STDERR "./configure $arg\n"; 66 exit 1; 67 } 68 if(system("make -sj10")) { 69 print STDERR "Build problem\n"; 70 print STDERR "./configure $arg\n"; 71 exit 1; 72 } 73 if(system("./src/curl -V 2>/dev/null")) { 74 print STDERR "Running problem\n"; 75 print STDERR "./configure $arg\n"; 76 exit 1; 77 } 78 } while(1);