diff --git a/.gitignore b/.gitignore index 4622b5750..16d2722cd 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ duplicates.txt /infer/tests/build_systems/genrule/report.json /infer/tests/build_systems/incremental_analysis_remove_file/src /infer/tests/build_systems/incremental_analysis_cost_change/src +/infer/tests/build_systems/incremental_analysis_add_procedure/src /infer/tests/build_systems/java_test_determinator/*.test /infer/tests/codetoanalyze/java/classloads/*.loads /infer/tests/codetoanalyze/java/classloads/loads.exp diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/Makefile b/infer/tests/build_systems/incremental_analysis_add_procedure/Makefile new file mode 100644 index 000000000..2e064cfdb --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_add_procedure/Makefile @@ -0,0 +1,43 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +TESTS_DIR = ../.. + +MODIFIED_FILES_FILE = changed_files.txt +SOURCES = $(wildcard src_after/*.c src_after/*.h src_before/*.c src_before/*.h) +INFER_OPTIONS = --changed-files-index $(MODIFIED_FILES_FILE) \ + --incremental-analysis \ + --debug-level-analysis 1 + +include $(TESTS_DIR)/differential.make + +.PHONY: compare_cg +compare_cg: $(PREVIOUS_REPORT) + $(QUIET)$(call check_no_diff,\ + reverse_analysis_callgraph.dot,\ + reverse_analysis_callgraph.dot.test) + +replace_cg: $(PREVIOUS_REPORT) + $(COPY) reverse_analysis_callgraph.dot.test reverse_analysis_callgraph.dot + +test: compare_cg +replace: replace_cg + +$(CURRENT_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) + $(QUIET)$(REMOVE_DIR) src + $(QUIET)$(MKDIR_P) src + $(QUIET)$(COPY) src_after/* src/ + $(QUIET)$(INFER_BIN) -o $(CURRENT_DIR) -- clang -c src/*.c + +$(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT) + $(QUIET)$(REMOVE_DIR) src + $(QUIET)$(MKDIR_P) src + $(QUIET)$(COPY) src_before/* src/ + $(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR) + $(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR) + $(QUIET)$(REMOVE) $@ + $(QUIET)$(INFER_BIN) -o $(PREVIOUS_DIR) $(INFER_OPTIONS) -- clang -c src/*.c + $(QUIET)$(COPY) $(PREVIOUS_DIR)/reverse_analysis_callgraph.dot \ + reverse_analysis_callgraph.dot.test diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/changed_files.txt b/infer/tests/build_systems/incremental_analysis_add_procedure/changed_files.txt new file mode 100644 index 000000000..e7231522a --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_add_procedure/changed_files.txt @@ -0,0 +1 @@ +src/main.c diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/fixed.exp b/infer/tests/build_systems/incremental_analysis_add_procedure/fixed.exp new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/introduced.exp b/infer/tests/build_systems/incremental_analysis_add_procedure/introduced.exp new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/preexisting.exp b/infer/tests/build_systems/incremental_analysis_add_procedure/preexisting.exp new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/reverse_analysis_callgraph.dot b/infer/tests/build_systems/incremental_analysis_add_procedure/reverse_analysis_callgraph.dot new file mode 100644 index 000000000..b5e31b681 --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_add_procedure/reverse_analysis_callgraph.dot @@ -0,0 +1,13 @@ + +digraph callgraph { + N1 [ label = "b", flag = true ]; + + N0 [ label = "a", flag = true ]; + N0 -> N1 ; + + N2 [ label = "c", flag = true ]; + N2 -> N3 ; + + N3 [ label = "main", flag = true ]; + +} diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/src_after/main.c b/infer/tests/build_systems/incremental_analysis_add_procedure/src_after/main.c new file mode 100644 index 000000000..06aba2fff --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_add_procedure/src_after/main.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +void a() {} + +void b() { a(); } + +void c() {} + +int main() { + c(); + return 0; +} diff --git a/infer/tests/build_systems/incremental_analysis_add_procedure/src_before/main.c b/infer/tests/build_systems/incremental_analysis_add_procedure/src_before/main.c new file mode 100644 index 000000000..194aa9c1c --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_add_procedure/src_before/main.c @@ -0,0 +1,8 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +int main() { return 0; } diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile b/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile index f13705b4e..89bea7c9f 100644 --- a/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile @@ -3,8 +3,6 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -# E2E test involving the interesting_paths_filter function - TESTS_DIR = ../.. MODIFIED_FILES_FILE = changed_files.txt diff --git a/infer/tests/build_systems/incremental_analysis_cost_change/Makefile b/infer/tests/build_systems/incremental_analysis_cost_change/Makefile index 576e87bbb..81dcf540d 100644 --- a/infer/tests/build_systems/incremental_analysis_cost_change/Makefile +++ b/infer/tests/build_systems/incremental_analysis_cost_change/Makefile @@ -3,8 +3,6 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -# E2E test involving the interesting_paths_filter function - TESTS_DIR = ../.. MODIFIED_FILES_FILE = changed_files.txt diff --git a/infer/tests/build_systems/incremental_analysis_remove_file/Makefile b/infer/tests/build_systems/incremental_analysis_remove_file/Makefile index 85ce48211..2e064cfdb 100644 --- a/infer/tests/build_systems/incremental_analysis_remove_file/Makefile +++ b/infer/tests/build_systems/incremental_analysis_remove_file/Makefile @@ -3,8 +3,6 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -# E2E test involving the interesting_paths_filter function - TESTS_DIR = ../.. MODIFIED_FILES_FILE = changed_files.txt