diff --git a/Makefile b/Makefile index d35f8b327..5b002f9b5 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ DIRECT_TESTS += java_checkers_test java_eradicate_test java_infer_test java_trac endif ifneq ($(XCODE_SELECT),no) TARGETS_TO_TEST += objc objcpp +DIRECT_TESTS += objc_infer_test endif TARGETS_TO_TEST := $(shell echo $(TARGETS_TO_TEST)) @@ -119,6 +120,9 @@ java_tracing_test: java_quandary_test: make -C ./infer/tests/codetoanalyze/java/quandary test +objc_infer_test: + make -C ./infer/tests/codetoanalyze/objc/errors test + buck_test: infer make $(DIRECT_TESTS) NO_BUCKD=1 buck clean diff --git a/infer/tests/endtoend/BUCK b/infer/tests/endtoend/BUCK index 5b00eb71e..319e40d6a 100644 --- a/infer/tests/endtoend/BUCK +++ b/infer/tests/endtoend/BUCK @@ -15,7 +15,6 @@ tests_dependencies = [ java_test( name='objc_endtoend_tests', deps=[ - '//infer/tests/endtoend/objc/infer:infer', '//infer/tests/endtoend/objc/linters:linters', ], visibility=[ diff --git a/infer/tests/endtoend/objc/infer/AutoreleaseTest.java b/infer/tests/endtoend/objc/infer/AutoreleaseTest.java deleted file mode 100644 index 54663943c..000000000 --- a/infer/tests/endtoend/objc/infer/AutoreleaseTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class AutoreleaseTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/AutoreleaseExample.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void whenInferRunsOnAutoreleaseExampleThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - memory_leak_file, - "autorelease_main")); - } - /* - @Test - public void whenInferRunsOnAutoreleaseExampleTest1ThenMLIstFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain memory leak", - inferResults, - contains( - inferError( - MEMORY_LEAK, - memory_leak_file, - "autorelease_test1"))); - } */ - - @Test - public void whenInferRunsOnAutoreleaseExampleTest2ThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - memory_leak_file, - "autorelease_test2")); - } - - @Test - public void whenInferRunsOnAutoreleaseExampleTest3ThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - memory_leak_file, - "autorelease_test3")); - } - -} diff --git a/infer/tests/endtoend/objc/infer/BUCK b/infer/tests/endtoend/objc/infer/BUCK deleted file mode 100644 index 03c93ca6d..000000000 --- a/infer/tests/endtoend/objc/infer/BUCK +++ /dev/null @@ -1,35 +0,0 @@ -tests_dependencies = [ - '//infer/lib/java/android:android', - '//dependencies/java/guava:guava', - '//dependencies/java/junit:hamcrest', - '//dependencies/java/jackson:jackson', - '//dependencies/java/jsr-305:jsr-305', - '//dependencies/java/junit:junit', - '//dependencies/java/opencsv:opencsv', - '//infer/tests/utils:utils', -] - -objc_infer_test_sources = glob(['*.java']) -objc_infer_test_deps = [] -for test_source in objc_infer_test_sources: - target_name = test_source.replace("/", "_")[:-len(".java")] - objc_infer_test_deps.append(target_name) - - java_test( - name=target_name, - srcs=[test_source], - deps=tests_dependencies, - visibility=[ - 'PUBLIC', - ], - source='7', - target='7', - ) - -java_test( - name='infer', - deps=[':' + x for x in objc_infer_test_deps], - visibility=[ - 'PUBLIC', - ], -) diff --git a/infer/tests/endtoend/objc/infer/BlockDispatchTest.java b/infer/tests/endtoend/objc/infer/BlockDispatchTest.java deleted file mode 100644 index 75884a92e..000000000 --- a/infer/tests/endtoend/objc/infer/BlockDispatchTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -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 org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BlockDispatchTest { - - public static final String FILE = "infer/tests/codetoanalyze/objc/frontend/block/dispatch.m"; - - private static ImmutableList inferCmd; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets(folder, FILE, "cf", false); - } - - @Test - public void whenInferRunsOnMThenNPEIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - String[] procedures = { - "DispatchA_dispatch_a_block_variable_from_macro_delivers_initialised_object" - }; - assertThat( - "Results should contain the expected " + DIVIDE_BY_ZERO, - inferResults, - containsExactly( - DIVIDE_BY_ZERO, //No NPEs are found. If the call to dispatch_once didn't work - // we would get an NPE. We find only one divide by zero. - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/BlockDivideByZeroTest.java b/infer/tests/endtoend/objc/infer/BlockDivideByZeroTest.java deleted file mode 100644 index 72a13223b..000000000 --- a/infer/tests/endtoend/objc/infer/BlockDivideByZeroTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -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 org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BlockDivideByZeroTest { - - public static final String FILE = "infer/tests/codetoanalyze/objc/frontend/block/block.m"; - - private static ImmutableList inferCmd; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnMain1ThenDivideByZeroIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - "main1", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/BlockGlobalVariableTest.java b/infer/tests/endtoend/objc/infer/BlockGlobalVariableTest.java deleted file mode 100644 index 395b8e702..000000000 --- a/infer/tests/endtoend/objc/infer/BlockGlobalVariableTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -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 org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BlockGlobalVariableTest { - - public static final String FILE = "infer/tests/codetoanalyze/objc/frontend/block/block_no_args.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnMThenNPEIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - "m", - }; - assertThat( - "Results should contain the expected null pointer exception", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/BlockReleaseTest.java b/infer/tests/endtoend/objc/infer/BlockReleaseTest.java deleted file mode 100644 index d12f12875..000000000 --- a/infer/tests/endtoend/objc/infer/BlockReleaseTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BlockReleaseTest { - - public static final String FILE = "infer/tests/codetoanalyze/objc/frontend/block/block_release.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnMnThenMemoryLeakIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - // TODO: don't report on this test - "blockReleaseTODO" - }; - assertThat( - "Results should contain the expected memory leak", - inferResults, - containsExactly( - MEMORY_LEAK, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/BlockVarTest.java b/infer/tests/endtoend/objc/infer/BlockVarTest.java deleted file mode 100644 index abe40da80..000000000 --- a/infer/tests/endtoend/objc/infer/BlockVarTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -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 org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BlockVarTest { - - public static final String FILE = "infer/tests/codetoanalyze/objc/frontend/block/BlockVar.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - "navigateToURLInBackground", - "blockPostBad", - "capturedNullDeref" - }; - assertThat( - "Results should contain the expected null pointer exception", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/BoxedNumberNoNPETest.java b/infer/tests/endtoend/objc/infer/BoxedNumberNoNPETest.java deleted file mode 100644 index 3cb48a0de..000000000 --- a/infer/tests/endtoend/objc/infer/BoxedNumberNoNPETest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BoxedNumberNoNPETest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/npe/BoxedNumberExample.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnBoxedExampleNoNPEIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - String[] procedures = { - }; - assertThat( - "Results should contain no " + NULL_DEREFERENCE, - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/CADisplayLinkTest.java b/infer/tests/endtoend/objc/infer/CADisplayLinkTest.java deleted file mode 100644 index 9cc763b03..000000000 --- a/infer/tests/endtoend/objc/infer/CADisplayLinkTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class CADisplayLinkTest { - - public static final String CAD_FILE = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CADisplayLinkRetainCycle.m"; - - private static ImmutableList inferCmd; - - public static final String RETAIN_CYCLE = "RETAIN_CYCLE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand( - folder, - CAD_FILE); - } - - @Test - public void RetainCycleShouldBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] methods = { - "testCycle", - }; - assertThat( - "Results should contain " + RETAIN_CYCLE, - inferResults, - containsExactly( - RETAIN_CYCLE, - CAD_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/CategoryProcdescTest.java b/infer/tests/endtoend/objc/infer/CategoryProcdescTest.java deleted file mode 100644 index d9dc7f337..000000000 --- a/infer/tests/endtoend/objc/infer/CategoryProcdescTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class CategoryProcdescTest { - - public static final String MAIN_FILE = - "infer/tests/" + - "codetoanalyze/objc/errors/category_procdesc/main.c"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, MAIN_FILE); - } - - @Test - public void whenInferRunsOnEOCPersonThenMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain a memory leak. " + - "This shows that it doesn't stop because of procdesc not found.", - inferResults, - contains( - MEMORY_LEAK, - MAIN_FILE, - "CategoryProcdescMain" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/CompoundLiteralExprTest.java b/infer/tests/endtoend/objc/infer/CompoundLiteralExprTest.java deleted file mode 100644 index ac3656ad6..000000000 --- a/infer/tests/endtoend/objc/infer/CompoundLiteralExprTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class CompoundLiteralExprTest { - - public static final String FILE = - "infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c"; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - private static ImmutableList inferCmd; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCInferCommand(folder, FILE); - } - - @Test - public void compoundLiteralExprTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - String[] procedures = { - "init_with_compound_literal", - }; - assertThat( - "Results should contain divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/DispatchInMacroTest.java b/infer/tests/endtoend/objc/infer/DispatchInMacroTest.java deleted file mode 100644 index f70caa0f6..000000000 --- a/infer/tests/endtoend/objc/infer/DispatchInMacroTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class DispatchInMacroTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/frontend/block/dispatch_in_macro.m"; - - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnAtomicProperty() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - new String[]{} - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/DispatchTest.java b/infer/tests/endtoend/objc/infer/DispatchTest.java deleted file mode 100644 index 9b0d1c8d8..000000000 --- a/infer/tests/endtoend/objc/infer/DispatchTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class DispatchTest { - - public static final String NPE_FILE = - "infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPE_FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnDispatch_once_exampleThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "dispatch_once_example")); - } - - @Test - public void whenInferRunsOnDispatch_async_exampleThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "dispatch_async_example")); - } - - @Test - public void whenInferRunsOnDispatch_after_exampleThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "dispatch_after_example")); - } - - @Test - public void whenInferRunsOnDispatch_group_exampleThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "dispatch_group_example")); - } - - @Test - public void whenInferRunsOnDispatch_group_notify_exampleThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "dispatch_group_notify_example")); - } - - @Test - public void whenInferRunsOnDispatch_barrier_exampleThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "dispatch_barrier_example")); - } - - - -} diff --git a/infer/tests/endtoend/objc/infer/ExplicitIvarNameInGetterTest.java b/infer/tests/endtoend/objc/infer/ExplicitIvarNameInGetterTest.java deleted file mode 100644 index 9139c8ad6..000000000 --- a/infer/tests/endtoend/objc/infer/ExplicitIvarNameInGetterTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class ExplicitIvarNameInGetterTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/property/ExplicitIvarName.m"; - - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnAtomicProperty() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - new String[]{ - "testExplicit", - "testDefaultName" - } - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/FieldSuperclassTest.java b/infer/tests/endtoend/objc/infer/FieldSuperclassTest.java deleted file mode 100644 index 14e4c27e3..000000000 --- a/infer/tests/endtoend/objc/infer/FieldSuperclassTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class FieldSuperclassTest { - - public static final String FIELD_FILE = - "infer/tests/" + - "codetoanalyze/objc/errors/field_superclass/field.c"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FIELD_FILE); - } - - @Test - public void whenInferRunsOnEOCPersonThenNoMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain a memory leak.", - inferResults, - doesNotContain( - MEMORY_LEAK, - FIELD_FILE, - "main" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/GetterBuiltinTest.java b/infer/tests/endtoend/objc/infer/GetterBuiltinTest.java deleted file mode 100644 index 03ecb643e..000000000 --- a/infer/tests/endtoend/objc/infer/GetterBuiltinTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class GetterBuiltinTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/frontend/property/GetterExample.m"; - - private static ImmutableList inferCmd; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - FILE, - "cf", - false); - } - - @Test - public void whenInferRunsOnGetterExample() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - assertThat( - "Results should contain " + DIVIDE_BY_ZERO, - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - new String[]{ - } - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/GlobalConstNPETest.java b/infer/tests/endtoend/objc/infer/GlobalConstNPETest.java deleted file mode 100644 index 24c199272..000000000 --- a/infer/tests/endtoend/objc/infer/GlobalConstNPETest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class GlobalConstNPETest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/global_const/global_const.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnMain1ThenDivideByZeroIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = {"doSomethingBadWithDict:andString:"}; - assertThat( - "Results should contain the expected " + NULL_DEREFERENCE, - inferResults, - containsExactly(NULL_DEREFERENCE, FILE, procedures) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/InitListExprTest.java b/infer/tests/endtoend/objc/infer/InitListExprTest.java deleted file mode 100644 index 38d9323b2..000000000 --- a/infer/tests/endtoend/objc/infer/InitListExprTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class InitListExprTest { - - public static final String FILE = - "infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c"; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - private static ImmutableList inferCmd; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets(folder, FILE, "cf", true); - } - - @Test - public void nullDereferenceTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - String[] procedures = { - "point_coords_set_correctly", "field_set_correctly", "implicit_expr_set_correctly" - }; - assertThat( - "Results should contain divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/KindOfClassTest.java b/infer/tests/endtoend/objc/infer/KindOfClassTest.java deleted file mode 100644 index 82c9ac9f1..000000000 --- a/infer/tests/endtoend/objc/infer/KindOfClassTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class KindOfClassTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/subtyping/KindOfClassExample.m"; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - private static ImmutableList inferCmd; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets(folder, FILE, "cf", true); - } - - @Test - public void nullDereferenceTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - String[] procedures = { - "shouldThrowDivideByZero1", - "shouldThrowDivideByZero2", - "shouldThrowDivideByZero3" - }; - assertThat( - "Results should contain divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/MemoryLeakBucketingArcTest.java b/infer/tests/endtoend/objc/infer/MemoryLeakBucketingArcTest.java deleted file mode 100644 index 2d38dbda6..000000000 --- a/infer/tests/endtoend/objc/infer/MemoryLeakBucketingArcTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class MemoryLeakBucketingArcTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/" + - "RetainReleaseExampleBucketingArc.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - memory_leak_file, - "narc", - true); - } - - @Test - public void whenInferRunsOnTestWithBucketingThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - memory_leak_file, - "RetainReleaseArcTest")); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/MemoryLeakBucketingTest.java b/infer/tests/endtoend/objc/infer/MemoryLeakBucketingTest.java deleted file mode 100644 index f29cc8072..000000000 --- a/infer/tests/endtoend/objc/infer/MemoryLeakBucketingTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class MemoryLeakBucketingTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExampleBucketing.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void whenInferRunsOnTestWithBucketingThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - memory_leak_file, - "RetainReleaseTest")); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/MemoryLeakRaiiTest.java b/infer/tests/endtoend/objc/infer/MemoryLeakRaiiTest.java deleted file mode 100644 index 36187c7d0..000000000 --- a/infer/tests/endtoend/objc/infer/MemoryLeakRaiiTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class MemoryLeakRaiiTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/" + - "memory_leaks_benchmark/MemoryLeakRaii.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = {}; - assertThat( - "Results should contain the expected memory leak", - inferResults, - containsExactly( - MEMORY_LEAK, - memory_leak_file, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/MemoryLeakTest.java b/infer/tests/endtoend/objc/infer/MemoryLeakTest.java deleted file mode 100644 index 2fdc60cbf..000000000 --- a/infer/tests/endtoend/objc/infer/MemoryLeakTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class MemoryLeakTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/" + - "memory_leaks_benchmark/MemoryLeakExample.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - "test", - "measureFrameSizeForText", - "test1:", - "createCloseCrossGlyph:", - "test2:", - "regularLeak", - "blockCapturedVarLeak", - // TODO: don't report on this test - "blockFreeNoLeakTODO" - }; - assertThat( - "Results should contain the expected memory leak", - inferResults, - containsExactly( - MEMORY_LEAK, - memory_leak_file, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/MemoryLeaksFromModelsTest.java b/infer/tests/endtoend/objc/infer/MemoryLeaksFromModelsTest.java deleted file mode 100644 index afec646e9..000000000 --- a/infer/tests/endtoend/objc/infer/MemoryLeaksFromModelsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class MemoryLeaksFromModelsTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/" + - "NSStringInitWithBytesNoCopyExample.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test -public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = {"macForIV:"}; - assertThat( - "Results should contain the expected memory leak", - inferResults, - containsExactly( - MEMORY_LEAK, - memory_leak_file, - procedures - ) - ); -} -} diff --git a/infer/tests/endtoend/objc/infer/NPDCoreFoundationClassTest.java b/infer/tests/endtoend/objc/infer/NPDCoreFoundationClassTest.java deleted file mode 100644 index 1c7b25c93..000000000 --- a/infer/tests/endtoend/objc/infer/NPDCoreFoundationClassTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPDCoreFoundationClassTest { - - public static final String NPD_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPD_FILE, - "cf", - false); - - } - - - @Test - public void whenInferRunsTest2ThenOnlyTheExpectedErrorsAreFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmdNPD); - String[] expectedProcedures = { - "NullDeref_test2" - }; - assertThat( - "No unexpected errors should be found", inferResults, - containsOnly( - NULL_DEREFERENCE, - NPD_FILE, - expectedProcedures)); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NPEArrayLiteralTest.java b/infer/tests/endtoend/objc/infer/NPEArrayLiteralTest.java deleted file mode 100644 index a8426c38b..000000000 --- a/infer/tests/endtoend/objc/infer/NPEArrayLiteralTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPEArrayLiteralTest { - - public static final String PREMATURE_NIL_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/nil_in_array_literal.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folderNPD, - PREMATURE_NIL_FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnTestThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - PREMATURE_NIL_FILE, - "no_problem")); - - String[] expectedNPEProcedures = { - "nilInArrayLiteral0", - "nilInArrayLiteral1", - "nilInArrayLiteral2", - "nilInArrayLiteral3", - "nilInArrayWithObject" - }; - assertThat( - "Only NPE should be found", inferResults, - containsExactly( - NULL_DEREFERENCE, - PREMATURE_NIL_FILE, - expectedNPEProcedures)); - } -} diff --git a/infer/tests/endtoend/objc/infer/NPEConditionalTest.java b/infer/tests/endtoend/objc/infer/NPEConditionalTest.java deleted file mode 100644 index 3c126953e..000000000 --- a/infer/tests/endtoend/objc/infer/NPEConditionalTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2016 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPEConditionalTest { - - public static final String NPE_CONDITIONAL = - "infer/tests/codetoanalyze/objc/errors/npe/npe_conditional.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folderNPD, - NPE_CONDITIONAL, - "cf", - true); - } - - @Test - public void whenInferRunsOnTestThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - - String[] expectedNPEProcedures = { - "conditionalNPE" - }; - assertThat( - "Only NPE should be found", inferResults, - containsExactly( - NULL_DEREFERENCE, - NPE_CONDITIONAL, - expectedNPEProcedures)); - } -} diff --git a/infer/tests/endtoend/objc/infer/NPEDictionaryLiteralTest.java b/infer/tests/endtoend/objc/infer/NPEDictionaryLiteralTest.java deleted file mode 100644 index a36a264cc..000000000 --- a/infer/tests/endtoend/objc/infer/NPEDictionaryLiteralTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPEDictionaryLiteralTest { - - public static final String PREMATURE_NIL_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/nil_in_dictionary_literal.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folderNPD, - PREMATURE_NIL_FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnTestThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - PREMATURE_NIL_FILE, - "no_problem")); - - String[] expectedNPEProcedures = { - "nilInDictionaryLiteralKey0", - "nilInDictionaryLiteralKey1", - "nilInDictionaryLiteralKey2", - "nilInDictionaryLiteralKey3", - "nilInDictionaryLiteralValue0", - "nilInDictionaryLiteralValue1", - "nilInDictionaryLiteralValue2", - "nilInDictionaryLiteralValue3" - }; - assertThat( - "Only NPE should be found", inferResults, - containsExactly( - NULL_DEREFERENCE, - PREMATURE_NIL_FILE, - expectedNPEProcedures)); - } -} diff --git a/infer/tests/endtoend/objc/infer/NPEEqualNamesTest.java b/infer/tests/endtoend/objc/infer/NPEEqualNamesTest.java deleted file mode 100644 index 46bcbc2f0..000000000 --- a/infer/tests/endtoend/objc/infer/NPEEqualNamesTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPEEqualNamesTest { - - public static final String NPE_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/Npe_with_equal_names.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPE_FILE, - "cf", - false); - } - - @Test - public void nullDereferenceTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - String[] procedures = { - "EqualNamesTest", - }; - assertThat( - "Results should contain null pointer dereference error", - inferResults, - containsExactly( - NULL_DEREFERENCE, - NPE_FILE, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NPEMallocTest.java b/infer/tests/endtoend/objc/infer/NPEMallocTest.java deleted file mode 100644 index 700331bc4..000000000 --- a/infer/tests/endtoend/objc/infer/NPEMallocTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPEMallocTest { - - public static final String NPE_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createObjCInferCommand( - folderNPD, - NPE_FILE); - } - - @Test - public void whenInferRunsOnTestThenNoNPENotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "test")); - } -} diff --git a/infer/tests/endtoend/objc/infer/NPEObjCMethodInConditionTest.java b/infer/tests/endtoend/objc/infer/NPEObjCMethodInConditionTest.java deleted file mode 100644 index b57c74c30..000000000 --- a/infer/tests/endtoend/objc/infer/NPEObjCMethodInConditionTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPEObjCMethodInConditionTest { - - public static final String NPE_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/ObjCMethodCallInCondition.m"; - - private static ImmutableList inferCmdNPD; - - public static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPE_FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOncaptureManagerSessionDidStartThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - String[] procedures = {}; - assertThat( - "Results should not contain parameter not null checked", - inferResults, - containsExactly( - PARAMETER_NOT_NULL_CHECKED, - NPE_FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/NPESelfTest.java b/infer/tests/endtoend/objc/infer/NPESelfTest.java deleted file mode 100644 index 118718a8f..000000000 --- a/infer/tests/endtoend/objc/infer/NPESelfTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NPESelfTest { - - public static final String NPE_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/npe_self.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPE_FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOncaptureManagerSessionDidStartThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "captureManagerSessionDidStart")); - } - - @Test - public void whenInferRunsOnInitThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "init")); - } - - @Test - public void whenInferRunsOnTestThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should be found, and the field name in the error message is correct", inferResults, - contains( - NULL_DEREFERENCE, - NPE_FILE, - "test")); - } - - @Test - public void whenInferRunsOnIsEqualThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNPD); - assertThat( - "NPE should not be found", inferResults, - doesNotContain( - NULL_DEREFERENCE, - NPE_FILE, - "isEqual:")); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/NSAssertTest.java b/infer/tests/endtoend/objc/infer/NSAssertTest.java deleted file mode 100644 index 305c416b9..000000000 --- a/infer/tests/endtoend/objc/infer/NSAssertTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NSAssertTest { - - public static final String ASSERT_FILE = - "infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, ASSERT_FILE); - } - - @Test - public void whenInferRunsOnNSAssertAddTargetNoNPEisFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain null point dereference", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - ASSERT_FILE, - "addTarget:")); - } - - @Test - public void whenInferRunsOnNSAssertNoNPEIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain null point dereference", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - ASSERT_FILE, - "initWithRequest:")); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NSMakeCollectableTest.java b/infer/tests/endtoend/objc/infer/NSMakeCollectableTest.java deleted file mode 100644 index 12e8eb4f0..000000000 --- a/infer/tests/endtoend/objc/infer/NSMakeCollectableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NSMakeCollectableTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSMakeCollectableExample.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void whenInferRunsOnTestWithBucketingThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - }; - assertThat( - "Results should not contain memory leak", - inferResults, - containsExactly( - MEMORY_LEAK, - memory_leak_file, - procedures)); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/NilParamDerefObjCClassTest.java b/infer/tests/endtoend/objc/infer/NilParamDerefObjCClassTest.java deleted file mode 100644 index 216f8b00a..000000000 --- a/infer/tests/endtoend/objc/infer/NilParamDerefObjCClassTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NilParamDerefObjCClassTest { - - public static final String NIL_PARAM_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/nil_param.m"; - - private static ImmutableList inferCmdNil; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - - @ClassRule - public static DebuggableTemporaryFolder folderNil = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNil = InferRunner.createObjCInferCommand(folderNil, NIL_PARAM_FILE); - } - - - @Test - public void whenInferRunsOnNil_ParamNoErrorsAreFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNil); - assertThat( - "Results should not contain null point dereference", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - NIL_PARAM_FILE, - "test1:")); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NoMemoryLeakBlockIteratorTest.java b/infer/tests/endtoend/objc/infer/NoMemoryLeakBlockIteratorTest.java deleted file mode 100644 index cf0730dea..000000000 --- a/infer/tests/endtoend/objc/infer/NoMemoryLeakBlockIteratorTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NoMemoryLeakBlockIteratorTest { - - public static final String block_file = - "infer/tests/codetoanalyze/objc/frontend/block/block-it.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - block_file, - "cf", - false); - } - - @Test - public void whenInferRunsOnLayoutSubviewsThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - block_file, - "array")); - } -} diff --git a/infer/tests/endtoend/objc/infer/NonnullAttributeTest.java b/infer/tests/endtoend/objc/infer/NonnullAttributeTest.java deleted file mode 100644 index 36e96f5ed..000000000 --- a/infer/tests/endtoend/objc/infer/NonnullAttributeTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NonnullAttributeTest { - - public static final String NONNULL_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m"; - - private static ImmutableList inferCmdNil; - - public static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED"; - - - @ClassRule - public static DebuggableTemporaryFolder folderNil = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNil = InferRunner.createiOSInferCommandWithMLBuckets( - folderNil, - NONNULL_FILE, - "cf", - false); - } - - @Test - public void angelismTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdNil); - String[] procedures = {}; - assertThat( - "Results should not contain parameter not null checked", - inferResults, - containsExactly( - PARAMETER_NOT_NULL_CHECKED, - NONNULL_FILE, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NullDerefObjCBlockTest.java b/infer/tests/endtoend/objc/infer/NullDerefObjCBlockTest.java deleted file mode 100644 index 6c41a7103..000000000 --- a/infer/tests/endtoend/objc/infer/NullDerefObjCBlockTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NullDerefObjCBlockTest { - - public static final String BLOCK_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/block.m"; - - - private static ImmutableList inferCmdBlock; - - private static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED"; - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - public static final String IVAR_NOT_NULL_CHECKED = "IVAR_NOT_NULL_CHECKED"; - - @ClassRule - public static DebuggableTemporaryFolder folderBlock = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdBlock = InferRunner.createObjCInferCommandWithMLBuckets( - folderBlock, - BLOCK_FILE, - "cf", - false); - - } - - @Test - public void whenInferRunsOnAClass1ThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdBlock); - assertThat( - "Results should contain parameter not null checked error", - inferResults, - contains( - PARAMETER_NOT_NULL_CHECKED, - BLOCK_FILE, - "doSomethingThenCallback:" - ) - ); - } - - @Test - public void whenInferRunsOnAClass2ThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdBlock); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - BLOCK_FILE, - "foo" - ) - ); - } - - @Test - public void whenInferRunsOnAClass3ThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdBlock); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - BLOCK_FILE, - "foo3:" - ) - ); - } - - @Test - public void whenInferRunsOnAClass4ThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdBlock); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - BLOCK_FILE, - "foo4:" - ) - ); - } - - - @Test - public void whenInferRunsOnAClass5ThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdBlock); - assertThat( - "Results should contain ivar not nullable error", - inferResults, - contains( - IVAR_NOT_NULL_CHECKED, - BLOCK_FILE, - "foo7" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/NullDerefObjCClassTest.java b/infer/tests/endtoend/objc/infer/NullDerefObjCClassTest.java deleted file mode 100644 index 88d305601..000000000 --- a/infer/tests/endtoend/objc/infer/NullDerefObjCClassTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NullDerefObjCClassTest { - - public static final String FRACTION_FILE = - "infer/tests/codetoanalyze/objc/errors/npe/Fraction.m"; - - private static ImmutableList inferCmdFraction; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderFraction = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdFraction = InferRunner.createObjCInferCommandWithMLBuckets( - folderFraction, - FRACTION_FILE, - "cf", - false); - - } - - @Test - public void whenInferRunsOnNull_deref_objc_classThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmdFraction); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - FRACTION_FILE, - "test_virtual_call" - ) - ); - } - - @Test - public void whenInferRunsOnNpeThenOnlyTheExpectedErrorsAreFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmdFraction); - String[] expectedProcedures = { - "test_virtual_call" - }; - assertThat( - "No unexpected errors should be found", inferResults, - containsOnly( - NULL_DEREFERENCE, - FRACTION_FILE, - expectedProcedures)); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NullParamTest.java b/infer/tests/endtoend/objc/infer/NullParamTest.java deleted file mode 100644 index 502d87961..000000000 --- a/infer/tests/endtoend/objc/infer/NullParamTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NullParamTest { - - public static final String block_file = - "infer/tests/codetoanalyze/objc/errors/npe/blockenum.m"; - - private static ImmutableList inferCmd; - - public static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand( - folder, - block_file - ); - } - - @Test - public void whenInferRunsOnFoo1ParameterNilIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - PARAMETER_NOT_NULL_CHECKED, - block_file, - "foo1:")); - } - @Test - public void whenInferRunsOnAllResultsListParameterNilIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - PARAMETER_NOT_NULL_CHECKED, - block_file, - "allResultsList:")); - } -} diff --git a/infer/tests/endtoend/objc/infer/NullReturnedByMethodTest.java b/infer/tests/endtoend/objc/infer/NullReturnedByMethodTest.java deleted file mode 100644 index 059da98cb..000000000 --- a/infer/tests/endtoend/objc/infer/NullReturnedByMethodTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NullReturnedByMethodTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/npe/null_returned_by_method.m"; - - private static ImmutableList inferCmdFraction; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderFraction = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdFraction = InferRunner.createObjCInferCommand( - folderFraction, - FILE); - - } - - @Test - public void whenInferRunsOnTest1ThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - FILE, - "test1" - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/NullableTest.java b/infer/tests/endtoend/objc/infer/NullableTest.java deleted file mode 100644 index cca52b9b8..000000000 --- a/infer/tests/endtoend/objc/infer/NullableTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NullableTest { - - public static final String NPE_FILE = "infer/tests/codetoanalyze/objc/errors/npe/nullable.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPE_FILE, - "cf", - true); - } - - @Test - public void nullDereferenceTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmdNPD); - String[] procedures = { - "derefNullableParamDirect", - "derefNullableParamIndirect", - "parameter_nullable_bug" - }; - assertThat( - "Results should contain null pointer dereference error", - inferResults, - containsExactly( - NULL_DEREFERENCE, - NPE_FILE, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/ParameterNotNullableTest.java b/infer/tests/endtoend/objc/infer/ParameterNotNullableTest.java deleted file mode 100644 index 0013811bb..000000000 --- a/infer/tests/endtoend/objc/infer/ParameterNotNullableTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class ParameterNotNullableTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/warnings/ParameterNotNullableExample.m"; - - private static ImmutableList inferCmdFraction; - - public static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED"; - - public static final String IVAR_NOT_NULL_CHECKED = "IVAR_NOT_NULL_CHECKED"; - - @ClassRule - public static DebuggableTemporaryFolder folderFraction = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdFraction = InferRunner.createObjCInferCommand( - folderFraction, - FILE); - } - - @Test - public void whenInferRunsOnFBAudioInputCallbackSimpleThenPNNIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain a parameter not nullable warning", - inferResults, - contains( - PARAMETER_NOT_NULL_CHECKED, - FILE, - "FBAudioInputCallbackSimple:" - ) - ); - } - - @Test - public void whenInferRunsOnFBAudioInputCallbackSimpleAliasingThenPNNIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain a parameter not nullable warning", - inferResults, - contains( - PARAMETER_NOT_NULL_CHECKED, - FILE, - "FBAudioInputCallbackSimpleAliasing:" - ) - ); - } - - @Test - public void whenInferRunsOnFBAudioInputCallbackChainThenPNNIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain a parameter not nullable warning", - inferResults, - contains( - PARAMETER_NOT_NULL_CHECKED, - FILE, - "FBAudioInputCallbackChain:" - ) - ); - } - - @Test - public void whenInferRunsOnInitThenPNNIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should not contain a parameter not nullable warning", - inferResults, - doesNotContain( - PARAMETER_NOT_NULL_CHECKED, - FILE, - "init" - ) - ); - } - - @Test - public void whenInferRunsOnTestThenPNNIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should not contain a parameter not nullable warning", - inferResults, - doesNotContain( - PARAMETER_NOT_NULL_CHECKED, - FILE, - "test" - ) - ); - } - - @Test - public void whenInferRunsOnFBAudioInputCallbackFieldThenIVNNIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain an ivar not nullable warning", - inferResults, - contains( - IVAR_NOT_NULL_CHECKED, - FILE, - "FBAudioInputCallbackField" - ) - ); - } - - @Test - public void whenInferRunsOnFBAudioInputCallbackChainThenIVNNIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain an ivar not nullable warning", - inferResults, - contains( - IVAR_NOT_NULL_CHECKED, - FILE, - "FBAudioInputCallbackChain:" - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/PrematureNilTerminationTest.java b/infer/tests/endtoend/objc/infer/PrematureNilTerminationTest.java deleted file mode 100644 index 4b0873d12..000000000 --- a/infer/tests/endtoend/objc/infer/PrematureNilTerminationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class PrematureNilTerminationTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m"; - - private static ImmutableList inferCmd; - - public static final String PREMATURE_NIL_TERMINATION_ARGUMENT = - "PREMATURE_NIL_TERMINATION_ARGUMENT"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folderNPD, - SOURCE_FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnPrematureNileFileThenOnePNTAIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] expectedPNTAProcedures = {"nilInArrayWithObjects"}; - - assertThat( - "Only PNTA should be found", inferResults, - containsExactly( - PREMATURE_NIL_TERMINATION_ARGUMENT, - SOURCE_FILE, - expectedPNTAProcedures)); - } - -} diff --git a/infer/tests/endtoend/objc/infer/ProcdescTest.java b/infer/tests/endtoend/objc/infer/ProcdescTest.java deleted file mode 100644 index e9608dff5..000000000 --- a/infer/tests/endtoend/objc/infer/ProcdescTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class ProcdescTest { - - public static final String MAIN_FILE = - "infer/tests/" + - "codetoanalyze/objc/errors/procdescs/main.c"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, MAIN_FILE); - } - - @Test - public void whenInferRunsOnNull_deref_objc_classThenMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - assertThat( - "Results should contain a memory leak. " + - "This shows that it doesn't stop because of procdesc not found.", - inferResults, - contains( - MEMORY_LEAK, - MAIN_FILE, - "ProcdescMain" - ) - ); - } - - @Test - public void whenInferRunsOnCall_nslogThenMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - assertThat( - "Results should contain a memory leak. " + - "This shows that it doesn't stop because of procdesc not found.", - inferResults, - contains( - MEMORY_LEAK, - MAIN_FILE, - "call_nslog" - ) - ); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/PropertyMemoryLeakTest.java b/infer/tests/endtoend/objc/infer/PropertyMemoryLeakTest.java deleted file mode 100644 index 2da6e8c83..000000000 --- a/infer/tests/endtoend/objc/infer/PropertyMemoryLeakTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class PropertyMemoryLeakTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/frontend/property/PropertyAttributes.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void whenInferRunsOnLayoutPropertyAttributesThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - MEMORY_LEAK, - memory_leak_file, - "test")); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/PropertyTest.java b/infer/tests/endtoend/objc/infer/PropertyTest.java deleted file mode 100644 index a03cf24c2..000000000 --- a/infer/tests/endtoend/objc/infer/PropertyTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class PropertyTest { - - public static final String MAIN_FILE = - "infer/tests/" + - "codetoanalyze/objc/errors/property/main.c"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, MAIN_FILE); - } - - @Test - public void whenInferRunsOnPropertyDeclarationThenMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - assertThat( - "Results should contain a memory leak.", - inferResults, - contains( - MEMORY_LEAK, - MAIN_FILE, - "property_main" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/ProtocolProcdescTest.java b/infer/tests/endtoend/objc/infer/ProtocolProcdescTest.java deleted file mode 100644 index d94af3921..000000000 --- a/infer/tests/endtoend/objc/infer/ProtocolProcdescTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class ProtocolProcdescTest { - - public static final String MAIN_FILE = - "infer/tests/" + - "codetoanalyze/objc/errors/procdescs/main.c"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, MAIN_FILE); - } - - @Test - public void whenInferRunsOnBicycleThenMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain a memory leak. " + - "This shows that it doesn't stop because of procdesc not found.", - inferResults, - contains( - MEMORY_LEAK, - MAIN_FILE, - "ProcdescMain" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/ResourceLeakTest.java b/infer/tests/endtoend/objc/infer/ResourceLeakTest.java deleted file mode 100644 index 18cc597c1..000000000 --- a/infer/tests/endtoend/objc/infer/ResourceLeakTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class ResourceLeakTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/resource_leaks/ResourceLeakExample.m"; - - private static ImmutableList inferCmd; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - false); - } - - @Test - public void whenInferRunsOnFileHandleForLoggingAtPathThenRLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain resource leak", - inferResults, - doesNotContain( - RESOURCE_LEAK, - memory_leak_file, - "fileHandleForLoggingAtPath")); - } - - @Test - public void whenInferRunsOnNewOutputThenRLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain resource leak", - inferResults, - doesNotContain( - RESOURCE_LEAK, - memory_leak_file, - "newOutput")); - } - -} diff --git a/infer/tests/endtoend/objc/infer/RetainCycle2Test.java b/infer/tests/endtoend/objc/infer/RetainCycle2Test.java deleted file mode 100644 index e61183d00..000000000 --- a/infer/tests/endtoend/objc/infer/RetainCycle2Test.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RetainCycle2Test { - - public static final String retain_cycle_file = - "infer/tests/codetoanalyze/objc/errors/" + - "memory_leaks_benchmark/retain_cycle2.m"; - - private static ImmutableList inferCmd; - - public static final String RETAIN_CYCLE = "RETAIN_CYCLE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - retain_cycle_file, - "cf", - true); - } - - - - @Test - public void whenInferRunsOnStrongCycleThenRCIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain retain cycle", - inferResults, - containsExactly( - RETAIN_CYCLE, - retain_cycle_file, - new String[]{"strongcycle2"})); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/RetainCycleStaticVarTest.java b/infer/tests/endtoend/objc/infer/RetainCycleStaticVarTest.java deleted file mode 100644 index bb1dd2c8c..000000000 --- a/infer/tests/endtoend/objc/infer/RetainCycleStaticVarTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RetainCycleStaticVarTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainCycleStaticVar.m"; - - private static ImmutableList inferCmd; - - public static final String RETAIN_CYCLE = "RETAIN_CYCLE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnStrongCycleThenRCIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] procedures = { - "RetainCSVycleStaticVar", - }; - assertThat( - "Results should contain the expected retain cycles", - inferResults, - containsExactly( - RETAIN_CYCLE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/RetainCycleTest.java b/infer/tests/endtoend/objc/infer/RetainCycleTest.java deleted file mode 100644 index a34677964..000000000 --- a/infer/tests/endtoend/objc/infer/RetainCycleTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RetainCycleTest { - - public static final String retain_cycle_file = - "infer/tests/codetoanalyze/objc/errors/" + - "memory_leaks_benchmark/retain_cycle.m"; - - private static ImmutableList inferCmd; - - public static final String RETAIN_CYCLE = "RETAIN_CYCLE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - retain_cycle_file, - "cf", - true); - } - - - - @Test - public void whenInferRunsOnStrongCycleThenRCIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain retain cycle", - inferResults, - contains( - RETAIN_CYCLE, - retain_cycle_file, - "strongcycle")); - } - - @Test - public void whenInferRunsOnUnsafeUnretainedCycleThenIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - RETAIN_CYCLE, - retain_cycle_file, - "unsafeunretainedcycle")); - } - - @Test - public void whenInferRunsOnWeakCycleThenIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - RETAIN_CYCLE, - retain_cycle_file, - "weakcycle")); - } - - - @Test - public void whenInferRunsOnAssignCycleThenIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain memory leak", - inferResults, - doesNotContain( - RETAIN_CYCLE, - retain_cycle_file, - "assigncycle")); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/RetainreleaseTest.java b/infer/tests/endtoend/objc/infer/RetainreleaseTest.java deleted file mode 100644 index fc61a9f63..000000000 --- a/infer/tests/endtoend/objc/infer/RetainreleaseTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RetainreleaseTest { - - public static final String retain_release_file = - "infer/tests/" + - "codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand( - folder, - retain_release_file); - } - - - @Test - public void whenInferRunsOnSimpleTest3ThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain memory leak error", - inferResults, - contains( - MEMORY_LEAK, - retain_release_file, - "test3" - ) - ); - } - - @Test - public void whenInferRunsOnSimpleTest6ThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain memory leak error", - inferResults, - contains( - MEMORY_LEAK, - retain_release_file, - "test6" - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/ReturnTest.java b/infer/tests/endtoend/objc/infer/ReturnTest.java deleted file mode 100644 index 57ff5b9a1..000000000 --- a/infer/tests/endtoend/objc/infer/ReturnTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class ReturnTest { - - public static final String SRC_FILE = - "infer/tests/" + - "codetoanalyze/objc/errors/returnstmt/return_npe_test.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, SRC_FILE); - } - - @Test - public void whenInferRunsOnMyClassThenNoNPEIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain null point dereference", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - SRC_FILE, - "aMethod:" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/SkipMethodWithNilObjectTest.java b/infer/tests/endtoend/objc/infer/SkipMethodWithNilObjectTest.java deleted file mode 100644 index 4a53fb98c..000000000 --- a/infer/tests/endtoend/objc/infer/SkipMethodWithNilObjectTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class SkipMethodWithNilObjectTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/npe/skip_method_with_nil_object.m"; - - private static ImmutableList inferCmd; - - public static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - FILE, - "cf", - false); - } - - @Test - public void whenInferRunsOnFBAudioInputCallbackSimpleThenPNNIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] expectedProcedures = {"testBug:"}; - assertThat( - "Results should contain " + PARAMETER_NOT_NULL_CHECKED, inferResults, - containsExactly( - PARAMETER_NOT_NULL_CHECKED, - FILE, - expectedProcedures)); - } - -} diff --git a/infer/tests/endtoend/objc/infer/SubtypingTest.java b/infer/tests/endtoend/objc/infer/SubtypingTest.java deleted file mode 100644 index 86772a923..000000000 --- a/infer/tests/endtoend/objc/infer/SubtypingTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class SubtypingTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/field_superclass/SubtypingExample.m"; - - private static ImmutableList inferCmd; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets(folder, FILE, "cf", true); - } - - @Test - public void whenInferRunsOnDiv0MethodsErrorIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmd); - String[] procedures = { - "Employee_initWithName:andAge:andEducation:", - "subtyping_test" - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/SuperTest.java b/infer/tests/endtoend/objc/infer/SuperTest.java deleted file mode 100644 index 6709191f7..000000000 --- a/infer/tests/endtoend/objc/infer/SuperTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class SuperTest { - - public static final String MAIN_FILE = "infer/tests/codetoanalyze/objc/" + - "errors/field_superclass/SuperExample.m"; - - private static ImmutableList inferCmd; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommand(folder, MAIN_FILE); - } - - @Test - public void whenInferRunsOnEOCPersonThenMemoryLeakIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain null pointer dereference error.", - inferResults, - contains( - NULL_DEREFERENCE, - MAIN_FILE, - "init" - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/Taint2Test.java b/infer/tests/endtoend/objc/infer/Taint2Test.java deleted file mode 100644 index 43a2115b6..000000000 --- a/infer/tests/endtoend/objc/infer/Taint2Test.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class Taint2Test { - - public static final String TaintFile = - "infer/tests/codetoanalyze/objc/errors/taint/sources.m"; - - public static final String TAINTED_VALUE = "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION"; - - private static ImmutableList inferCmd; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - TaintFile, - "cf", - false); - } - - @Test - public void whenInferRunsOnTaintFileErrorFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] methods = { - "testNSHTTPCookie1", - "testNSHTTPCookie2", - "testNSHTTPCookie3", - "testNSHTTPCookie4" - }; - - assertThat( - "Results should contain tainted value reaching sensitive function.", - inferResults, - containsExactly( - TAINTED_VALUE, - TaintFile, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/TaintTest.java b/infer/tests/endtoend/objc/infer/TaintTest.java deleted file mode 100644 index 52be85482..000000000 --- a/infer/tests/endtoend/objc/infer/TaintTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class TaintTest { - - public static final String TaintFile = - "infer/tests/codetoanalyze/objc/errors/taint/viewController.m"; - - public static final String TAINTED_VALUE = "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION"; - - private static ImmutableList inferCmd; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCInferCommandWithMLBuckets( - folder, - TaintFile, - "cf", - false); - } - - @Test - public void whenInferRunsOnTaintFileErrorFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] methods = { - "application:openURL:sourceApplication:annotation:" - }; - - assertThat( - "Results should contain tainted value reaching sensitive function.", - inferResults, - containsExactly( - TAINTED_VALUE, - TaintFile, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/infer/TollBridgeTest.java b/infer/tests/endtoend/objc/infer/TollBridgeTest.java deleted file mode 100644 index 6b7b15537..000000000 --- a/infer/tests/endtoend/objc/infer/TollBridgeTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.InferError.inferError; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsExactly.containsExactly; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class TollBridgeTest { - - public static final String memory_leak_file = - "infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.m"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createiOSInferCommandWithMLBuckets( - folder, - memory_leak_file, - "cf", - true); - } - - @Test - public void whenInferRunsOnTollBridgeExampleThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain memory leaks", - inferResults, - containsExactly( - MEMORY_LEAK, - memory_leak_file, - new String[]{ - "bridge", - "brideRetained", - } - ) - ); - } -} diff --git a/infer/tests/endtoend/objc/infer/UpdateDictNPETest.java b/infer/tests/endtoend/objc/infer/UpdateDictNPETest.java deleted file mode 100644 index 732b159e4..000000000 --- a/infer/tests/endtoend/objc/infer/UpdateDictNPETest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class UpdateDictNPETest { - - public static final String NPE_FILE = "infer/tests/codetoanalyze/objc/errors/npe/UpdateDict.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - NPE_FILE, - "cf", - true); - } - - @Test - public void nullDereferenceTest() throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmdNPD); - String[] procedures = { - "update_dict_with_key_null", - "update_array_with_null", - "add_nil_to_array", - "insert_nil_in_array", - "add_nil_in_dict", - "nullable_NSDictionary_objectForKey", - "nullable_NSDictionary_objectForKeyedSubscript", - "nullable_NSMapTable_objectForKey" - }; - assertThat( - "Results should contain null pointer dereference error", - inferResults, - containsExactly( - NULL_DEREFERENCE, - NPE_FILE, - procedures - ) - ); - } - - -} diff --git a/infer/tests/endtoend/objc/infer/WeakVariableInBlockNPETest.java b/infer/tests/endtoend/objc/infer/WeakVariableInBlockNPETest.java deleted file mode 100644 index e7f2afbd5..000000000 --- a/infer/tests/endtoend/objc/infer/WeakVariableInBlockNPETest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * 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. - */ - -package endtoend.objc.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class WeakVariableInBlockNPETest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/errors/npe/WeakCapturedVarsNPE.m"; - - private static ImmutableList inferCmdNPD; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - @ClassRule - public static DebuggableTemporaryFolder folderNPD = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdNPD = InferRunner.createiOSInferCommandWithMLBuckets( - folderNPD, - FILE, - "cf", - true); - } - - @Test - public void whenInferRunsOnWeakCapturedVariablesNPEThenNPEsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferC(inferCmdNPD); - String[] procedures = {"__objc_anonymous_block_WeakCapturedA_strongSelfNoCheck______2"}; - assertThat( - "Results should not contain null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -}