From 674f30de2ca2260cd3042565c54b2b4c95109646 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 30 Aug 2016 01:04:32 -0700 Subject: [PATCH] Convert java infer tests to the new direct format Reviewed By: sblackshear Differential Revision: D3784844 fbshipit-source-id: 44c021d --- .buckconfig | 2 - Makefile | 10 +- infer/src/backend/InferPrint.re | 7 +- infer/tests/codetoanalyze/java/Makefile | 6 +- .../codetoanalyze/java/checkers/Makefile | 4 +- .../codetoanalyze/java/eradicate/Makefile | 4 +- .../codetoanalyze/java/infer/.inferconfig | 25 ++ infer/tests/codetoanalyze/java/infer/Makefile | 46 ++ .../tests/codetoanalyze/java/infer/issues.exp | 214 +++++++++ .../java/infer/AnalysisStopsTest.java | 415 ------------------ .../java/infer/ArrayOutOfBoundsTest.java | 55 --- .../java/infer/AutoGeneratedTest.java | 55 --- .../endtoend/java/infer/BuiltinsTest.java | 57 --- .../java/infer/ClassCastExceptionsTest.java | 100 ----- .../java/infer/CloseableAsResourceTest.java | 60 --- .../endtoend/java/infer/ContextLeaksTest.java | 61 --- .../endtoend/java/infer/CursorLeaksTest.java | 60 --- .../endtoend/java/infer/DivideByZeroTest.java | 52 --- .../java/infer/DynamicDispatchTest.java | 59 --- .../infer/FilterInputStreamLeaksTest.java | 67 --- .../infer/FilterOutputStreamLeaksTest.java | 68 --- .../endtoend/java/infer/GuardedByTest.java | 74 ---- .../endtoend/java/infer/HashMapModelTest.java | 118 ----- .../endtoend/java/infer/IntegerClassTest.java | 51 --- .../java/infer/JunitAssertionTest.java | 66 --- .../java/infer/NullPointerExceptionTest.java | 92 ---- .../endtoend/java/infer/ReaderLeaksTest.java | 66 --- .../java/infer/ResourceLeaksTest.java | 138 ------ .../java/infer/ReturnValueIgnoredTest.java | 65 --- .../tests/endtoend/java/infer/TaintTest.java | 81 ---- .../endtoend/java/infer/WriterLeaksTest.java | 62 --- infer/tests/utils/InferResults.java | 1 - 32 files changed, 307 insertions(+), 1934 deletions(-) create mode 100644 infer/tests/codetoanalyze/java/infer/.inferconfig create mode 100644 infer/tests/codetoanalyze/java/infer/Makefile create mode 100644 infer/tests/codetoanalyze/java/infer/issues.exp delete mode 100644 infer/tests/endtoend/java/infer/AnalysisStopsTest.java delete mode 100644 infer/tests/endtoend/java/infer/ArrayOutOfBoundsTest.java delete mode 100644 infer/tests/endtoend/java/infer/AutoGeneratedTest.java delete mode 100644 infer/tests/endtoend/java/infer/BuiltinsTest.java delete mode 100644 infer/tests/endtoend/java/infer/ClassCastExceptionsTest.java delete mode 100644 infer/tests/endtoend/java/infer/CloseableAsResourceTest.java delete mode 100644 infer/tests/endtoend/java/infer/ContextLeaksTest.java delete mode 100644 infer/tests/endtoend/java/infer/CursorLeaksTest.java delete mode 100644 infer/tests/endtoend/java/infer/DivideByZeroTest.java delete mode 100644 infer/tests/endtoend/java/infer/DynamicDispatchTest.java delete mode 100644 infer/tests/endtoend/java/infer/FilterInputStreamLeaksTest.java delete mode 100644 infer/tests/endtoend/java/infer/FilterOutputStreamLeaksTest.java delete mode 100644 infer/tests/endtoend/java/infer/GuardedByTest.java delete mode 100644 infer/tests/endtoend/java/infer/HashMapModelTest.java delete mode 100644 infer/tests/endtoend/java/infer/IntegerClassTest.java delete mode 100644 infer/tests/endtoend/java/infer/JunitAssertionTest.java delete mode 100644 infer/tests/endtoend/java/infer/NullPointerExceptionTest.java delete mode 100644 infer/tests/endtoend/java/infer/ReaderLeaksTest.java delete mode 100644 infer/tests/endtoend/java/infer/ResourceLeaksTest.java delete mode 100644 infer/tests/endtoend/java/infer/ReturnValueIgnoredTest.java delete mode 100644 infer/tests/endtoend/java/infer/TaintTest.java delete mode 100644 infer/tests/endtoend/java/infer/WriterLeaksTest.java diff --git a/.buckconfig b/.buckconfig index a2a11542d..866bf4653 100644 --- a/.buckconfig +++ b/.buckconfig @@ -17,8 +17,6 @@ java_libraries = //dependencies/java:java_libraries infer = //infer/tests/endtoend/java/infer:infer - eradicate = //infer/tests/endtoend/java/eradicate:eradicate - checkers = //infer/tests/endtoend/java/checkers:checkers tracing = //infer/tests/endtoend/java/tracing:tracing linters = //infer/tests/endtoend:linters diff --git a/Makefile b/Makefile index fd3faa2f8..11fb8ca19 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ TARGETS_TO_TEST += c cpp endif ifeq ($(BUILD_JAVA_ANALYZERS),yes) TARGETS_TO_TEST += java -DIRECT_TESTS += checkers_test eradicate_test +DIRECT_TESTS += java_checkers_test java_eradicate_test java_infer_test endif ifneq ($(XCODE_SELECT),no) TARGETS_TO_TEST += objc objcpp @@ -97,12 +97,16 @@ endif ocaml_unit_test: test_this_build $(TEST_BUILD_DIR)/unit/inferunit.byte -checkers_test: +java_checkers_test: make -C ./infer/tests/codetoanalyze/java/checkers test -eradicate_test: +java_eradicate_test: make -C ./infer/tests/codetoanalyze/java/eradicate test +java_infer_test: + make -C ./infer/tests/codetoanalyze/java/infer test + + buck_test: infer make $(DIRECT_TESTS) NO_BUCKD=1 buck clean diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index e30a743dd..4fdf3f005 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -475,7 +475,7 @@ let module IssuesJson = { let module IssuesTests = { /** Write bug report in a format suitable for tests on analysis results. */ let pp_issues_of_error_log fmt error_filter _ proc_loc_opt proc_name err_log => { - let pp_row _ loc _ _ in_footprint error_name error_desc _ _ _ _ => { + let pp_row _ loc _ ekind in_footprint error_name error_desc _ _ _ _ => { let (source_file, line_offset) = switch proc_loc_opt { | Some proc_loc => @@ -483,7 +483,10 @@ let module IssuesTests = { (proc_loc.Location.file, line_offset) | None => (loc.Location.file, 0) }; - if (in_footprint && error_filter source_file error_desc error_name) { + let should_report = + ekind == Exceptions.Kerror || + IList.exists (Localise.equal error_name) [Localise.return_value_ignored]; + if (in_footprint && should_report && error_filter source_file error_desc error_name) { F.fprintf fmt "%s, %a, %d, %a@." diff --git a/infer/tests/codetoanalyze/java/Makefile b/infer/tests/codetoanalyze/java/Makefile index 899ef5bf9..ee5bc3a05 100644 --- a/infer/tests/codetoanalyze/java/Makefile +++ b/infer/tests/codetoanalyze/java/Makefile @@ -12,15 +12,17 @@ ANDROID19 = $(JAVA_LIB_DIR)/android/android-19.jar ANDROIDSUPPORT = $(DEPENDENCIES_DIR)/java/android/support/v4/android-support-v4.jar ANNOTATIONS = $(ANNOTATIONS_DIR)/annotations.jar BUTTERKNIFE = $(DEPENDENCIES_DIR)/java/butterknife/butterknife-7.0.1.jar +JACKSON = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar JSR305 = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar INJECT = $(DEPENDENCIES_DIR)/java/jsr-330/javax.inject.jar +MODELS = $(JAVA_LIB_DIR)/models.jar -CLASSPATH=$(ANDROID19):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(JSR305):$(INJECT):. +CLASSPATH=$(ANDROID19):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(JACKSON):$(JSR305):$(INJECT):$(MODELS):. default: compile print: analyze - $(INFERPRINT_BIN) -q --issues-tests issues.exp.test + $(INFERPRINT_BIN) -q -a $(ANALYZER) --issues-tests issues.exp.test LC_ALL=C sort -o issues.exp.test issues.exp.test test: analyze print diff --git a/infer/tests/codetoanalyze/java/checkers/Makefile b/infer/tests/codetoanalyze/java/checkers/Makefile index 8a074088d..d1d84713c 100644 --- a/infer/tests/codetoanalyze/java/checkers/Makefile +++ b/infer/tests/codetoanalyze/java/checkers/Makefile @@ -7,6 +7,8 @@ include ../Makefile +ANALYZER = checkers + FILES = \ Branch.java \ FragmentRetainsViewExample.java \ @@ -25,4 +27,4 @@ compile: javac -cp $(CLASSPATH) $(FILES) analyze: - $(INFER_BIN) -a checkers -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null + $(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null diff --git a/infer/tests/codetoanalyze/java/eradicate/Makefile b/infer/tests/codetoanalyze/java/eradicate/Makefile index 0045fe205..211d22dc1 100644 --- a/infer/tests/codetoanalyze/java/eradicate/Makefile +++ b/infer/tests/codetoanalyze/java/eradicate/Makefile @@ -7,6 +7,8 @@ include ../Makefile +ANALYZER = eradicate + FILES = \ ActivityFieldNotInitialized.java \ FieldNotInitialized.java \ @@ -27,4 +29,4 @@ compile: analyze: ERADICATE_RETURN_OVER_ANNOTATED=1 \ - $(INFER_BIN) -a eradicate -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null + $(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null diff --git a/infer/tests/codetoanalyze/java/infer/.inferconfig b/infer/tests/codetoanalyze/java/infer/.inferconfig new file mode 100644 index 000000000..afe8db3e3 --- /dev/null +++ b/infer/tests/codetoanalyze/java/infer/.inferconfig @@ -0,0 +1,25 @@ +{ + "never_returning_null": [ + { + "language": "Java", + "source_contains": "_AUTOMATICALLY_GENERATED_" + }, + { + "language": "Java", + "class": "codetoanalyze.java.infer.SomeLibrary", + "method": "get" + } + ], + "infer-blacklist-files-containing": [ + "@generated" + ], + "enable_checks": [ + "UNSAFE_GUARDED_BY_ACCESS" + ], + "skip_translation": [ + { + "language": "Java", + "source_contains": "_SHOULD_BE_SKIPPED_" + } + ] +} diff --git a/infer/tests/codetoanalyze/java/infer/Makefile b/infer/tests/codetoanalyze/java/infer/Makefile new file mode 100644 index 000000000..446d59445 --- /dev/null +++ b/infer/tests/codetoanalyze/java/infer/Makefile @@ -0,0 +1,46 @@ +# 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. + +include ../Makefile + +ANALYZER = infer + +FILES = \ + SomeLibrary.java \ + SkippedSourceFile.java \ + T.java \ + Utils.java \ + \ + AnalysisStops.java \ + ArrayOutOfBounds.java \ + AutoGenerated.java \ + Builtins.java \ + ClassCastExceptions.java \ + CloseableAsResourceExample.java \ + ContextLeaks.java \ + CursorLeaks.java \ + DivideByZero.java \ + DynamicDispatch.java \ + FilterInputStreamLeaks.java \ + FilterOutputStreamLeaks.java \ + GuardedByExample.java \ + HashMapExample.java \ + IntegerExample.java \ + JunitAssertion.java \ + NeverNullSource.java \ + NullPointerExceptions.java \ + ReaderLeaks.java \ + ResourceLeaks.java \ + ReturnValueIgnored.java \ + TaintExample.java \ + WriterLeaks.java \ + +compile: + javac -cp $(CLASSPATH) $(FILES) + +analyze: + $(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null diff --git a/infer/tests/codetoanalyze/java/infer/issues.exp b/infer/tests/codetoanalyze/java/infer/issues.exp new file mode 100644 index 000000000..e626e0bb6 --- /dev/null +++ b/infer/tests/codetoanalyze/java/infer/issues.exp @@ -0,0 +1,214 @@ +AnalysisStops.java, void AnalysisStops.accessPathInCalleeMayCauseFalseNegative(), 3, NULL_DEREFERENCE +AnalysisStops.java, void AnalysisStops.callOnCastUndefinedObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.callOnUndefinedObjMayCauseFalseNegative(), 2, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.castFailureOnUndefinedObjMayCauseFalseNegative(), 1, RETURN_VALUE_IGNORED +AnalysisStops.java, void AnalysisStops.castFailureOnUndefinedObjMayCauseFalseNegative(), 2, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.fieldReadAferCastMayCauseFalseNegative(Iterator), 6, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.fieldReadInCalleeMayCauseFalseNegative(), 3, NULL_DEREFERENCE +AnalysisStops.java, void AnalysisStops.fieldReadInCalleeWithAngelicObjFieldMayCauseFalseNegative(), 3, NULL_DEREFERENCE +AnalysisStops.java, void AnalysisStops.fieldReadOnUndefinedObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.fieldWriteOnUndefinedObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.heapFieldOfAngelicObjMayCauseFalseNegative(), 4, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.infiniteMaterializationMayCauseFalseNegative(boolean), 5, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.primitiveFieldOfAngelicObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.primitiveFieldOfAngelicObjMayCauseFalseNegative(), 5, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.recursiveAngelicTypesMayCauseFalseNegative(), 4, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.skipFunctionInLoopMayCauseFalseNegative(), 5, NULL_DEREFERENCE +AnalysisStops.java, void AnalysisStops.skipPointerDerefMayCauseCalleeFalseNegative(), 2, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.skipPointerDerefMayCauseInterprocFalseNegative(), 2, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.skipPointerDerefMayCauseLocalFalseNegative(), 3, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.specInferenceMayFailAndCauseFalseNegative(boolean,Iterator), 2, RETURN_VALUE_IGNORED +AnalysisStops.java, void AnalysisStops.specInferenceMayFailAndCauseFalseNegative(boolean,Iterator), 26, DIVIDE_BY_ZERO +AnalysisStops.java, void AnalysisStops.specInferenceMayFailAndCauseFalseNegative(boolean,Iterator), 3, RETURN_VALUE_IGNORED +ArrayOutOfBounds.java, int ArrayOutOfBounds.arrayOutOfBounds(), 2, ARRAY_OUT_OF_BOUNDS_L1 +Builtins.java, void Builtins.causeError(Object), 2, NULL_DEREFERENCE +Builtins.java, void Builtins.doNotBlockError(Object), 3, NULL_DEREFERENCE +ClassCastExceptions.java, int ClassCastExceptions.classCastExceptionImplementsInterface(), 0, CLASS_CAST_EXCEPTION +ClassCastExceptions.java, void ClassCastExceptions.classCastException(), 2, CLASS_CAST_EXCEPTION +CloseableAsResourceExample.java, T CloseableAsResourceExample.sourceOfNullWithResourceLeak(), 1, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.failToCloseWithCloseQuietly(), 5, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.leakFoundWhenIndirectlyImplementingCloseable(), 1, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingCloseable(), 1, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingWrapper(), 2, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.skippedVritualCallDoesNotCloseResourceOnReceiver(), 2, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.withException(), 4, RESOURCE_LEAK +ContextLeaks.java, ContextLeaks$Singleton ContextLeaks$Singleton.getInstance(Context), 4, CONTEXT_LEAK +ContextLeaks.java, ContextLeaks$Singleton ContextLeaks.singletonLeak(), 1, CONTEXT_LEAK +ContextLeaks.java, void ContextLeaks.directLeak(), 2, CONTEXT_LEAK +ContextLeaks.java, void ContextLeaks.indirectLeak(), 4, CONTEXT_LEAK +ContextLeaks.java, void ContextLeaks.leakAfterInstanceFieldWrite(), 3, CONTEXT_LEAK +ContextLeaks.java, void ContextLeaks.nonStaticInnerClassLeak(), 2, CONTEXT_LEAK +CursorLeaks.java, int CursorLeaks.completeDownloadNotClosed(DownloadManager), 8, RESOURCE_LEAK +CursorLeaks.java, int CursorLeaks.cursorNotClosed(SQLiteDatabase), 4, RESOURCE_LEAK +CursorLeaks.java, int CursorLeaks.getBucketCountNotClosed(), 10, RESOURCE_LEAK +CursorLeaks.java, int CursorLeaks.getImageCountHelperNotClosed(String), 13, RESOURCE_LEAK +CursorLeaks.java, void CursorLeaks.loadPrefsFromContentProviderNotClosed(), 11, RESOURCE_LEAK +CursorLeaks.java, void CursorLeaks.queryUVMLegacyDbNotClosed(), 4, RESOURCE_LEAK +DivideByZero.java, int DivideByZero.callDivideByZeroInterProc(), 1, DIVIDE_BY_ZERO +DivideByZero.java, int DivideByZero.divByZeroLocal(String), 3, DIVIDE_BY_ZERO +DivideByZero.java, int DivideByZero.divideByZeroWithStaticField(), 2, DIVIDE_BY_ZERO +DynamicDispatch.java, void DynamicDispatch.dynamicDispatchShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE +DynamicDispatch.java, void DynamicDispatch.interfaceShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE +DynamicDispatch.java, void DynamicDispatch.interfaceShouldNotCauseFalseNegativeHard(DynamicDispatch$Interface), 2, NULL_DEREFERENCE +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.bufferedInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.checkedInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.cipherInputStreamNotClosedAfterSkip(), 7, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.dataInputStreamNotClosedAfterRead(), 8, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.deflaterInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.digestInputStreamNotClosedAfterRead(), 8, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.gzipInputStreamNotClosedAfterRead(), 4, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.gzipInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.inflaterInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK +FilterInputStreamLeaks.java, void FilterInputStreamLeaks.pushbackInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.bufferedOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.checkedOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.cipherOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.dataOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.deflaterOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.digestOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.filterOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.gzipOutputStreamNotClosedAfterFlush(), 4, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.gzipOutputStreamNotClosedAfterFlush(), 7, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.inflaterOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK +FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.printStreamNotClosedAfterWrite(), 6, RESOURCE_LEAK +GuardedByExample.java, Object GuardedByExample.byRefTrickyBad(), 5, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, String GuardedByExample$3.readFromInnerClassBad1(), 2, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, String GuardedByExample$4.readFromInnerClassBad2(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.readFAfterBlockBad(), 3, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.readFBad(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.readFBadWrongAnnotation(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.readFBadWrongLock(), 2, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.readHBad(), 2, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.readHBadSynchronizedMethodShouldntHelp(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.synchronizedMethodReadBad(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.synchronizedMethodWriteBad(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.synchronizedOnThisBad(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.writeFAfterBlockBad(), 3, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.writeFBad(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.writeFBadWrongLock(), 2, UNSAFE_GUARDED_BY_ACCESS +HashMapExample.java, Integer HashMapExample.getOrCreateInteger(HashMap,int), 8, RETURN_VALUE_IGNORED +HashMapExample.java, int HashMapExample.getOneIntegerWithoutCheck(), 6, NULL_DEREFERENCE +HashMapExample.java, void HashMapExample.getTwoIntegersWithOneCheck(Integer,Integer), 11, NULL_DEREFERENCE +HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 6, RETURN_VALUE_IGNORED +HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 7, RETURN_VALUE_IGNORED +JunitAssertion.java, void JunitAssertion.inconsistentAssertion(JunitAssertion$A), 2, NULL_DEREFERENCE +NullPointerExceptions.java, String NullPointerExceptions.hashmapNPE(HashMap,Object), 1, NULL_DEREFERENCE +NullPointerExceptions.java, String NullPointerExceptions.nullTryLock(FileChannel), 2, NULL_DEREFERENCE +NullPointerExceptions.java, String NullPointerExceptions.testSystemGetPropertyArgument(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, String NullPointerExceptions.tryLockThrows(FileChannel), 6, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.NPEvalueOfFromHashmapBad(HashMap,int), 1, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullListFiles(String), 3, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullPointerException(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionInterProc(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithAChainOfFields(NullPointerExceptions$C), 2, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithArray(), 3, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithExceptionHandling(boolean), 5, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions$$$Class$Name$With$Dollars.npeWithDollars(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.badCheckShouldCauseNPE(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.cursorFromContentResolverNPE(String), 9, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.derefNull(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.derefNullableGetter(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.derefNullableRet(boolean), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.derefUndefNullableRet(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.derefUndefNullableRetWrapper(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterLoopOnList(NullPointerExceptions$L), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock1(Lock), 4, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock2(Lock), 6, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionArrayLength(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionCallArrayReadMethod(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFailingFileOutputStreamConstructor(), 7, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFaillingResourceConstructor(), 6, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionInArrayLengthLoop(java.lang.Object[]), 3, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionUnlessFrameFails(), 4, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullArrayParameter(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullObjectParameter(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullableFieldNPE(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.nullableParamNPE(Object), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.optionalNPE(Optional), 1, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.someNPEAfterResourceLeak(), 2, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.stringConstantEqualsFalseNotNPE_FP(), 10, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.stringVarEqualsFalseNPE(), 5, NULL_DEREFERENCE +NullPointerExceptions.java, void NullPointerExceptions.testSystemGetPropertyReturn(), 2, NULL_DEREFERENCE +ReaderLeaks.java, void ReaderLeaks.bufferedReaderNotClosedAfterRead(), 6, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.fileReaderNotClosedAfterRead(), 6, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.inputStreamReaderNotClosedAfterRead(), 6, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.pipedReaderFalsePositive(), 5, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.pipedReaderNotClosedAfterConnect(PipedWriter), 7, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.pipedReaderNotClosedAfterConstructedWithWriter(), 8, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.pushbackReaderNotClosedAfterRead(), 6, RESOURCE_LEAK +ReaderLeaks.java, void ReaderLeaks.readerNotClosedAfterRead(), 6, RESOURCE_LEAK +ResourceLeaks.java, String ResourceLeaks.readInstallationFileBad(File), 6, RESOURCE_LEAK +ResourceLeaks.java, boolean ResourceLeaks.jarFileNotClosed(), 3, RESOURCE_LEAK +ResourceLeaks.java, int ResourceLeaks.fileOutputStreamTwoLeaks1(boolean), 3, RESOURCE_LEAK +ResourceLeaks.java, int ResourceLeaks.fileOutputStreamTwoLeaks1(boolean), 6, RESOURCE_LEAK +ResourceLeaks.java, int ResourceLeaks.readConfigNotCloseStream(String), 5, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.activityObtainTypedArrayAndLeak(Activity), 2, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.contextObtainTypedArrayAndLeak(Context), 2, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.copyFileLeak(File,File), 11, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.copyFileLeak(File,File), 11, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.deflaterLeak(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.fileInputStreamNotClosedAfterRead(), 6, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.fileOutputStreamNotClosed(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.fileOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.fileOutputStreamOneLeak(), 2, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.fileOutputStreamTwoLeaks2(), 2, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.fileOutputStreamTwoLeaks2(), 5, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.inflaterLeak(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.jarInputStreamLeak(), 3, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.jarOutputStreamLeak(), 3, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.nestedBad1(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.nestedBad2(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.nestedBadJarInputStream(File), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.nestedBadJarOutputStream(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.objectInputStreamClosedNestedBad(), 3, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.objectInputStreamNotClosedAfterRead(), 3, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.objectInputStreamNotClosedAfterRead(), 6, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.objectOutputStreamClosedNestedBad(), 3, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.objectOutputStreamNotClosedAfterWrite(), 4, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.objectOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.openHttpURLConnectionNotDisconnected(), 7, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.openHttpsURLConnectionNotDisconnected(), 3, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 5, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.pipedInputStreamNotClosedAfterRead(PipedOutputStream), 6, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.pipedOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.scannerNotClosed(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.serverSocketNotClosed(), 12, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.socketNotClosed(), 1, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.themeObtainTypedArrayAndLeak(Resources$Theme), 2, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.twoResources(), 11, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.twoResourcesRandomAccessFile(), 10, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 10, RESOURCE_LEAK +ResourceLeaks.java, void ResourceLeaks.zipFileLeakExceptionalBranch(), 5, RESOURCE_LEAK +ReturnValueIgnored.java, void ReturnValueIgnored.returnValueIgnored(), 1, RETURN_VALUE_IGNORED +TaintExample.java, InputStream TaintExample.socketIgnoreExceptionNoVerify(SSLSocketFactory), 9, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, InputStream TaintExample.socketVerifiedForgotToCheckRetval(SSLSocketFactory,HostnameVerifier,SSLSession), 7, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference1(SSLSocketFactory), 4, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference2(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.contentValuesPutWithTaintedString(ContentValues,SharedPreferences,String,String), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods2(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods3(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethodsUndefined1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethodsUndefined2(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethodsUndefined3(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.simpleTaintErrorWithModelMethods(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.simpleTaintErrorWithModelMethodsUndefined(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testIntegritySinkAnnotReport(String), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testIntegritySourceAnnot(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testIntegritySourceInstanceFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testIntegritySourceStaticFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testPrivacySinkAnnot1(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testPrivacySinkAnnot3(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testPrivacySourceAnnot(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testPrivacySourceFieldAnnotPropagation(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testPrivacySourceInstanceFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +TaintExample.java, void TaintExample.testPrivacySourceStaticFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION +WriterLeaks.java, void WriterLeaks.bufferedWriterNotClosedAfterWrite(), 7, RESOURCE_LEAK +WriterLeaks.java, void WriterLeaks.fileWriterNotClosedAfterWrite(), 6, RESOURCE_LEAK +WriterLeaks.java, void WriterLeaks.outputStreamWriterNotClosedAfterWrite(), 6, RESOURCE_LEAK +WriterLeaks.java, void WriterLeaks.pipedWriterNotClosedAfterConnect(PipedReader), 7, RESOURCE_LEAK +WriterLeaks.java, void WriterLeaks.pipedWriterNotClosedAfterConstructedWithReader(), 8, RESOURCE_LEAK +WriterLeaks.java, void WriterLeaks.printWriterNotClosedAfterAppend(), 4, RESOURCE_LEAK +WriterLeaks.java, void WriterLeaks.writerNotClosedAfterWrite(), 6, RESOURCE_LEAK diff --git a/infer/tests/endtoend/java/infer/AnalysisStopsTest.java b/infer/tests/endtoend/java/infer/AnalysisStopsTest.java deleted file mode 100644 index bb849c009..000000000 --- a/infer/tests/endtoend/java/infer/AnalysisStopsTest.java +++ /dev/null @@ -1,415 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNumberOfErrorsInMethod.containsNumberOfErrors; -import static utils.matchers.ResultContainsZeroErrorsInMethod.containsZeroErrors; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class AnalysisStopsTest { - - public static final String AnalysisStops = - "infer/tests/codetoanalyze/java/infer/AnalysisStops.java"; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(AnalysisStopsTest.class, AnalysisStops); - } - - @Test - public void skipPtrDerefDoesntCauseLocalFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "skipPointerDerefMayCauseLocalFalseNegative" - ) - ); - } - - @Test - public void skipPtrDerefDoesntCauseCalleeFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "skipPointerDerefMayCauseCalleeFalseNegative" - ) - ); - } - - @Test - public void skipPtrDerefDoesntCauseCalleeFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "skipPointerDerefMayCauseCalleeFalsePositive")); - } - - @Test - public void skipPtrDerefDoesntCauseInterprocFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "skipPointerDerefMayCauseInterprocFalseNegative" - ) - ); - } - - @Test - public void castUndefinedObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "castFailureOnUndefinedObjMayCauseFalseNegative" - ) - ); - } - - @Test - public void callOnCastUndefinedObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "callOnCastUndefinedObjMayCauseFalseNegative" - ) - ); - } - - @Test - public void callOnUndefinedObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "callOnUndefinedObjMayCauseFalseNegative" - ) - ); - } - - @Test - public void callOnUndefinedObjDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "callOnUndefinedObjMayCauseFalsePositive")); - } - - @Test - public void fieldWriteOnUndefinedObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "fieldWriteOnUndefinedObjMayCauseFalseNegative" - ) - ); - } - - @Test - public void fieldWriteOnUndefinedObjDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "fieldWriteOnUndefinedObjMayCauseFalsePositive")); - } - - @Test - public void fieldReadOnUndefinedObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "fieldReadOnUndefinedObjMayCauseFalseNegative" - ) - ); - } - - @Test - public void fieldReadOnUndefinedObjDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "fieldReadOnUndefinedObjMayCauseFalsePositive")); - } - - @Test - public void recursiveAngelicTypesDontCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "recursiveAngelicTypesMayCauseFalseNegative" - ) - ); - } - - @Test - public void recursiveAngelicTypesDontCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "recursiveAngelicTypeMayCauseFalsePositive")); - } - - @Test - public void infiniteMaterializationDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "infiniteMaterializationMayCauseFalseNegative" - ) - ); - } - - @Test - public void infiniteMaterializationDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "infiniteMaterializationMayCauseFalsePositive")); - } - - @Test - public void primitiveFieldOfAngelicObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - containsNumberOfErrors( - DIVIDE_BY_ZERO, - AnalysisStops, - "primitiveFieldOfAngelicObjMayCauseFalseNegative", - 2 - ) - ); - } - - @Test - public void primitiveFieldOfAngelicObjDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "primitiveFieldOfAngelicObjMayCauseFalsePositive")); - } - - @Test - public void heapFieldOfAngelicObjDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "heapFieldOfAngelicObjMayCauseFalseNegative" - ) - ); - } - - @Test - public void heapFieldOfAngelicObjDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "heapFieldOfAngelicObjMayCauseFalsePositive")); - } - - @Test - public void fieldReadAfterCastDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "fieldReadAferCastMayCauseFalseNegative" - ) - ); - } - - @Test - public void fieldReadInCalleeDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "fieldReadInCalleeMayCauseFalsePositive")); - } - - // these do not work yet - @Test - public void fieldReadInCalleeDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - NULL_DEREFERENCE, - AnalysisStops, - "fieldReadInCalleeMayCauseFalseNegative" - ) - ); - } - - @Test - public void fieldReadInCalleeWithAngelicObjFieldDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "fieldReadInCalleeWithAngelicObjFieldMayCauseFalsePositive")); - } - - @Test - public void fieldReadInCalleeWithAngelicObjFieldDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - NULL_DEREFERENCE, - AnalysisStops, - "fieldReadInCalleeWithAngelicObjFieldMayCauseFalseNegative" - ) - ); - } - - @Test - public void accessPathInCalleeDoesntCauseFalsePositive() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain no errors", - inferResults, - containsZeroErrors( - AnalysisStops, - "accessPathInCalleeMayCauseFalseNegative")); - } - - @Test - public void accessPathInCalleeDoesntCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - NULL_DEREFERENCE, - AnalysisStops, - "accessPathInCalleeMayCauseFalseNegative" - ) - ); - } - - @Test - public void skipFunctionInLoopShouldNotCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - NULL_DEREFERENCE, - AnalysisStops, - "skipFunctionInLoopMayCauseFalseNegative" - ) - ); - } - - @Test - public void specInferenceFailureShouldNotCauseFalseNegative() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain error", - inferResults, - contains( - DIVIDE_BY_ZERO, - AnalysisStops, - "specInferenceMayFailAndCauseFalseNegative" - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/ArrayOutOfBoundsTest.java b/infer/tests/endtoend/java/infer/ArrayOutOfBoundsTest.java deleted file mode 100644 index 809fa6a80..000000000 --- a/infer/tests/endtoend/java/infer/ArrayOutOfBoundsTest.java +++ /dev/null @@ -1,55 +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.java.infer; - - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ArrayOutOfBoundsTest { - - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java"; - - public static final String ARRAY_OUT_OF_BOUNDS_L1 = "ARRAY_OUT_OF_BOUNDS_L1"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(ArrayOutOfBoundsTest.class, SOURCE_FILE); - } - - @Test - public void whenInferRunsOnArrayOutOfBoundsThenErrorIsFound() - throws IOException, InterruptedException, InferException { - String[] methods = { - "arrayOutOfBounds", - }; - assertThat( - "Results should contain out of bounds error.", inferResults, - containsExactly( - ARRAY_OUT_OF_BOUNDS_L1, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/AutoGeneratedTest.java b/infer/tests/endtoend/java/infer/AutoGeneratedTest.java deleted file mode 100644 index dabc4b387..000000000 --- a/infer/tests/endtoend/java/infer/AutoGeneratedTest.java +++ /dev/null @@ -1,55 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class AutoGeneratedTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/AutoGenerated.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - AutoGeneratedTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - }; - assertThat( - "Results should contain no errors", - inferResults, - containsExactly( - NULL_DEREFERENCE, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/BuiltinsTest.java b/infer/tests/endtoend/java/infer/BuiltinsTest.java deleted file mode 100644 index 89cef1899..000000000 --- a/infer/tests/endtoend/java/infer/BuiltinsTest.java +++ /dev/null @@ -1,57 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class BuiltinsTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/Builtins.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - BuiltinsTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "doNotBlockError", - "causeError" - }; - assertThat( - "Results should contain " + NULL_DEREFERENCE, - inferResults, - containsExactly( - NULL_DEREFERENCE, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/ClassCastExceptionsTest.java b/infer/tests/endtoend/java/infer/ClassCastExceptionsTest.java deleted file mode 100644 index df18a6bdd..000000000 --- a/infer/tests/endtoend/java/infer/ClassCastExceptionsTest.java +++ /dev/null @@ -1,100 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; -import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ClassCastExceptionsTest { - - public static final String ClassCastExceptions = - "infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java"; - - public static final String CLASS_CAST_EXCEPTION = "CLASS_CAST_EXCEPTION"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - ClassCastExceptionsTest.class, - ClassCastExceptions); - } - - @Test - public void whenInferRunsOnClassCastExceptionThenCCEFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain class cast exception.", - inferResults, - contains( - CLASS_CAST_EXCEPTION, - ClassCastExceptions, - "classCastException" - ) - ); - } - - @Test - public void whenInferRunsOnClassCastExceptionImplementsIThenCCEErrorFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain class cast exception.", - inferResults, - contains( - CLASS_CAST_EXCEPTION, - ClassCastExceptions, - "classCastExceptionImplementsInterface" - ) - ); - } - - @Test - public void whenInferRunsOnOpenHttpURLConnectionThenCCEErrorNotFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should not contain class cast exception.", - inferResults, - doesNotContain( - CLASS_CAST_EXCEPTION, - ClassCastExceptions, - "openHttpURLConnection" - ) - ); - } - - @Test - public void whenInferIsRunCCEThenOnlyTheExpectedErrorsAreFound() - throws InterruptedException, IOException, InferException { - String[] expectedMethods = { - "classCastException", - "classCastExceptionImplementsInterface", - "openHttpURLConnection" - }; - assertThat( - "No unexpected errors should be found", - inferResults, - containsOnly( - CLASS_CAST_EXCEPTION, - ClassCastExceptions, - expectedMethods)); - } - -} diff --git a/infer/tests/endtoend/java/infer/CloseableAsResourceTest.java b/infer/tests/endtoend/java/infer/CloseableAsResourceTest.java deleted file mode 100644 index 70efeb79d..000000000 --- a/infer/tests/endtoend/java/infer/CloseableAsResourceTest.java +++ /dev/null @@ -1,60 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class CloseableAsResourceTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/CloseableAsResourceExample.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws IOException { - inferResults = InferResults.loadInferResults(CloseableAsResourceTest.class, SOURCE_FILE); - } - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "withException", - "notClosingCloseable", - "notClosingWrapper", - "failToCloseWithCloseQuietly", - "sourceOfNullWithResourceLeak", - "leakFoundWhenIndirectlyImplementingCloseable", - "skippedVritualCallDoesNotCloseResourceOnReceiver", - }; - assertThat( - "Results should contain resource leak errors", - inferResults, - containsExactly( - RESOURCE_LEAK, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/ContextLeaksTest.java b/infer/tests/endtoend/java/infer/ContextLeaksTest.java deleted file mode 100644 index f20a383e8..000000000 --- a/infer/tests/endtoend/java/infer/ContextLeaksTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package endtoend.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ContextLeaksTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/ContextLeaks.java"; - - public static final String CONTEXT_LEAK = "CONTEXT_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - ContextLeaksTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "directLeak", - "indirectLeak", - "nonStaticInnerClassLeak", - "leakAfterInstanceFieldWrite", - "singletonLeak", - "getInstance", - }; - assertThat( - "Results should contain " + CONTEXT_LEAK, - inferResults, - containsExactly( - CONTEXT_LEAK, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/CursorLeaksTest.java b/infer/tests/endtoend/java/infer/CursorLeaksTest.java deleted file mode 100644 index 8c73f5398..000000000 --- a/infer/tests/endtoend/java/infer/CursorLeaksTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package endtoend.java.infer; - - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class CursorLeaksTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/CursorLeaks.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws IOException { - inferResults = InferResults.loadInferResults(CursorLeaksTest.class, SOURCE_FILE); - } - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "cursorNotClosed", - "getImageCountHelperNotClosed", - "getBucketCountNotClosed", - "queryUVMLegacyDbNotClosed", - "completeDownloadNotClosed", - "loadPrefsFromContentProviderNotClosed", - }; - assertThat( - "Results should not contain resource leak errors", - inferResults, - containsExactly( - RESOURCE_LEAK, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/DivideByZeroTest.java b/infer/tests/endtoend/java/infer/DivideByZeroTest.java deleted file mode 100644 index 15fe68066..000000000 --- a/infer/tests/endtoend/java/infer/DivideByZeroTest.java +++ /dev/null @@ -1,52 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class DivideByZeroTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/DivideByZero.java"; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(DivideByZeroTest.class, SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "divByZeroLocal", - "callDivideByZeroInterProc", - "divideByZeroWithStaticField", - }; - assertThat("Results should contain " + DIVIDE_BY_ZERO, - inferResults, - containsExactly(DIVIDE_BY_ZERO, - SOURCE_FILE, - methods)); - } - -} diff --git a/infer/tests/endtoend/java/infer/DynamicDispatchTest.java b/infer/tests/endtoend/java/infer/DynamicDispatchTest.java deleted file mode 100644 index 2a32fc444..000000000 --- a/infer/tests/endtoend/java/infer/DynamicDispatchTest.java +++ /dev/null @@ -1,59 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class DynamicDispatchTest { - - public static final String DynamicDispatchFile = - "infer/tests/codetoanalyze/java/infer/DynamicDispatch.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(DynamicDispatchTest.class, DynamicDispatchFile); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - String[] methods = { - "interfaceShouldNotCauseFalseNegativeEasy", - "dynamicDispatchShouldNotCauseFalseNegativeEasy", - "interfaceShouldNotCauseFalseNegativeHard" - // TODO: add dynamic dispatch support to make these tests work - // "dynamicDispatchShouldNotCauseFalseNegativeHardTODO" - }; - - assertThat( - "Results should contain null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - DynamicDispatchFile, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/FilterInputStreamLeaksTest.java b/infer/tests/endtoend/java/infer/FilterInputStreamLeaksTest.java deleted file mode 100644 index 39843a99a..000000000 --- a/infer/tests/endtoend/java/infer/FilterInputStreamLeaksTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -//Class to tests resource leaks on the class FilterInputStream and its subclasses - -package endtoend.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class FilterInputStreamLeaksTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/FilterInputStreamLeaks.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - FilterInputStreamLeaksTest.class, - SOURCE_FILE); - } - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "bufferedInputStreamNotClosedAfterRead", - "checkedInputStreamNotClosedAfterRead", - "cipherInputStreamNotClosedAfterSkip", - "dataInputStreamNotClosedAfterRead", - "deflaterInputStreamNotClosedAfterRead", - "gzipInputStreamNotClosedAfterRead", - "gzipInputStreamNotClosedAfterRead", - "digestInputStreamNotClosedAfterRead", - "inflaterInputStreamNotClosedAfterRead", - "pushbackInputStreamNotClosedAfterRead", - }; - assertThat( - "Results should contain a resource leak error", - inferResults, - containsExactly( - RESOURCE_LEAK, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/FilterOutputStreamLeaksTest.java b/infer/tests/endtoend/java/infer/FilterOutputStreamLeaksTest.java deleted file mode 100644 index 368910fbd..000000000 --- a/infer/tests/endtoend/java/infer/FilterOutputStreamLeaksTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -//Class to tests resource leaks on the class FilterOutputStream and its subclasses - -package endtoend.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class FilterOutputStreamLeaksTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/FilterOutputStreamLeaks.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - FilterOutputStreamLeaksTest.class, - SOURCE_FILE); - } - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "filterOutputStreamNotClosedAfterWrite", - "dataOutputStreamNotClosedAfterWrite", - "bufferedOutputStreamNotClosedAfterWrite", - "checkedOutputStreamNotClosedAfterWrite", - "cipherOutputStreamNotClosedAfterWrite", - "deflaterOutputStreamNotClosedAfterWrite", - "digestOutputStreamNotClosedAfterWrite", - "inflaterOutputStreamNotClosedAfterWrite", - "gzipOutputStreamNotClosedAfterFlush", - "gzipOutputStreamNotClosedAfterFlush", - "printStreamNotClosedAfterWrite", - }; - assertThat( - "Results should contain a resource leak error", - inferResults, - containsExactly( - RESOURCE_LEAK, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/GuardedByTest.java b/infer/tests/endtoend/java/infer/GuardedByTest.java deleted file mode 100644 index 6403cc31f..000000000 --- a/infer/tests/endtoend/java/infer/GuardedByTest.java +++ /dev/null @@ -1,74 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class GuardedByTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/GuardedByExample.java"; - - public static final String UNSAFE_GUARDED_BY_ACCESS = "UNSAFE_GUARDED_BY_ACCESS"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - GuardedByTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "readFBad", - "writeFBad", - "readFBadWrongLock", - "writeFBadWrongLock", - "readFAfterBlockBad", - "writeFAfterBlockBad", - "readFBadWrongAnnotation", - "synchronizedMethodReadBad", - "synchronizedMethodWriteBad", - "readHBad", - "readHBadSynchronizedMethodShouldntHelp", - "synchronizedOnThisBad", - "readFromInnerClassBad1", - "readFromInnerClassBad2", - "byRefTrickyBad", - // TODO: report these - // "unguardedCallSiteBad1", - // "unguardedCallSiteBad2", - // "unguardedCallSiteBad3", - }; - assertThat( - "Results should contain " + UNSAFE_GUARDED_BY_ACCESS, - inferResults, - containsExactly( - UNSAFE_GUARDED_BY_ACCESS, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/HashMapModelTest.java b/infer/tests/endtoend/java/infer/HashMapModelTest.java deleted file mode 100644 index 9d1a83c76..000000000 --- a/infer/tests/endtoend/java/infer/HashMapModelTest.java +++ /dev/null @@ -1,118 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class HashMapModelTest { - - public static final String HashMapModelTest = - "infer/tests/codetoanalyze/java/infer/HashMapExample.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - HashMapModelTest.class, - HashMapModelTest); - } - - @Test - public void whenInferRunsOnPutIntegerTwiceThenGetTwiceThenNPEIsNotFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should not contain null pointer exception error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - HashMapModelTest, - "putIntegerTwiceThenGetTwice") - ); - } - - @Test - public void whenInferRunsOnContainsIntegerTwiceThenGetTwiceThenNPEIsNotFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain null pointer exception error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - HashMapModelTest, - "containsIntegerTwiceThenGetTwice") - ); - } - - @Test - public void whenInferRunsOnGetOneIntegerWithoutCheckThenNPEIsFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain null pointer exception error", - inferResults, - contains( - NULL_DEREFERENCE, - HashMapModelTest, - "getOneIntegerWithoutCheck") - ); - } - - @Test - public void whenInferRunsOnGetTwoIntegersWithOneCheckThenNPEIsFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain null pointer exception error", - inferResults, - contains( - NULL_DEREFERENCE, - HashMapModelTest, - "getTwoIntegersWithOneCheck") - ); - } - - @Test - public void whenInferRunsOnGetOrCreateIntegerThenNPEIsNotFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should not contain null pointer exception error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - HashMapModelTest, - "getOrCreateInteger") - ); - } - - @Test - public void whenInferRunsOnGetOrCreateIntegerThenDerefThenNPEIsNotFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should not contain null pointer exception error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - HashMapModelTest, - "getOrCreateIntegerThenDeref") - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/IntegerClassTest.java b/infer/tests/endtoend/java/infer/IntegerClassTest.java deleted file mode 100644 index 7f65f4efa..000000000 --- a/infer/tests/endtoend/java/infer/IntegerClassTest.java +++ /dev/null @@ -1,51 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class IntegerClassTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/IntegerExample.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws IOException { - inferResults = InferResults.loadInferResults(IntegerClassTest.class, SOURCE_FILE); - } - - @Test - public void test() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should not contain NPE errors", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - SOURCE_FILE, - "testIntegerEquals" - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/JunitAssertionTest.java b/infer/tests/endtoend/java/infer/JunitAssertionTest.java deleted file mode 100644 index 542c640fc..000000000 --- a/infer/tests/endtoend/java/infer/JunitAssertionTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package endtoend.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class JunitAssertionTest { - - public static final String JunitAssertionFile = - "infer/tests/codetoanalyze/java/infer/JunitAssertion.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(JunitAssertionTest.class, JunitAssertionFile); - } - - @Test - public void inferShouldUseAssertedPredicate() - throws IOException, InterruptedException, InferException { - assertThat( - "Results should contain null pointer exception error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - JunitAssertionFile, - "consistentAssertion" - ) - ); - } - - @Test - public void inferShouldUseAssertionInconsistency() - throws IOException, InterruptedException, InferException { - assertThat( - "Results should contain null pointer exception error", - inferResults, - contains( - NULL_DEREFERENCE, - JunitAssertionFile, - "inconsistentAssertion" - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/NullPointerExceptionTest.java b/infer/tests/endtoend/java/infer/NullPointerExceptionTest.java deleted file mode 100644 index 99e728dc5..000000000 --- a/infer/tests/endtoend/java/infer/NullPointerExceptionTest.java +++ /dev/null @@ -1,92 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class NullPointerExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults( - NullPointerExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "nullPointerException", - "nullPointerExceptionInterProc", - "nullPointerExceptionWithExceptionHandling", - "nullPointerExceptionWithArray", - "nullPointerExceptionWithAChainOfFields", - "nullPointerExceptionWithNullObjectParameter", - "nullPointerExceptionWithNullArrayParameter", - "nullPointerExceptionFromFaillingResourceConstructor", - "nullPointerExceptionFromFailingFileOutputStreamConstructor", - "nullPointerExceptionUnlessFrameFails", - "hashmapNPE", - "NPEvalueOfFromHashmapBad", - "cursorFromContentResolverNPE", - "nullPointerExceptionInArrayLengthLoop", - "nullPointerExceptionCallArrayReadMethod", - "nullableFieldNPE", - "nullableParamNPE", - "badCheckShouldCauseNPE", - "nullPointerExceptionArrayLength", - "npeWithDollars", - "someNPEAfterResourceLeak", - "derefNullableGetter", - "derefNullableRet", - "derefUndefNullableRet", - "derefUndefNullableRetWrapper", - "testSystemGetPropertyArgument", - "testSystemGetPropertyReturn", - "derefNull", - "nullListFiles", - "nullTryLock", - "tryLockThrows", - "dereferenceAfterLoopOnList", - "dereferenceAfterUnlock1", - "dereferenceAfterUnlock2", - "optionalNPE", - "stringVarEqualsFalseNPE", - "stringConstantEqualsFalseNotNPE_FP", - }; - assertThat( - "Results should contain " + NULL_DEREFERENCE, - inferResults, - containsExactly( - NULL_DEREFERENCE, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/ReaderLeaksTest.java b/infer/tests/endtoend/java/infer/ReaderLeaksTest.java deleted file mode 100644 index af095e7e1..000000000 --- a/infer/tests/endtoend/java/infer/ReaderLeaksTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -//Class to tests resource leaks on the class FilterOutputStream and its subclasses - -package endtoend.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.nio.file.Path; - -import utils.InferException; -import utils.InferResults; - -public class ReaderLeaksTest { - - Path t; - - public static final String ReaderLeaks = - "infer/tests/codetoanalyze/java/infer/ReaderLeaks.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(ReaderLeaksTest.class, ReaderLeaks); - } - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "readerNotClosedAfterRead", - "bufferedReaderNotClosedAfterRead", - "inputStreamReaderNotClosedAfterRead", - "fileReaderNotClosedAfterRead", - "pushbackReaderNotClosedAfterRead", - "pipedReaderNotClosedAfterConstructedWithWriter", - "pipedReaderNotClosedAfterConnect", - "pipedReaderFalsePositive", - }; - assertThat( - "Results should contain the following resource leak errors", - inferResults, - containsExactly( - RESOURCE_LEAK, - ReaderLeaks, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/ResourceLeaksTest.java b/infer/tests/endtoend/java/infer/ResourceLeaksTest.java deleted file mode 100644 index 49327e709..000000000 --- a/infer/tests/endtoend/java/infer/ResourceLeaksTest.java +++ /dev/null @@ -1,138 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsNumberOfErrorsInMethod.containsNumberOfErrors; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ResourceLeaksTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/ResourceLeaks.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(ResourceLeaksTest.class, SOURCE_FILE); - } - - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "fileOutputStreamNotClosed", - "fileOutputStreamNotClosedAfterWrite", - "fileOutputStreamOneLeak", - "fileOutputStreamTwoLeaks1", - "fileOutputStreamTwoLeaks2", - "twoResources", - "twoResourcesServerSocket", - "twoResourcesRandomAccessFile", - "nestedBad1", - "nestedBad2", - "objectInputStreamClosedNestedBad", - "objectOutputStreamClosedNestedBad", - "zipFileLeakExceptionalBranch", - "jarFileNotClosed", - "fileInputStreamNotClosedAfterRead", - "pipedInputStreamNotClosedAfterRead", - "pipedOutputStreamNotClosedAfterWrite", - "objectOutputStreamNotClosedAfterWrite", - "objectInputStreamNotClosedAfterRead", - "jarInputStreamLeak", - "nestedBadJarInputStream", - "jarOutputStreamLeak", - "nestedBadJarOutputStream", - "socketNotClosed", - "serverSocketNotClosed", - "openHttpURLConnectionNotDisconnected", - "openHttpsURLConnectionNotDisconnected", - "parseFromInputStreamAndLeak", - "readInstallationFileBad", - "readConfigNotCloseStream", - "themeObtainTypedArrayAndLeak", - "activityObtainTypedArrayAndLeak", - "contextObtainTypedArrayAndLeak", - "copyFileLeak", - "copyFileLeak", - "scannerNotClosed", - "deflaterLeak", - "inflaterLeak", - }; - assertThat( - "Results should contain the following resource leak errors", - inferResults, - containsExactly( - RESOURCE_LEAK, - SOURCE_FILE, - methods - ) - ); - } - - @Test - public void whenInferRunsOnFileOutputStreamOneLeakThenOneLeaksIsFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain 1 resource leak error", - inferResults, - containsNumberOfErrors( - RESOURCE_LEAK, - SOURCE_FILE, - "fileOutputStreamOneLeak", - 1 - ) - ); - } - - @Test - public void whenInferRunsOnFileOutputStreamTwoLeaks1ThenTwoLeaksAreFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain 2 resource leak errors", - inferResults, - containsNumberOfErrors( - RESOURCE_LEAK, - SOURCE_FILE, - "fileOutputStreamTwoLeaks1", - 2 - ) - ); - } - - @Test - public void whenInferRunsOnFileOutputStreamTwoLeaks2ThenTwoLeaksAreFound() - throws InterruptedException, IOException, InferException { - assertThat( - "Results should contain 2 resource leak errors", - inferResults, - containsNumberOfErrors( - RESOURCE_LEAK, - SOURCE_FILE, - "fileOutputStreamTwoLeaks2", - 2 - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/ReturnValueIgnoredTest.java b/infer/tests/endtoend/java/infer/ReturnValueIgnoredTest.java deleted file mode 100644 index 5962f5d82..000000000 --- a/infer/tests/endtoend/java/infer/ReturnValueIgnoredTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package endtoend.java.infer; - - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsErrorInMethod.contains; -import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ReturnValueIgnoredTest { - - public static final String ReturnValueIgnored = - "infer/tests/codetoanalyze/java/infer/ReturnValueIgnored.java"; - - public static final String RETURN_VALUE_IGNORED = "RETURN_VALUE_IGNORED"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(ReturnValueIgnoredTest.class, ReturnValueIgnored); - } - - @Test - public void returnValueIgnoredTest() - throws IOException, InferException, InterruptedException { - assertThat( - "Results should contain a return value ignored error", - inferResults, - contains( - RETURN_VALUE_IGNORED, - ReturnValueIgnored, - "returnValueIgnored" - ) - ); - } - - @Test - public void whenInferRunsOnReturnValueIgThenOnlyTheExpectedErrorsAreFound() - throws InterruptedException, IOException, InferException { - String[] expectedMethods = {"returnValueIgnored"}; - assertThat( - "No unexpected errors should be found", inferResults, - containsOnly( - RETURN_VALUE_IGNORED, - ReturnValueIgnored, - expectedMethods)); - } - -} diff --git a/infer/tests/endtoend/java/infer/TaintTest.java b/infer/tests/endtoend/java/infer/TaintTest.java deleted file mode 100644 index 2dfc8cc7e..000000000 --- a/infer/tests/endtoend/java/infer/TaintTest.java +++ /dev/null @@ -1,81 +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.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class TaintTest { - - public static final String TaintFile = - "infer/tests/codetoanalyze/java/infer/TaintExample.java"; - - public static final String TAINTED_VALUE = "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION"; - - public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(TaintTest.class, TaintFile); - } - - @Test - public void whenInferRunsOnTaintFileErrorFound() - throws InterruptedException, IOException, InferException { - String[] methods = { - "socketNotVerifiedSimple", - "socketVerifiedForgotToCheckRetval", - "socketIgnoreExceptionNoVerify", - "callReadInputStreamCauseTaintError", - "taintingShouldNotPreventInference1", - "taintingShouldNotPreventInference2", - "simpleTaintErrorWithModelMethods", - "interprocTaintErrorWithModelMethods1", - "interprocTaintErrorWithModelMethods2", - "interprocTaintErrorWithModelMethods3", - "simpleTaintErrorWithModelMethodsUndefined", - "interprocTaintErrorWithModelMethodsUndefined1", - "interprocTaintErrorWithModelMethodsUndefined2", - "interprocTaintErrorWithModelMethodsUndefined3", - "contentValuesPutWithTaintedString", - "testPrivacySourceAnnot", - "testPrivacySinkAnnot1", - "testPrivacySinkAnnot3", - "testPrivacySourceInstanceFieldAnnot", - "testPrivacySourceStaticFieldAnnot", - "testPrivacySourceFieldAnnotPropagation", - "testIntegritySourceAnnot", - "testIntegritySourceInstanceFieldAnnot", - "testIntegritySourceStaticFieldAnnot", - "testIntegritySinkAnnotReport", - }; - - assertThat( - "Results should contain tainted value reaching sensitive function.", - inferResults, - containsExactly( - TAINTED_VALUE, - TaintFile, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/infer/WriterLeaksTest.java b/infer/tests/endtoend/java/infer/WriterLeaksTest.java deleted file mode 100644 index 7ca67c639..000000000 --- a/infer/tests/endtoend/java/infer/WriterLeaksTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package endtoend.java.infer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class WriterLeaksTest { - - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/WriterLeaks.java"; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadInferResults(WriterLeaksTest.class, SOURCE_FILE); - } - - - @Test - public void test() - throws InterruptedException, IOException, InferException { - String[] methods = { - "writerNotClosedAfterWrite", - "printWriterNotClosedAfterAppend", - "bufferedWriterNotClosedAfterWrite", - "outputStreamWriterNotClosedAfterWrite", - "fileWriterNotClosedAfterWrite", - "pipedWriterNotClosedAfterConstructedWithReader", - "pipedWriterNotClosedAfterConnect", - }; - assertThat( - "Results should contain a resource leak error", - inferResults, - containsExactly( - RESOURCE_LEAK, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/utils/InferResults.java b/infer/tests/utils/InferResults.java index d483297ab..93bd9ebc2 100644 --- a/infer/tests/utils/InferResults.java +++ b/infer/tests/utils/InferResults.java @@ -56,7 +56,6 @@ public class InferResults { String errorKind = items[1].trim(); String errorType = items[2].trim(); if (errorKind.equals("ERROR") || - errorType.equals("RETURN_VALUE_IGNORED") || errorType.equals("ASSIGN_POINTER_WARNING") || errorType.equals("STRONG_DELEGATE_WARNING") || errorType.equals("DIRECT_ATOMIC_PROPERTY_ACCESS") ||