Changeset 77ac1519 in rtems


Ignore:
Timestamp:
Dec 20, 2019, 9:55:36 AM (8 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
556e45f2
Parents:
8c3b0d7
git-author:
Sebastian Huber <sebastian.huber@…> (12/20/19 09:55:36)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/20/19 10:06:13)
Message:

libtest: Use test configuration in T_now()

Use the user provided now handler of the test configuration to get the
time in T_now().

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/t.h

    r8c3b0d7 r77ac1519  
    21472147void T_time_to_seconds_and_nanoseconds(T_time, uint32_t *, uint32_t *);
    21482148
     2149T_time T_now(void);
     2150
    21492151#ifdef __rtems__
    2150 int64_t _Timecounter_Sbinuptime(void);
    2151 
    2152 static inline T_time
    2153 T_now(void)
    2154 {
    2155         return (T_time)_Timecounter_Sbinuptime();
    2156 }
    2157 
    21582152static inline T_ticks
    21592153T_tick(void)
     
    21622156}
    21632157#else
    2164 T_time T_now(void);
    2165 
    21662158T_ticks T_tick(void);
    21672159#endif
    21682160
     2161T_time T_now_clock(void);
     2162
    21692163T_time T_now_dummy(void);
    21702164
    2171 T_time T_now_via_tick(void);
     2165T_time T_now_tick(void);
    21722166
    21732167T_time T_case_begin_time(void);
  • cpukit/libtest/t-test-time.c

    r8c3b0d7 r77ac1519  
    202202}
    203203
     204T_time
     205T_now_clock(void)
     206{
    204207#ifndef __rtems__
    205 T_time
    206 T_now(void)
    207 {
    208208        struct timespec tp;
    209209
    210210        (void)clock_gettime(CLOCK_MONOTONIC, &tp);
    211211        return (T_time)tp.tv_sec * (T_time)1000000000 + (T_time)tp.tv_nsec;
    212 }
    213 
     212#else /* __rtems__ */
     213        return (T_time)_Timecounter_Sbinuptime();
     214#endif /* __rtems__ */
     215}
     216
     217#ifndef __rtems__
    214218T_ticks
    215219T_tick(void)
     
    219223#endif
    220224
    221 static atomic_uint dummy_time;
     225static atomic_uint T_dummy_time;
    222226
    223227T_time
    224228T_now_dummy(void)
    225229{
    226         return atomic_fetch_add_explicit(&dummy_time, 1, memory_order_relaxed);
    227 }
    228 
    229 T_time
    230 T_now_via_tick(void)
     230        return atomic_fetch_add_explicit(&T_dummy_time, 1,
     231            memory_order_relaxed);
     232}
     233
     234T_time
     235T_now_tick(void)
    231236{
    232237        return T_ticks_to_time(T_tick());
  • cpukit/libtest/t-test.c

    r8c3b0d7 r77ac1519  
    995995        ctx->putchar_arg = new_arg;
    996996}
     997
     998T_time
     999T_now(void)
     1000{
     1001        T_context *ctx;
     1002        const T_config *config;
     1003
     1004        ctx = &T_instance;
     1005        config = ctx->config;
     1006        return (*config->now)();
     1007}
  • testsuites/libtests/ttest01/init.c

    r8c3b0d7 r77ac1519  
    3333#include <rtems.h>
    3434#include <rtems/bspIo.h>
    35 #include <rtems/timecounter.h>
    36 #include <rtems/sysinit.h>
    3735
    3836#include "t-self-test.h"
     
    5553        size_t case_begin_count;
    5654        size_t case_end_count;
    57         struct timecounter tc;
    5855        T_putchar putchar;
    5956        void *putchar_arg;
     
    181178}
    182179
    183 static const char expected_final[] = "Z:ttest01:C:341:N:1316:F:790:D:0.682999\n"
    184 "Y:ReportHash:SHA256:62d6f3b37299137932ea2c2f0505c8b8f12b95749c81d5af19570e9470203475\n";
     180static const char expected_final[] = "Z:ttest01:C:341:N:1316:F:790:D:0.685999\n"
     181"Y:ReportHash:SHA256:cb5ba027ade5b907d9e988776e393835f34a76cc2381d67bb9db44d986a3fecf\n";
    185182
    186183static void
     
    226223        return t * SBT_1MS;
    227224}
    228 
    229 static uint32_t
    230 get_timecount(struct timecounter *tc)
    231 {
    232         return 0;
    233 }
    234 
    235 static void
    236 install_timecounter(void)
    237 {
    238         test_context *ctx;
    239 
    240         ctx = &test_instance;
    241         ctx->tc.tc_get_timecount = get_timecount;
    242         ctx->tc.tc_counter_mask = 0xffffffff;
    243         ctx->tc.tc_frequency = 1000000000;
    244         ctx->tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER + 1;
    245         rtems_timecounter_install(&ctx->tc);
    246 }
    247 
    248 RTEMS_SYSINIT_ITEM(install_timecounter, RTEMS_SYSINIT_DEVICE_DRIVERS,
    249     RTEMS_SYSINIT_ORDER_FIRST);
    250225
    251226static char buffer[512];
  • testsuites/libtests/ttest01/test-time.c

    r8c3b0d7 r77ac1519  
    204204T_TEST_OUTPUT(now,
    205205"B:now\n"
    206 "L:0.000000000\n"
    207 "E:now:N:0:F:0:D:0.001000\n");
     206"L:0.001000000\n"
     207"E:now:N:0:F:0:D:0.003000\n");
    208208
    209209T_TEST_OUTPUT(tick,
     
    269269T_TEST_OUTPUT(begin_time,
    270270"B:begin_time\n"
    271 "L:time at test case begin 0.325000046\n"
    272 "E:begin_time:N:0:F:0:D:0.001000\n");
     271"L:time at test case begin 0.001000000\n"
     272"E:begin_time:N:0:F:0:D:0.002000\n");
    273273
    274274/*
Note: See TracChangeset for help on using the changeset viewer.