test_stack_check_cxx.cpp 528 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "unity.h"
  7. #if CONFIG_COMPILER_STACK_CHECK
  8. static void recur_and_smash_cxx()
  9. {
  10. static int cnt;
  11. volatile uint8_t buf[50];
  12. volatile int num = sizeof(buf)+10;
  13. if (cnt++ < 1) {
  14. recur_and_smash_cxx();
  15. }
  16. for (int i = 0; i < num; i++) {
  17. buf[i] = 0;
  18. }
  19. }
  20. TEST_CASE("stack smashing protection CXX", "[stack_check] [ignore]")
  21. {
  22. recur_and_smash_cxx();
  23. }
  24. #endif