summaryrefslogtreecommitdiffstats
path: root/openmp/testsuite/ompts_makeHeader.pl
blob: 7212cece207fddfe38b62caf62435dbc74024d80 (plain)
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
100
101
#!/usr/bin/perl -w

# ompts_makeHeader [options] -f=NAME -t=DIR
#
# Creats the headerfile for the OpenMP-Testsuite out of the templatefiles 
# witch are in the default/explicitely specified dir and the settings in the
# given config file. 
# 
# ATTENTION:
#	At the moment it builts only a c-headerfile!
#
# -f=FILENAME: Using file FILENAME as configfile
# -t=DIR:	Directory holding the template files
# 
# options
# -i=FILENAME: Include other Headerfile. The files to be included must be specified
# 	after setting this option. (Not implemented yet.)
# -o=FILENAME: outputfilename (default is "omp_testsuite.h")

$headerfile = "\/\* Global headerfile of the OpenMP Testsuite \*\/\n\n\/\* This file was created with the ompts_makeHeader.pl script using the following opions:\ *\/\n\/\* ";
if(@ARGV > 0)
{
	foreach $opt (@ARGV)
	{
		$headerfile .= "$opt ";
	}
}
else
{
	$headerfile .= "No options were specified";
}
$headerfile .=" \*\/\n\n\n";

use Getopt::Long;
GetOptions("-o=s" => \$outfile, "-f=s" =>\$configfile, "-t=s" => \$templatedir, "-i=s" => \$include);

$include = "";


# Getting and verifying the necessary options:
if(!$configfile) {	
	die "Config file name is missing.";
}	
else {
    if (!(-e $configfile)) {
	  die "Could not find config file $configfile.";
	}
}
	
if(!$templatedir) {	
	die "Directoryname is missing.";
}	

if(!$outfile){
	$outfile = "omp_testsuite.h";	# setting default value for the headerfile
}



#@includefiles;					# list holing extra includefiles specified by the user 


# generating the head of the includeguard:
$headerfile .= "\#ifndef OMP_TESTSUITE_H\n\#define OMP_TESTSUITE_H\n\n";

# inserting general settings out of the configfile:
open(OMPTS_CONF,$configfile) or die "Could not open the global config file $configfile.";
while(<OMPTS_CONF>){
	$headerfile .= $_;
}
close(OMPTS_CONF);

# searching the tests:
opendir TEMPLATEDIR, $templatedir or die "Could not open dir $templatedir.";
@templates = grep /(.*)\.c/, readdir TEMPLATEDIR;
closedir TEMPLATEDIR;

# inserting the function declarations:
foreach $template (@templates){
	$source = "";
	open(TEMPLATE,$templatedir."/".$template) or die "Could not open the following sourcefile: ".$templatedir."/".$template;
	while(<TEMPLATE>){
		$source .= $_;
	}
	close(TEMPLATE);
	$source =~ /\<ompts\:testcode\:functionname\>(.*)\<\/ompts\:testcode\:functionname\>/;
	$functionname = $1."(FILE \* logfile);";
	$source =~ /\<ompts\:directive\>(.*)\<\/ompts\:directive\>/;
	$directive = $1;
	$headerfile .= "int test_".$functionname."  /* Test for ".$directive." */\n";
	$headerfile .= "int crosstest_".$functionname."  /* Crosstest for ".$directive." */\n";
}

# inserting the end of the includeguard:
$headerfile .= "\n#endif";

# craeting the headerfile:
open(OUTFILE,">".$outfile) or die "Could not create the haedaerfile ($outfile)";
print OUTFILE $headerfile."\n";
close(OUTFILE);

OpenPOWER on IntegriCloud