[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
master
Jeremy Dubreil 10 years ago
parent 9b63476805
commit 902e5afa61

@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * 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 x = 0;
int y = 5; int y = 5;
return y / x; return y / x;

@ -6,7 +6,8 @@
* LICENSE file in the root directory of this source tree. An additional grant * 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. * 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}}}; 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]; return t[0][1][0]/t[1][2][1];
} }

@ -37,7 +37,7 @@ public class DivideByZeroTest {
@Test @Test
public void whenInferRunsOnDivideByZeroThenDivideByZeroIsFound() public void whenInferRunsOnDivideByZeroThenDivideByZeroIsFound()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
String[] procedures = {"divide_by_zero"}; String[] procedures = {"arith_divide_by_zero"};
assertThat( assertThat(
"Results should contain divide by zero error", "Results should contain divide by zero error",
inferResults, inferResults,

@ -10,7 +10,7 @@
package endtoend.c; package endtoend.c;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.ResultContainsErrorInMethod.contains; import static utils.matchers.ResultContainsExactly.containsExactly;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -27,33 +27,31 @@ import utils.InferRunner;
public class InitListExprTest { public class InitListExprTest {
public static final String initlistexpr_file = public static final String SOURCE_FILE =
"infer/tests/" + "initialization/initlistexpr.c";
"codetoanalyze/c/errors/initialization/initlistexpr.c";
private static ImmutableList<String> inferCmd;
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
@ClassRule private static InferResults inferResults;
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
@BeforeClass @BeforeClass
public static void runInfer() throws InterruptedException, IOException { public static void loadResults() throws InterruptedException, IOException {
inferCmd = InferRunner.createCInferCommand(folder, initlistexpr_file); inferResults = InferResults.loadCInferResults(InitListExprTest.class, SOURCE_FILE);
} }
@Test @Test
public void whenInferRunsOnInitListExprThenDivideByZeroIsFound() public void whenInferRunsOnInitListExprThenDivideByZeroIsFound()
throws InterruptedException, IOException, InferException { throws InterruptedException, IOException, InferException {
InferResults inferResults = InferRunner.runInferC(inferCmd); String[] methods = {
"init_divide_by_zero"
};
assertThat( assertThat(
"Results should contain divide by zero error", "Results should contain " + DIVIDE_BY_ZERO,
inferResults, inferResults,
contains( containsExactly(
DIVIDE_BY_ZERO, DIVIDE_BY_ZERO,
initlistexpr_file, SOURCE_FILE,
"divide_by_zero" methods
) )
); );
} }

Loading…
Cancel
Save