mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
AArch64 does not have divide-by-zero exception. This change modifies the corresponding test to work with AArch64. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
39 lines
971 B
C++
39 lines
971 B
C++
/** @file
|
|
This is a sample to demonstrates the use of GoogleTest that supports host
|
|
execution environments.
|
|
|
|
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#include <Library/GoogleTestLib.h>
|
|
extern "C" {
|
|
#include <Uefi.h>
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/MemoryAllocationLib.h>
|
|
#include <Library/HostMemoryAllocationBelowAddressLib.h>
|
|
}
|
|
|
|
UINTN
|
|
DivideWithNoParameterChecking (
|
|
UINTN Dividend,
|
|
UINTN Divisor
|
|
)
|
|
{
|
|
//
|
|
// Perform integer division with no check for divide by zero
|
|
//
|
|
return (Dividend / Divisor);
|
|
}
|
|
|
|
/**
|
|
Sample unit test that performs a divide by 0
|
|
**/
|
|
TEST (SanitizerTests, DivideByZeroDeathTest) {
|
|
//
|
|
// Divide by 0 should be caught by address sanitizer, log details, and exit
|
|
//
|
|
EXPECT_DEATH (DivideWithNoParameterChecking (10, 0), "ERROR: AddressSanitizer: ");
|
|
}
|