mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 14:29:23 +08:00
* include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
99 lines
2.2 KiB
C
99 lines
2.2 KiB
C
/*
|
|
* COPYRIGHT (c) 1989-2009.
|
|
* On-Line Applications Research Corporation (OAR).
|
|
*
|
|
* The license and distribution terms for this file may be
|
|
* found in the file LICENSE in this distribution or at
|
|
* http://www.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#ifndef __POSIX_TEST_MACROS_h
|
|
#define __POSIX_TEST_MACROS_h
|
|
|
|
#if defined(__rtems__)
|
|
#include <bsp.h>
|
|
#endif
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
#include <tmacros.h>
|
|
#include <buffer_test_io.h>
|
|
|
|
/*
|
|
* These help manipulate the "struct tm" form of time
|
|
*/
|
|
|
|
#define TM_SUNDAY 0
|
|
#define TM_MONDAY 1
|
|
#define TM_TUESDAY 2
|
|
#define TM_WEDNESDAY 3
|
|
#define TM_THURSDAY 4
|
|
#define TM_FRIDAY 5
|
|
#define TM_SATURDAY 6
|
|
|
|
#define TM_JANUARY 0
|
|
#define TM_FEBRUARY 1
|
|
#define TM_MARCH 2
|
|
#define TM_APRIL 3
|
|
#define TM_MAY 4
|
|
#define TM_JUNE 5
|
|
#define TM_JULY 6
|
|
#define TM_AUGUST 7
|
|
#define TM_SEPTEMBER 8
|
|
#define TM_OCTOBER 9
|
|
#define TM_NOVEMBER 10
|
|
#define TM_DECEMBER 11
|
|
|
|
#ifndef tm_build_time
|
|
#define tm_build_time( TM, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
|
|
{ (TM)->tm_year = YR; \
|
|
(TM)->tm_mon = MON; \
|
|
(TM)->tm_mday = DAY; \
|
|
(TM)->tm_wday = WEEKDAY; \
|
|
(TM)->tm_hour = HR; \
|
|
(TM)->tm_min = MIN; \
|
|
(TM)->tm_sec = SEC; }
|
|
#endif
|
|
|
|
#define set_time( WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
|
|
do { \
|
|
struct tm tm; \
|
|
struct timespec tv; \
|
|
int status; \
|
|
\
|
|
tm_build_time( &tm, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ); \
|
|
\
|
|
tv.tv_sec = mktime( &tm ); \
|
|
tv.tv_nsec = 0; \
|
|
rtems_test_assert( tv.tv_sec != -1 ); \
|
|
\
|
|
status = clock_settime( CLOCK_REALTIME, &tv ); \
|
|
rtems_test_assert( !status ); \
|
|
} while ( 0 )
|
|
|
|
#define print_current_time(s1, s2) \
|
|
do { \
|
|
char _time_buffer[32]; \
|
|
int _status; \
|
|
struct timespec _tv; \
|
|
\
|
|
_status = clock_gettime( CLOCK_REALTIME, &_tv ); \
|
|
rtems_test_assert( !_status ); \
|
|
\
|
|
(void) ctime_r( &_tv.tv_sec, _time_buffer ); \
|
|
_time_buffer[ strlen( _time_buffer ) - 1 ] = 0; \
|
|
printf( "%s%s%s\n", s1, _time_buffer, s2 ); \
|
|
fflush(stdout); \
|
|
} while ( 0 )
|
|
|
|
#define empty_line() puts( "" )
|
|
|
|
#endif
|
|
|
|
/* end of file */
|