blob: bca7cac26d5e3671feaed28e1f7d55b9226b931e [file] [log] [blame]
Markus Pfeiffera26a0052014-04-22 20:16:15 +00001#!/usr/bin/env perl
SimonB3ddf3552016-02-10 23:50:28 +00002
3# generate_code.pl
Paul Bakker367dae42009-06-28 21:50:27 +00004#
Bence Szépkúti44bfbe32020-08-19 16:54:51 +02005# Copyright The Mbed TLS Contributors
Bence Szépkúti4e9f7122020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti09b4f192020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkúti4e9f7122020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
SimonB152ea182016-02-15 23:27:28 +000047# Purpose
48#
SimonB3ddf3552016-02-10 23:50:28 +000049# Generates the test suite code given inputs of the test suite directory that
50# contain the test suites, and the test suite file names for the test code and
51# test data.
52#
53# Usage: generate_code.pl <suite dir> <code file> <data file> [main code file]
SimonB152ea182016-02-15 23:27:28 +000054#
55# Structure of files
56#
57# - main code file - 'main_test.function'
58# Template file that contains the main() function for the test suite,
59# test dispatch code as well as support functions. It contains the
60# following symbols which are substituted by this script during
61# processing:
SimonB15942102016-04-25 21:34:49 +010062# TESTCASE_FILENAME
63# TESTCODE_FILENAME
SimonB152ea182016-02-15 23:27:28 +000064# SUITE_PRE_DEP
65# MAPPING_CODE
66# FUNCTION CODE
67# SUITE_POST_DEP
68# DEP_CHECK_CODE
69# DISPATCH_FUNCTION
SimonB15942102016-04-25 21:34:49 +010070# !LINE_NO!
SimonB152ea182016-02-15 23:27:28 +000071#
72# - common helper code file - 'helpers.function'
73# Common helper functions
74#
75# - test suite code file - file name in the form 'test_suite_xxx.function'
76# Code file that contains the actual test cases. The file contains a
77# series of code sequences delimited by the following:
78# BEGIN_HEADER / END_HEADER - list of headers files
79# BEGIN_SUITE_HELPERS / END_SUITE_HELPERS - helper functions common to
80# the test suite
81# BEGIN_CASE / END_CASE - the test cases in the test suite. Each test
82# case contains at least one function that is used to create the
83# dispatch code.
84#
85# - test data file - file name in the form 'test_suite_xxxx.data'
86# The test case parameters to to be used in execution of the test. The
SimonB15942102016-04-25 21:34:49 +010087# file name is used to replace the symbol 'TESTCASE_FILENAME' in the main
88# code file above.
SimonB152ea182016-02-15 23:27:28 +000089#
Gilles Peskineb04e2c32017-09-29 15:45:12 +020090# A test data file consists of a sequence of paragraphs separated by
91# a single empty line. Line breaks may be in Unix (LF) or Windows (CRLF)
92# format. Lines starting with the character '#' are ignored
93# (the parser behaves as if they were not present).
94#
95# Each paragraph describes one test case and must consist of: (1) one
96# line which is the test case name; (2) an optional line starting with
97# the 11-character prefix "depends_on:"; (3) a line containing the test
98# function to execute and its parameters.
99#
100# A depends_on: line consists of a list of compile-time options
101# separated by the character ':', with no whitespace. The test case
102# is executed only if this compilation option is enabled in config.h.
103#
104# The last line of each paragraph contains a test function name and
105# a list of parameters separated by the character ':'. Running the
106# test case calls this function with the specified parameters. Each
107# parameter may either be an integer written in decimal or hexadecimal,
108# or a string surrounded by double quotes which may not contain the
109# ':' character.
110#
Paul Bakker367dae42009-06-28 21:50:27 +0000111
112use strict;
113
114my $suite_dir = shift or die "Missing suite directory";
115my $suite_name = shift or die "Missing suite name";
Paul Bakker46c17942011-07-13 14:54:54 +0000116my $data_name = shift or die "Missing data name";
Rich Evansf4253c72015-01-14 19:23:00 +0000117my $test_main_file = do { my $arg = shift; defined($arg) ? $arg : $suite_dir."/main_test.function" };
Paul Bakker46c17942011-07-13 14:54:54 +0000118my $test_file = $data_name.".c";
SimonB152ea182016-02-15 23:27:28 +0000119my $test_common_helper_file = $suite_dir."/helpers.function";
Paul Bakker367dae42009-06-28 21:50:27 +0000120my $test_case_file = $suite_dir."/".$suite_name.".function";
Paul Bakker19343182013-08-16 13:31:10 +0200121my $test_case_data = $suite_dir."/".$data_name.".data";
Paul Bakker367dae42009-06-28 21:50:27 +0000122
123my $line_separator = $/;
124undef $/;
125
SimonB15942102016-04-25 21:34:49 +0100126
127#
128# Open and read in the input files
129#
130
SimonB152ea182016-02-15 23:27:28 +0000131open(TEST_HELPERS, "$test_common_helper_file") or die "Opening test helpers
132'$test_common_helper_file': $!";
133my $test_common_helpers = <TEST_HELPERS>;
Paul Bakker367dae42009-06-28 21:50:27 +0000134close(TEST_HELPERS);
135
Paul Bakker19343182013-08-16 13:31:10 +0200136open(TEST_MAIN, "$test_main_file") or die "Opening test main '$test_main_file': $!";
SimonB15942102016-04-25 21:34:49 +0100137my @test_main_lines = split/^/, <TEST_MAIN>;
138my $test_main;
SimonB43dba3d2016-05-02 21:31:51 +0100139my $index = 2;
SimonB15942102016-04-25 21:34:49 +0100140for my $line (@test_main_lines) {
141 $line =~ s/!LINE_NO!/$index/;
142 $test_main = $test_main.$line;
143 $index++;
144}
Paul Bakker19343182013-08-16 13:31:10 +0200145close(TEST_MAIN);
146
Paul Bakker367dae42009-06-28 21:50:27 +0000147open(TEST_CASES, "$test_case_file") or die "Opening test cases '$test_case_file': $!";
SimonB15942102016-04-25 21:34:49 +0100148my @test_cases_lines = split/^/, <TEST_CASES>;
149my $test_cases;
SimonB43dba3d2016-05-02 21:31:51 +0100150my $index = 2;
SimonB15942102016-04-25 21:34:49 +0100151for my $line (@test_cases_lines) {
SimonB37f26202016-05-02 21:58:19 +0100152 if ($line =~ /^\/\* BEGIN_SUITE_HELPERS .*\*\//)
153 {
154 $line = $line."#line $index \"$test_case_file\"\n";
155 }
156
SimonB15942102016-04-25 21:34:49 +0100157 if ($line =~ /^\/\* BEGIN_CASE .*\*\//)
158 {
159 $line = $line."#line $index \"$test_case_file\"\n";
160 }
161
SimonBc1d2eb32016-05-02 15:52:52 +0100162 $line =~ s/!LINE_NO!/$index/;
163
SimonB15942102016-04-25 21:34:49 +0100164 $test_cases = $test_cases.$line;
165 $index++;
166}
167
Paul Bakker367dae42009-06-28 21:50:27 +0000168close(TEST_CASES);
Paul Bakker19343182013-08-16 13:31:10 +0200169
170open(TEST_DATA, "$test_case_data") or die "Opening test data '$test_case_data': $!";
171my $test_data = <TEST_DATA>;
172close(TEST_DATA);
173
SimonB15942102016-04-25 21:34:49 +0100174
175#
176# Find the headers, dependencies, and suites in the test cases file
177#
178
Paul Bakker33b43f12013-08-20 11:48:36 +0200179my ( $suite_header ) = $test_cases =~ /\/\* BEGIN_HEADER \*\/\n(.*?)\n\/\* END_HEADER \*\//s;
180my ( $suite_defines ) = $test_cases =~ /\/\* BEGIN_DEPENDENCIES\n \* (.*?)\n \* END_DEPENDENCIES/s;
SimonB152ea182016-02-15 23:27:28 +0000181my ( $suite_helpers ) = $test_cases =~ /\/\* BEGIN_SUITE_HELPERS \*\/\n(.*?)\n\/\* END_SUITE_HELPERS \*\//s;
Paul Bakker5690efc2011-05-26 13:16:06 +0000182
183my $requirements;
184if ($suite_defines =~ /^depends_on:/)
185{
186 ( $requirements ) = $suite_defines =~ /^depends_on:(.*)$/;
187}
Paul Bakker19343182013-08-16 13:31:10 +0200188
Paul Bakker5690efc2011-05-26 13:16:06 +0000189my @var_req_arr = split(/:/, $requirements);
190my $suite_pre_code;
191my $suite_post_code;
Paul Bakker19343182013-08-16 13:31:10 +0200192my $dispatch_code;
193my $mapping_code;
194my %mapping_values;
Paul Bakker5690efc2011-05-26 13:16:06 +0000195
196while (@var_req_arr)
197{
198 my $req = shift @var_req_arr;
Manuel Pégourié-Gonnarde46c6c32015-03-23 13:59:10 +0100199 $req =~ s/(!?)(.*)/$1defined($2)/;
Paul Bakker5690efc2011-05-26 13:16:06 +0000200
Manuel Pégourié-Gonnarde46c6c32015-03-23 13:59:10 +0100201 $suite_pre_code .= "#if $req\n";
Paul Bakker5690efc2011-05-26 13:16:06 +0000202 $suite_post_code .= "#endif /* $req */\n";
203}
Paul Bakker367dae42009-06-28 21:50:27 +0000204
205$/ = $line_separator;
206
207open(TEST_FILE, ">$test_file") or die "Opening destination file '$test_file': $!";
208print TEST_FILE << "END";
SimonB152ea182016-02-15 23:27:28 +0000209/*
210 * *** THIS FILE HAS BEEN MACHINE GENERATED ***
211 *
212 * This file has been machine generated using the script: $0
213 *
214 * Test file : $test_file
215 *
216 * The following files were used to create this file.
217 *
218 * Main code file : $test_main_file
219 * Helper file : $test_common_helper_file
220 * Test suite file : $test_case_file
Simon Butcher64d60da2016-03-01 18:35:02 +0000221 * Test suite data : $test_case_data
SimonB152ea182016-02-15 23:27:28 +0000222 *
SimonB152ea182016-02-15 23:27:28 +0000223 */
224
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200225#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000226#include <mbedtls/config.h>
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +0200227#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200228#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +0200229#endif
Paul Bakker5690efc2011-05-26 13:16:06 +0000230
SimonB152ea182016-02-15 23:27:28 +0000231
232/*----------------------------------------------------------------------------*/
SimonB0269dad2016-02-17 23:34:30 +0000233/* Common helper code */
SimonB152ea182016-02-15 23:27:28 +0000234
235$test_common_helpers
236
237
238/*----------------------------------------------------------------------------*/
239/* Test Suite Code */
Rich Evans00ab4702015-02-06 13:43:58 +0000240
Paul Bakkerde56ca12013-09-15 17:05:21 +0200241$suite_pre_code
Paul Bakker367dae42009-06-28 21:50:27 +0000242$suite_header
SimonB152ea182016-02-15 23:27:28 +0000243$suite_helpers
Paul Bakkerde56ca12013-09-15 17:05:21 +0200244$suite_post_code
Paul Bakker367dae42009-06-28 21:50:27 +0000245
Paul Bakker367dae42009-06-28 21:50:27 +0000246END
247
Paul Bakkerb34fef22013-08-20 12:06:33 +0200248$test_main =~ s/SUITE_PRE_DEP/$suite_pre_code/;
249$test_main =~ s/SUITE_POST_DEP/$suite_post_code/;
250
Paul Bakker33b43f12013-08-20 11:48:36 +0200251while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\//msg)
Paul Bakker367dae42009-06-28 21:50:27 +0000252{
Paul Bakker19343182013-08-16 13:31:10 +0200253 my $function_deps = $1;
Paul Bakker33b43f12013-08-20 11:48:36 +0200254 my $function_decl = $2;
255
256 # Sanity checks of function
SimonB15942102016-04-25 21:34:49 +0100257 if ($function_decl !~ /^#line\s*.*\nvoid /)
Paul Bakker33b43f12013-08-20 11:48:36 +0200258 {
SimonB15942102016-04-25 21:34:49 +0100259 die "Test function does not have 'void' as return type.\n" .
260 "Function declaration:\n" .
261 $function_decl;
Paul Bakker33b43f12013-08-20 11:48:36 +0200262 }
SimonB15942102016-04-25 21:34:49 +0100263 if ($function_decl !~ /^(#line\s*.*)\nvoid (\w+)\(\s*(.*?)\s*\)\s*{(.*)}/ms)
Paul Bakker33b43f12013-08-20 11:48:36 +0200264 {
265 die "Function declaration not in expected format\n";
266 }
SimonB15942102016-04-25 21:34:49 +0100267 my $line_directive = $1;
268 my $function_name = $2;
269 my $function_params = $3;
Paul Bakker19343182013-08-16 13:31:10 +0200270 my $function_pre_code;
271 my $function_post_code;
Paul Bakker19343182013-08-16 13:31:10 +0200272 my $param_defs;
273 my $param_checks;
274 my @dispatch_params;
Paul Bakker33b43f12013-08-20 11:48:36 +0200275 my @var_def_arr = split(/,\s*/, $function_params);
Paul Bakker19343182013-08-16 13:31:10 +0200276 my $i = 1;
277 my $mapping_regex = "".$function_name;
278 my $mapping_count = 0;
Paul Bakker367dae42009-06-28 21:50:27 +0000279
SimonB15942102016-04-25 21:34:49 +0100280 $function_decl =~ s/(^#line\s*.*)\nvoid /$1\nvoid test_suite_/;
Paul Bakker33b43f12013-08-20 11:48:36 +0200281
Paul Bakker318d0fe2014-07-10 14:59:25 +0200282 # Add exit label if not present
283 if ($function_decl !~ /^exit:$/m)
284 {
285 $function_decl =~ s/}\s*$/\nexit:\n return;\n}/;
286 }
287
Paul Bakker19343182013-08-16 13:31:10 +0200288 if ($function_deps =~ /^depends_on:/)
Paul Bakkerccff1672009-10-03 19:57:10 +0000289 {
Paul Bakker19343182013-08-16 13:31:10 +0200290 ( $function_deps ) = $function_deps =~ /^depends_on:(.*)$/;
Paul Bakkerccff1672009-10-03 19:57:10 +0000291 }
292
Paul Bakker19343182013-08-16 13:31:10 +0200293 foreach my $req (split(/:/, $function_deps))
Paul Bakker367dae42009-06-28 21:50:27 +0000294 {
Paul Bakker19343182013-08-16 13:31:10 +0200295 $function_pre_code .= "#ifdef $req\n";
296 $function_post_code .= "#endif /* $req */\n";
Paul Bakker367dae42009-06-28 21:50:27 +0000297 }
Paul Bakker367dae42009-06-28 21:50:27 +0000298
Paul Bakker19343182013-08-16 13:31:10 +0200299 foreach my $def (@var_def_arr)
300 {
301 # Handle the different parameter types
Paul Bakker33b43f12013-08-20 11:48:36 +0200302 if( substr($def, 0, 4) eq "int " )
Paul Bakker19343182013-08-16 13:31:10 +0200303 {
304 $param_defs .= " int param$i;\n";
SimonB8ca7bc42016-04-17 23:24:50 +0100305 $param_checks .= " if( verify_int( params[$i], &param$i ) != 0 ) return( DISPATCH_INVALID_TEST_DATA );\n";
Paul Bakker19343182013-08-16 13:31:10 +0200306 push @dispatch_params, "param$i";
Paul Bakker367dae42009-06-28 21:50:27 +0000307
Paul Bakker19343182013-08-16 13:31:10 +0200308 $mapping_regex .= ":([\\d\\w |\\+\\-\\(\\)]+)";
309 $mapping_count++;
310 }
Paul Bakker33b43f12013-08-20 11:48:36 +0200311 elsif( substr($def, 0, 6) eq "char *" )
Paul Bakker19343182013-08-16 13:31:10 +0200312 {
313 $param_defs .= " char *param$i = params[$i];\n";
SimonB8ca7bc42016-04-17 23:24:50 +0100314 $param_checks .= " if( verify_string( &param$i ) != 0 ) return( DISPATCH_INVALID_TEST_DATA );\n";
Paul Bakker19343182013-08-16 13:31:10 +0200315 push @dispatch_params, "param$i";
Andres AG9060d4d2017-02-02 14:36:49 +0000316 $mapping_regex .= ":(?:\\\\.|[^:\n])+";
Paul Bakker19343182013-08-16 13:31:10 +0200317 }
Paul Bakker33b43f12013-08-20 11:48:36 +0200318 else
319 {
320 die "Parameter declaration not of supported type (int, char *)\n";
321 }
Paul Bakker19343182013-08-16 13:31:10 +0200322 $i++;
Paul Bakker367dae42009-06-28 21:50:27 +0000323
Paul Bakker19343182013-08-16 13:31:10 +0200324 }
325
326 # Find non-integer values we should map for this function
327 if( $mapping_count)
328 {
329 my @res = $test_data =~ /^$mapping_regex/msg;
330 foreach my $value (@res)
331 {
Manuel Pégourié-Gonnard18c443d2013-10-17 14:58:24 +0200332 next unless ($value !~ /^\d+$/);
333 if ( $mapping_values{$value} ) {
334 ${ $mapping_values{$value} }{$function_pre_code} = 1;
335 } else {
336 $mapping_values{$value} = { $function_pre_code => 1 };
337 }
Paul Bakker19343182013-08-16 13:31:10 +0200338 }
339 }
340
341 my $call_params = join ", ", @dispatch_params;
342 my $param_count = @var_def_arr + 1;
343 $dispatch_code .= << "END";
344if( strcmp( params[0], "$function_name" ) == 0 )
345{
346$function_pre_code
347$param_defs
348 if( cnt != $param_count )
349 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200350 mbedtls_fprintf( stderr, "\\nIncorrect argument count (%d != %d)\\n", cnt, $param_count );
SimonB8ca7bc42016-04-17 23:24:50 +0100351 return( DISPATCH_INVALID_TEST_DATA );
Paul Bakker19343182013-08-16 13:31:10 +0200352 }
353
354$param_checks
Paul Bakker33b43f12013-08-20 11:48:36 +0200355 test_suite_$function_name( $call_params );
SimonB8ca7bc42016-04-17 23:24:50 +0100356 return ( DISPATCH_TEST_SUCCESS );
Paul Bakker19343182013-08-16 13:31:10 +0200357$function_post_code
SimonB8ca7bc42016-04-17 23:24:50 +0100358 return ( DISPATCH_UNSUPPORTED_SUITE );
Paul Bakker19343182013-08-16 13:31:10 +0200359}
360else
361END
362
SimonB15942102016-04-25 21:34:49 +0100363 my $function_code = $function_pre_code . $function_decl . "\n" .
364 $function_post_code;
Paul Bakker33b43f12013-08-20 11:48:36 +0200365 $test_main =~ s/FUNCTION_CODE/$function_code\nFUNCTION_CODE/;
Paul Bakker19343182013-08-16 13:31:10 +0200366}
367
368# Find specific case dependencies that we should be able to check
369# and make check code
370my $dep_check_code;
371
Hanno Beckerf058f342017-07-23 10:24:22 +0100372my @res = $test_data =~ /^depends_on:([!:\w]+)/msg;
Paul Bakker19343182013-08-16 13:31:10 +0200373my %case_deps;
374foreach my $deps (@res)
375{
376 foreach my $dep (split(/:/, $deps))
377 {
378 $case_deps{$dep} = 1;
379 }
380}
381while( my ($key, $value) = each(%case_deps) )
382{
Hanno Beckerf058f342017-07-23 10:24:22 +0100383 if( substr($key, 0, 1) eq "!" )
384 {
385 my $key = substr($key, 1);
386 $dep_check_code .= << "END";
387 if( strcmp( str, "!$key" ) == 0 )
388 {
389#if !defined($key)
390 return( DEPENDENCY_SUPPORTED );
391#else
392 return( DEPENDENCY_NOT_SUPPORTED );
393#endif
394 }
395END
396 }
397 else
398 {
399 $dep_check_code .= << "END";
Paul Bakker19343182013-08-16 13:31:10 +0200400 if( strcmp( str, "$key" ) == 0 )
401 {
402#if defined($key)
SimonB8ca7bc42016-04-17 23:24:50 +0100403 return( DEPENDENCY_SUPPORTED );
Paul Bakker19343182013-08-16 13:31:10 +0200404#else
SimonB8ca7bc42016-04-17 23:24:50 +0100405 return( DEPENDENCY_NOT_SUPPORTED );
Paul Bakker19343182013-08-16 13:31:10 +0200406#endif
407 }
Paul Bakker367dae42009-06-28 21:50:27 +0000408END
Hanno Beckerf058f342017-07-23 10:24:22 +0100409 }
Paul Bakker367dae42009-06-28 21:50:27 +0000410}
411
Paul Bakker19343182013-08-16 13:31:10 +0200412# Make mapping code
413while( my ($key, $value) = each(%mapping_values) )
414{
Manuel Pégourié-Gonnard18c443d2013-10-17 14:58:24 +0200415 my $key_mapping_code = << "END";
Paul Bakker19343182013-08-16 13:31:10 +0200416 if( strcmp( str, "$key" ) == 0 )
417 {
418 *value = ( $key );
SimonB8ca7bc42016-04-17 23:24:50 +0100419 return( KEY_VALUE_MAPPING_FOUND );
Paul Bakker19343182013-08-16 13:31:10 +0200420 }
421END
Manuel Pégourié-Gonnard18c443d2013-10-17 14:58:24 +0200422
423 # handle depenencies, unless used at least one without depends
424 if ($value->{""}) {
425 $mapping_code .= $key_mapping_code;
426 next;
427 }
428 for my $ifdef ( keys %$value ) {
429 (my $endif = $ifdef) =~ s!ifdef!endif //!g;
430 $mapping_code .= $ifdef . $key_mapping_code . $endif;
431 }
Paul Bakker19343182013-08-16 13:31:10 +0200432}
433
434$dispatch_code =~ s/^(.+)/ $1/mg;
435
SimonB15942102016-04-25 21:34:49 +0100436$test_main =~ s/TESTCASE_FILENAME/$test_case_data/g;
437$test_main =~ s/TESTCODE_FILENAME/$test_case_file/g;
Paul Bakker19343182013-08-16 13:31:10 +0200438$test_main =~ s/FUNCTION_CODE//;
439$test_main =~ s/DEP_CHECK_CODE/$dep_check_code/;
440$test_main =~ s/DISPATCH_FUNCTION/$dispatch_code/;
441$test_main =~ s/MAPPING_CODE/$mapping_code/;
442
Paul Bakker367dae42009-06-28 21:50:27 +0000443print TEST_FILE << "END";
Paul Bakker19343182013-08-16 13:31:10 +0200444$test_main
Paul Bakker367dae42009-06-28 21:50:27 +0000445END
446
Paul Bakker367dae42009-06-28 21:50:27 +0000447close(TEST_FILE);