From d20d71da50db4d65b4ec9f9ddcdfdab5929dcfc3 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Sun, 23 Apr 2017 23:23:52 -0700 Subject: [PATCH] [bufferoverrun][tests] Move bufferoverrun cpp tests to their own directory Summary: `bufferoverrun` is not part of `checkers` yet so bufferoverrun tests require their own Makefile Reviewed By: jvillard Differential Revision: D4937558 fbshipit-source-id: 20380f1 --- Makefile | 4 +++- .../codetoanalyze/cpp/bufferoverrun/Makefile | 24 +++++++++++++++++++ .../cpp/bufferoverrun/issues.exp | 1 + .../cpp/bufferoverrun/trivial.cpp | 16 +++++++++++++ .../{checkers => }/bufferoverrun/vector.cpp | 0 .../tests/codetoanalyze/cpp/checkers/Makefile | 1 - 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile create mode 100644 infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp create mode 100644 infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp rename infer/tests/codetoanalyze/cpp/{checkers => }/bufferoverrun/vector.cpp (100%) diff --git a/Makefile b/Makefile index e66970698..040d73f6b 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,9 @@ BUILD_SYSTEMS_TESTS += \ waf \ DIRECT_TESTS += \ - c_errors c_frontend c_bufferoverrun cpp_checkers cpp_errors cpp_frontend cpp_quandary + c_bufferoverrun c_errors c_frontend \ + cpp_bufferoverrun cpp_checkers cpp_errors cpp_frontend cpp_quandary \ + ifneq ($(BUCK),no) BUILD_SYSTEMS_TESTS += buck-clang-db endif diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile b/infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile new file mode 100644 index 000000000..eec20303a --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile @@ -0,0 +1,24 @@ +# 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 = bufferoverrun +# see explanations in cpp/errors/Makefile for the custom isystem +CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed +INFERPRINT_OPTIONS = --issues-tests + +SOURCES = \ + trivial.cpp \ + vector.cpp \ + +HEADERS = + +include $(TESTS_DIR)/clang.make + +infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp b/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp new file mode 100644 index 000000000..6f24ef3cf --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp @@ -0,0 +1 @@ +codetoanalyze/cpp/bufferoverrun/trivial.cpp, trivial, 2, BUFFER_OVERRUN, [Offset : [10, 10] Size : [10, 10] @ codetoanalyze/cpp/bufferoverrun/trivial.cpp:15:3] diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp b/infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp new file mode 100644 index 000000000..a97f8c585 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2016 - present + * + * Programming Research Laboratory (ROPAS) + * Seoul National University, Korea + * 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. + */ + +void trivial() { + int a[10]; + a[10] = 0; /* BUG */ +} diff --git a/infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp b/infer/tests/codetoanalyze/cpp/bufferoverrun/vector.cpp similarity index 100% rename from infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp rename to infer/tests/codetoanalyze/cpp/bufferoverrun/vector.cpp diff --git a/infer/tests/codetoanalyze/cpp/checkers/Makefile b/infer/tests/codetoanalyze/cpp/checkers/Makefile index b93268b9b..aa6b8906a 100644 --- a/infer/tests/codetoanalyze/cpp/checkers/Makefile +++ b/infer/tests/codetoanalyze/cpp/checkers/Makefile @@ -23,7 +23,6 @@ SOURCES = \ siof/siof_templated.cpp \ siof/siof_different_tu.cpp \ siof/std_ios_base_init.cpp \ - bufferoverrun/vector.cpp \ HEADERS = siof/siof_types.h