mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-16 14:08:45 +00:00
test: Wrap assert macros in ({ ... }) and fix missing semicolons
Wrap the assert macros in ({ ... }) so they can be safely used both as right side argument as well as in conditionals without curly brackets around them. In the process, find a bunch of missing semicolons, fix them. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
This commit is contained in:
parent
20aaff677d
commit
fa847bb409
9 changed files with 124 additions and 72 deletions
|
@ -125,36 +125,47 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
|
||||||
fmt, ##args)
|
fmt, ##args)
|
||||||
|
|
||||||
/* Assert that a condition is non-zero */
|
/* Assert that a condition is non-zero */
|
||||||
#define ut_assert(cond) \
|
#define ut_assert(cond) ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (!(cond)) { \
|
if (!(cond)) { \
|
||||||
ut_fail(uts, __FILE__, __LINE__, __func__, #cond); \
|
ut_fail(uts, __FILE__, __LINE__, __func__, #cond); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
}
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that a condition is non-zero, with printf() string */
|
/* Assert that a condition is non-zero, with printf() string */
|
||||||
#define ut_assertf(cond, fmt, args...) \
|
#define ut_assertf(cond, fmt, args...) ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (!(cond)) { \
|
if (!(cond)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, #cond, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, #cond, \
|
||||||
fmt, ##args); \
|
fmt, ##args); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
}
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that two int expressions are equal */
|
/* Assert that two int expressions are equal */
|
||||||
#define ut_asserteq(expr1, expr2) { \
|
#define ut_asserteq(expr1, expr2) ({ \
|
||||||
unsigned int _val1 = (expr1), _val2 = (expr2); \
|
unsigned int _val1 = (expr1), _val2 = (expr2); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (_val1 != _val2) { \
|
if (_val1 != _val2) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr1 " == " #expr2, \
|
#expr1 " == " #expr2, \
|
||||||
"Expected %#x (%d), got %#x (%d)", \
|
"Expected %#x (%d), got %#x (%d)", \
|
||||||
_val1, _val1, _val2, _val2); \
|
_val1, _val1, _val2, _val2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that two 64 int expressions are equal */
|
/* Assert that two 64 int expressions are equal */
|
||||||
#define ut_asserteq_64(expr1, expr2) { \
|
#define ut_asserteq_64(expr1, expr2) ({ \
|
||||||
u64 _val1 = (expr1), _val2 = (expr2); \
|
u64 _val1 = (expr1), _val2 = (expr2); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (_val1 != _val2) { \
|
if (_val1 != _val2) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
|
@ -164,43 +175,49 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
|
||||||
(unsigned long long)_val1, \
|
(unsigned long long)_val1, \
|
||||||
(unsigned long long)_val2, \
|
(unsigned long long)_val2, \
|
||||||
(unsigned long long)_val2); \
|
(unsigned long long)_val2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that two string expressions are equal */
|
/* Assert that two string expressions are equal */
|
||||||
#define ut_asserteq_str(expr1, expr2) { \
|
#define ut_asserteq_str(expr1, expr2) ({ \
|
||||||
const char *_val1 = (expr1), *_val2 = (expr2); \
|
const char *_val1 = (expr1), *_val2 = (expr2); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (strcmp(_val1, _val2)) { \
|
if (strcmp(_val1, _val2)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr1 " = " #expr2, \
|
#expr1 " = " #expr2, \
|
||||||
"Expected \"%s\", got \"%s\"", _val1, _val2); \
|
"Expected \"%s\", got \"%s\"", _val1, _val2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert that two string expressions are equal, up to length of the
|
* Assert that two string expressions are equal, up to length of the
|
||||||
* first
|
* first
|
||||||
*/
|
*/
|
||||||
#define ut_asserteq_strn(expr1, expr2) { \
|
#define ut_asserteq_strn(expr1, expr2) ({ \
|
||||||
const char *_val1 = (expr1), *_val2 = (expr2); \
|
const char *_val1 = (expr1), *_val2 = (expr2); \
|
||||||
int _len = strlen(_val1); \
|
int _len = strlen(_val1); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (memcmp(_val1, _val2, _len)) { \
|
if (memcmp(_val1, _val2, _len)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr1 " = " #expr2, \
|
#expr1 " = " #expr2, \
|
||||||
"Expected \"%.*s\", got \"%.*s\"", \
|
"Expected \"%.*s\", got \"%.*s\"", \
|
||||||
_len, _val1, _len, _val2); \
|
_len, _val1, _len, _val2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that two memory areas are equal */
|
/* Assert that two memory areas are equal */
|
||||||
#define ut_asserteq_mem(expr1, expr2, len) { \
|
#define ut_asserteq_mem(expr1, expr2, len) ({ \
|
||||||
const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \
|
const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \
|
||||||
const uint __len = len; \
|
const uint __len = len; \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (memcmp(_val1, _val2, __len)) { \
|
if (memcmp(_val1, _val2, __len)) { \
|
||||||
char __buf1[64 + 1] = "\0"; \
|
char __buf1[64 + 1] = "\0"; \
|
||||||
|
@ -211,128 +228,163 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
|
||||||
#expr1 " = " #expr2, \
|
#expr1 " = " #expr2, \
|
||||||
"Expected \"%s\", got \"%s\"", \
|
"Expected \"%s\", got \"%s\"", \
|
||||||
__buf1, __buf2); \
|
__buf1, __buf2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that two pointers are equal */
|
/* Assert that two pointers are equal */
|
||||||
#define ut_asserteq_ptr(expr1, expr2) { \
|
#define ut_asserteq_ptr(expr1, expr2) ({ \
|
||||||
const void *_val1 = (expr1), *_val2 = (expr2); \
|
const void *_val1 = (expr1), *_val2 = (expr2); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (_val1 != _val2) { \
|
if (_val1 != _val2) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr1 " = " #expr2, \
|
#expr1 " = " #expr2, \
|
||||||
"Expected %p, got %p", _val1, _val2); \
|
"Expected %p, got %p", _val1, _val2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that two addresses (converted from pointers) are equal */
|
/* Assert that two addresses (converted from pointers) are equal */
|
||||||
#define ut_asserteq_addr(expr1, expr2) { \
|
#define ut_asserteq_addr(expr1, expr2) ({ \
|
||||||
ulong _val1 = map_to_sysmem(expr1); \
|
ulong _val1 = map_to_sysmem(expr1); \
|
||||||
ulong _val2 = map_to_sysmem(expr2); \
|
ulong _val2 = map_to_sysmem(expr2); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (_val1 != _val2) { \
|
if (_val1 != _val2) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr1 " = " #expr2, \
|
#expr1 " = " #expr2, \
|
||||||
"Expected %lx, got %lx", _val1, _val2); \
|
"Expected %lx, got %lx", _val1, _val2); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that a pointer is NULL */
|
/* Assert that a pointer is NULL */
|
||||||
#define ut_assertnull(expr) { \
|
#define ut_assertnull(expr) ({ \
|
||||||
const void *_val = (expr); \
|
const void *_val = (expr); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (_val) { \
|
if (_val) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr " != NULL", \
|
#expr " != NULL", \
|
||||||
"Expected NULL, got %p", _val); \
|
"Expected NULL, got %p", _val); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that a pointer is not NULL */
|
/* Assert that a pointer is not NULL */
|
||||||
#define ut_assertnonnull(expr) { \
|
#define ut_assertnonnull(expr) ({ \
|
||||||
const void *_val = (expr); \
|
const void *_val = (expr); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (!_val) { \
|
if (!_val) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr " = NULL", \
|
#expr " = NULL", \
|
||||||
"Expected non-null, got NULL"); \
|
"Expected non-null, got NULL"); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that a pointer is not an error pointer */
|
/* Assert that a pointer is not an error pointer */
|
||||||
#define ut_assertok_ptr(expr) { \
|
#define ut_assertok_ptr(expr) ({ \
|
||||||
const void *_val = (expr); \
|
const void *_val = (expr); \
|
||||||
|
int __ret = 0; \
|
||||||
\
|
\
|
||||||
if (IS_ERR(_val)) { \
|
if (IS_ERR(_val)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
#expr " = NULL", \
|
#expr " = NULL", \
|
||||||
"Expected pointer, got error %ld", \
|
"Expected pointer, got error %ld", \
|
||||||
PTR_ERR(_val)); \
|
PTR_ERR(_val)); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
}
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that an operation succeeds (returns 0) */
|
/* Assert that an operation succeeds (returns 0) */
|
||||||
#define ut_assertok(cond) ut_asserteq(0, cond)
|
#define ut_assertok(cond) ut_asserteq(0, cond)
|
||||||
|
|
||||||
/* Assert that the next console output line matches */
|
/* Assert that the next console output line matches */
|
||||||
#define ut_assert_nextline(fmt, args...) \
|
#define ut_assert_nextline(fmt, args...) ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (ut_check_console_line(uts, fmt, ##args)) { \
|
if (ut_check_console_line(uts, fmt, ##args)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
"console", "\nExpected '%s',\n got '%s'", \
|
"console", "\nExpected '%s',\n got '%s'", \
|
||||||
uts->expect_str, uts->actual_str); \
|
uts->expect_str, uts->actual_str); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that the next console output line matches up to the length */
|
/* Assert that the next console output line matches up to the length */
|
||||||
#define ut_assert_nextlinen(fmt, args...) \
|
#define ut_assert_nextlinen(fmt, args...) ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (ut_check_console_linen(uts, fmt, ##args)) { \
|
if (ut_check_console_linen(uts, fmt, ##args)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
"console", "\nExpected '%s',\n got '%s'", \
|
"console", "\nExpected '%s',\n got '%s'", \
|
||||||
uts->expect_str, uts->actual_str); \
|
uts->expect_str, uts->actual_str); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that there is a 'next' console output line, and skip it */
|
/* Assert that there is a 'next' console output line, and skip it */
|
||||||
#define ut_assert_skipline() \
|
#define ut_assert_skipline() ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (ut_check_skipline(uts)) { \
|
if (ut_check_skipline(uts)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
"console", "\nExpected a line, got end"); \
|
"console", "\nExpected a line, got end"); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that a following console output line matches */
|
/* Assert that a following console output line matches */
|
||||||
#define ut_assert_skip_to_line(fmt, args...) \
|
#define ut_assert_skip_to_line(fmt, args...) ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (ut_check_skip_to_line(uts, fmt, ##args)) { \
|
if (ut_check_skip_to_line(uts, fmt, ##args)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
"console", "\nExpected '%s',\n got to '%s'", \
|
"console", "\nExpected '%s',\n got to '%s'", \
|
||||||
uts->expect_str, uts->actual_str); \
|
uts->expect_str, uts->actual_str); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that there is no more console output */
|
/* Assert that there is no more console output */
|
||||||
#define ut_assert_console_end() \
|
#define ut_assert_console_end() ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (ut_check_console_end(uts)) { \
|
if (ut_check_console_end(uts)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
"console", "Expected no more output, got '%s'",\
|
"console", "Expected no more output, got '%s'",\
|
||||||
uts->actual_str); \
|
uts->actual_str); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that the next lines are print_buffer() dump at an address */
|
/* Assert that the next lines are print_buffer() dump at an address */
|
||||||
#define ut_assert_nextlines_are_dump(total_bytes) \
|
#define ut_assert_nextlines_are_dump(total_bytes) ({ \
|
||||||
|
int __ret = 0; \
|
||||||
|
\
|
||||||
if (ut_check_console_dump(uts, total_bytes)) { \
|
if (ut_check_console_dump(uts, total_bytes)) { \
|
||||||
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
ut_failf(uts, __FILE__, __LINE__, __func__, \
|
||||||
"console", \
|
"console", \
|
||||||
"Expected dump of length %x bytes, got '%s'", \
|
"Expected dump of length %x bytes, got '%s'", \
|
||||||
total_bytes, uts->actual_str); \
|
total_bytes, uts->actual_str); \
|
||||||
return CMD_RET_FAILURE; \
|
__ret = CMD_RET_FAILURE; \
|
||||||
} \
|
} \
|
||||||
|
__ret; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Assert that the next console output line is empty */
|
/* Assert that the next console output line is empty */
|
||||||
#define ut_assert_nextline_empty() \
|
#define ut_assert_nextline_empty() \
|
||||||
|
|
|
@ -27,11 +27,11 @@ static int dm_test_pwm_cmd(struct unit_test_state *uts)
|
||||||
/* pwm <invert> <pwm_dev_num> <channel> <polarity> */
|
/* pwm <invert> <pwm_dev_num> <channel> <polarity> */
|
||||||
/* cros-ec-pwm doesn't support invert */
|
/* cros-ec-pwm doesn't support invert */
|
||||||
ut_asserteq(1, run_command("pwm invert 0 0 1", 0));
|
ut_asserteq(1, run_command("pwm invert 0 0 1", 0));
|
||||||
ut_assert_nextline("error(-38)")
|
ut_assert_nextline("error(-38)");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
ut_asserteq(1, run_command("pwm invert 0 0 0", 0));
|
ut_asserteq(1, run_command("pwm invert 0 0 0", 0));
|
||||||
ut_assert_nextline("error(-38)")
|
ut_assert_nextline("error(-38)");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
/* pwm <config> <pwm_dev_num> <channel> <period_ns> <duty_ns> */
|
/* pwm <config> <pwm_dev_num> <channel> <period_ns> <duty_ns> */
|
||||||
|
|
|
@ -1083,7 +1083,7 @@ static int dm_test_acpi_write_name(struct unit_test_state *uts)
|
||||||
ut_asserteq(NAME_OP, *ptr++);
|
ut_asserteq(NAME_OP, *ptr++);
|
||||||
ptr += 10;
|
ptr += 10;
|
||||||
ut_asserteq(STRING_PREFIX, *ptr++);
|
ut_asserteq(STRING_PREFIX, *ptr++);
|
||||||
ut_asserteq_str("baldrick", (char *)ptr)
|
ut_asserteq_str("baldrick", (char *)ptr);
|
||||||
ptr += 9;
|
ptr += 9;
|
||||||
|
|
||||||
ut_asserteq(NAME_OP, *ptr++);
|
ut_asserteq(NAME_OP, *ptr++);
|
||||||
|
|
|
@ -51,13 +51,13 @@ static int dm_test_misc(struct unit_test_state *uts)
|
||||||
/* Read back last issued ioctl */
|
/* Read back last issued ioctl */
|
||||||
ut_assertok(misc_call(dev, 2, NULL, 0, &last_ioctl,
|
ut_assertok(misc_call(dev, 2, NULL, 0, &last_ioctl,
|
||||||
sizeof(last_ioctl)));
|
sizeof(last_ioctl)));
|
||||||
ut_asserteq(6, last_ioctl)
|
ut_asserteq(6, last_ioctl);
|
||||||
|
|
||||||
ut_assertok(misc_ioctl(dev, 23, NULL));
|
ut_assertok(misc_ioctl(dev, 23, NULL));
|
||||||
/* Read back last issued ioctl */
|
/* Read back last issued ioctl */
|
||||||
ut_assertok(misc_call(dev, 2, NULL, 0, &last_ioctl,
|
ut_assertok(misc_call(dev, 2, NULL, 0, &last_ioctl,
|
||||||
sizeof(last_ioctl)));
|
sizeof(last_ioctl)));
|
||||||
ut_asserteq(23, last_ioctl)
|
ut_asserteq(23, last_ioctl);
|
||||||
|
|
||||||
/* Enable / disable tests */
|
/* Enable / disable tests */
|
||||||
|
|
||||||
|
|
|
@ -28,22 +28,22 @@ static int dm_test_phy_base(struct unit_test_state *uts)
|
||||||
/*
|
/*
|
||||||
* Get the same phy port in 2 different ways and compare.
|
* Get the same phy port in 2 different ways and compare.
|
||||||
*/
|
*/
|
||||||
ut_assertok(generic_phy_get_by_name(parent, "phy1", &phy1_method1))
|
ut_assertok(generic_phy_get_by_name(parent, "phy1", &phy1_method1));
|
||||||
ut_assertok(generic_phy_get_by_index(parent, 0, &phy1_method2))
|
ut_assertok(generic_phy_get_by_index(parent, 0, &phy1_method2));
|
||||||
ut_asserteq(phy1_method1.id, phy1_method2.id);
|
ut_asserteq(phy1_method1.id, phy1_method2.id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the second phy port. Check that the same phy provider (device)
|
* Get the second phy port. Check that the same phy provider (device)
|
||||||
* provides this 2nd phy port, but that the IDs are different
|
* provides this 2nd phy port, but that the IDs are different
|
||||||
*/
|
*/
|
||||||
ut_assertok(generic_phy_get_by_name(parent, "phy2", &phy2))
|
ut_assertok(generic_phy_get_by_name(parent, "phy2", &phy2));
|
||||||
ut_asserteq_ptr(phy1_method2.dev, phy2.dev);
|
ut_asserteq_ptr(phy1_method2.dev, phy2.dev);
|
||||||
ut_assert(phy1_method1.id != phy2.id);
|
ut_assert(phy1_method1.id != phy2.id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the third phy port. Check that the phy provider is different
|
* Get the third phy port. Check that the phy provider is different
|
||||||
*/
|
*/
|
||||||
ut_assertok(generic_phy_get_by_name(parent, "phy3", &phy3))
|
ut_assertok(generic_phy_get_by_name(parent, "phy3", &phy3));
|
||||||
ut_assert(phy2.dev != phy3.dev);
|
ut_assert(phy2.dev != phy3.dev);
|
||||||
|
|
||||||
/* Try to get a non-existing phy */
|
/* Try to get a non-existing phy */
|
||||||
|
|
|
@ -187,10 +187,10 @@ static int dm_test_scmi_resets(struct unit_test_state *uts)
|
||||||
ut_assertnonnull(agent);
|
ut_assertnonnull(agent);
|
||||||
|
|
||||||
/* Test SCMI resect controller manipulation */
|
/* Test SCMI resect controller manipulation */
|
||||||
ut_assert(!agent->reset[0].asserted)
|
ut_assert(!agent->reset[0].asserted);
|
||||||
|
|
||||||
ut_assertok(reset_assert(&scmi_devices->reset[0]));
|
ut_assertok(reset_assert(&scmi_devices->reset[0]));
|
||||||
ut_assert(agent->reset[0].asserted)
|
ut_assert(agent->reset[0].asserted);
|
||||||
|
|
||||||
ut_assertok(reset_deassert(&scmi_devices->reset[0]));
|
ut_assertok(reset_deassert(&scmi_devices->reset[0]));
|
||||||
ut_assert(!agent->reset[0].asserted);
|
ut_assert(!agent->reset[0].asserted);
|
||||||
|
|
|
@ -15,12 +15,12 @@ static int lib_test_is_enabled(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
ulong val;
|
ulong val;
|
||||||
|
|
||||||
ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE))
|
ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE));
|
||||||
ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED))
|
ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED));
|
||||||
|
|
||||||
ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE))
|
ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE));
|
||||||
ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA))
|
ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA));
|
||||||
ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED))
|
ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED));
|
||||||
|
|
||||||
ut_asserteq(0xc000,
|
ut_asserteq(0xc000,
|
||||||
IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR));
|
IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR));
|
||||||
|
|
|
@ -15,9 +15,9 @@ static int lib_test_spl_is_enabled(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
ulong val;
|
ulong val;
|
||||||
|
|
||||||
ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE))
|
ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE));
|
||||||
ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA))
|
ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA));
|
||||||
ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED))
|
ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
|
* This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
|
||||||
|
|
|
@ -192,7 +192,7 @@ static int unicode_test_utf8_get(struct unit_test_state *uts)
|
||||||
if (!code)
|
if (!code)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ut_asserteq_ptr(s, d2 + 9)
|
ut_asserteq_ptr(s, d2 + 9);
|
||||||
|
|
||||||
/* Check characters less than 0x10000 */
|
/* Check characters less than 0x10000 */
|
||||||
s = d3;
|
s = d3;
|
||||||
|
@ -203,7 +203,7 @@ static int unicode_test_utf8_get(struct unit_test_state *uts)
|
||||||
if (!code)
|
if (!code)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ut_asserteq_ptr(s, d3 + 9)
|
ut_asserteq_ptr(s, d3 + 9);
|
||||||
|
|
||||||
/* Check character greater 0xffff */
|
/* Check character greater 0xffff */
|
||||||
s = d4;
|
s = d4;
|
||||||
|
@ -228,7 +228,7 @@ static int unicode_test_utf8_put(struct unit_test_state *uts)
|
||||||
|
|
||||||
/* Commercial at, translates to one character */
|
/* Commercial at, translates to one character */
|
||||||
pos = buffer;
|
pos = buffer;
|
||||||
ut_assert(!utf8_put('@', &pos))
|
ut_assert(!utf8_put('@', &pos));
|
||||||
ut_asserteq(1, pos - buffer);
|
ut_asserteq(1, pos - buffer);
|
||||||
ut_asserteq('@', buffer[0]);
|
ut_asserteq('@', buffer[0]);
|
||||||
ut_assert(!buffer[1]);
|
ut_assert(!buffer[1]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue