Reviewed By: dulmarod Differential Revision: D3876176 fbshipit-source-id: e6cc634master
parent
afebcdad60
commit
25cd7dbe89
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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',
|
|
||||||
],
|
|
||||||
)
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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[]{}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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[]{
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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:"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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:"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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:"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> 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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue