Skip to content

Commit 947ea75

Browse files
committed
tests: move lib/timespec_util to unit/timeutil
Since native_sim and unit_testing platforms can now be compiled with time_t as 64-bits, that means that all platforms in Zephyr are consistent. Move the (now platform-independent) lib/timespec_util tests to unit/timeutil. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent 95807ab commit 947ea75

File tree

7 files changed

+15
-51
lines changed

7 files changed

+15
-51
lines changed

tests/lib/timespec_util/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/lib/timespec_util/prj.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/lib/timespec_util/testcase.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/unit/timeutil/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ target_sources(testbinary
1414
test_s32.c
1515
test_s64.c
1616
test_sync.c
17+
timespec.c
1718
)

tests/unit/timeutil/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "timeutil_test.h"
99
#include "../../../lib/utils/timeutil.c"
1010

11+
extern void *setup(void);
12+
1113
void timeutil_check(const struct timeutil_test_data *tp,
1214
size_t count)
1315
{
@@ -52,4 +54,4 @@ void timeutil_check(const struct timeutil_test_data *tp,
5254
}
5355
}
5456

55-
ZTEST_SUITE(timeutil_api, NULL, NULL, NULL, NULL, NULL);
57+
ZTEST_SUITE(timeutil_api, NULL, setup, NULL, NULL, NULL);

tests/unit/timeutil/testcase.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ tests:
88

99
utilities.time.64bit:
1010
extra_args: M64_MODE=1
11+
12+
utilities.time.timeout32:
13+
extra_configs:
14+
- CONFIG_TIMEOUT_64BIT=n
15+
16+
utilities.time.timeout64:
17+
extra_configs:
18+
- CONFIG_TIMEOUT_64BIT=y

tests/lib/timespec_util/src/main.c renamed to tests/unit/timeutil/timespec.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ ZTEST(timeutil_api, test_timespec_equal)
268268
zexpect_false(timespec_equal(&a, &b));
269269
}
270270

271-
#define K_TICK_MAX ((uint64_t)(CONFIG_TIMEOUT_64BIT ? (INT64_MAX) : (UINT32_MAX)))
271+
#define K_TICK_MAX ((uint64_t)(IS_ENABLED(CONFIG_TIMEOUT_64BIT) ? (INT64_MAX) : (UINT32_MAX)))
272272
#define NS_PER_TICK (NSEC_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC)
273273

274274
/* 0 := lower limit, 2 := upper limit */
@@ -365,10 +365,10 @@ ZTEST(timeutil_api, test_timespec_to_timeout)
365365
}
366366
}
367367

368-
static void *setup(void)
368+
void *setup(void)
369369
{
370370
printk("CONFIG_64BIT=%c\n", IS_ENABLED(CONFIG_64BIT) ? 'y' : 'n');
371-
printk("CONFIG_TIMEOUT_64BIT=%c\n", CONFIG_TIMEOUT_64BIT ? 'y' : 'n');
371+
printk("CONFIG_TIMEOUT_64BIT=%c\n", IS_ENABLED(CONFIG_TIMEOUT_64BIT) ? 'y' : 'n');
372372
printk("K_TICK_MAX: %lld\n", (long long)K_TICK_MAX);
373373
printk("minimum timeout: {%lld, %lld}\n", (long long)k_timeout_limits[0].tv_sec,
374374
(long long)k_timeout_limits[0].tv_nsec);
@@ -377,5 +377,3 @@ static void *setup(void)
377377

378378
return NULL;
379379
}
380-
381-
ZTEST_SUITE(timeutil_api, NULL, setup, NULL, NULL, NULL);

0 commit comments

Comments
 (0)