From: Matthew Fernandez Date: Thu, 8 Sep 2022 02:46:10 +0000 (-0700) Subject: add a test case for #2272 X-Git-Tag: 6.0.1~6^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1539784a590c57d38d81f45dedca7b743c460d89;p=graphviz add a test case for #2272 --- diff --git a/tests/2272.c b/tests/2272.c new file mode 100644 index 000000000..72024a8cd --- /dev/null +++ b/tests/2272.c @@ -0,0 +1,28 @@ +/// \file +/// \brief test case for repeated use of agmemread() with unterminated strings +/// +/// See test_regression.py:test_2272 + +#include +#include + +#ifdef NDEBUG +#error "this code is not intended to be compiled with assertions disabled" +#endif + +int main(void) { + + // parse a graph with an unterminated string + Agraph_t *g = agmemread("graph { a[label=\"abc"); + + // this should have failed + assert(g == NULL && "unterminated string was not rejected"); + + // try parsing this graph again + g = agmemread("graph { a[label=\"abc"); + + // this one should fail too + assert(g == NULL); + + return 0; +} diff --git a/tests/test_regression.py b/tests/test_regression.py index 6316adf24..c7dac5474 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -1969,3 +1969,22 @@ def test_2270(tmp_path: Path): # it should have produced output in the expected location output = tmp_path / "hello.gv.core.dot.plain" assert output.exists(), "-O resulted in an unexpected output filename" + +@pytest.mark.xfail() +def test_2272(): + """ + using `agmemread` with an unterminated string should not fail assertions + https://gitlab.com/graphviz/graphviz/-/issues/2272 + """ + + # FIXME: Remove skip when + # https://gitlab.com/graphviz/graphviz/-/issues/1777 is fixed + if os.getenv("build_system") == "msbuild": + pytest.skip("Windows MSBuild release does not contain any header files (#1777)") + + # find co-located test source + c_src = (Path(__file__).parent / "2272.c").resolve() + assert c_src.exists(), "missing test case" + + # run the test + run_c(c_src, link=["cgraph", "gvc"])