From: Dwight Perry Date: Mon, 19 Sep 2011 21:58:20 +0000 (-0400) Subject: Added test cases for imagepath attribute feature X-Git-Tag: LAST_LIBGRAPH~32^2~660 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2fb1f691195b859fa22515d49a69d731a43eb6c;p=graphviz Added test cases for imagepath attribute feature --- diff --git a/rtest/imagepath_test.txt b/rtest/imagepath_test.txt new file mode 100644 index 000000000..28d588b32 --- /dev/null +++ b/rtest/imagepath_test.txt @@ -0,0 +1,76 @@ +# Graphviz test suite +# Tests are separated by blank or comment lines. +# Tests have the following syntax: +# testname +# Test input (one-line graph or name of .gv file or =) +# In the last case, the input file is taken as testname.gv +# One or more subtests of the form: +# layout_alg output_format additional_flags +# +# For example, the test +# Shapes +# shapes.gv +# dot ps +# neato png "-Gsize=3,3 -Ncolor=red" +# specifies the "shapes" test, using shapes.gv as input, and +# run "dot -Tps" and "neato -Tpng -Gsize=3,3 -Ncolor=red" on the input. +# +#Test graph names indicate the image attribute and the imagepath attribute +#being tested. For instance val_val.gv, is a graph that has the image +#attribute directory set to a valid directory name and the imagepath attribute +#directory set to a valid directory name. Likewise inv_inv.gv has both +#attribute directories set to an invalid directory name and nul_nul.gv has +#no setting for the image attribute and the imagepath attribute directories. +#Graphs named with combinations of val, inv and nul have +#image and imagepath attributes set correspondingly. + +#Since this test relies on absolute pathnames, it is necessary to run a +#shell script to generate the test graphs. +#Run imagepath_test.sh from within the imagepath_test directory before running +#rtest on this test suite. This script creates the input graphs and output png +#files and stores them in the graphs and imagepath_test/nshare directories. +#The png files may be copied into the nshare directory by running +#imagepath_test/save_png_files.sh when it is appropriate to update the expected +#test output. + +#The graphs in this test suite should also be tested using the mac os user +#interface. Select each of the test graphs from the Graphviz.app and visually +#determine whether the tests complete successfully. The image that is displayed +#should correspond to the expected result message that appears below it. + +val_val += +dot png + +val_inv += +dot png + +val_nul += +dot png + +inv_val += +dot png + +inv_inv += +dot png + +inv_nul += +dot png + +nul_val += +dot png + +nul_inv += +dot png + +nul_nul += +dot png + diff --git a/rtest/imagepath_test/base.gv b/rtest/imagepath_test/base.gv new file mode 100644 index 000000000..70a45272d --- /dev/null +++ b/rtest/imagepath_test/base.gv @@ -0,0 +1,10 @@ +graph G { imagepath_attr + +a[shape=plaintext,label=<
+config +
>]; +b[shape=box,fontsize=30,fontname="Helvetica-Bold",label=expect,image_attr]; +} + diff --git a/rtest/imagepath_test/delim.sed b/rtest/imagepath_test/delim.sed new file mode 100644 index 000000000..aed0b544e --- /dev/null +++ b/rtest/imagepath_test/delim.sed @@ -0,0 +1 @@ +s:/:\\/:g diff --git a/rtest/imagepath_test/gen_graph.sh b/rtest/imagepath_test/gen_graph.sh new file mode 100755 index 000000000..57a357288 --- /dev/null +++ b/rtest/imagepath_test/gen_graph.sh @@ -0,0 +1,100 @@ +#! /home/dperry/work_related/packages/arch/linux.i386-64/src/cmd/ksh93/ksh + +#directory where the executable is located +project_dir=`pwd | sed -f delim.sed` + +#directory pointed to by the image attribute +image_dir=`pwd | sed -e s:$:\\/image_dir: | sed -f delim.sed` + +#directory pointed to by the imagepath attribute +imagepath_dir=`pwd | sed -e s:$:\\/imagepath_dir: | sed -f delim.sed` + +#an invalid absolute path +inv_dir=`echo -n "/inv_dir" | sed -f delim.sed` + +#echo "project_dir=${project_dir}" +#echo "abs_dir=${abs_dir}" +#echo "rel_dir=${rel_dir}" +#echo "cur_dir=${cur_dir}" +#echo "inv_dir=${inv_dir}" + +#input parameters: +# a - image attribute directory type: val (valid), inv (invalid), nul (not present) +# b - imagepath attribute directory type: val (valid), inv (invalid), nul (not present) +# c - expectation +# d - name of output graph + +read a b c d + +#set image attribute directory +case $a in + "val") image="${image_dir}\/"; + image_attr="valid absolute pathname";; + "inv") image="${inv_dir}\/"; + image_attr="invalid absolute pathname";; + "nul") image=""; + image_attr="null";; + *) echo "Missing image attribute"; + echo "Usage arg0 image imagepath expectation output_filename"; + echo "image and imagepath valid values: val, inv, nul" + echo "expectation - expected outcome message" + echo "output_filename - defaults to test" + exit 1;; +esac + +#set imagepath attribute directory +case $b in + "val") imagepath="${imagepath_dir}\/"; + imagepath_attr="valid absolute pathname";; + "inv") imagepath="${inv_dir}\/"; + imagepath_attr="invalid absolute pathname";; + "nul") imagepath=""; + imagepath_attr="null";; + *) echo "Missing imagepath attribute"; + echo "Usage arg0 image imagepath expectation output_filename"; + echo "image and imagepath valid values: val, inv, nul" + echo "expectation - expected outcome message" + echo "output_filename - defaults to test" + exit 1;; +esac + +#set the expectation message that will be displayed on graph output +case $c in + "") echo "Missing expectation message"; + echo "Usage arg0 image imagepath expectation output_filename"; + echo "image and imagepath valid values: val, inv, nul" + echo "expectation - expected outcome message" + echo "output_filename - defaults to test" + exit 1;; + *) expect=$c;; +esac + + +#set the output graph filename +case $d in + "") outfile="test";; + *) outfile=$d;; +esac + +echo +echo "case: ${a}_${b}" +echo "image attribute: ${image_attr}" +echo "imagepath attribute: ${imagepath_attr}" + +#base.gv is a template for the graph being created +#construct the graph file and store in ../graphs +#space characters must be converted to '^' characters to not confuse sed +#restore '^' character to space before outputting the graph + +config="image attribute \(${image_attr}\)<\/FONT><\/TD><\/TR>imagepath attribute \(${imagepath_attr}\)<\/FONT><\/TD><\/TR>" +config=`echo -n $config | tr ' ' '^'` +expect=`echo -n $expect | tr ' ' '^'` +sed -e s/image_attr/image\=\"${image}image.jpg\",labelloc=b/ \ +-e s/expect/${expect}/ \ +-e s/config/${config}/ \ +-e s/imagepath_attr/imagepath\=\"${imagepath}\"/ base.gv | tr '^' ' ' > ../graphs/${outfile}.gv + +#place the image file into the nshare directory +dot -Tpng -o nshare/${outfile}_dot.png ../graphs/${outfile}.gv + + diff --git a/rtest/imagepath_test/image.jpg b/rtest/imagepath_test/image.jpg new file mode 100644 index 000000000..14dc00c79 Binary files /dev/null and b/rtest/imagepath_test/image.jpg differ diff --git a/rtest/imagepath_test/image_dir/image.jpg b/rtest/imagepath_test/image_dir/image.jpg new file mode 100644 index 000000000..abbfdd1cf Binary files /dev/null and b/rtest/imagepath_test/image_dir/image.jpg differ diff --git a/rtest/imagepath_test/imagepath_dir/image.jpg b/rtest/imagepath_test/imagepath_dir/image.jpg new file mode 100644 index 000000000..9066b0d70 Binary files /dev/null and b/rtest/imagepath_test/imagepath_dir/image.jpg differ diff --git a/rtest/imagepath_test/imagepath_test.sh b/rtest/imagepath_test/imagepath_test.sh new file mode 100755 index 000000000..4b9db1d1b --- /dev/null +++ b/rtest/imagepath_test/imagepath_test.sh @@ -0,0 +1,9 @@ +#! /bin/ksh + +let count=1 +while [ $count -lt `wc -l test_cases` ] +do +cat test_cases | sed -ne ${count}p | ./gen_graph.sh +let count++ +done + diff --git a/rtest/imagepath_test/save_png_files.sh b/rtest/imagepath_test/save_png_files.sh new file mode 100755 index 000000000..6673778ee --- /dev/null +++ b/rtest/imagepath_test/save_png_files.sh @@ -0,0 +1,2 @@ +cp nshare/* ../nshare + diff --git a/rtest/imagepath_test/test_cases b/rtest/imagepath_test/test_cases new file mode 100644 index 000000000..56e6e92a5 --- /dev/null +++ b/rtest/imagepath_test/test_cases @@ -0,0 +1,10 @@ +val val "image^from^image^attribute^directory^should^be^displayed" val_val +val inv "image^from^image^attribute^directory^should^be^displayed" val_inv +val nul "image^from^image^attribute^directory^should^be^displayed" val_nul +inv val "no^image^should^be^displayed" inv_val +inv inv "no^image^should^be^displayed" inv_inv +inv nul "no^image^should^be^displayed" inv_nul +nul val "image^from^imagepath^attribute^directory^or^working^directory^should^be^displayed" nul_val +nul inv "no^image^for^Graphviz.app,^else^image^from^working^directory" nul_inv +nul nul "image^in^working^directory^should^be^displayed" nul_nul +