[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / libc / test / src / compiler / stack_chk_guard_test.cpp
blob4ec8398c9fc95dc9ea5b6b16083be07dcee54c52
1 //===-- Unittests for __stack_chk_fail ------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "hdr/signal_macros.h"
10 #include "src/__support/macros/sanitizer.h"
11 #include "src/compiler/__stack_chk_fail.h"
12 #include "src/string/memset.h"
13 #include "test/UnitTest/Test.h"
15 TEST(LlvmLibcStackChkFail, Death) {
16 EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
19 // Disable the test when asan is enabled so that it doesn't immediately fail
20 // after the memset, but before the stack canary is re-checked.
21 #ifndef LIBC_HAS_ADDRESS_SANITIZER
22 TEST(LlvmLibcStackChkFail, Smash) {
23 EXPECT_DEATH(
24 [] {
25 int arr[20];
26 LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
28 WITH_SIGNAL(SIGABRT));
30 #endif // LIBC_HAS_ADDRESS_SANITIZER