Path: blob/main/contrib/llvm-project/compiler-rt/lib/rtsan/tests/rtsan_test_context.cpp
35268 views
//===--- rtsan_test_context.cpp - Realtime Sanitizer ------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8//===----------------------------------------------------------------------===//910#include "rtsan_test_utilities.h"1112#include "rtsan_context.h"1314TEST(TestRtsanContext, CanCreateContext) { __rtsan::Context context{}; }1516TEST(TestRtsanContext, ExpectNotRealtimeDoesNotDieBeforeRealtimePush) {17__rtsan::Context context{};18context.ExpectNotRealtime("do_some_stuff");19}2021TEST(TestRtsanContext, ExpectNotRealtimeDoesNotDieAfterPushAndPop) {22__rtsan::Context context{};23context.RealtimePush();24context.RealtimePop();25context.ExpectNotRealtime("do_some_stuff");26}2728TEST(TestRtsanContext, ExpectNotRealtimeDiesAfterRealtimePush) {29__rtsan::Context context{};3031context.RealtimePush();32EXPECT_DEATH(context.ExpectNotRealtime("do_some_stuff"), "");33}3435TEST(TestRtsanContext,36ExpectNotRealtimeDiesAfterRealtimeAfterMorePushesThanPops) {37__rtsan::Context context{};3839context.RealtimePush();40context.RealtimePush();41context.RealtimePush();42context.RealtimePop();43context.RealtimePop();44EXPECT_DEATH(context.ExpectNotRealtime("do_some_stuff"), "");45}4647TEST(TestRtsanContext, ExpectNotRealtimeDoesNotDieAfterBypassPush) {48__rtsan::Context context{};4950context.RealtimePush();51context.BypassPush();52context.ExpectNotRealtime("do_some_stuff");53}5455TEST(TestRtsanContext,56ExpectNotRealtimeDoesNotDieIfBypassDepthIsGreaterThanZero) {57__rtsan::Context context{};5859context.RealtimePush();60context.BypassPush();61context.BypassPush();62context.BypassPush();63context.BypassPop();64context.BypassPop();65context.ExpectNotRealtime("do_some_stuff");66context.BypassPop();67EXPECT_DEATH(context.ExpectNotRealtime("do_some_stuff"), "");68}697071