1#!/pro/bin/perl
2
3use strict;
4use warnings;
5
6BEGIN {
7    use Test::More;
8    my $tests = 135;
9    unless ($ENV{PERL_CORE}) {
10	require Test::NoWarnings;
11	Test::NoWarnings->import ();
12	$tests++;
13	}
14
15    plan tests => $tests;
16    }
17
18use Config::Perl::V qw( summary );
19
20ok (my $conf = Config::Perl::V::plv2hash (<DATA>), "Read perl -v block");
21ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc );
22
23is ($conf->{build}{osname}, $conf->{config}{osname}, "osname");
24is ($conf->{build}{stamp}, "Feb 28 2023 18:30:03", "Build time");
25is ($conf->{config}{version}, "5.37.10", "reconstructed \$Config{version}");
26
27my $opt = Config::Perl::V::plv2hash ("")->{build}{options};
28foreach my $o (sort qw(
29	DEBUGGING HAS_TIMES MULTIPLICITY PERL_COPY_ON_WRITE PERL_RC_STACK
30	PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_SIPHASH13 PERL_HASH_USE_SBOX32
31	PERLIO_LAYERS PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV
32	PERL_TRACK_MEMPOOL PERL_USE_DEVEL PERL_USE_SAFE_PUTENV USE_64_BIT_ALL
33	USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE
34	USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME
35	USE_LONG_DOUBLE USE_PERL_ATOF USE_PERLIO USE_REENTRANT_API
36	USE_THREAD_SAFE_LOCALE
37	)) {
38    is ($conf->{build}{options}{$o}, 1, "Runtime option $o set");
39    delete $opt->{$o};
40    }
41foreach my $o (sort keys %$opt) {
42    is ($conf->{build}{options}{$o}, 0, "Runtime option $o unset");
43    }
44
45eval { require Digest::MD5; };
46my $md5 = $@ ? "0" x 32 : "964776ac5595a8a584dfba7ee063e4b9";
47ok (my $sig = Config::Perl::V::signature ($conf), "Get signature");
48
49SKIP: {
50    ord "A" == 65 or skip "ASCII-centric test", 1;
51    is ($sig, $md5, "MD5");
52    }
53
54is_deeply ($conf->{build}{patches}, [ "uncommitted-changes" ], "No patches");
55
56my %check = (
57    alignbytes      => 16,
58    api_version     => 37,
59    bincompat5005   => undef,	# GONE, chainsawed
60    byteorder       => 12345678,
61    cc              => "cc",
62    cccdlflags      => "-fPIC",
63    ccdlflags       => "-Wl,-E",
64    config_args     => "-Dusedevel -Duse64bitall -Dusethreads -Duseithreads -Duselongdouble -Doptimize='-O0\\ -g' -Accflags=-DPERL_RC_STACK -des",
65    gccversion      => "12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]",
66    gnulibc_version => "2.37",
67    ivsize          => 8,
68    ivtype          => "long",
69    ld              => "cc",
70    lddlflags       => "-shared -O0 -g -L/pro/local/lib -fstack-protector-strong",
71    ldflags         => "-L/pro/local/lib -fstack-protector-strong",
72    libc            => "/lib/../lib64/libc.so.6",
73    lseektype       => "off_t",
74    osvers          => "6.1.12-1-default",
75    use64bitall     => "define",
76    use64bitint     => "define",
77    usemymalloc     => "n",
78    default_inc_excludes_dot
79		    => "define",
80    );
81is ($conf->{config}{$_}, $check{$_}, "reconstructed \$Config{$_}") for sort keys %check;
82
83ok (my $info = summary ($conf), "A summary");
84ok (exists $info->{$_}, "Summary has $_") for qw( cc config_args usemymalloc default_inc_excludes_dot );
85is ($info->{default_inc_excludes_dot}, "define", "This build has . NOT in INC");
86
87__END__
88Summary of my perl5 (revision 5 version 37 subversion 10) configuration:
89  Derived from: f0cf813c73daf1ae652b454fc8bc4828aec1f049
90  Platform:
91    osname=linux
92    osvers=6.1.12-1-default
93    archname=x86_64-linux-thread-multi-ld
94    uname='linux lx09 6.1.12-1-default #1 smp preempt_dynamic wed feb 15 05:31:41 utc 2023 (373f017) x86_64 x86_64 x86_64 gnulinux '
95    config_args='-Dusedevel -Duse64bitall -Dusethreads -Duseithreads -Duselongdouble -Doptimize='-O0\ -g' -Accflags=-DPERL_RC_STACK -des'
96    hint=recommended
97    useposix=true
98    d_sigaction=define
99    useithreads=define
100    usemultiplicity=define
101    use64bitint=define
102    use64bitall=define
103    uselongdouble=define
104    usemymalloc=n
105    default_inc_excludes_dot=define
106  Compiler:
107    cc='cc'
108    ccflags ='-D_REENTRANT -D_GNU_SOURCE -pie -fPIE -fPIC -DDEBUGGING -DPERL_RC_STACK -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
109    optimize='-O0 -g'
110    cppflags='-D_REENTRANT -D_GNU_SOURCE -pie -fPIE -fPIC -DDEBUGGING -DPERL_RC_STACK -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/pro/local/include'
111    ccversion=''
112    gccversion='12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]'
113    gccosandvers=''
114    intsize=4
115    longsize=8
116    ptrsize=8
117    doublesize=8
118    byteorder=12345678
119    doublekind=3
120    d_longlong=define
121    longlongsize=8
122    d_longdbl=define
123    longdblsize=16
124    longdblkind=3
125    ivtype='long'
126    ivsize=8
127    nvtype='long double'
128    nvsize=16
129    Off_t='off_t'
130    lseeksize=8
131    alignbytes=16
132    prototype=define
133  Linker and Libraries:
134    ld='cc'
135    ldflags ='-L/pro/local/lib -fstack-protector-strong'
136    libpth=/usr/local/lib /usr/x86_64-suse-linux/lib /usr/lib /data/pro/local/lib /usr/lib64 /usr/local/lib64
137    libs=-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
138    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
139    libc=/lib/../lib64/libc.so.6
140    so=so
141    useshrplib=false
142    libperl=libperl.a
143    gnulibc_version='2.37'
144  Dynamic Linking:
145    dlsrc=dl_dlopen.xs
146    dlext=so
147    d_dlsymun=undef
148    ccdlflags='-Wl,-E'
149    cccdlflags='-fPIC'
150    lddlflags='-shared -O0 -g -L/pro/local/lib -fstack-protector-strong'
151
152
153Characteristics of this binary (from libperl): 
154  Compile-time options:
155    DEBUGGING
156    HAS_TIMES
157    MULTIPLICITY
158    PERLIO_LAYERS
159    PERL_COPY_ON_WRITE
160    PERL_DONT_CREATE_GVSV
161    PERL_HASH_FUNC_SIPHASH13
162    PERL_HASH_USE_SBOX32
163    PERL_MALLOC_WRAP
164    PERL_OP_PARENT
165    PERL_PRESERVE_IVUV
166    PERL_RC_STACK
167    PERL_TRACK_MEMPOOL
168    PERL_USE_DEVEL
169    PERL_USE_SAFE_PUTENV
170    USE_64_BIT_ALL
171    USE_64_BIT_INT
172    USE_ITHREADS
173    USE_LARGE_FILES
174    USE_LOCALE
175    USE_LOCALE_COLLATE
176    USE_LOCALE_CTYPE
177    USE_LOCALE_NUMERIC
178    USE_LOCALE_TIME
179    USE_LONG_DOUBLE
180    USE_PERLIO
181    USE_PERL_ATOF
182    USE_REENTRANT_API
183    USE_THREAD_SAFE_LOCALE
184  Locally applied patches:
185    uncommitted-changes
186  Built under linux
187  Compiled at Feb 28 2023 18:30:03
188  %ENV:
189    PERL5LIB="/pro/3gl/CPAN/perl-git/lib"
190    PERL6LIB="inst#/pro/3gl/CPAN/rakudo/install"
191    PERL_ARCHLIB="/pro/3gl/CPAN/perl-git"
192    PERL_CORE="1"
193    PERL_INC="/pro/3gl/CPAN/perl-git"
194    PERL_LIB="/pro/3gl/CPAN/perl-git/lib"
195    PERL_SRC="/pro/3gl/CPAN/perl-git"
196  @INC:
197    /pro/3gl/CPAN/perl-git/lib
198    /pro/3gl/CPAN/perl-git/lib
199    /pro/lib/perl5/site_perl/5.37.10/x86_64-linux-thread-multi-ld
200    /pro/lib/perl5/site_perl/5.37.10
201    /pro/lib/perl5/5.37.10/x86_64-linux-thread-multi-ld
202    /pro/lib/perl5/5.37.10
203