[tests] convert ndk-build test to Makefile

Reviewed By: jberdine

Differential Revision: D4329644

fbshipit-source-id: d1b88da
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent facdcbe6f2
commit dece9f1386

2
.gitignore vendored

@ -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

@ -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)

@ -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@

@ -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

@ -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'),

@ -1,7 +0,0 @@
[
{
"bug_type": "NULL_DEREFERENCE",
"file": "hello.c",
"procedure": "test"
}
]

@ -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)

@ -0,0 +1 @@
hello.c, test, 2, NULL_DEREFERENCE, [start of procedure test()]
Loading…
Cancel
Save