[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 |
---|
[c499856] | 12 | * http://www.rtems.org/license/LICENSE. |
---|
[b68d231] | 13 | */ |
---|
| 14 | |
---|
| 15 | #ifdef HAVE_CONFIG_H |
---|
| 16 | #include "config.h" |
---|
| 17 | #endif |
---|
| 18 | |
---|
| 19 | #include <tmacros.h> |
---|
| 20 | |
---|
[6c0301d] | 21 | const char rtems_test_name[] = "SPNSEXT 1"; |
---|
| 22 | |
---|
[b68d231] | 23 | static rtems_task Init(rtems_task_argument argument) |
---|
| 24 | { |
---|
| 25 | rtems_status_code sc = RTEMS_SUCCESSFUL; |
---|
[d0061287] | 26 | RTEMS_INTERRUPT_LOCK_DECLARE(, lock) |
---|
[d50acdbb] | 27 | rtems_interrupt_lock_context lock_context; |
---|
[b68d231] | 28 | rtems_interval t0 = 0; |
---|
| 29 | rtems_interval t1 = 0; |
---|
| 30 | int i = 0; |
---|
| 31 | int n = 0; |
---|
| 32 | struct timespec uptime; |
---|
| 33 | struct timespec new_uptime; |
---|
| 34 | |
---|
[6c0301d] | 35 | TEST_BEGIN(); |
---|
[b68d231] | 36 | |
---|
| 37 | /* Align with clock tick */ |
---|
| 38 | t0 = rtems_clock_get_ticks_since_boot(); |
---|
| 39 | while ((t1 = rtems_clock_get_ticks_since_boot()) == t0) { |
---|
| 40 | /* Do nothing */ |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | t0 = t1; |
---|
| 44 | sc = rtems_clock_get_uptime(&uptime); |
---|
| 45 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 46 | while ((t1 = rtems_clock_get_ticks_since_boot()) == t0) { |
---|
| 47 | ++n; |
---|
| 48 | sc = rtems_clock_get_uptime(&new_uptime); |
---|
| 49 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
[b4e4f25] | 50 | rtems_test_assert(!_Timespec_Less_than(&new_uptime, &uptime)); |
---|
[b68d231] | 51 | uptime = new_uptime; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | n = (3 * n) / 2; |
---|
| 55 | |
---|
[53ad908] | 56 | rtems_interrupt_lock_initialize(&lock, "test"); |
---|
[d50acdbb] | 57 | rtems_interrupt_lock_acquire(&lock, &lock_context); |
---|
[b68d231] | 58 | sc = rtems_clock_get_uptime(&uptime); |
---|
| 59 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 60 | for (i = 0; i < n; ++i) { |
---|
| 61 | /* Preserve execution time of previous loop */ |
---|
| 62 | rtems_clock_get_ticks_since_boot(); |
---|
| 63 | |
---|
| 64 | sc = rtems_clock_get_uptime(&new_uptime); |
---|
| 65 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
[b4e4f25] | 66 | rtems_test_assert(!_Timespec_Less_than(&new_uptime, &uptime)); |
---|
[b68d231] | 67 | uptime = new_uptime; |
---|
| 68 | } |
---|
[d50acdbb] | 69 | rtems_interrupt_lock_release(&lock, &lock_context); |
---|
[28779c7] | 70 | rtems_interrupt_lock_destroy(&lock); |
---|
[b68d231] | 71 | |
---|
[6c0301d] | 72 | TEST_END(); |
---|
[b68d231] | 73 | |
---|
| 74 | rtems_test_exit(0); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | #define CONFIGURE_INIT |
---|
| 78 | |
---|
| 79 | #define CONFIGURE_MICROSECONDS_PER_TICK 100000 |
---|
| 80 | |
---|
| 81 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
| 82 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 83 | |
---|
| 84 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
| 85 | #define CONFIGURE_MAXIMUM_DRIVERS 2 |
---|
| 86 | |
---|
[6c0301d] | 87 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
| 88 | |
---|
[b68d231] | 89 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 90 | |
---|
| 91 | #include <rtems/confdefs.h> |
---|