[b68d231] | 1 | /* |
---|
| 2 | * Copyright (c) 2011 embedded brains GmbH. All rights reserved. |
---|
| 3 | * |
---|
| 4 | * embedded brains GmbH |
---|
| 5 | * Obere Lagerstr. 30 |
---|
| 6 | * 82178 Puchheim |
---|
| 7 | * Germany |
---|
| 8 | * <rtems@embedded-brains.de> |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
| 12 | * http://www.rtems.com/license/LICENSE. |
---|
| 13 | * |
---|
| 14 | * $Id$ |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #ifdef HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
| 21 | #include <tmacros.h> |
---|
| 22 | |
---|
| 23 | static rtems_task Init(rtems_task_argument argument) |
---|
| 24 | { |
---|
| 25 | rtems_status_code sc = RTEMS_SUCCESSFUL; |
---|
| 26 | rtems_interrupt_level level; |
---|
| 27 | rtems_interval t0 = 0; |
---|
| 28 | rtems_interval t1 = 0; |
---|
| 29 | int i = 0; |
---|
| 30 | int n = 0; |
---|
| 31 | struct timespec uptime; |
---|
| 32 | struct timespec new_uptime; |
---|
| 33 | |
---|
| 34 | puts("\n\n*** TEST NANO SECONDS EXTENSION 1 ***"); |
---|
| 35 | |
---|
| 36 | /* Align with clock tick */ |
---|
| 37 | t0 = rtems_clock_get_ticks_since_boot(); |
---|
| 38 | while ((t1 = rtems_clock_get_ticks_since_boot()) == t0) { |
---|
| 39 | /* Do nothing */ |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | t0 = t1; |
---|
| 43 | sc = rtems_clock_get_uptime(&uptime); |
---|
| 44 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 45 | while ((t1 = rtems_clock_get_ticks_since_boot()) == t0) { |
---|
| 46 | ++n; |
---|
| 47 | sc = rtems_clock_get_uptime(&new_uptime); |
---|
| 48 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
[b4e4f25] | 49 | rtems_test_assert(!_Timespec_Less_than(&new_uptime, &uptime)); |
---|
[b68d231] | 50 | uptime = new_uptime; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | n = (3 * n) / 2; |
---|
| 54 | |
---|
| 55 | rtems_interrupt_disable(level); |
---|
| 56 | sc = rtems_clock_get_uptime(&uptime); |
---|
| 57 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 58 | for (i = 0; i < n; ++i) { |
---|
| 59 | /* Preserve execution time of previous loop */ |
---|
| 60 | rtems_clock_get_ticks_since_boot(); |
---|
| 61 | |
---|
| 62 | sc = rtems_clock_get_uptime(&new_uptime); |
---|
| 63 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
[b4e4f25] | 64 | rtems_test_assert(!_Timespec_Less_than(&new_uptime, &uptime)); |
---|
[b68d231] | 65 | uptime = new_uptime; |
---|
| 66 | } |
---|
| 67 | rtems_interrupt_enable(level); |
---|
| 68 | |
---|
| 69 | puts("*** END OF TEST NANO SECONDS EXTENSION 1 ***"); |
---|
| 70 | |
---|
| 71 | rtems_test_exit(0); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | #define CONFIGURE_INIT |
---|
| 75 | |
---|
| 76 | #define CONFIGURE_MICROSECONDS_PER_TICK 100000 |
---|
| 77 | |
---|
| 78 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
| 79 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 80 | |
---|
| 81 | #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM |
---|
| 82 | |
---|
| 83 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
| 84 | #define CONFIGURE_MAXIMUM_DRIVERS 2 |
---|
| 85 | |
---|
| 86 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 87 | |
---|
| 88 | #include <rtems/confdefs.h> |
---|