File: generate-test-list.pl

package info (click to toggle)
gf2x 1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 2,612 kB
  • ctags: 725
  • sloc: sh: 11,112; ansic: 7,549; cpp: 1,369; makefile: 490; perl: 151
file content (99 lines) | stat: -rwxr-xr-x 3,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/perl
#  This file is part of the gf2x library.
#
#  Copyright 2007, 2008, 2009, 2010
#  Richard Brent, Pierrick Gaudry, Emmanuel Thome', Paul Zimmermann
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2 of the License, or (at your
#  option) any later version.
#
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
#
#  You should have received a copy of the GNU General Public License along
#  with this program; see the file COPYING.  If not, write to the Free
#  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
#  02111-1307, USA.


use warnings;
use strict;

my $fragment = '';
while (<>) {
    if (/^# -- begin generated code --$/) {
        print;
        print $fragment;
        while (<>) {
            if (/^# -- end generated code --$/) {
                print;
                last;
            }
        }
        next;
    }
    if (!/^#\*/) {
        print;
        next;
    }
    /^#\*\s*(.*)$/ or die;
    my $cmd = $1;
    $cmd =~ s/(\S*)\{(\d+)\.\.(\d+)\}(\S*)/join(" ", map { "$1$_$4" } ($2..$3))/gex;

    if ($cmd =~ /^test_sizes ([\d\s]+)$/) {
        my @sizes = split(' ', $1);
        for my $x (@sizes) {
            $fragment .= <<EOF;
tuning_undefs_$x.h: \$(srcdir)/tuning_undefs_pre.h ; sed -e s/\@\@SIZE\@\@/$x/g < \$(srcdir)/tuning_undefs_pre.h > tuning_undefs_$x.h
tuneup_$x.c: \$(srcdir)/tuneup_pre.c ; sed -e s/\@\@SIZE\@\@/$x/g < \$(srcdir)/tuneup_pre.c > tuneup_$x.c
tuneup_$x.\$(OBJEXT): tuning_undefs_$x.h
BUILT_SOURCES +=tuneup_$x.c tuning_undefs_$x.h
EXTRA_LTLIBRARIES+=libtuneup-s$x.la
nodist_libtuneup_s${x}_la_SOURCES=tuneup_$x.c tuning_undefs_$x.h
libtuneup_s${x}_la_CPPFLAGS=-I\$(top_builddir) -I\$(top_srcdir)
CLEANFILES+=tuning_undefs_$x.h
DISTCLEANFILES+=tuning_undefs_$x.h
EOF
            $fragment .= "\n";
        }
    } elsif ($cmd =~ /^test\s+(.*)/) {
        my $funcs = $1;
        for my $f (split(' ', $funcs)) {
            $f =~ /^((?:gen_)?mul(\d+)\w+)$/ or die;
            my $code=$1;
            my $size=$2;
            if ($code =~ /^gen/) {
                $code =~ /w(\d+)k(\d+)/ or die;
                my $w = $1;
                my $k = $2;
                $fragment .= <<EOF;
LOWLEVEL+=tune_$code\$(EXEEXT)
tune_${code}_CPPFLAGS=-I\$(top_builddir) -I\$(top_srcdir) -DTUNING=$size
nodist_tune_${code}_SOURCES=$code.c tuning_undefs_$size.h
$code.\$(OBJEXT): tuning_undefs_$size.h
tune_${code}_LDADD=libtuneup-s$size.la libtiming.la ../libgf2x.la
$code.c: gen_bb_mul_code\$(EXEEXT_FOR_BUILD) ; ./gen_bb_mul_code\$(EXEEXT_FOR_BUILD) $w $k > \$@
BUILT_SOURCES+=$code.c
EOF
            } else {
                $fragment .= <<EOF;
LOWLEVEL+=tune_${code}\$(EXEEXT)
tune_${code}_CPPFLAGS=-I\$(top_builddir) -I\$(top_srcdir) -DTUNING=$size
tune_${code}_SOURCES=$code.c
nodist_tune_${code}_SOURCES=tuning_undefs_$size.h
tune_${code}_LDADD=libtuneup-s$size.la libtiming.la ../libgf2x.la
$code.\$(OBJEXT): tuning_undefs_$size.h
EOF
            }
            $fragment .= "\n";
            $fragment .= "\n";
        }
    } else {
        $fragment .= "$cmd\n";
    }
    print;
}