mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:17:35 +00:00
Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
This commit is contained in:
parent
b33a6a443e
commit
5d180d1f99
725 changed files with 3448 additions and 3448 deletions
|
@ -48,7 +48,7 @@ int main(int, char**)
|
|||
struct sockaddr_un addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
ASSERT(strlcpy(addr.sun_path, path, sizeof(addr.sun_path)) < sizeof(addr.sun_path));
|
||||
VERIFY(strlcpy(addr.sun_path, path, sizeof(addr.sun_path)) < sizeof(addr.sun_path));
|
||||
|
||||
rc = bind(fd, (struct sockaddr*)(&addr), sizeof(addr));
|
||||
if (rc < 0 && errno == EADDRINUSE) {
|
||||
|
|
|
@ -63,16 +63,16 @@ static void do_systematic_tests()
|
|||
}
|
||||
// This is pure torture
|
||||
rc = syscall(Syscall::Function(i), 0xc0000001, 0xc0000002, 0xc0000003);
|
||||
ASSERT(rc != -ENOSYS);
|
||||
VERIFY(rc != -ENOSYS);
|
||||
}
|
||||
|
||||
// Finally, test invalid syscalls:
|
||||
dbgln("Testing syscall #{} (n+1)", (int)Syscall::Function::__Count);
|
||||
rc = syscall(Syscall::Function::__Count, 0xc0000001, 0xc0000002, 0xc0000003);
|
||||
ASSERT(rc == -ENOSYS);
|
||||
VERIFY(rc == -ENOSYS);
|
||||
dbgln("Testing syscall #-1");
|
||||
rc = syscall(Syscall::Function(-1), 0xc0000001, 0xc0000002, 0xc0000003);
|
||||
ASSERT(rc == -ENOSYS);
|
||||
VERIFY(rc == -ENOSYS);
|
||||
}
|
||||
|
||||
static void randomize_from(size_t* buffer, size_t len, const Vector<size_t>& values)
|
||||
|
@ -102,7 +102,7 @@ static void do_weird_call(size_t attempt, int syscall_fn, size_t arg1, size_t ar
|
|||
|
||||
// Actually do the syscall ('fake_params' is passed indirectly, if any of arg1, arg2, or arg3 point to it.
|
||||
int rc = syscall(Syscall::Function(syscall_fn), arg1, arg2, arg3);
|
||||
ASSERT(rc != -ENOSYS || is_nosys_syscall(syscall_fn));
|
||||
VERIFY(rc != -ENOSYS || is_nosys_syscall(syscall_fn));
|
||||
}
|
||||
|
||||
static void do_random_tests()
|
||||
|
@ -111,7 +111,7 @@ static void do_random_tests()
|
|||
{
|
||||
struct sigaction act_ignore = { { SIG_IGN }, 0, 0 };
|
||||
int rc = sigaction(SIGALRM, &act_ignore, nullptr);
|
||||
ASSERT(rc == 0);
|
||||
VERIFY(rc == 0);
|
||||
}
|
||||
|
||||
// Note that we will also make lots of syscalls for randomness and debugging.
|
||||
|
|
|
@ -87,7 +87,7 @@ static void sleep_steps(useconds_t steps)
|
|||
const int rc = usleep(steps * STEP_SIZE);
|
||||
if (rc < 0) {
|
||||
perror("usleep");
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ static void run_pz()
|
|||
// Time 3: T1 calls thread_exit()
|
||||
dbgln("PZ(T1) calls thread_exit");
|
||||
pthread_exit(nullptr);
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static void* run_pz_t2_wrap(void*)
|
||||
|
|
|
@ -95,7 +95,7 @@ static void sleep_steps(useconds_t steps)
|
|||
const int rc = usleep(steps * STEP_SIZE);
|
||||
if (rc < 0) {
|
||||
perror("usleep");
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ int main(int, char**)
|
|||
}
|
||||
exit(1);
|
||||
}
|
||||
ASSERT(rc == 1);
|
||||
VERIFY(rc == 1);
|
||||
if (buf == 0) {
|
||||
printf("PASS\n");
|
||||
return 0;
|
||||
|
@ -171,7 +171,7 @@ static void run_pa1(void*)
|
|||
int rc = setsid();
|
||||
if (rc < 0) {
|
||||
perror("setsid (PA)");
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
dbgln("PA1 did setsid() -> PGA={}, SA={}, yay!", rc, getsid(0));
|
||||
sleep_steps(1);
|
||||
|
@ -210,7 +210,7 @@ static void run_pb1(void* pipe_fd_ptr)
|
|||
int rc = setsid();
|
||||
if (rc < 0) {
|
||||
perror("setsid (PB)");
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
dbgln("PB1 did setsid() -> PGB={}, SB={}, yay!", rc, getsid(0));
|
||||
sleep_steps(1);
|
||||
|
@ -258,7 +258,7 @@ static void run_pb2(void* pipe_fd_ptr)
|
|||
dbgln("PB2: setgpid SUCCESSFUL! CHANGED PGROUP!");
|
||||
to_write = 1;
|
||||
} else {
|
||||
ASSERT(rc == -1);
|
||||
VERIFY(rc == -1);
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
dbgln("PB2: Failed with EACCES. Huh?!");
|
||||
|
@ -286,7 +286,7 @@ static void run_pb2(void* pipe_fd_ptr)
|
|||
|
||||
dbgln("PB2 ends with SID={}, PGID={}, PID={}.", getsid(0), getpgid(0), getpid());
|
||||
int* pipe_fd = static_cast<int*>(pipe_fd_ptr);
|
||||
ASSERT(*pipe_fd);
|
||||
VERIFY(*pipe_fd);
|
||||
rc = write(*pipe_fd, &to_write, 1);
|
||||
if (rc != 1) {
|
||||
dbgln("Wrote only {} bytes instead of 1?!", rc);
|
||||
|
|
|
@ -100,9 +100,9 @@ int main()
|
|||
all_good &= check_result("getcwd", expected_str, getcwd(nullptr, 0));
|
||||
all_good &= check_result("realpath", expected_str, realpath(".", nullptr));
|
||||
|
||||
ASSERT(strlen(PATH_LOREM_250) == 250);
|
||||
ASSERT(strlen(TMPDIR_PATTERN) + ITERATION_DEPTH * (1 + strlen(PATH_LOREM_250)) == expected_str.length());
|
||||
ASSERT(expected_str.length() > PATH_MAX);
|
||||
VERIFY(strlen(PATH_LOREM_250) == 250);
|
||||
VERIFY(strlen(TMPDIR_PATTERN) + ITERATION_DEPTH * (1 + strlen(PATH_LOREM_250)) == expected_str.length());
|
||||
VERIFY(expected_str.length() > PATH_MAX);
|
||||
|
||||
if (all_good) {
|
||||
printf("Overall: %sPASS%s\n", TEXT_PASS, TEXT_RESET);
|
||||
|
|
|
@ -126,7 +126,7 @@ static Array<u8, 32> arg_to_value_t(const Argument& arg)
|
|||
return value;
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
#define DECL_WITH_TYPE(ty) \
|
||||
|
|
|
@ -76,7 +76,7 @@ static bool test_single(const Testcase& testcase)
|
|||
ByteBuffer actual = ByteBuffer::create_uninitialized(SANDBOX_CANARY_SIZE + testcase.dest_n + SANDBOX_CANARY_SIZE);
|
||||
AK::fill_with_random(actual.data(), actual.size());
|
||||
ByteBuffer expected = actual.isolated_copy();
|
||||
ASSERT(actual.offset_pointer(0) != expected.offset_pointer(0));
|
||||
VERIFY(actual.offset_pointer(0) != expected.offset_pointer(0));
|
||||
actual.overwrite(SANDBOX_CANARY_SIZE, testcase.dest, testcase.dest_n);
|
||||
expected.overwrite(SANDBOX_CANARY_SIZE, testcase.dest_expected, testcase.dest_expected_n);
|
||||
// "unsigned char" != "char", so we have to convince the compiler to allow this.
|
||||
|
|
|
@ -78,7 +78,7 @@ static bool test_single(const Testcase& testcase)
|
|||
ByteBuffer actual = ByteBuffer::create_uninitialized(SANDBOX_CANARY_SIZE + testcase.dest_n + SANDBOX_CANARY_SIZE);
|
||||
AK::fill_with_random(actual.data(), actual.size());
|
||||
ByteBuffer expected = actual.isolated_copy();
|
||||
ASSERT(actual.offset_pointer(0) != expected.offset_pointer(0));
|
||||
VERIFY(actual.offset_pointer(0) != expected.offset_pointer(0));
|
||||
actual.overwrite(SANDBOX_CANARY_SIZE, testcase.dest, testcase.dest_n);
|
||||
expected.overwrite(SANDBOX_CANARY_SIZE, testcase.dest_expected, testcase.dest_expected_n);
|
||||
// "unsigned char" != "char", so we have to convince the compiler to allow this.
|
||||
|
|
|
@ -58,7 +58,7 @@ static void run_test(void* region, ssize_t offset, size_t bits)
|
|||
write64(ptr);
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ int main(int argc, char** argv)
|
|||
run_test(region, offset, 64);
|
||||
} else {
|
||||
void* region = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
|
||||
ASSERT(region);
|
||||
VERIFY(region);
|
||||
run_test(region, offset, bits);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue