diff --git a/Makefile b/Makefile index b60ced540..62773cda1 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ BUILD_SYSTEMS_TESTS += \ utf8_in_procname \ export_changed_functions \ incremental_analysis_remove_file \ + incremental_analysis_change_procedure \ DIRECT_TESTS += \ c_biabduction \ diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile b/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile new file mode 100644 index 000000000..683fddf7d --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/Makefile @@ -0,0 +1,39 @@ +# 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. + +# E2E test involving the interesting_paths_filter function + +TESTS_DIR = ../.. + +MODIFIED_FILES_FILE = changed_files.txt +SOURCES = $(wildcard src/*.c src/*.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)$(INFER_BIN) -o $(CURRENT_DIR) -- clang -c src/*.c + +$(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT) + $(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR) + $(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR) + $(QUIET)$(REMOVE_DIR) $@ + $(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_change_procedure/changed_files.txt b/infer/tests/build_systems/incremental_analysis_change_procedure/changed_files.txt new file mode 100644 index 000000000..a77c8959c --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/changed_files.txt @@ -0,0 +1 @@ +src/a_and_d.c diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/costs_summary.json.exp b/infer/tests/build_systems/incremental_analysis_change_procedure/costs_summary.json.exp new file mode 100644 index 000000000..d04696a0c --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/costs_summary.json.exp @@ -0,0 +1 @@ +{"top":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[]} \ No newline at end of file diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/fixed.exp b/infer/tests/build_systems/incremental_analysis_change_procedure/fixed.exp new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/introduced.exp b/infer/tests/build_systems/incremental_analysis_change_procedure/introduced.exp new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/preexisting.exp b/infer/tests/build_systems/incremental_analysis_change_procedure/preexisting.exp new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/reverse_analysis_callgraph.dot b/infer/tests/build_systems/incremental_analysis_change_procedure/reverse_analysis_callgraph.dot new file mode 100644 index 000000000..414cf7d18 --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/reverse_analysis_callgraph.dot @@ -0,0 +1,27 @@ + +digraph callgraph { + N1 [ label = "a", flag = true ]; + N1 -> N7 ; + + N5 [ label = "f", flag = false ]; + N5 -> N4 ; + + N0 [ label = "b", flag = true ]; + N0 -> N1 ; + + N7 [ label = "main", flag = true ]; + + N6 [ label = "e", flag = true ]; + N6 -> N7 ; + + N4 [ label = "d", flag = true ]; + N4 -> N6 ; + N4 -> N3 ; + + N2 [ label = "g", flag = false ]; + N2 -> N1 ; + + N3 [ label = "c", flag = true ]; + N3 -> N0 ; + +} diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/src/a_and_d.c b/infer/tests/build_systems/incremental_analysis_change_procedure/src/a_and_d.c new file mode 100644 index 000000000..4940d64f3 --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/src/a_and_d.c @@ -0,0 +1,14 @@ +/* + * 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. + */ +#include "b_c_f_g_and_e.h" + +void a() { + g(); + b(); +} + +void d() { f(); } diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/src/a_and_d.h b/infer/tests/build_systems/incremental_analysis_change_procedure/src/a_and_d.h new file mode 100644 index 000000000..ba4d565a6 --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/src/a_and_d.h @@ -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. + */ +void a(); +void d(); diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/src/b_c_f_g_and_e.c b/infer/tests/build_systems/incremental_analysis_change_procedure/src/b_c_f_g_and_e.c new file mode 100644 index 000000000..5db649502 --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/src/b_c_f_g_and_e.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. + */ +#include "a_and_d.h" + +void e() { d(); } + +void g() {} + +void f() {} + +void c() { d(); } + +void b() { c(); } diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/src/b_c_f_g_and_e.h b/infer/tests/build_systems/incremental_analysis_change_procedure/src/b_c_f_g_and_e.h new file mode 100644 index 000000000..cb04dd1ca --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/src/b_c_f_g_and_e.h @@ -0,0 +1,9 @@ +/* + * 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 g(); +void f(); +void b(); diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/src/main.c b/infer/tests/build_systems/incremental_analysis_change_procedure/src/main.c new file mode 100644 index 000000000..02784479c --- /dev/null +++ b/infer/tests/build_systems/incremental_analysis_change_procedure/src/main.c @@ -0,0 +1,14 @@ +/* + * 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. + */ +#include "a_and_d.h" +#include "b_c_f_g_and_e.h" + +int main() { + e(); + a(); + return 0; +} diff --git a/infer/tests/build_systems/incremental_analysis_change_procedure/src/main.h b/infer/tests/build_systems/incremental_analysis_change_procedure/src/main.h new file mode 100644 index 000000000..e69de29bb