From 5fa9f8928535a7459265c8f431162a91391b09b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Fri, 16 Aug 2019 03:12:58 -0700 Subject: [PATCH] [cost] Fix misleading test names Summary: Functions with empty body have unit cost, not zero. The unit cost comes from the start node. Reviewed By: skcho Differential Revision: D16855642 fbshipit-source-id: 6b5181faf --- infer/tests/codetoanalyze/c/performance/cost_test.c | 3 ++- infer/tests/codetoanalyze/c/performance/issues.exp | 4 ++-- infer/tests/codetoanalyze/java/performance/Cost_test.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/infer/tests/codetoanalyze/c/performance/cost_test.c b/infer/tests/codetoanalyze/c/performance/cost_test.c index fb6afec16..847a014c4 100644 --- a/infer/tests/codetoanalyze/c/performance/cost_test.c +++ b/infer/tests/codetoanalyze/c/performance/cost_test.c @@ -127,7 +127,8 @@ void call_while_upto20_10_good() { while_upto20_bad(10); } void call_while_upto20_unsigned_good(unsigned x) { while_upto20_bad(x); } -void zero_cost_function() {} +// Cost: 1 +void unit_cost_function() {} int always(int i) { return i % 2 == (i + 2) % 2; } diff --git a/infer/tests/codetoanalyze/c/performance/issues.exp b/infer/tests/codetoanalyze/c/performance/issues.exp index 9b014af0c..5a81eeabb 100644 --- a/infer/tests/codetoanalyze/c/performance/issues.exp +++ b/infer/tests/codetoanalyze/c/performance/issues.exp @@ -19,9 +19,9 @@ codetoanalyze/c/performance/compound_loop_guard.c, while_and_or, 0, INFINITE_EXE codetoanalyze/c/performance/compound_loop_guard.c, while_and_or, 2, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here] codetoanalyze/c/performance/compound_loop_guard.c, while_and_or, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] codetoanalyze/c/performance/cost_test.c, alias_OK, 5, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [Binary operation: ([-oo, +oo] + 1):signed32] -codetoanalyze/c/performance/cost_test.c, call_infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Call to infinite,Unbounded loop,Loop at line 143, column 3] +codetoanalyze/c/performance/cost_test.c, call_infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Call to infinite,Unbounded loop,Loop at line 144, column 3] codetoanalyze/c/performance/cost_test.c, call_while_upto20_minus100_bad, 0, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 606, O(1), degree = 0] -codetoanalyze/c/performance/cost_test.c, infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 143, column 3] +codetoanalyze/c/performance/cost_test.c, infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 144, column 3] codetoanalyze/c/performance/cost_test.c, infinite, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,,Assignment,Binary operation: ([-oo, +oo] + [0, +oo]):signed32] codetoanalyze/c/performance/cost_test.c, infinite_FN, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,,Assignment,Binary operation: ([-oo, +oo] + [0, +oo]):signed32] codetoanalyze/c/performance/cost_test.c, loop0_bad, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 1103, O(1), degree = 0] diff --git a/infer/tests/codetoanalyze/java/performance/Cost_test.java b/infer/tests/codetoanalyze/java/performance/Cost_test.java index 7febe985f..0f787ea1e 100644 --- a/infer/tests/codetoanalyze/java/performance/Cost_test.java +++ b/infer/tests/codetoanalyze/java/performance/Cost_test.java @@ -117,6 +117,6 @@ public class Cost_test { return 0; } - // Cost: 0 - private static void zeroCostFunction() {} + // Cost: 1 + private static void unitCostFunction() {} }