Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a618dc3

Browse filesBrowse files
tniessenRafaelGSS
authored andcommitted
test: use CHECK instead of EXPECT where necessary
GetPageSize() and OverrunGuardedBuffer currently use non-fatal EXPECT_* macros because GoogleTest does not allow the fatal variants ASSERT_* in non-void returning functions (i.e., in this file, nowhere outside of the TEST itself). The EXPECT_* macros continue execution upon failure, but we really don't want that (and static analysis apparently does not like it either). Since we cannot use GoogleTest's ASSERT_* here, use our own CHECK_* instead of EXPECT_* outside of the TEST. Hopefully, this will finally pacify static analysis. Refs: #44666 PR-URL: #44795 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent ffba321 commit a618dc3
Copy full SHA for a618dc3

File tree

Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Collapse file

‎test/cctest/test_crypto_clienthello.cc‎

Copy file name to clipboardExpand all lines: test/cctest/test_crypto_clienthello.cc
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#if defined(USE_MPROTECT)
3333
size_t GetPageSize() {
3434
int page_size = sysconf(_SC_PAGE_SIZE);
35-
EXPECT_GE(page_size, 1);
35+
CHECK_GE(page_size, 1);
3636
return page_size;
3737
}
3838
#elif defined(USE_VIRTUALPROTECT)
@@ -49,32 +49,32 @@ class OverrunGuardedBuffer {
4949
OverrunGuardedBuffer() {
5050
#if defined(USE_MPROTECT) || defined(USE_VIRTUALPROTECT)
5151
size_t page = GetPageSize();
52-
EXPECT_GE(page, N);
52+
CHECK_GE(page, N);
5353
#endif
5454
#ifdef USE_MPROTECT
5555
// Place the packet right before a guard page, which, when accessed, causes
5656
// a segmentation fault.
5757
alloc_base = static_cast<uint8_t*>(aligned_alloc(page, 2 * page));
58-
EXPECT_NE(alloc_base, nullptr);
58+
CHECK_NOT_NULL(alloc_base);
5959
uint8_t* second_page = alloc_base + page;
60-
EXPECT_EQ(mprotect(second_page, page, PROT_NONE), 0);
60+
CHECK_EQ(mprotect(second_page, page, PROT_NONE), 0);
6161
data_base = second_page - N;
6262
#elif defined(USE_VIRTUALPROTECT)
6363
// On Windows, it works almost the same way.
6464
alloc_base = static_cast<uint8_t*>(
6565
VirtualAlloc(nullptr, 2 * page, MEM_COMMIT, PAGE_READWRITE));
66-
EXPECT_NE(alloc_base, nullptr);
66+
CHECK_NOT_NULL(alloc_base);
6767
uint8_t* second_page = alloc_base + page;
6868
DWORD old_prot;
69-
EXPECT_NE(VirtualProtect(second_page, page, PAGE_NOACCESS, &old_prot), 0);
70-
EXPECT_EQ(old_prot, PAGE_READWRITE);
69+
CHECK_NE(VirtualProtect(second_page, page, PAGE_NOACCESS, &old_prot), 0);
70+
CHECK_EQ(old_prot, PAGE_READWRITE);
7171
data_base = second_page - N;
7272
#else
7373
// Place the packet in a regular allocated buffer. The bug causes undefined
7474
// behavior, which might crash the process, and when it does not, address
7575
// sanitizers and valgrind will catch it.
7676
alloc_base = static_cast<uint8_t*>(malloc(N));
77-
EXPECT_NE(alloc_base, nullptr);
77+
CHECK_NOT_NULL(alloc_base);
7878
data_base = alloc_base;
7979
#endif
8080
}
@@ -92,7 +92,7 @@ class OverrunGuardedBuffer {
9292
#ifdef USE_MPROTECT
9393
// Revert page protection such that the memory can be free()'d.
9494
uint8_t* second_page = alloc_base + page;
95-
EXPECT_EQ(mprotect(second_page, page, PROT_READ | PROT_WRITE), 0);
95+
CHECK_EQ(mprotect(second_page, page, PROT_READ | PROT_WRITE), 0);
9696
#endif
9797
free(alloc_base);
9898
#endif

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.