From dece9f13864a5db8acae8faf3fc83907e806438d Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 15 Dec 2016 09:03:20 -0800 Subject: [PATCH] [tests] convert ndk-build test to Makefile Reviewed By: jberdine Differential Revision: D4329644 fbshipit-source-id: d1b88da --- .gitignore | 2 ++ Makefile | 3 ++ Makefile.config.in | 1 + configure.ac | 9 +++++- .../build_systems/build_integration_tests.py | 24 ---------------- .../expected_outputs/ndk-build_report.json | 7 ----- infer/tests/build_systems/ndk_build/Makefile | 28 +++++++++++++++++++ .../tests/build_systems/ndk_build/issues.exp | 1 + 8 files changed, 43 insertions(+), 32 deletions(-) delete mode 100644 infer/tests/build_systems/expected_outputs/ndk-build_report.json create mode 100644 infer/tests/build_systems/ndk_build/Makefile create mode 100644 infer/tests/build_systems/ndk_build/issues.exp diff --git a/.gitignore b/.gitignore index ff848830b..571d0c853 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,8 @@ duplicates.txt *.ast.sh *.ast.bdump *.ast.biniou +/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/libs/ +/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/obj/ # generated by oUnit /oUnit-all.cache diff --git a/Makefile b/Makefile index f7fb102a1..3aba271fa 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,9 @@ endif ifneq ($(CMAKE),no) BUILD_SYSTEMS_TESTS += clang_compilation_db cmake endif +ifneq ($(NDKBUILD),no) +BUILD_SYSTEMS_TESTS += ndk_build +endif DIRECT_TESTS= ifeq ($(BUILD_C_ANALYZERS),yes) diff --git a/Makefile.config.in b/Makefile.config.in index 352e5862a..b1ff7560b 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -45,6 +45,7 @@ MKDIR_P_CMD = case "@MKDIR_P@" in \ esac MKDIR_P = $(shell $(MKDIR_P_CMD)) NCPU = @NCPU@ +NDKBUILD = @NDKBUILD@ prefix = @prefix@ USER_JAVA_HOME = @USER_JAVA_HOME@ XCODE_SELECT = @XCODE_SELECT@ diff --git a/configure.ac b/configure.ac index 0392f1e24..665b067b2 100644 --- a/configure.ac +++ b/configure.ac @@ -264,7 +264,7 @@ else fi AC_SUBST([NCPU]) -# tools that are optional, eg build systems to be run in integration tests +# progs that are optional, eg build systems to be run in integration tests AC_CHECK_TOOL([ANT], [ant], [no]) if test ! -z "$SANDCASTLE"; then BUCK=buck @@ -272,6 +272,13 @@ if test ! -z "$SANDCASTLE"; then else AC_CHECK_TOOL([BUCK], [buck], [no]) fi +AC_CHECK_TOOL([NDKBUILD], [ndk-build], [no]) +if test x"$NDKBUILD" = x"no"; then +# ndk-build not in $PATH, look into potential android NDK install paths and record the absolute path +# to ndk-build + AC_PATH_PROG([NDKBUILD], [ndk-build], [no], + [$PATH$PATH_SEPARATOR$ANDROID_NDK$PATH_SEPARATOR/opt/android_ndk/r10e]) +fi AC_CONFIG_FILES([ Makefile.config diff --git a/infer/tests/build_systems/build_integration_tests.py b/infer/tests/build_systems/build_integration_tests.py index c6eba3bff..0e28bca64 100755 --- a/infer/tests/build_systems/build_integration_tests.py +++ b/infer/tests/build_systems/build_integration_tests.py @@ -61,7 +61,6 @@ CODETOANALYZE_DIR = os.path.join(SCRIPT_DIR, 'codetoanalyze') EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs') ALL_TESTS = [ - 'ndk-build', 'pmd-xml', 'reactive', 'unknown_ext', @@ -352,29 +351,6 @@ class BuildIntegrationTest(unittest.TestCase): enabled=enabled, report_fname=report_fname) - def test_ndkbuild_integration(self): - root = os.path.join(CODETOANALYZE_DIR, 'ndk-build', 'hello_app') - gen_lib_dir = os.path.join(root, 'libs') - gen_obj_dir = os.path.join(root, 'obj') - env = os.environ.copy() - ndk_dir = os.getenv('ANDROID_NDK', - os.path.join(os.path.sep, - 'opt', - 'android_ndk', - 'r10e')) - env['PATH'] = '{}:{}'.format(os.getenv('PATH'), ndk_dir) - if test('ndk-build', 'ndk-build', - root, - [{'compile': ['ndk-build', '-B', - 'NDK_LIBS_OUT=./libs', 'NDK_OUT=./obj']}], - clean_commands=[['ndk-build', 'clean']], - available=lambda: is_tool_available([ - os.path.join(ndk_dir, 'ndk-build'), '-v']), - env=env): - # remove libs/ and obj/ directories - shutil.rmtree(gen_lib_dir) - shutil.rmtree(gen_obj_dir) - def test_waf_integration(self): test('waf', 'waf', os.path.join(CODETOANALYZE_DIR, 'make'), diff --git a/infer/tests/build_systems/expected_outputs/ndk-build_report.json b/infer/tests/build_systems/expected_outputs/ndk-build_report.json deleted file mode 100644 index a6ed10eff..000000000 --- a/infer/tests/build_systems/expected_outputs/ndk-build_report.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "bug_type": "NULL_DEREFERENCE", - "file": "hello.c", - "procedure": "test" - } -] \ No newline at end of file diff --git a/infer/tests/build_systems/ndk_build/Makefile b/infer/tests/build_systems/ndk_build/Makefile new file mode 100644 index 000000000..aeb4fc53c --- /dev/null +++ b/infer/tests/build_systems/ndk_build/Makefile @@ -0,0 +1,28 @@ +# 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. + +TESTS_DIR = ../.. + +ANALYZER = infer + +PROJECT_ROOT = ../codetoanalyze/ndk-build/hello_app +SOURCES = $(PROJECT_ROOT)/hello.c +OBJECTS = $(PROJECT_ROOT)/hello.o +INFERPRINT_OPTIONS = --issues-tests +CLEAN_EXTRA = libs obj + +include $(TESTS_DIR)/base.make + +$(OBJECTS): $(SOURCES) + cd $(PROJECT_ROOT) && \ + $(NDKBUILD) -B NDK_LIBS_OUT=./libs NDK_OUT=./obj + +infer-out/report.json: $(CLANG_DEPS) $(SOURCES) + cd $(PROJECT_ROOT) && \ + $(call silent_on_success,\ + $(INFER_BIN) -a $(ANALYZER) --results-dir $(CURDIR)/infer-out -- \ + $(NDKBUILD) -B NDK_LIBS_OUT=./libs NDK_OUT=./obj) diff --git a/infer/tests/build_systems/ndk_build/issues.exp b/infer/tests/build_systems/ndk_build/issues.exp new file mode 100644 index 000000000..d03e4fd25 --- /dev/null +++ b/infer/tests/build_systems/ndk_build/issues.exp @@ -0,0 +1 @@ +hello.c, test, 2, NULL_DEREFERENCE, [start of procedure test()]