File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ include ($ENV{ZEPHYR_BASE} /cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
2
+ project (NONE)
3
+
4
+ target_include_directories (app PRIVATE $ENV{ZEPHYR_BASE} /include /posix)
5
+ FILE (GLOB app_sources src/*.c)
6
+ target_sources (app PRIVATE ${app_sources} )
Original file line number Diff line number Diff line change
1
+ CONFIG_TEST=y
2
+ CONFIG_PTHREAD_IPC=y
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2018 Intel Corporation
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <tc_util.h>
8
+ #include <pthread.h>
9
+
10
+ #define SLEEP_SECONDS 1
11
+
12
+ void main (void )
13
+ {
14
+ u32_t status ;
15
+ s64_t nsecs_elapsed , secs_elapsed ;
16
+ struct timespec ts , te ;
17
+
18
+ TC_START ("POSIX clock APIs\n" );
19
+ clock_gettime (CLOCK_MONOTONIC , & ts );
20
+ /* 2 Sec Delay */
21
+ sleep (SLEEP_SECONDS );
22
+ usleep (SLEEP_SECONDS * USEC_PER_SEC );
23
+ clock_gettime (CLOCK_MONOTONIC , & te );
24
+
25
+ if (te .tv_nsec >= ts .tv_nsec ) {
26
+ secs_elapsed = te .tv_sec - ts .tv_sec ;
27
+ nsecs_elapsed = te .tv_nsec - ts .tv_nsec ;
28
+ } else {
29
+ nsecs_elapsed = NSEC_PER_SEC + te .tv_nsec - ts .tv_nsec ;
30
+ secs_elapsed = (te .tv_sec - ts .tv_sec - 1 );
31
+ }
32
+
33
+ status = secs_elapsed == (2 * SLEEP_SECONDS ) ? TC_PASS : TC_FAIL ;
34
+
35
+ TC_PRINT ("POSIX clock APIs test done\n" );
36
+ TC_END_REPORT (status );
37
+ }
Original file line number Diff line number Diff line change
1
+ tests :
2
+ test :
3
+ tags : core
You can’t perform that action at this time.
0 commit comments