mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
tests: move tests for PROTECT_ERRNO to the right file
Also, rename them to uppercase so that the test name matches what we're actually testing.
This commit is contained in:
@@ -47,4 +47,35 @@ TEST(STRERROR_OR_ELSE) {
|
||||
log_info("STRERROR_OR_ELSE(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM));
|
||||
}
|
||||
|
||||
TEST(PROTECT_ERRNO) {
|
||||
errno = 12;
|
||||
{
|
||||
PROTECT_ERRNO;
|
||||
errno = 11;
|
||||
}
|
||||
assert_se(errno == 12);
|
||||
}
|
||||
|
||||
static void test_unprotect_errno_inner_function(void) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
errno = 2222;
|
||||
}
|
||||
|
||||
TEST(UNPROTECT_ERRNO) {
|
||||
errno = 4711;
|
||||
|
||||
PROTECT_ERRNO;
|
||||
|
||||
errno = 815;
|
||||
|
||||
UNPROTECT_ERRNO;
|
||||
|
||||
assert_se(errno == 4711);
|
||||
|
||||
test_unprotect_errno_inner_function();
|
||||
|
||||
assert_se(errno == 4711);
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN(LOG_INFO);
|
||||
|
||||
@@ -83,37 +83,6 @@ TEST(log2i) {
|
||||
assert_se(log2i(INT_MAX) == sizeof(int)*8-2);
|
||||
}
|
||||
|
||||
TEST(protect_errno) {
|
||||
errno = 12;
|
||||
{
|
||||
PROTECT_ERRNO;
|
||||
errno = 11;
|
||||
}
|
||||
assert_se(errno == 12);
|
||||
}
|
||||
|
||||
static void test_unprotect_errno_inner_function(void) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
errno = 2222;
|
||||
}
|
||||
|
||||
TEST(unprotect_errno) {
|
||||
errno = 4711;
|
||||
|
||||
PROTECT_ERRNO;
|
||||
|
||||
errno = 815;
|
||||
|
||||
UNPROTECT_ERRNO;
|
||||
|
||||
assert_se(errno == 4711);
|
||||
|
||||
test_unprotect_errno_inner_function();
|
||||
|
||||
assert_se(errno == 4711);
|
||||
}
|
||||
|
||||
TEST(eqzero) {
|
||||
const uint32_t zeros[] = {0, 0, 0};
|
||||
const uint32_t ones[] = {1, 1};
|
||||
|
||||
Reference in New Issue
Block a user