00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdio.h>
00027 #include <errno.h>
00028 #include <string.h>
00029 #include <time.h>
00030 #include "testdefinitiondatatypes.h"
00031 #include "manual_executor.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 LOCAL xmlChar *get_comments ();
00070
00071 LOCAL int check_user_input(char *buff, int *result);
00072
00073
00074
00075
00076
00077
00078
00084 LOCAL int check_user_input(char *buff, int *result)
00085 {
00086 char *p;
00087
00088 *result = 1;
00089 p = strchr (buff, '\n');
00090 if (p)
00091 *p = '\0';
00092
00093 if (strlen (buff) == 0)
00094 return 1;
00095
00096 if (strlen (buff) == 1) {
00097 if (buff[0] == 'p' || buff[0] == 'P') {
00098 *result = CASE_PASS;
00099 return 0;
00100 }
00101 if (buff[0] == 'f' || buff[0] == 'F') {
00102 *result = CASE_FAIL;
00103 return 0;
00104 }
00105 if (buff[0] == 'n' || buff[0] == 'N') {
00106 *result = CASE_NA;
00107 return 0;
00108 }
00109
00110 }
00111
00112 if (strlen (buff) == 3) {
00113 if (!strcasecmp (buff, "n/a")) {
00114 *result = CASE_NA;
00115 return 0;
00116 }
00117 }
00118
00119 if (strlen (buff) != 4)
00120 return 1;
00121
00122 if (!strcasecmp (buff, "pass")) {
00123 *result = CASE_PASS;
00124 return 0;
00125 }
00126
00127 if (!strcasecmp (buff, "fail")) {
00128 *result = CASE_FAIL;
00129 return 0;
00130 }
00131
00132 return 1;
00133 }
00134
00138 LOCAL xmlChar *get_comments ()
00139 {
00140 char buff [4096], *p;
00141 buff [0] = '\0';
00142 xmlChar *ret = NULL;
00143 printf ("Please enter additional comments (ENTER to finish): ");
00144 p = fgets (buff, 4096, stdin);
00145 if (p) {
00146 p = strchr (buff, '\n');
00147 if (p)
00148 *p = '\0';
00149 ret = xmlCharStrdup (buff);
00150 }
00151 return ret;
00152 }
00153
00154
00155
00159 void pre_manual (td_case *c)
00160 {
00161 printf ("\nDescription of test case:\n%s\n",
00162 (char *)((char *)c->gen.description ?
00163 (char *)c->gen.description : " "));
00164
00165 }
00166
00171 int execute_manual (td_step *step)
00172 {
00173 char buff [256], *p;
00174 int ret = 0;
00175
00176 step->start = time (NULL);
00177 printf ("--- Execute test step ---\n");
00178 printf ("Description: ");
00179 if (step->step)
00180 printf ("%s\n", step->step);
00181
00182 buff [0] = '\0';
00183 printf ("Please enter the result ([P/p]ass,[F/f]ail or [N/n]/a): ");
00184 p = fgets (buff, 256, stdin);
00185 while (check_user_input(buff, &ret)) {
00186 printf ("Invalid input.\n");
00187 p = fgets (buff, 256, stdin);
00188 }
00189 switch (ret) {
00190 case CASE_NA:
00191 step->has_result = 0;
00192 break;
00193 case CASE_FAIL:
00194 step->has_result = 1;
00195 step->return_code = !step->expected_result;
00196 break;
00197 case CASE_PASS:
00198 step->has_result = 1;
00199 step->return_code = step->expected_result;
00200 break;
00201 }
00202 step->end = time (NULL);
00203
00204 return ret;
00205 }
00206
00210 void post_manual (td_case *c)
00211 {
00212 printf ("--- Test steps executed, case is ");
00213 switch (c->case_res) {
00214 case CASE_FAIL:
00215 printf ("FAILED");
00216 break;
00217 case CASE_PASS:
00218 printf ("PASSED");
00219 break;
00220 case CASE_NA:
00221 printf ("N/A");
00222 break;
00223 default:
00224 printf ("Unknown result code");
00225 }
00226 printf (" ---\n");
00227 c->comment = get_comments();
00228 }
00229
00230
00231
00232
00233
00234