From dbc8f29835a88a9d4550f1982f929d933d5c2df2 Mon Sep 17 00:00:00 2001 From: Dino Distefano Date: Wed, 2 May 2018 03:40:41 -0700 Subject: [PATCH] Added array test where we get TOP Reviewed By: mbouaziz Differential Revision: D7843528 fbshipit-source-id: 46e23c3 --- Makefile | 2 +- .../java/performance/ArrayCost.java | 22 +++++++++++++++++++ .../codetoanalyze/java/performance/Makefile | 15 +++++++++++++ .../codetoanalyze/java/performance/issues.exp | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 infer/tests/codetoanalyze/java/performance/ArrayCost.java create mode 100644 infer/tests/codetoanalyze/java/performance/Makefile create mode 100644 infer/tests/codetoanalyze/java/performance/issues.exp diff --git a/Makefile b/Makefile index f1919be37..34ab77a0d 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ BUILD_SYSTEMS_TESTS += \ DIRECT_TESTS += \ java_checkers java_eradicate java_infer java_lab java_tracing java_quandary \ - java_racerd java_stability java_crashcontext java_starvation + java_racerd java_stability java_crashcontext java_starvation java_performance ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif diff --git a/infer/tests/codetoanalyze/java/performance/ArrayCost.java b/infer/tests/codetoanalyze/java/performance/ArrayCost.java new file mode 100644 index 000000000..5f5383cfc --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/ArrayCost.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 - 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. + */ +public class ArrayCost { + + private void ArrayCost_FP(int signum, int[] mag) { + if (mag.length > 0) { + + int i = 0; + + while (i < mag.length && mag[i] == 0) { + i++; + } + + } + } +} diff --git a/infer/tests/codetoanalyze/java/performance/Makefile b/infer/tests/codetoanalyze/java/performance/Makefile new file mode 100644 index 000000000..8e0a76d33 --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/Makefile @@ -0,0 +1,15 @@ +# Copyright (c) 2018 - 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 = checkers +INFER_OPTIONS = --cost-only --debug-exceptions +INFERPRINT_OPTIONS = --issues-tests +SOURCES = $(wildcard *.java) + +include $(TESTS_DIR)/javac.make diff --git a/infer/tests/codetoanalyze/java/performance/issues.exp b/infer/tests/codetoanalyze/java/performance/issues.exp new file mode 100644 index 000000000..7b6823da8 --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/issues.exp @@ -0,0 +1 @@ +codetoanalyze/java/performance/ArrayCost.java, void ArrayCost.ArrayCost_FP(int,int[]), 0, INFINITE_EXECUTION_TIME_CALL, ERROR, []