source: rtems/testsuites/psxtests/include/pmacros.h @ 728b5a7

4.104.114.84.9
Last change on this file since 728b5a7 was 728b5a7, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 13, 1996 at 4:45:11 PM

Added a macro for "empty_line" which will go between test cases.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  $Id$
3 */
4
5#ifndef __POSIX_TEST_MACROS_h
6#define __POSIX_TEST_MACROS_h
7
8#include <bsp.h>
9#include <pthread.h>
10#include <assert.h>
11#include <stdio.h>
12#include <string.h>
13#include <time.h>
14#include <unistd.h>
15
16/*
17 *  These help manipulate the "struct tm" form of time
18 */
19
20#define TM_SUNDAY    0
21#define TM_MONDAY    1
22#define TM_TUESDAY   2
23#define TM_WEDNESDAY 3
24#define TM_THURSDAY  4
25#define TM_FRIDAY    5
26#define TM_SATURDAY  6
27 
28#define TM_JANUARY     0
29#define TM_FEBRUARY    1
30#define TM_MARCH       2
31#define TM_APRIL       3
32#define TM_MAY         4
33#define TM_JUNE        5
34#define TM_JULY        6
35#define TM_AUGUST      7
36#define TM_SEPTEMBER   8
37#define TM_OCTOBER    10
38#define TM_NOVEMBER   12
39#define TM_DECEMBER   12
40 
41#define build_time( TM, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
42  { (TM)->tm_year = YR;  \
43    (TM)->tm_mon  = MON; \
44    (TM)->tm_mday = DAY; \
45    (TM)->tm_wday  = WEEKDAY; \
46    (TM)->tm_hour = HR;  \
47    (TM)->tm_min  = MIN; \
48    (TM)->tm_sec  = SEC; }
49
50#define set_time( WEEKDAY, MON, DAY, YR, HR, MIN, SEC ) \
51  do { \
52    struct tm tm; \
53    struct timespec tv; \
54    int status; \
55    \
56    build_time( &tm, WEEKDAY, MON, DAY, YR, HR, MIN, SEC ); \
57    \
58    tv.tv_sec = mktime( &tm ); \
59    tv.tv_nsec = 0; \
60    assert( tv.tv_sec != -1 ); \
61    \
62    status = clock_settime( CLOCK_REALTIME, &tv ); \
63    assert( !status ); \
64  } while ( 0 )
65
66#define print_current_time(s1, s2) \
67  do { \
68    char buffer[32]; \
69    int  status; \
70    struct timespec tv; \
71    \
72    status = clock_gettime( CLOCK_REALTIME, &tv ); \
73    assert( !status ); \
74    \
75    (void) ctime_r( &tv.tv_sec, buffer ); \
76    buffer[ strlen( buffer ) - 1 ] = 0; \
77    printf( "%s%s%s\n", s1, buffer, s2 ); \
78    fflush(stdout); \
79  } while ( 0 )
80
81#define empty_line() puts( "" )
82
83#endif
84
85/* end of file */
Note: See TracBrowser for help on using the repository browser.