The UUID library utilities require dynamic memory allocation for certain
operations, but MINIMAL_LIBC provides no malloc heap by default. This
causes test failures when UUID functions attempt to allocate memory.
Add CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=256 to provide a minimal heap
arena sufficient for UUID operations which typically
require small heap allocations.
Signed-off-by: Mohamed Moawad <moawad@synopsys.com>
Make sure that net_buf pools created by NET_BUF_POOL_VAR_ALIGN_DEFINE
are aligned according to user needs.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
It is not possible to build anymore in that mode, so this filter
is not needed.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
A segmentation fault occurs when a zero initialized struct with a string
field (JSON_TOK_STRING) is encoded. Encode a string null pointer as an
empty JSON string "".
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
These two (sub)tests assume the system tick period divides evenly all
time interval values being tested, but this is not the case in general,
and when it is not, these tests fail.
Let's skip these 2 tests by now so we can release without a broken
CI, and do not block other development while the tests themselves are
being fixed.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add tests to ensure 100% line and branch coverage of previously untested
net_buf_linearize() function.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The prj.conf was missing CONFIG_COMMON_LIBC_MALLOC causing
warning of the depended config CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE
Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
Presumably the time testsuite was separate from the c library set of
testsuites because it had a depedency on POSIX.
Since that dependency no longer exists, colocate the time testsuite
with the other c library testsuites.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use sys_clock_gettime() instead of clock_gettime() and use
timespec_add() instead of manually adding timespec structures.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use `timespec_from_timeout(K_MSEC(msec), &ts)` instead of leaning on
lazily-crafted timespecs with invalid tv_nsec fields.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The specification does not say that the first struct timespec passed to
thrd_sleep() may be NULL.
Preserving the testpoint so that a possible future testsuite can be
run that expects faults to occur when undefined behaviour is used.
Faults are one possible solution to handling undefined behaviour, but
it would be good to come to a concensus about how that should be
handled in Zephyr for standard function calls belonging to ISO C or
POSIX.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The C standard does not guarantee that `thrd_success` is equal to
zero, so ensure that the test takes that into account.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
See Discussion https://github.com/zephyrproject-rtos/zephyr/discussions/83659
for information about the purpose of this change.
Modifies run actions of hierarchical state machines
to return a value indicating if the event was handled
by the run action or should be propagated up to the
parent run action. Flat state machines are not affected,
and their run action returns void.
smf_set_handled() has been removed and replaced by
this return value. smf_set_state() will not propagate
events regardless of the return value as the transition
is considered to have occurred.
Documentation, tests, samples, has been updated.
USB-C and hawkBit use SMF and have been updated to use
the new return codes.
Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
This test fails sporadically on SMP, so make it run only on one CPU.
Related to zephyrproject-rtos/zephyr#91620
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
On arrays DT_ENUM_HAS_VALUE() and DT_INST_ENUM_HAS_VALUE()
were only checking the first index, this changes it to check all indexes.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add missing tests for edge cases (ex. peek on empty heap, push to full
heap, ...) to get to 100% coverage (lines & branches)
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
make test cases more readable using more direct assert_ macros, for
example zassert_not_null(foo, ...) instead of
zassert_true(foo != NULL, ...).
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
In 9.3 due to font licensing issues LV_FONT_SIMSUN_16_CJK was deprecated.
Instead select now LV_FONT_SOURCE_HAN_SANS_SC_16_CJK symbol.
Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
Introduce test suite using Ztest for validating the min-heap API.
Covers insertion, removal, ordering, and custom comparators.
The tests verify correct behavior under both static and dynamic
initialization modes.
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
The combination of
323126924474c9e7afab
broke this test, when __SIZEOF_DOUBLE__ != 8.
In that case the test will fail to build,
as the variables the code uses are left ifdef'ed out.
Let's fix it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This test only works for 64-bit values. On targets which use 32 bits for
double, skip this version. The float test will check the 32-bit math for
that.
This is the 'nicer' version of this fix which uses sizeof rather than
relying on __SIZEOF_DOUBLE__.
Signed-off-by: Keith Packard <keithp@keithp.com>
This test only works for 64-bit values. On targets which use 32 bits for
double, skip this version. The float test will check the 32-bit math for
that.
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add a timespec util testsuite. This should have reasonably high enough
coverage to be useful.
I would have preferred to add this as an architecture-independent
unit test (for the unit_testing platform) under tests/unit/timeutil but
there is an inconsistency about the size of time_t on the unit_testing
and native_sim/native platforms. On every other platform supported by
Zephyr, time_t is 64-bits. However, on those platforms, time_t is only
32-bits.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Turns off time slicing as these tests do not expect time slicing and
previously operated without time slicing, but now fallback to the new
default of a time slice size of 20 added in e337b7b. This explicitly sets
the time slice size to 0.
Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
gettimeofday() was already implemented, but incorrectly lumped into
POSIX_TIMERS.
putenv() is really just a wrapper around setenv().
The only one left to implement was gethostid() which was relatively
trivial.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Zero-initialize the `test_int_limits` and `test_enums` structs before
assignment and decoding in their respective tests.
This ensures that all padding bytes are set to zero, making
`memcmp`-based comparisons reliable and portable across different
architectures and compilers.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use CLOCK_REALTIME for the default clock source throughout
the POSIX implementation and tests so that we are
consistent with the specification.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Support parsing and serializing of struct fields that are defined as a
char array.
Use the token JSON_TOK_STRING_BUF to parse and serialize a string for a
char array, for example:
struct foo {
const char *str;
char str_buf[30];
};
struct json_obj_descr foo_descr[] = {
JSON_OBJ_DESCR_PRIM(struct foo, str, JSON_TOK_STRING),
JSON_OBJ_DESCR_PRIM(struct foo, str_buf, JSON_TOK_STRING_BUF),
};
The struct 'json_obj_descr' now has an additional union member 'field'
to store the size of the struct field, which is used with the token
'JSON_TOK_STRING_BUF' to determine the element size.
Fixes: #65200
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
Update the JSON test cases to explicitly cast NAN and INFINITY to double
type to avoid implicit promotion.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Up to now, the handling of type float was offloaded to the users of the
JSON utility, with the token JSON_TOK_FLOAT.
Improve handling of floating point types and support the types 'float'
and 'double' in a built-in way so that they can be directly parsed to
and serialized from variables (of type float or double).
The types are serialized in the shortest representation, either as a
decimal number or in scientific notation:
* float (with JSON_TOK_FLOAT_FP): encoded with maximal 9 digits
* double (with JSON_TOK_DOUBLE_FP): encoded with maximal 16 digits
* NaN, Infinity, -Infinity: encoded and decoded as:
{"nan_val":NaN,"inf_pos":Infinity,"inf_neg":-Infinity}
Enable the floating point functionality with the Kconfig option:
JSON_LIBRARY_FP_SUPPORT=y
It requires a libc implementation with support for floating point
functions: strtof(), strtod(), isnan() and isinf().
Fixes: #59412
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
The calculation of the object size may be incorrect when the size of
a field is smaller than the struct alignment. When such a struct is
used in an array field, the decoded object contains wrong values.
The alignment influences the object size. For example the following
struct has a calculated object size of 8 bytes, however due to
alignment the real size of the struct is 12 bytes:
struct test_bool {
bool b1; /* offset 0, size 1 */
/* 3-byte padding */
int i1; /* offset 4, size 4 */
bool b2; /* offset 8, size 1 */
/* 3-byte padding */
};
This commit changes the object size calculation and computes the size
with the offset and size of the last field in the struct (rounded up
by the struct alignment).
Fixes: #85121
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
Few tests are being skipped for no goot reason (anymore). Add some
coverage using few platforms that work with intention to expand if all
works well and if needed.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>