Blame test/recipes/99-test_fuzz.t

Packit c4476c
#!/usr/bin/env perl
Packit c4476c
# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
#
Packit c4476c
# Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
# this file except in compliance with the License.  You can obtain a copy
Packit c4476c
# in the file LICENSE in the source distribution or at
Packit c4476c
# https://www.openssl.org/source/license.html
Packit c4476c
Packit c4476c
use strict;
Packit c4476c
use warnings;
Packit c4476c
Packit c4476c
use OpenSSL::Glob;
Packit c4476c
use OpenSSL::Test qw/:DEFAULT srctop_file/;
Packit c4476c
use OpenSSL::Test::Utils;
Packit c4476c
Packit c4476c
setup("test_fuzz");
Packit c4476c
Packit c4476c
my @fuzzers = ('asn1', 'asn1parse', 'bignum', 'bndiv', 'client', 'conf', 'crl', 'server', 'x509');
Packit c4476c
if (!disabled("cms")) {
Packit c4476c
    push @fuzzers, 'cms';
Packit c4476c
}
Packit c4476c
if (!disabled("ct")) {
Packit c4476c
    push @fuzzers, 'ct';
Packit c4476c
}
Packit c4476c
plan tests => scalar @fuzzers;
Packit c4476c
Packit c4476c
foreach my $f (@fuzzers) {
Packit c4476c
    subtest "Fuzzing $f" => sub {
Packit c4476c
        my @dirs = glob(srctop_file('fuzz', 'corpora', $f));
Packit c4476c
        push @dirs, glob(srctop_file('fuzz', 'corpora', "$f-*"));
Packit c4476c
Packit c4476c
        plan skip_all => "No corpora for $f-test" unless @dirs;
Packit c4476c
Packit c4476c
        plan tests => scalar @dirs;
Packit c4476c
Packit c4476c
        foreach (@dirs) {
Packit c4476c
            ok(run(fuzz(["$f-test", $_])));
Packit c4476c
        }
Packit c4476c
    }
Packit c4476c
}