From 902e5afa6170136544ac1b2353d0af7cd984e004 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Fri, 17 Jul 2015 10:08:48 -0700 Subject: [PATCH] [infer][clang] fix name collision in the C tests Summary: There was a name collision between two files which was preventing to run the tests based on Makefile --- .../c/errors/arithmetic/divide_by_zero.c | 2 +- .../c/errors/initialization/initlistexpr.c | 3 +- infer/tests/endtoend/c/DivideByZeroTest.java | 2 +- infer/tests/endtoend/c/InitListExprTest.java | 28 +++++++++---------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/infer/tests/codetoanalyze/c/errors/arithmetic/divide_by_zero.c b/infer/tests/codetoanalyze/c/errors/arithmetic/divide_by_zero.c index 8adb2f358..007b47a68 100644 --- a/infer/tests/codetoanalyze/c/errors/arithmetic/divide_by_zero.c +++ b/infer/tests/codetoanalyze/c/errors/arithmetic/divide_by_zero.c @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int divide_by_zero() { +int arith_divide_by_zero() { int x = 0; int y = 5; return y / x; diff --git a/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c b/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c index 58a72a43c..a38bd1a59 100644 --- a/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c +++ b/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c @@ -6,7 +6,8 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ -int divide_by_zero() { + +int init_divide_by_zero() { int t[2][3][2] = {{{1,1},{2,2},{3,3}},{{4,4},{5,5},{1,0}}}; return t[0][1][0]/t[1][2][1]; } diff --git a/infer/tests/endtoend/c/DivideByZeroTest.java b/infer/tests/endtoend/c/DivideByZeroTest.java index 6aec42027..698621d93 100644 --- a/infer/tests/endtoend/c/DivideByZeroTest.java +++ b/infer/tests/endtoend/c/DivideByZeroTest.java @@ -37,7 +37,7 @@ public class DivideByZeroTest { @Test public void whenInferRunsOnDivideByZeroThenDivideByZeroIsFound() throws InterruptedException, IOException, InferException { - String[] procedures = {"divide_by_zero"}; + String[] procedures = {"arith_divide_by_zero"}; assertThat( "Results should contain divide by zero error", inferResults, diff --git a/infer/tests/endtoend/c/InitListExprTest.java b/infer/tests/endtoend/c/InitListExprTest.java index bff535e89..c42b05ae1 100644 --- a/infer/tests/endtoend/c/InitListExprTest.java +++ b/infer/tests/endtoend/c/InitListExprTest.java @@ -10,7 +10,7 @@ package endtoend.c; import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; +import static utils.matchers.ResultContainsExactly.containsExactly; import com.google.common.collect.ImmutableList; @@ -27,33 +27,31 @@ import utils.InferRunner; public class InitListExprTest { - public static final String initlistexpr_file = - "infer/tests/" + - "codetoanalyze/c/errors/initialization/initlistexpr.c"; - - private static ImmutableList inferCmd; + public static final String SOURCE_FILE = + "initialization/initlistexpr.c"; public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); + private static InferResults inferResults; @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCInferCommand(folder, initlistexpr_file); + public static void loadResults() throws InterruptedException, IOException { + inferResults = InferResults.loadCInferResults(InitListExprTest.class, SOURCE_FILE); } @Test public void whenInferRunsOnInitListExprThenDivideByZeroIsFound() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); + String[] methods = { + "init_divide_by_zero" + }; assertThat( - "Results should contain divide by zero error", + "Results should contain " + DIVIDE_BY_ZERO, inferResults, - contains( + containsExactly( DIVIDE_BY_ZERO, - initlistexpr_file, - "divide_by_zero" + SOURCE_FILE, + methods ) ); }