1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2012. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <tmacros.h> |
---|
15 | |
---|
16 | #include <sys/types.h> |
---|
17 | #include <rtems/score/timespec.h> |
---|
18 | #include <rtems/score/threadq.h> |
---|
19 | |
---|
20 | /* forward declarations to avoid warnings */ |
---|
21 | rtems_task Init(rtems_task_argument argument); |
---|
22 | void timespec_divide_by_zero(void); |
---|
23 | void timespec_greater_than_lhs_sec_less(void); |
---|
24 | |
---|
25 | void timespec_divide_by_zero(void) |
---|
26 | { |
---|
27 | struct timespec t1; |
---|
28 | struct timespec zero; |
---|
29 | uint32_t ival_percentage; |
---|
30 | uint32_t fval_percentage; |
---|
31 | |
---|
32 | t1.tv_sec = 1; |
---|
33 | t1.tv_nsec = 0; |
---|
34 | |
---|
35 | zero.tv_sec = 0; |
---|
36 | zero.tv_nsec = 0; |
---|
37 | |
---|
38 | ival_percentage = 1234; |
---|
39 | fval_percentage = 5678; |
---|
40 | |
---|
41 | puts( "Init - _Timespec_Divide - by zero" ); |
---|
42 | _Timespec_Divide( &t1, &zero, &ival_percentage, &fval_percentage ); |
---|
43 | rtems_test_assert( ival_percentage == 0 ); |
---|
44 | rtems_test_assert( fval_percentage == 0 ); |
---|
45 | } |
---|
46 | |
---|
47 | void timespec_greater_than_lhs_sec_less(void) |
---|
48 | { |
---|
49 | struct timespec lhs; |
---|
50 | struct timespec rhs; |
---|
51 | bool rc; |
---|
52 | |
---|
53 | lhs.tv_sec = 100; |
---|
54 | lhs.tv_nsec = 0; |
---|
55 | |
---|
56 | rhs.tv_sec = 101; |
---|
57 | rhs.tv_nsec = 0; |
---|
58 | |
---|
59 | puts( "Init - _Timespec_Greater_than - lhs seconds less" ); |
---|
60 | rc = _Timespec_Greater_than( &lhs, &rhs ); |
---|
61 | rtems_test_assert( rc == false ); |
---|
62 | } |
---|
63 | |
---|
64 | rtems_task Init( |
---|
65 | rtems_task_argument ignored |
---|
66 | ) |
---|
67 | { |
---|
68 | puts( "\n\n*** TEST 58 ***" ); |
---|
69 | |
---|
70 | timespec_divide_by_zero(); |
---|
71 | timespec_greater_than_lhs_sec_less(); |
---|
72 | |
---|
73 | puts( "*** END OF TEST 58 ***" ); |
---|
74 | rtems_test_exit(0); |
---|
75 | } |
---|
76 | |
---|
77 | /* configuration information */ |
---|
78 | |
---|
79 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
80 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
81 | |
---|
82 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
83 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
84 | |
---|
85 | #define CONFIGURE_INIT |
---|
86 | #include <rtems/confdefs.h> |
---|
87 | |
---|
88 | /* global variables */ |
---|