diff --git a/.gitignore b/.gitignore index 68e9e51ce..9d468380c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ *.orig *.rej *.start +*.exp.test +infer/tests/codetoanalyze/java/*/codetoanalyze # Directories generated by Ocamlbuild _build @@ -56,6 +58,7 @@ org.eclipse.core.resources.prefs infer-sources.tar.gz infer-osx-*.tar.xz infer-linux64-*.tar.xz +infer-out* # Directories generated by buck buck-out/ diff --git a/Makefile b/Makefile index 8c48d6d92..71c6b82f7 100644 --- a/Makefile +++ b/Makefile @@ -170,9 +170,8 @@ inferTraceBugs_test: infer .PHONY: check_missing_mli check_missing_mli: - @bash -c '\ - for x in `find infer/src -name "*.ml" -or -name "*.re"`; do \ - test -f "$$x"i || echo Missing "$$x"i; done' + @for x in $$(find infer/src -name "*.ml" -or -name "*.re"); do \ + test -f "$$x"i || echo Missing "$$x"i; done .PHONY: toplevel toplevel: infer @@ -193,6 +192,11 @@ test_xml: test_build ocaml_unit_test buck_test_xml inferTraceBugs_test .PHONY: quick-test quick-test: test_this_build ocaml_unit_test +.PHONY: test-replace +test-replace: + @for file in $$(find infer/tests -name "*.exp.test"); do \ + mv -f $$file $$(dirname $$file)/$$(basename -s .exp.test $$file).exp; done + .PHONY: uninstall uninstall: $(REMOVE_DIR) $(DESTDIR)$(libdir)/infer/ diff --git a/infer/src/Makefile b/infer/src/Makefile index e234b3b27..3fa29fd66 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -257,7 +257,6 @@ inc_flags:=$(foreach dir,$(src_dirs),-I $(dir)) root_flags:=$(foreach root,$(roots),-r $(root)) cluster_flags:=$(foreach cluster,$(clusters),-c $(cluster)) -.PHONY: mod_dep_dot mod_dep.dot: $(ml_src_files) $(re_src_files) $(MAKE) -C $(DEPENDENCIES_DIR)/ocamldot { ocamldep.opt $(inc_flags) -ml-synonym .re -mli-synonym .rei $(ml_src_files); \ @@ -266,7 +265,6 @@ mod_dep.dot: $(ml_src_files) $(re_src_files) | grep -v -e "\"IList\"\|\"Utils\"" \ > mod_dep.dot -.PHONY: mod_dep.pdf mod_dep.pdf: mod_dep.dot dot -Tpdf -o mod_dep.pdf mod_dep.dot diff --git a/infer/tests/codetoanalyze/cpp/quandary/Makefile b/infer/tests/codetoanalyze/cpp/quandary/Makefile index 29f03a515..bc6e27a85 100644 --- a/infer/tests/codetoanalyze/cpp/quandary/Makefile +++ b/infer/tests/codetoanalyze/cpp/quandary/Makefile @@ -7,7 +7,7 @@ include ../../Makefile.clang -OPTIONS = -x c++ -std=c++11 -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c +OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c ANALYZER = quandary INFERPRINT_OPTIONS = --issues-txt @@ -20,5 +20,5 @@ compile: clang $(OPTIONS) $(FILES) analyze: - $(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt + $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) 2>duplicates.txt) grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 diff --git a/infer/tests/codetoanalyze/java/checkers/Makefile b/infer/tests/codetoanalyze/java/checkers/Makefile index 18cc092ec..9b449fe6a 100644 --- a/infer/tests/codetoanalyze/java/checkers/Makefile +++ b/infer/tests/codetoanalyze/java/checkers/Makefile @@ -5,28 +5,11 @@ # 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 +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/java.make ANALYZER = checkers -FILES = \ - Branch.java \ - ExpensiveCallExample.java \ - ExpensiveInheritanceExample.java \ - ExpensiveInterfaceExample.java \ - ExpensiveSubtypingExample.java \ - FragmentDoesNotRetainViewExample.java \ - FragmentRetainsViewExample.java \ - ImmutableCast.java \ - NoAllocationExample.java \ - NotThreadSafeExample.java \ - PrintfArgsChecker.java \ - ThreadSafeExample.java \ - TraceCallSequence.java \ - TwoCheckersExample.java +INFER_OPTIONS = --thread-safety -compile: - javac -cp $(CLASSPATH) $(FILES) - -analyze: - $(call silent_on_success,$(INFER_BIN) --thread-safety -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES)) +JAVA_SOURCE_FILES = $(wildcard *.java) diff --git a/infer/tests/codetoanalyze/java/Makefile b/infer/tests/codetoanalyze/java/config.make similarity index 72% rename from infer/tests/codetoanalyze/java/Makefile rename to infer/tests/codetoanalyze/java/config.make index ee5dad536..b16a2b8d3 100644 --- a/infer/tests/codetoanalyze/java/Makefile +++ b/infer/tests/codetoanalyze/java/config.make @@ -17,19 +17,3 @@ JSR305 = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar INJECT = $(DEPENDENCIES_DIR)/java/jsr-330/javax.inject.jar CLASSPATH=$(ANDROID19):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(JACKSON):$(JSR305):$(INJECT):$(JAVA_BUILTINS_DIR):. - -INFERPRINT_OPTIONS = --issues-tests - -default: compile - -print: analyze - $(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) issues.exp.test - LC_ALL=C sort -t: -k1,1 -k2n,2 -o issues.exp.test issues.exp.test - -test: analyze print - $(MAKE) clean - diff -u issues.exp issues.exp.test - rm issues.exp.test - -clean: - rm -rf codetoanalyze infer-out *.class diff --git a/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.exp b/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.exp deleted file mode 100644 index 337b87d5b..000000000 --- a/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.exp +++ /dev/null @@ -1 +0,0 @@ -{"stack":[{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.bar():void","location":{"location_type":"call_site","file":"BranchingCallsExample.java","line":24,"blame_range":[{"start_line":22,"end_line":24}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.foo():void","location":{"location_type":"call_site","file":"BranchingCallsExample.java","line":29,"blame_range":[{"start_line":27,"end_line":30}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.bar():void","location":{"location_type":"proc_start","file":"BranchingCallsExample.java","line":22,"blame_range":[{"start_line":22,"end_line":24}]},"callees":[]},{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.pre_bar():void","location":{"location_type":"proc_start","file":"BranchingCallsExample.java","line":14,"blame_range":[{"start_line":14,"end_line":15}]},"callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"BranchingCallsExample.java","line":34,"blame_range":[{"start_line":33,"end_line":34}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.foo():void","location":{"location_type":"proc_start","file":"BranchingCallsExample.java","line":27,"blame_range":[{"start_line":27,"end_line":30}]},"callees":[]}]}]} \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/crashcontext/Makefile b/infer/tests/codetoanalyze/java/crashcontext/Makefile index a80e77f3a..cb8c51625 100644 --- a/infer/tests/codetoanalyze/java/crashcontext/Makefile +++ b/infer/tests/codetoanalyze/java/crashcontext/Makefile @@ -5,38 +5,47 @@ # 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 - +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/config.make ANALYZER = crashcontext -FILES = \ - BranchingCallsExample \ - MethodNameClashExample \ - MinimalCrashExample \ - MultiStackFrameCrashExample \ - NativeMethodExample \ - -compile: - for file in $(FILES) ; do \ - javac -cp $(CLASSPATH) $$file.java ; \ - done - -analyze: - for file in $(FILES) ; do \ - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --stacktrace $$file.stacktrace.json -- javac -cp $(CLASSPATH) $$file.java) ; \ - cp infer-out/crashcontext/crashcontext.json $$file.exp.test ; \ - done - -# overwrite -print: - -# overwrite -test: analyze - set -e; \ - for file in $(FILES) ; do \ - diff -u $$file.exp $$file.exp.test ; \ - rm $$file.exp.test ; \ - done - $(MAKE) clean +JAVA_SOURCE_FILES = $(wildcard *.java) +JAVA_CLASS_FILES = $(patsubst %.java,%.class,$(JAVA_SOURCE_FILES)) +EXP_TESTs = $(sort $(patsubst %.java,%.exp.test,$(JAVA_SOURCE_FILES))) +INFER_OUTs = $(patsubst %.java,infer-out-%,$(JAVA_SOURCE_FILES)) + +$(JAVA_CLASS_FILES): $(JAVA_SOURCE_FILES) + javac -cp $(CLASSPATH) $(JAVA_SOURCE_FILES) + +# analyze a single source file and generate the test results for it +%.exp.test: $(INFER_BIN) %.stacktrace.json %.java + $(call silent_on_success,\ + $(INFER_BIN) -a $(ANALYZER) -o infer-out-$* --stacktrace $*.stacktrace.json \ + -- javac -cp $(CLASSPATH) $*.java) +# add a newline at the end of the json when creating the exp.test + bash -c 'cat infer-out-$*/crashcontext/crashcontext.json <(echo) > $*.exp.test' + +# combine the test results for all the source files +issues.exp.test: $(EXP_TESTs) + cat $(EXP_TESTs) > issues.exp.test + + +default: compile + +.PHONY: compile +compile: $(JAVA_CLASS_FILES) + +.PHONY: analyze +analyze: $(EXP_TESTs) + +.PHONY: print +print: issues.exp.test + +.PHONY: test +test: issues.exp.test + diff -u issues.exp issues.exp.test +.PHONY: clean +clean: + $(REMOVE_DIR) $(INFER_OUTs) $(JAVA_CLASS_FILES) $(EXP_TESTs) diff --git a/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.exp b/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.exp deleted file mode 100644 index 0f0813fb4..000000000 --- a/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.exp +++ /dev/null @@ -1 +0,0 @@ -{"stack":[{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$A.foo():void","location":{"location_type":"call_site","file":"MethodNameClashExample.java","line":18,"blame_range":[{"start_line":16,"end_line":18}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$B.foo():void","location":{"location_type":"call_site","file":"MethodNameClashExample.java","line":26,"blame_range":[{"start_line":26,"end_line":26}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$A.foo():void","location":{"location_type":"proc_start","file":"MethodNameClashExample.java","line":16,"blame_range":[{"start_line":16,"end_line":18}]},"callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"MethodNameClashExample.java","line":32,"blame_range":[{"start_line":31,"end_line":32}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$B.foo():void","location":{"location_type":"proc_start","file":"MethodNameClashExample.java","line":26,"blame_range":[{"start_line":26,"end_line":26}]},"callees":[]}]}]} \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.exp b/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.exp deleted file mode 100644 index d71d793b4..000000000 --- a/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.exp +++ /dev/null @@ -1 +0,0 @@ -{"stack":[{"method_name":"codetoanalyze.java.crashcontext.MinimalCrashExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"MinimalCrashExample.java","line":16,"blame_range":[{"start_line":14,"end_line":16}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]}]} \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.exp b/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.exp deleted file mode 100644 index 88988ada6..000000000 --- a/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.exp +++ /dev/null @@ -1 +0,0 @@ -{"stack":[{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.bar():void","location":{"location_type":"call_site","file":"MultiStackFrameCrashExample.java","line":16,"blame_range":[{"start_line":14,"end_line":16}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.foo():void","location":{"location_type":"call_site","file":"MultiStackFrameCrashExample.java","line":20,"blame_range":[{"start_line":19,"end_line":20}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.bar():void","location":{"location_type":"proc_start","file":"MultiStackFrameCrashExample.java","line":14,"blame_range":[{"start_line":14,"end_line":16}]},"callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"MultiStackFrameCrashExample.java","line":24,"blame_range":[{"start_line":23,"end_line":24}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.foo():void","location":{"location_type":"proc_start","file":"MultiStackFrameCrashExample.java","line":19,"blame_range":[{"start_line":19,"end_line":20}]},"callees":[]}]}]} \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.exp b/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.exp deleted file mode 100644 index 3ee9cfa53..000000000 --- a/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.exp +++ /dev/null @@ -1 +0,0 @@ -{"stack":[{"method_name":"codetoanalyze.java.crashcontext.NativeMethodExample.foo():void","location":{"location_type":"call_site","file":"NativeMethodExample.java","line":18,"blame_range":[{"start_line":16,"end_line":18}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"sun.reflect.NativeMethodAccessorImpl.invoke0","location":{"location_type":"call_site","file":"Native Method","blame_range":[]},"callees":[]},{"method_name":"sun.reflect.NativeMethodAccessorImpl.invoke","location":{"location_type":"call_site","file":"NativeMethodAccessorImpl.java","line":62,"blame_range":[]},"callees":[]},{"method_name":"sun.reflect.DelegatingMethodAccessorImpl.invoke","location":{"location_type":"call_site","file":"DelegatingMethodAccessorImpl.java","line":43,"blame_range":[]},"callees":[]},{"method_name":"java.lang.reflect.Method.invoke","location":{"location_type":"call_site","file":"Method.java","line":497,"blame_range":[]},"callees":[]},{"method_name":"codetoanalyze.java.crashcontext.NativeMethodExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"NativeMethodExample.java","line":27,"blame_range":[{"start_line":21,"end_line":29}]},"callees":[{"method_name":"java.lang.Class.getDeclaredMethod(java.lang.String,java.lang.Class[]):java.lang.reflect.Method","callees":[]},{"method_name":"java.lang.reflect.Method.invoke(java.lang.Object,java.lang.Object[]):java.lang.Object","callees":[]},{"method_name":"__new_array","callees":[]}]}]} \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/crashcontext/issues.exp b/infer/tests/codetoanalyze/java/crashcontext/issues.exp new file mode 100644 index 000000000..b79386662 --- /dev/null +++ b/infer/tests/codetoanalyze/java/crashcontext/issues.exp @@ -0,0 +1,5 @@ +{"stack":[{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.bar():void","location":{"location_type":"call_site","file":"BranchingCallsExample.java","line":24,"blame_range":[{"start_line":22,"end_line":24}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.foo():void","location":{"location_type":"call_site","file":"BranchingCallsExample.java","line":29,"blame_range":[{"start_line":27,"end_line":30}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.bar():void","location":{"location_type":"proc_start","file":"BranchingCallsExample.java","line":22,"blame_range":[{"start_line":22,"end_line":24}]},"callees":[]},{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.pre_bar():void","location":{"location_type":"proc_start","file":"BranchingCallsExample.java","line":14,"blame_range":[{"start_line":14,"end_line":15}]},"callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"BranchingCallsExample.java","line":34,"blame_range":[{"start_line":33,"end_line":34}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.BranchingCallsExample.foo():void","location":{"location_type":"proc_start","file":"BranchingCallsExample.java","line":27,"blame_range":[{"start_line":27,"end_line":30}]},"callees":[]}]}]} +{"stack":[{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$A.foo():void","location":{"location_type":"call_site","file":"MethodNameClashExample.java","line":18,"blame_range":[{"start_line":16,"end_line":18}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$B.foo():void","location":{"location_type":"call_site","file":"MethodNameClashExample.java","line":26,"blame_range":[{"start_line":26,"end_line":26}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$A.foo():void","location":{"location_type":"proc_start","file":"MethodNameClashExample.java","line":16,"blame_range":[{"start_line":16,"end_line":18}]},"callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"MethodNameClashExample.java","line":32,"blame_range":[{"start_line":31,"end_line":32}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MethodNameClashExample$B.foo():void","location":{"location_type":"proc_start","file":"MethodNameClashExample.java","line":26,"blame_range":[{"start_line":26,"end_line":26}]},"callees":[]}]}]} +{"stack":[{"method_name":"codetoanalyze.java.crashcontext.MinimalCrashExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"MinimalCrashExample.java","line":16,"blame_range":[{"start_line":14,"end_line":16}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]}]} +{"stack":[{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.bar():void","location":{"location_type":"call_site","file":"MultiStackFrameCrashExample.java","line":16,"blame_range":[{"start_line":14,"end_line":16}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.foo():void","location":{"location_type":"call_site","file":"MultiStackFrameCrashExample.java","line":20,"blame_range":[{"start_line":19,"end_line":20}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.bar():void","location":{"location_type":"proc_start","file":"MultiStackFrameCrashExample.java","line":14,"blame_range":[{"start_line":14,"end_line":16}]},"callees":[]}]},{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"MultiStackFrameCrashExample.java","line":24,"blame_range":[{"start_line":23,"end_line":24}]},"callees":[{"method_name":"codetoanalyze.java.crashcontext.MultiStackFrameCrashExample.foo():void","location":{"location_type":"proc_start","file":"MultiStackFrameCrashExample.java","line":19,"blame_range":[{"start_line":19,"end_line":20}]},"callees":[]}]}]} +{"stack":[{"method_name":"codetoanalyze.java.crashcontext.NativeMethodExample.foo():void","location":{"location_type":"call_site","file":"NativeMethodExample.java","line":18,"blame_range":[{"start_line":16,"end_line":18}]},"callees":[{"method_name":"java.lang.String.toString():java.lang.String","callees":[]}]},{"method_name":"sun.reflect.NativeMethodAccessorImpl.invoke0","location":{"location_type":"call_site","file":"Native Method","blame_range":[]},"callees":[]},{"method_name":"sun.reflect.NativeMethodAccessorImpl.invoke","location":{"location_type":"call_site","file":"NativeMethodAccessorImpl.java","line":62,"blame_range":[]},"callees":[]},{"method_name":"sun.reflect.DelegatingMethodAccessorImpl.invoke","location":{"location_type":"call_site","file":"DelegatingMethodAccessorImpl.java","line":43,"blame_range":[]},"callees":[]},{"method_name":"java.lang.reflect.Method.invoke","location":{"location_type":"call_site","file":"Method.java","line":497,"blame_range":[]},"callees":[]},{"method_name":"codetoanalyze.java.crashcontext.NativeMethodExample.main(java.lang.String[]):void","location":{"location_type":"call_site","file":"NativeMethodExample.java","line":27,"blame_range":[{"start_line":21,"end_line":29}]},"callees":[{"method_name":"java.lang.Class.getDeclaredMethod(java.lang.String,java.lang.Class[]):java.lang.reflect.Method","callees":[]},{"method_name":"java.lang.reflect.Method.invoke(java.lang.Object,java.lang.Object[]):java.lang.Object","callees":[]},{"method_name":"__new_array","callees":[]}]}]} diff --git a/infer/tests/codetoanalyze/java/eradicate/Makefile b/infer/tests/codetoanalyze/java/eradicate/Makefile index b105611cf..5c758dc5b 100644 --- a/infer/tests/codetoanalyze/java/eradicate/Makefile +++ b/infer/tests/codetoanalyze/java/eradicate/Makefile @@ -5,27 +5,11 @@ # 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 +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/java.make ANALYZER = eradicate -FILES = \ - ActivityFieldNotInitialized.java \ - FieldNotInitialized.java \ - FieldNotNullable.java \ - InconsistentSubclassAnnotationInterface.java \ - InconsistentSubclassAnnotation.java \ - LibraryCalls.java \ - NoReuseUndefFunctionValues.java \ - NullFieldAccess.java \ - NullMethodCall.java \ - ParameterNotNullable.java \ - ReturnNotNullable.java \ - SuppressWarningsExample.java \ - SuppressedFieldNotInitializedExample.java +INFER_OPTIONS = --eradicate-return-over-annotated -compile: - javac -cp $(CLASSPATH) $(FILES) - -analyze: - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --eradicate-return-over-annotated -- javac -cp $(CLASSPATH) $(FILES)) +JAVA_SOURCE_FILES = $(wildcard *.java) diff --git a/infer/tests/codetoanalyze/java/harness/Makefile b/infer/tests/codetoanalyze/java/harness/Makefile index 7ffc46913..4d8be7536 100644 --- a/infer/tests/codetoanalyze/java/harness/Makefile +++ b/infer/tests/codetoanalyze/java/harness/Makefile @@ -5,15 +5,12 @@ # 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 +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/java.make ANALYZER = infer -FILES = \ - BasicHarnessActivity.java \ - -compile: - javac -cp $(CLASSPATH) $(FILES) +INFER_OPTIONS = --android-harness -analyze: - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --android-harness -- javac -cp $(CLASSPATH) $(FILES)) +JAVA_SOURCE_FILES = \ + BasicHarnessActivity.java \ diff --git a/infer/tests/codetoanalyze/java/infer/Makefile b/infer/tests/codetoanalyze/java/infer/Makefile index 99f37e870..d14ba49db 100644 --- a/infer/tests/codetoanalyze/java/infer/Makefile +++ b/infer/tests/codetoanalyze/java/infer/Makefile @@ -5,42 +5,9 @@ # 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 +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/java.make 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: - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES)) +JAVA_SOURCE_FILES = $(wildcard *.java) diff --git a/infer/tests/codetoanalyze/java/java.make b/infer/tests/codetoanalyze/java/java.make new file mode 100644 index 000000000..e04f2177b --- /dev/null +++ b/infer/tests/codetoanalyze/java/java.make @@ -0,0 +1,49 @@ +# 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. + +# Makefiles that include this one must define JAVA_TEST_DIR and then include +# $(JAVA_TEST_DIR)/java.make in order for config.make to be found. +# +# Makefiles that include this one must define the ANALYZER and JAVA_SOURCE_FILES +# variables, and may optionally define INFER_OPTIONS and INFERPRINT_OPTIONS. + +include $(JAVA_TEST_DIR)/config.make + +INFERPRINT_OPTIONS = --issues-tests + +JAVA_CLASS_FILES = $(patsubst %.java,%.class,$(JAVA_SOURCE_FILES)) + +$(JAVA_CLASS_FILES): $(JAVA_SOURCE_FILES) + javac -cp $(CLASSPATH) $(JAVA_SOURCE_FILES) + +infer-out/report.json: $(INFER_BIN) $(JAVA_SOURCE_FILES) + $(call silent_on_success,\ + $(INFER_BIN) $(INFER_OPTIONS) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(JAVA_SOURCE_FILES)) + +issues.exp.test: $(INFERPRINT_BIN) infer-out/report.json + $(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) issues.exp.test + LC_ALL=C sort -t: -k1,1 -k2n,2 -o issues.exp.test issues.exp.test + + +default: compile + +.PHONY: compile +compile: $(JAVA_CLASS_FILES) + +.PHONY: analyze +analyze: infer-out/report.json + +.PHONY: print +print: issues.exp.test + +.PHONY: test +test: issues.exp.test + diff -u issues.exp issues.exp.test + +.PHONY: clean +clean: + rm -rf codetoanalyze issues.exp.test infer-out $(JAVA_CLASS_FILES) diff --git a/infer/tests/codetoanalyze/java/quandary/Makefile b/infer/tests/codetoanalyze/java/quandary/Makefile index b339685c1..965753976 100644 --- a/infer/tests/codetoanalyze/java/quandary/Makefile +++ b/infer/tests/codetoanalyze/java/quandary/Makefile @@ -5,25 +5,11 @@ # 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 +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/java.make ANALYZER = quandary -INFERPRINT_OPTIONS = --issues-txt - -FILES = \ - Arrays.java \ - Basics.java \ - DynamicDispatch.java \ - Exceptions.java \ - Fields.java \ - Intents.java \ - Interprocedural.java \ - LoggingPrivateData.java \ - Recursion.java \ - UnknownCode.java \ -compile: - javac -cp $(CLASSPATH) $(FILES) +INFERPRINT_OPTIONS = --issues-txt -analyze: - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES)) +JAVA_SOURCE_FILES = $(wildcard *.java) diff --git a/infer/tests/codetoanalyze/java/tracing/Makefile b/infer/tests/codetoanalyze/java/tracing/Makefile index b057168dd..e77ebb6c6 100644 --- a/infer/tests/codetoanalyze/java/tracing/Makefile +++ b/infer/tests/codetoanalyze/java/tracing/Makefile @@ -5,38 +5,9 @@ # 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 +JAVA_TEST_DIR = .. +include $(JAVA_TEST_DIR)/java.make ANALYZER = tracing -FILES_FOR_TRACING = \ - T2.java \ - \ - ArrayIndexOutOfBoundsExceptionExample.java \ - ClassCastExceptionExample.java \ - LazyDynamicDispatchExample.java \ - LocallyDefinedExceptionExample.java \ - NullPointerExceptionExample.java \ - ReportOnMainExample.java \ - UnavoidableExceptionExample.java \ - \ - -FILES_LINKED_FROM_INFER = \ - T.java \ - SkippedSourceFile.java \ - SomeLibrary.java \ - Utils.java \ - CloseableAsResourceExample.java \ - NeverNullSource.java \ - \ - ArrayOutOfBounds.java \ - ClassCastExceptions.java \ - NullPointerExceptions.java \ - -FILES = $(FILES_FOR_TRACING) $(FILES_LINKED_FROM_INFER) - -compile: - javac -cp $(CLASSPATH) $(FILES) - -analyze: - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES)) +JAVA_SOURCE_FILES = $(wildcard *.java)