mirror of
https://github.com/systemd/systemd
synced 2024-07-23 19:25:39 +00:00
Merge pull request #7280 from yuwata/fix-7270-2
test-event: do not work in assert()
This commit is contained in:
commit
4deff0b92b
|
@ -431,7 +431,7 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) {
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
assert (client->duid_len);
|
||||
assert(client->duid_len);
|
||||
r = dhcp6_option_append(&opt, &optlen, SD_DHCP6_OPTION_CLIENTID,
|
||||
client->duid_len, &client->duid);
|
||||
if (r < 0)
|
||||
|
|
|
@ -202,7 +202,7 @@ int icmp6_bind_router_advertisement(int index) {
|
|||
|
||||
int icmp6_receive(int fd, void *iov_base, size_t iov_len,
|
||||
struct in6_addr *dst, triple_timestamp *timestamp) {
|
||||
assert (read (fd, iov_base, iov_len) == (ssize_t)iov_len);
|
||||
assert_se(read (fd, iov_base, iov_len) == (ssize_t)iov_len);
|
||||
|
||||
if (timestamp)
|
||||
triple_timestamp_get(timestamp);
|
||||
|
|
|
@ -317,11 +317,11 @@ static void test_rtqueue(void) {
|
|||
|
||||
assert_se(sd_event_source_set_priority(v, -10) >= 0);
|
||||
|
||||
assert(sigqueue(getpid_cached(), SIGRTMIN+2, (union sigval) { .sival_int = 1 }) >= 0);
|
||||
assert(sigqueue(getpid_cached(), SIGRTMIN+3, (union sigval) { .sival_int = 2 }) >= 0);
|
||||
assert(sigqueue(getpid_cached(), SIGUSR2, (union sigval) { .sival_int = 3 }) >= 0);
|
||||
assert(sigqueue(getpid_cached(), SIGRTMIN+3, (union sigval) { .sival_int = 4 }) >= 0);
|
||||
assert(sigqueue(getpid_cached(), SIGUSR2, (union sigval) { .sival_int = 5 }) >= 0);
|
||||
assert_se(sigqueue(getpid_cached(), SIGRTMIN+2, (union sigval) { .sival_int = 1 }) >= 0);
|
||||
assert_se(sigqueue(getpid_cached(), SIGRTMIN+3, (union sigval) { .sival_int = 2 }) >= 0);
|
||||
assert_se(sigqueue(getpid_cached(), SIGUSR2, (union sigval) { .sival_int = 3 }) >= 0);
|
||||
assert_se(sigqueue(getpid_cached(), SIGRTMIN+3, (union sigval) { .sival_int = 4 }) >= 0);
|
||||
assert_se(sigqueue(getpid_cached(), SIGUSR2, (union sigval) { .sival_int = 5 }) >= 0);
|
||||
|
||||
assert_se(n_rtqueue == 0);
|
||||
assert_se(last_rtqueue_sigval == 0);
|
||||
|
|
|
@ -79,6 +79,9 @@ static void test_parse_pid(void) {
|
|||
|
||||
r = parse_pid("junk", &pid);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = parse_pid("", &pid);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_parse_mode(void) {
|
||||
|
@ -98,6 +101,8 @@ static void test_parse_mode(void) {
|
|||
static void test_parse_size(void) {
|
||||
uint64_t bytes;
|
||||
|
||||
assert_se(parse_size("", 1024, &bytes) == -EINVAL);
|
||||
|
||||
assert_se(parse_size("111", 1024, &bytes) == 0);
|
||||
assert_se(bytes == 111);
|
||||
|
||||
|
@ -257,6 +262,10 @@ static void test_parse_range(void) {
|
|||
assert_se(lower == 9999);
|
||||
assert_se(upper == 9999);
|
||||
|
||||
assert_se(parse_range("-123", &lower, &upper) == -EINVAL);
|
||||
assert_se(lower == 9999);
|
||||
assert_se(upper == 9999);
|
||||
|
||||
assert_se(parse_range("-111-123", &lower, &upper) == -EINVAL);
|
||||
assert_se(lower == 9999);
|
||||
assert_se(upper == 9999);
|
||||
|
@ -370,6 +379,15 @@ static void test_safe_atolli(void) {
|
|||
|
||||
r = safe_atolli("junk", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atolli("123x", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atolli("12.3", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atolli("", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_safe_atou16(void) {
|
||||
|
@ -398,6 +416,12 @@ static void test_safe_atou16(void) {
|
|||
|
||||
r = safe_atou16("123x", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atou16("12.3", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atou16("", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_safe_atoi16(void) {
|
||||
|
@ -431,6 +455,12 @@ static void test_safe_atoi16(void) {
|
|||
|
||||
r = safe_atoi16("123x", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atoi16("12.3", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atoi16("", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_safe_atou64(void) {
|
||||
|
@ -459,6 +489,12 @@ static void test_safe_atou64(void) {
|
|||
|
||||
r = safe_atou64("123x", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atou64("12.3", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atou64("", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_safe_atoi64(void) {
|
||||
|
@ -492,6 +528,12 @@ static void test_safe_atoi64(void) {
|
|||
|
||||
r = safe_atoi64("123x", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atoi64("12.3", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
r = safe_atoi64("", &l);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_safe_atod(void) {
|
||||
|
@ -513,6 +555,9 @@ static void test_safe_atod(void) {
|
|||
strtod("0,5", &e);
|
||||
assert_se(*e == ',');
|
||||
|
||||
r = safe_atod("", &d);
|
||||
assert_se(r == -EINVAL);
|
||||
|
||||
/* Check if this really is locale independent */
|
||||
if (setlocale(LC_NUMERIC, "de_DE.utf8")) {
|
||||
|
||||
|
@ -525,6 +570,9 @@ static void test_safe_atod(void) {
|
|||
|
||||
errno = 0;
|
||||
assert_se(fabs(strtod("0,5", &e) - 0.5) < 0.00001);
|
||||
|
||||
r = safe_atod("", &d);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
/* And check again, reset */
|
||||
|
@ -540,6 +588,9 @@ static void test_safe_atod(void) {
|
|||
errno = 0;
|
||||
strtod("0,5", &e);
|
||||
assert_se(*e == ',');
|
||||
|
||||
r = safe_atod("", &d);
|
||||
assert_se(r == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_parse_percent(void) {
|
||||
|
@ -558,6 +609,7 @@ static void test_parse_percent(void) {
|
|||
assert_se(parse_percent("%%") == -EINVAL);
|
||||
assert_se(parse_percent("%1") == -EINVAL);
|
||||
assert_se(parse_percent("1%%") == -EINVAL);
|
||||
assert_se(parse_percent("3.2%") == -EINVAL);
|
||||
}
|
||||
|
||||
static void test_parse_percent_unbounded(void) {
|
||||
|
@ -596,6 +648,8 @@ static void test_parse_nice(void) {
|
|||
static void test_parse_dev(void) {
|
||||
dev_t dev;
|
||||
|
||||
assert_se(parse_dev("", &dev) == -EINVAL);
|
||||
assert_se(parse_dev("junk", &dev) == -EINVAL);
|
||||
assert_se(parse_dev("0", &dev) == -EINVAL);
|
||||
assert_se(parse_dev("5", &dev) == -EINVAL);
|
||||
assert_se(parse_dev("5:", &dev) == -EINVAL);
|
||||
|
|
Loading…
Reference in a new issue