diff --git a/Makefile b/Makefile index 83d3b7ff7..c73147067 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ BUILD_SYSTEMS_TESTS += \ project_root_rel \ reactive \ run_hidden_linters \ - utf8_in_procname utf8_in_pwd \ + utf8_in_procname \ waf \ ifneq ($(CMAKE),no) @@ -50,7 +50,7 @@ endif # XCODE_SELECT endif # BUILD_C_ANALYZERS ifeq ($(BUILD_JAVA_ANALYZERS),yes) -BUILD_SYSTEMS_TESTS += gradle javac +BUILD_SYSTEMS_TESTS += gradle javac utf8_in_pwd ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif @@ -223,9 +223,15 @@ endtoend_test: print_direct_tests print_build_systems_tests .PHONY: inferTraceBugs_test inferTraceBugs_test: infer +ifeq ($(BUILD_JAVA_ANALYZERS),yes) $(INFER_BIN) -o __test-infer-out__ -- \ javac $(EXAMPLES_DIR)/Hello.java \ > /dev/null +else + $(INFER_BIN) -o __test-infer-out__ -- \ + clang -c $(EXAMPLES_DIR)/hello.c \ + > /dev/null +endif @rm -f Hello.class $(PYTHON_DIR)/inferTraceBugs -o __test-infer-out__ \ --select 0 --max-level max > /dev/null diff --git a/infer/src/Makefile b/infer/src/Makefile index 4669cb8c4..8256ad9cf 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -150,7 +150,9 @@ DEPENDENCIES += java_stubs endif ifeq ($(BUILD_C_ANALYZERS),yes) INFER_CONFIG_TARGETS += $(INFERCLANG_MAIN).native -DEPENDENCIES += clang +DEPENDENCIES += clang unit/clang +else +DEPENDENCIES += unit/clang_stubs endif OCAML_BASE_SOURCES = \ @@ -158,9 +160,9 @@ OCAML_BASE_SOURCES = \ $(DEPENDENCIES:=/[a-zA-Z]*.mll) $(DEPENDENCIES:=/[a-zA-Z]*.mly) \ $(DEPENDENCIES:=/[a-zA-Z]*.re) $(DEPENDENCIES:=/[a-zA-Z]*.rei)) \ $(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS) -OCAML_SOURCES = $(OCAML_BASE_SOURCES) +OCAML_CONFIG_SOURCES = $(OCAML_BASE_SOURCES) ifeq ($(BUILD_C_ANALYZERS),yes) -OCAML_SOURCES += $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) +OCAML_CONFIG_SOURCES += $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) endif OCAML_ALL_SOURCES = $(OCAML_BASE_SOURCES) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) @@ -171,7 +173,7 @@ all: infer # single out infer.native as the source of truth for make, knowing that in fact several targets are # produced by the build -$(INFER_BUILD_DIR)/$(INFER_MAIN).native: base/Version.ml $(BUILD_DIR) $(OCAML_SOURCES) \ +$(INFER_BUILD_DIR)/$(INFER_MAIN).native: base/Version.ml $(BUILD_DIR) $(OCAML_CONFIG_SOURCES) \ $(MAKEFILE_LIST) $(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) $(INFER_CONFIG_TARGETS) # let make know that the target is up-to-date even if ocamlbuild cached it @@ -197,9 +199,9 @@ ifeq ($(BUILD_C_ANALYZERS),yes) infer: $(CLANG_BINIOU_DICT) endif -$(INFER_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES) - $(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) \ - $(INFER_ALL_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte +$(INFER_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_CONFIG_SOURCES) + $(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) \ + $(INFER_CONFIG_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte @touch $@ $(INFER_BIN).byte: $(INFER_BUILD_DIR)/$(INFER_MAIN).byte $(BIN_DIR) @@ -228,11 +230,11 @@ module: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES) $(MFLAGS) \ $(M) -$(TEST_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES) \ +$(TEST_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_CONFIG_SOURCES) \ toplevel.mlpack $(MAKEFILE_LIST) - $(OCAMLBUILD_ALL) -build-dir $(TEST_BUILD_DIR) \ + $(OCAMLBUILD_CONFIG) -build-dir $(TEST_BUILD_DIR) \ -cflags -warn-error,$(OCAML_FATAL_WARNINGS) \ - $(INFER_ALL_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte toplevel.cmo + $(INFER_CONFIG_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte toplevel.cmo @touch $@ .PHONY: test_build @@ -283,7 +285,7 @@ $(shell \ | awk 'BEGIN { FS = "/"; OFS = "/" } ; {$$NF=toupper(substr($$NF,1,1))substr($$NF,2); print $$0}') endef -toplevel.mlpack: base/Version.ml $(OCAML_ALL_SOURCES) $(MAKEFILE_LIST) +toplevel.mlpack: base/Version.ml $(OCAML_CONFIG_SOURCES) $(MAKEFILE_LIST) # We need to pack all the infer modules into another module to avoid name clashes with some # of them coming from ocaml libraries (Ident for example). To do that, we generate a .mlpack # file containing namespaced modules. @@ -295,13 +297,13 @@ toplevel.mlpack: base/Version.ml $(OCAML_ALL_SOURCES) $(MAKEFILE_LIST) $(foreach module,\ $(filter-out $(foreach root,$(roots),%/$(root)),\ $(foreach source,\ - $(filter-out unit/% facebook/scripts/eradicate_stats.ml,$(OCAML_ALL_SOURCES)),\ + $(filter-out unit/% facebook/scripts/eradicate_stats.ml,$(OCAML_CONFIG_SOURCES)),\ $(call to_ocaml_module,$(source)))),\ $(shell echo $(module) >> $($@_tmp))) mv $($@_tmp) $@ $(INFER_BUILD_DIR)/toplevel.cmo: toplevel.mlpack $(BUILD_DIR) - $(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) toplevel.cmo + $(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) toplevel.cmo @touch $@ .PHONY: toplevel diff --git a/infer/src/unit/CiOSVersionNumbersTests.ml b/infer/src/unit/clang/CiOSVersionNumbersTests.ml similarity index 100% rename from infer/src/unit/CiOSVersionNumbersTests.ml rename to infer/src/unit/clang/CiOSVersionNumbersTests.ml diff --git a/infer/src/unit/clang/ClangTests.ml b/infer/src/unit/clang/ClangTests.ml new file mode 100644 index 000000000..801e31078 --- /dev/null +++ b/infer/src/unit/clang/ClangTests.ml @@ -0,0 +1,13 @@ +(* + * Copyright (c) 2017 - 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. + *) +open! IStd + +let tests = [ + CiOSVersionNumbersTests.tests; +] diff --git a/infer/src/unit/clang/ClangTests.mli b/infer/src/unit/clang/ClangTests.mli new file mode 100644 index 000000000..60afeade7 --- /dev/null +++ b/infer/src/unit/clang/ClangTests.mli @@ -0,0 +1,11 @@ +(* + * Copyright (c) 2017 - 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. + *) +open! IStd + +val tests : OUnit2.test list diff --git a/infer/src/unit/clang_stubs/ClangTests.ml b/infer/src/unit/clang_stubs/ClangTests.ml new file mode 100644 index 000000000..bb0d878b5 --- /dev/null +++ b/infer/src/unit/clang_stubs/ClangTests.ml @@ -0,0 +1,12 @@ +(* + * Copyright (c) 2017 - 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. + *) + +open! IStd + +let tests = OUnitTest.TestList [] diff --git a/infer/src/unit/inferunit.ml b/infer/src/unit/inferunit.ml index 5a7e57af5..113746d07 100644 --- a/infer/src/unit/inferunit.ml +++ b/infer/src/unit/inferunit.ml @@ -20,13 +20,12 @@ let () = AddressTakenTests.tests; BoundedCallTreeTests.tests; CopyPropagationTests.tests; - CiOSVersionNumbersTests.tests; ProcCfgTests.tests; LivenessTests.tests; SchedulerTests.tests; StacktraceTests.tests; TaintTests.tests; TraceTests.tests; - ] in + ] @ ClangTests.tests in let test_suite = "all" >::: tests in OUnit2.run_test_tt_main test_suite