From d707c717f00cc1bf1c95ca04c7622eab3c9ca2b7 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Thu, 9 Jun 2016 03:19:05 -0700 Subject: [PATCH] ndk-build integration test Reviewed By: jvillard Differential Revision: D3405859 fbshipit-source-id: 24a068f --- .../build_systems/build_integration_tests.py | 14 ++++++++++++++ .../codetoanalyze/ndk-build/hello_app/hello.c | 15 +++++++++++++++ .../ndk-build/hello_app/jni/Android.mk | 5 +++++ .../expected_outputs/ndk-build_report.json | 7 +++++++ 4 files changed, 41 insertions(+) create mode 100644 infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/hello.c create mode 100644 infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/jni/Android.mk create mode 100644 infer/tests/build_systems/expected_outputs/ndk-build_report.json diff --git a/infer/tests/build_systems/build_integration_tests.py b/infer/tests/build_systems/build_integration_tests.py index ea03f37c4..b43493f71 100755 --- a/infer/tests/build_systems/build_integration_tests.py +++ b/infer/tests/build_systems/build_integration_tests.py @@ -71,6 +71,7 @@ ALL_TESTS = [ 'unknown_ext', 'utf8_in_pwd', 'waf', + 'ndk-build', ] to_test = ALL_TESTS @@ -334,6 +335,19 @@ 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') + if test('ndk-build', 'ndk-build', + root, + [['ndk-build', '-B', 'NDK_LIBS_OUT=./libs', 'NDK_OUT=./obj']], + clean_commands=[['ndk-build', 'clean']], + available=lambda: is_tool_available(['ndk-build', '-v'])): + # remove libs/ and obj/ directories + shutil.rmtree(gen_lib_dir) + shutil.rmtree(gen_obj_dir) + def test_wonky_locale_integration(self): env = os.environ.copy() env['LC_ALL'] = 'C' diff --git a/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/hello.c b/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/hello.c new file mode 100644 index 000000000..a3c29e227 --- /dev/null +++ b/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/hello.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2015 - 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. + */ + +#include + +void test() { + int* s = NULL; + *s = 42; +} diff --git a/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/jni/Android.mk b/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/jni/Android.mk new file mode 100644 index 000000000..a0e310c0b --- /dev/null +++ b/infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/jni/Android.mk @@ -0,0 +1,5 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := hello +LOCAL_SRC_FILES := ../hello.c +include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/infer/tests/build_systems/expected_outputs/ndk-build_report.json b/infer/tests/build_systems/expected_outputs/ndk-build_report.json new file mode 100644 index 000000000..a6ed10eff --- /dev/null +++ b/infer/tests/build_systems/expected_outputs/ndk-build_report.json @@ -0,0 +1,7 @@ +[ + { + "bug_type": "NULL_DEREFERENCE", + "file": "hello.c", + "procedure": "test" + } +] \ No newline at end of file