From 71b73368ec7d68c22710ad4629209db90257233c Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Tue, 1 Nov 2016 07:07:04 -0700 Subject: [PATCH] Add basic integration test for assembly code Summary: Make sure that infer ignores the .S file and still finds an issue in `hello.c` Reviewed By: jvillard Differential Revision: D4110622 fbshipit-source-id: 32f907e --- .../build_systems/build_integration_tests.py | 6 ++++++ .../build_systems/codetoanalyze/example.S | 20 +++++++++++++++++++ .../expected_outputs/assembly_report.json | 7 +++++++ 3 files changed, 33 insertions(+) create mode 100644 infer/tests/build_systems/codetoanalyze/example.S create mode 100644 infer/tests/build_systems/expected_outputs/assembly_report.json diff --git a/infer/tests/build_systems/build_integration_tests.py b/infer/tests/build_systems/build_integration_tests.py index 0aab13338..aefa68282 100755 --- a/infer/tests/build_systems/build_integration_tests.py +++ b/infer/tests/build_systems/build_integration_tests.py @@ -61,6 +61,7 @@ EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs') ALL_TESTS = [ 'ant', + 'assembly', 'buck', 'cc1', 'cmake', @@ -496,6 +497,11 @@ class BuildIntegrationTest(unittest.TestCase): [], preprocess=preprocess) + def test_clang_assembly(self): + test('assembly', 'compile with assembly code', CODETOANALYZE_DIR, + [{'compile': ['clang', '-x', 'c', '-c', 'hello.c', '-x', + 'assembler-with-cpp', 'example.S']}]) + def test_clang_component_kit_imports(self): test('componentkit', 'component quality analyzer skips imports', os.path.join(CODETOANALYZE_DIR, 'componentkit'), diff --git a/infer/tests/build_systems/codetoanalyze/example.S b/infer/tests/build_systems/codetoanalyze/example.S new file mode 100644 index 000000000..ae962fae5 --- /dev/null +++ b/infer/tests/build_systems/codetoanalyze/example.S @@ -0,0 +1,20 @@ +/* + * 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. + */ + +// THIS CODE HAS NO REAL MEANING, DO NOT TRY TO USE IT + .file "example.S" + .text +test: + pushq %rbp + movq %rsp, %rbp + movl %edi, -4(%rbp) + movl -4(%rbp), %eax + addl $1, %eax + popq %rbp + ret diff --git a/infer/tests/build_systems/expected_outputs/assembly_report.json b/infer/tests/build_systems/expected_outputs/assembly_report.json new file mode 100644 index 000000000..a6ed10eff --- /dev/null +++ b/infer/tests/build_systems/expected_outputs/assembly_report.json @@ -0,0 +1,7 @@ +[ + { + "bug_type": "NULL_DEREFERENCE", + "file": "hello.c", + "procedure": "test" + } +] \ No newline at end of file