]> granicus.if.org Git - graphviz/commitdiff
add a variant of #2272 test case
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Dec 2022 19:34:18 +0000 (11:34 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 21 Dec 2022 02:54:30 +0000 (18:54 -0800)
While working on Small String Optimization, it became clear that a variant of
this test case which just passes an invalid string through the Graphviz binary
provokes some non-trivial behavior which is worth testing.

Gitlab: #2272

tests/test_regression.py

index faa79a3650d40c62a450962b912378010598ec9b..1d69e9f3dd89551e1d0385cfbf611fcd099c4da0 100644 (file)
@@ -1973,6 +1973,21 @@ def test_2272():
   # run the test
   run_c(c_src, link=["cgraph", "gvc"])
 
+def test_2272_2():
+  """
+  An unterminated string in the source should not crash Graphviz. Variant of
+  `test_2272`.
+  """
+
+  # a graph with an open string
+  graph = 'graph { a[label="abc'
+
+  # process it with Graphviz, which should not crash
+  p = subprocess.run(["dot", "-o", os.devnull], input=graph,
+                     universal_newlines=True)
+  assert p.returncode != 0, "dot accepted invalid input"
+  assert p.returncode == 1, "dot crashed"
+
 def test_2282():
   """
   using the `fdp` layout with JSON output should result in valid JSON