###
### Tool initialization file. For more information, see:
###
### http://www.gnu.org/software/dejagnu/manual/
###
###
### Run parameters
###
set KEEP_TEMPORARIES 0
###
### Useful global variables
###
#
# Directory and extension names
#
set svg_dir svg
set svg_temp_ext temp.svg
set output_ext output.ppm
set png_tempdir temp.png
set ppm_tempdir temp.ppm
set trans_tempdir temp.t
#
# Path id counter
#
set path_id 10
###
### Helper routines
###
#
# Delete temporaries
#
proc ale_cleanup {} {
global ppm_tempdir
global png_tempdir
global svg_temp_ext
global output_ext
exec find testsuite \( -name $ppm_tempdir -o -name $png_tempdir \) -type d -print0 | xargs -0 rm -rf
exec find testsuite -name "*.$svg_temp_ext" -print0 | xargs -r -0 rm
exec find testsuite -name "*.$output_ext" -print0 | xargs -r -0 rm
}
###
### Standard DejaGnu procedures
###
#
# Actions to take before exit
#
proc ale_exit {} {
global KEEP_TEMPORARIES
if $KEEP_TEMPORARIES {
return
}
#
# Delete temporaries if KEEP_TEMPORARIES is not set
#
ale_cleanup
}
#
# Display and return the version and path of the program being run.
#
proc ale_version {} {
global ALE
clone_output "\nProgram tested: [which $ALE]\n\nProgram Version:\n\n[exec $ALE --version]\n"
}
###
### SVG file creation routines (based on inkscape file output [http://www.inkscape.org])
###
proc svg_header {svg_file width height} {
puts $svg_file ""
puts $svg_file {
}
}
proc svg_open {name width height} {
global svg_dir
global srcdir
global subdir
global svg_temp_ext
exec mkdir -p $srcdir/$subdir/$svg_dir
set svg $srcdir/$subdir/$svg_dir/$name.$svg_temp_ext
set svg_file [open $svg "w"]
svg_header $svg_file $width $height
return $svg_file
}
proc svg_close {svg_file} {
svg_footer $svg_file
close $svg_file
}
proc svg_ellipse {svg_file px py rx ry {sc "#000000"} {fc "#000000"} {so 1.0} {fo 1.0} } {
global path_id
puts $svg_file "
}
incr path_id
}
proc svg_circle {svg_file px py r {sc "#000000"} {fc "#000000"} {so 1.0} {fo 1.0} } {
svg_ellipse $svg_file $px $py $r $r $sc $fc $so $fo
}
###
### File readers and converters
###
proc svg_file {name} {
global svg_dir
global srcdir
global subdir
global svg_temp_ext
set svg_base $srcdir/$subdir/$svg_dir/$name
if [file exists $svg_base.$svg_temp_ext] {
return $svg_base.$svg_temp_ext
} elseif [file exists $svg_base.svg] {
return $svg_base.svg
} else {
error "Cannot find SVG file for name \"$svg_base\"."
}
return $svg
}
proc png_file {name {bg "white"} } {
global png_tempdir
global srcdir
global subdir
set png $srcdir/$subdir/$png_tempdir/$name-$bg.png
if ([file exists $png]) {
return $png
}
exec mkdir -p $srcdir/$subdir/$png_tempdir
exec inkscape --export-dpi=1 -b $bg -f [svg_file $name] -e $png
if (![file exists $png]) {
error "Could not create $png."
}
return $png
}
proc ppm_file {name {bg "white"} } {
global ppm_tempdir
global srcdir
global subdir
set ppm $srcdir/$subdir/$ppm_tempdir/$name-$bg.ppm
if ([file exists $ppm]) {
return $ppm
}
exec mkdir -p $srcdir/$subdir/$ppm_tempdir
exec pngtopnm [png_file $name $bg] > $ppm
if (![file exists $ppm]) {
error "Could not create $ppm."
}
return $ppm
}
proc trans_file {name} {
global trans_tempdir
global srcdir
global subdir
set result $srcdir/$subdir/$trans_tempdir/$name.t
exec mkdir -p $srcdir/$subdir/$trans_tempdir
return $result
}
proc out_file {name} {
global ppm_tempdir
global srcdir
global subdir
global output_ext
set result $srcdir/$subdir/$ppm_tempdir/$name.$output_ext
exec mkdir -p $srcdir/$subdir/$ppm_tempdir
return $result
}
###
### Clean up before running anything
###
ale_cleanup