diff options
Diffstat (limited to 'debuginfo-tests/dexter/feature_tests/commands/penalty')
6 files changed, 173 insertions, 0 deletions
diff --git a/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_program_state.cpp b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_program_state.cpp new file mode 100644 index 00000000000..2d7c202f407 --- /dev/null +++ b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_program_state.cpp @@ -0,0 +1,37 @@ +// Purpose: +// Check that \DexExpectProgramState correctly applies a penalty when +// an expected program state is never found. +// +// REQUIRES: system-linux, lldb +// +// RUN: not %dexter test --fail-lt 1.0 -w \ +// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -glldb" -- %s \ +// RUN: | FileCheck %s +// CHECK: expect_program_state.cpp: + +int GCD(int lhs, int rhs) +{ + if (rhs == 0) // DexLabel('check') + return lhs; + return GCD(rhs, lhs % rhs); +} + +int main() +{ + return GCD(111, 259); +} + +/* +DexExpectProgramState({ + 'frames': [ + { + 'location': { + 'lineno': 'check' + }, + 'watches': { + 'lhs': '0', 'rhs': '0' + } + }, + ] +}) +*/ diff --git a/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_step_kinds.cpp b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_step_kinds.cpp new file mode 100644 index 00000000000..54f363e6fd0 --- /dev/null +++ b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_step_kinds.cpp @@ -0,0 +1,27 @@ +// Purpose: +// Check that \DexExpectStepKind correctly applies a penalty when +// unexpected step kinds are encountered. +// +// REQUIRES: system-linux, lldb +// +// RUN: not %dexter test --fail-lt 1.0 -w \ +// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" -- %s \ +// RUN: | FileCheck %s +// CHECK: expect_step_kinds.cpp: + +int abs(int i){ + return i < 0? i * -1: i; +} + +int main() +{ + volatile int x = 2; + for (int i = 0; i < x; ++i) { + abs(i); + } + return 0; +} + +// DexExpectStepKind('FUNC', 5) +// DexExpectStepKind('FUNC_EXTERNAL', 2) +// DexExpectStepKind('VERTICAL_BACKWARD', 2) diff --git a/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_step_order.cpp b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_step_order.cpp new file mode 100644 index 00000000000..84d2ab81d55 --- /dev/null +++ b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_step_order.cpp @@ -0,0 +1,18 @@ +// Purpose: +// Check that \DexExpectStepOrder correctly applies a penalty for steps +// found out of expected order. +// +// REQUIRES: system-linux, lldb +// +// RUN: not %dexter test --fail-lt 1.0 -w \ +// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" -- %s \ +// RUN: | FileCheck %s +// CHECK: expect_step_order.cpp: + +int main() +{ + volatile int x = 1; // DexExpectStepOrder(3) + volatile int y = 1; // DexExpectStepOrder(1) + volatile int z = 1; // DexExpectStepOrder(2) + return 0; +} diff --git a/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_watch_type.cpp b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_watch_type.cpp new file mode 100644 index 00000000000..a619a6d224f --- /dev/null +++ b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_watch_type.cpp @@ -0,0 +1,54 @@ +// Purpose: +// Check that \DexExpectWatchType applies penalties when expected +// types are not found and unexpected types are. +// +// REQUIRES: system-linux, lldb +// +// RUN: not %dexter test --fail-lt 1.0 -w \ +// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" -- %s \ +// RUN: | FileCheck %s +// CHECK: expect_watch_type.cpp: + +template<class T> +class Doubled { +public: + Doubled(const T & to_double) + : m_member(to_double * 2) {} + + T GetVal() { + T to_return = m_member; // DexLabel('gv_start') + return to_return; // DexLabel('gv_end') + } + + static T static_doubler(const T & to_double) { + T result = 0; // DexLabel('sd_start') + result = to_double * 2; + return result; // DexLabel('sd_end') + } + +private: + T m_member; +}; + +int main() { + auto myInt = Doubled<int>(5); // DexLabel('main_start') + auto myDouble = Doubled<double>(5.5); + auto staticallyDoubledInt = Doubled<int>::static_doubler(5); + auto staticallyDoubledDouble = Doubled<double>::static_doubler(5.5); + return int(double(myInt.GetVal()) + + double(staticallyDoubledInt) + + myDouble.GetVal() + + staticallyDoubledDouble); // DexLabel('main_end') +} + + +// DexExpectWatchType('m_member', 'int', 'double', from_line='gv_start', to_line='gv_end') + +// THIS COMMAND should create a penalty for a missing type 'const double' and unexpected type 'const double &' +// DexExpectWatchType('to_double', 'const double', 'const int &', from_line='sd_start', to_line='sd_end') + +// DexExpectWatchType('myInt', 'Doubled<int>', from_line='main_start', to_line='main_end') +// DexExpectWatchType('myDouble', 'Doubled<double>', from_line='main_start', to_line='main_end') +// DexExpectWatchType('staticallyDoubledInt', 'int', from_line='main_start', to_line='main_end') +// DexExpectWatchType('staticallyDoubledDouble', 'double', from_line='main_start', to_line='main_end') + diff --git a/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_watch_value.cpp b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_watch_value.cpp new file mode 100644 index 00000000000..ea30bc53a1b --- /dev/null +++ b/debuginfo-tests/dexter/feature_tests/commands/penalty/expect_watch_value.cpp @@ -0,0 +1,21 @@ +// Purpose: +// Check that \DexExpectWatchValue correctly applies a penalty when +// expected values are not found. +// +// REQUIRES: system-linux, lldb +// +// RUN: not %dexter test --fail-lt 1.0 -w \ +// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" -- %s \ +// RUN: | FileCheck %s +// CHECK: expect_watch_value.cpp: + +int main() +{ + for (int i = 0; i < 3; ++i) + int a = i; // DexLabel('loop') + return 0; // DexLabel('ret') +} + +// DexExpectWatchValue('i', '0', '1', '2', on_line='loop') +// DexExpectWatchValue('i', '3', on_line='ret') +// ---------------------^ out of scope diff --git a/debuginfo-tests/dexter/feature_tests/commands/penalty/unreachable.cpp b/debuginfo-tests/dexter/feature_tests/commands/penalty/unreachable.cpp new file mode 100644 index 00000000000..b089e6f6498 --- /dev/null +++ b/debuginfo-tests/dexter/feature_tests/commands/penalty/unreachable.cpp @@ -0,0 +1,16 @@ +// Purpose: +// Check that \DexUnreachable correctly applies a penalty if the command +// line is stepped on. +// +// REQUIRES: system-linux, lldb +// +// RUN: not %dexter test --fail-lt 1.0 -w \ +// RUN: --builder 'clang' --debugger 'lldb' --cflags "-O0 -g" -- %s \ +// RUN: | FileCheck %s +// CHECK: unreachable.cpp: + +int +main() +{ + return 1; // DexUnreachable() +} |