File: interact.c

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (156 lines) | stat: -rw-r--r-- 4,579 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * INTERACT.C - interactive test for PACT
 *
 * Source Version: 2.0
 * Software Release #92-0043
 *
 */

#include "cpyright.h"

/***********************************************************************
* File        : interact.c 
* Programmer  : Carolyn Sharp
* Machines    : sun3, phoenix, Cray 2, RS6000
*
* Description : Interactive tester for pact - tests those routines
*               which cannot be handled automatically. 
* Notes       : Use Ctrl-C at any time to quit.
* Caution     : Redirection of output -> terminal appears hung  but it's
*               just waiting for your terminal input.
***********************************************************************/

#include "score.h"

main()
   {int ifail = 0;
  
    ifail += tSC_wall_clock_time();
    ifail += tSC_pause();
    ifail += tSC_banner();

    if (ifail == 0)
       PRINT(STDOUT, "\nPASS Interactive Tester \n");
    else
       PRINT(stderr, "\nFAIL = %d in Interactive Tester \n", ifail);

    return(ifail ? 1 : 0);}

/***********************************************************************
* Function    : tSC_wall_clock_time
* Usage       : Interactive tester for pact/score/scctl.c function
*               SC_wall_clock_time
*
* Description : Displays time and instructions for user response.
*               Prints name of function if test fails.
*
* Returns     : 1|0 for PASS|FAIL.
***********************************************************************/

int tSC_wall_clock_time()
   {int cfail = 0;
    int time = 30;
    char reply[MAXLINE];                  /* MAXLINE defined in scstd.h */
    int i;
    int t0, t1;

    PRINT(STDOUT, "\n\n***** This is the test for SC_wall_clock_time ***** \n");

    t0 = SC_wall_clock_time();
    PRINT(STDOUT, "t0 = %d \n", t0);
    sleep(time);
    t1 = SC_wall_clock_time();
    PRINT(STDOUT, "t1 = %d \n", t1);
    PRINT(STDOUT, "Does %d = %d? \n",(t1-t0),time);

    for (i=0; i<time; i++)
        PRINT(STDOUT, "%d\n", SC_wall_clock_time());

    PRINT(STDOUT, "The starting time is: %11.3e \n", SC_wall_clock_time());
    PRINT(STDOUT, "(Taking %d second nap...zzz...) \n", time);
    sleep(time);
    PRINT(STDOUT, "The wake-up  time is: %11.3e \n", SC_wall_clock_time());
    PRINT(STDOUT, "\nIs that close enough?");
    PRINT(STDOUT, "TICKS_SECOND = %d", TICKS_SECOND);
    PRINT(STDOUT, "\nPlease reply y|n to set PASS|FAIL flag: ");
    if (gets(reply) == NULL)
       PRINT(STDOUT, "\n Error reading response \n");

    else
       if (reply[0] != 'y')
          cfail++;

    return(cfail);}

/***********************************************************************
* Function    : tSC_banner
* Usage       : Interactive tester for pact/score/scctl.c function
*               SC_banner 
*
* Description : Displays banner and instructions for user response.
*               Prints name of function if test fails.
*
* Returns     : 1|0 for PASS|FAIL.
***********************************************************************/

tSC_banner()
   {int bfail = 0;
    char reply[MAXLINE], bstr[MAXLINE];

    strcpy(bstr, "This message is brought to you by SC_banner.");

    PRINT(STDOUT, "\n\n***** This is the test for SC_banner ***** \n");
    PRINT(STDOUT, "You should see the message:\n %s \n", bstr);

    SC_banner(bstr);

    PRINT(STDOUT, "\nDo the messages match?");
    PRINT(STDOUT, "\nPlease reply y|n to set PASS|FAIL flag: ");
    if (gets(reply) == NULL)
       PRINT(STDOUT, "\n Error reading response \n");

    else
       {if (reply[0] != 'y')
	   bfail++;};

    if (bfail != 0)
       PRINT(STDOUT, "\nFAIL SC_banner \n");

    return(bfail);}

/***********************************************************************
* Function    : tSC_pause 
* Usage       : Interactive tester for pact/score/scctl.c function
*               SC_pause
*
* Description : Causes pause for user until <CR> received.
*               Prints name of function if test fails.
*
* Returns     : 1|0 for PASS|FAIL.
***********************************************************************/

tSC_pause()
   {int pfail = 0;
    char reply[MAXLINE];

    PRINT(STDOUT, "\n\n***** This is the test for SC_pause ***** \n");
    PRINT(STDOUT, "You should expect a pause until you press <CR>.\n");

    SC_pause();

    PRINT(STDOUT, "Was there a pause?\n");
    PRINT(STDOUT, "Please reply y|n to set PASS|FAIL flag: ");
    if (gets(reply) == NULL)
       PRINT(STDOUT, "\n Error reading response \n");

    else
       {if (reply[0] != 'y')
	   pfail++;};

    if (pfail != 0)
       PRINT(STDOUT, "\nFAIL SC_pause \n");

    return(pfail);}