]> granicus.if.org Git - graphviz/commitdiff
Added test cases for imagepath attribute feature
authorDwight Perry <dperry@research.att.com>
Mon, 19 Sep 2011 21:58:20 +0000 (17:58 -0400)
committerDwight Perry <dperry@research.att.com>
Mon, 19 Sep 2011 21:58:20 +0000 (17:58 -0400)
rtest/imagepath_test.txt [new file with mode: 0644]
rtest/imagepath_test/base.gv [new file with mode: 0644]
rtest/imagepath_test/delim.sed [new file with mode: 0644]
rtest/imagepath_test/gen_graph.sh [new file with mode: 0755]
rtest/imagepath_test/image.jpg [new file with mode: 0644]
rtest/imagepath_test/image_dir/image.jpg [new file with mode: 0644]
rtest/imagepath_test/imagepath_dir/image.jpg [new file with mode: 0644]
rtest/imagepath_test/imagepath_test.sh [new file with mode: 0755]
rtest/imagepath_test/save_png_files.sh [new file with mode: 0755]
rtest/imagepath_test/test_cases [new file with mode: 0644]

diff --git a/rtest/imagepath_test.txt b/rtest/imagepath_test.txt
new file mode 100644 (file)
index 0000000..28d588b
--- /dev/null
@@ -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 (file)
index 0000000..70a4527
--- /dev/null
@@ -0,0 +1,10 @@
+graph G { imagepath_attr
+
+a[shape=plaintext,label=<<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="0" 
+CELLBORDER="0"><TR><TD><TABLE CELLSPACING="3" CELLPADDING="1" BORDER="0" 
+CELLBORDER="0">
+config
+</TABLE></TD></TR></TABLE>>];
+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 (file)
index 0000000..aed0b54
--- /dev/null
@@ -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 (executable)
index 0000000..57a3572
--- /dev/null
@@ -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="<TR><TD ALIGN=\"left\"><FONT POINT-SIZE=\"30.0\" FACE=\"Helvetica-Bold\">image attribute \(${image_attr}\)<\/FONT><\/TD><\/TR><TR><TD ALIGN=\"left\"><FONT POINT-SIZE=\"30.0\" FACE=\"Helvetica-Bold\">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 (file)
index 0000000..14dc00c
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 (file)
index 0000000..abbfdd1
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 (file)
index 0000000..9066b0d
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 (executable)
index 0000000..4b9db1d
--- /dev/null
@@ -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 (executable)
index 0000000..6673778
--- /dev/null
@@ -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 (file)
index 0000000..56e6e92
--- /dev/null
@@ -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
+