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 fflush(stdout);
00145 p = fgets (buff, 4096, stdin);
00146 if (p) {
00147 p = strchr (buff, '\n');
00148 if (p)
00149 *p = '\0';
00150 ret = xmlCharStrdup (buff);
00151 }
00152 return ret;
00153 }
00154
00155
00156
00160 void pre_manual (td_case *c)
00161 {
00162 printf ("\nDescription of test case:\n%s\n",
00163 (char *)((char *)c->gen.description ?
00164 (char *)c->gen.description : " "));
00165
00166 }
00167
00172 int execute_manual (td_step *step)
00173 {
00174 char buff [256], *p;
00175 int ret = 0;
00176
00177 step->start = time (NULL);
00178 printf ("--- Execute test step ---\n");
00179 printf ("Description: ");
00180 if (step->step)
00181 printf ("%s\n", step->step);
00182
00183 buff [0] = '\0';
00184 printf ("Please enter the result ([P/p]ass,[F/f]ail or [N/n]/a): ");
00185 fflush(stdout);
00186 p = fgets (buff, 256, stdin);
00187 while (check_user_input(buff, &ret)) {
00188 printf ("Invalid input.\n");
00189 p = fgets (buff, 256, stdin);
00190 }
00191 switch (ret) {
00192 case CASE_NA:
00193 step->has_result = 0;
00194 break;
00195 case CASE_FAIL:
00196 step->has_result = 1;
00197 step->return_code = !step->expected_result;
00198 break;
00199 case CASE_PASS:
00200 step->has_result = 1;
00201 step->return_code = step->expected_result;
00202 break;
00203 }
00204 step->end = time (NULL);
00205
00206 return ret;
00207 }
00208
00212 void post_manual (td_case *c)
00213 {
00214 printf ("--- Test steps executed, case is ");
00215 switch (c->case_res) {
00216 case CASE_FAIL:
00217 printf ("FAILED");
00218 break;
00219 case CASE_PASS:
00220 printf ("PASSED");
00221 break;
00222 case CASE_NA:
00223 printf ("N/A");
00224 break;
00225 default:
00226 printf ("Unknown result code");
00227 }
00228 printf (" ---\n");
00229 c->comment = get_comments();
00230 }
00231
00232
00233
00234
00235
00236