Affix
view release on metacpan or search on metacpan
fuzz/fuzz_shared_lib.pl view on Meta::CPAN
use v5.40;
use blib;
use lib 'blib/lib', 'lib';
use Affix qw[:all];
use Test2::Tools::Affix qw[:all];
use Test2::V0 -no_srand => 1;
use Config;
use Data::Dumper;
$Data::Dumper::Terse = 1;
$|++;
#
my $max_iter = $ENV{FUZZ_MAX_ITER} // 1000;
my $timeout = $ENV{FUZZ_TIMEOUT} // 5;
my $verbose = $ENV{FUZZ_VERBOSE} // 0;
sub compile_source ($code) { compile_ok( <<~'' . $code ) }
#include <inttypes.h>
#include <locale.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h> // offsetof
#include <stdio.h>
#include <stdlib.h> // malloc
#include <string.h>
#include <stdint.h>
#include <wchar.h>
// Some tests might actually include perl.h which has the real version of this
#if !defined(warn)
#define warn(FORMAT, ...) \
fprintf(stderr, FORMAT " at %s line %i\n", ##__VA_ARGS__, __FILE__, __LINE__); \
fflush(stderr);
#endif
#if defined _WIN32 || defined __CYGWIN__
#include <BaseTsd.h>
//typedef SSIZE_T ssize_t;
typedef signed __int64 int64_t;
#ifdef __GNUC__
#define DLLEXPORT __attribute__((dllexport))
#else
#define DLLEXPORT __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#if __GNUC__ >= 4
#define DLLEXPORT __attribute__((visibility("default")))
#else
#define DLLEXPORT __attribute__((dllimport))
#endif
#else
#define DLLEXPORT __declspec(dllexport)
#endif
#include <inttypes.h>
#include <sys/types.h>
#endif
//ext: .c
# Type catalog: { c_type, infix_sig, perl_type, gen_value }
# Ranges are derived from sizeof() at runtime so they match the actual platform.
my @PRIMITIVES;
{
my @signed_ints = (
[ 'int8_t', 'sint8', sub { SInt8() } ],
[ 'int16_t', 'sint16', sub { SInt16() } ],
[ 'int32_t', 'sint32', sub { SInt32() } ],
[ 'int64_t', 'sint64', sub { SInt64() } ],
[ 'char', 'char', sub { Char() } ],
[ 'short', 'short', sub { Short() } ],
[ 'int', 'int', sub { Int() } ],
[ 'long', 'long', sub { Long() } ],
[ 'long long', 'longlong', sub { LongLong() } ]
);
my @unsigned_ints = (
[ 'uint8_t', 'uint8', sub { UInt8() } ],
[ 'uint16_t', 'uint16', sub { UInt16() } ],
[ 'uint32_t', 'uint32', sub { UInt32() } ],
[ 'uint64_t', 'uint64', sub { UInt64() } ],
[ 'unsigned char', 'uchar', sub { UChar() } ],
( run in 3.303 seconds using v1.01-cache-2.11-cpan-941387dca55 )