Lines Matching defs:test

14  * Heavily modified for curl's test suite
109 long testno; /* test case number */
236 static void read_ahead(struct testcase *test, int convert);
238 static ssize_t write_behind(struct testcase *test, int convert);
242 static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size);
244 static int validate_access(struct testcase *test, const char *fname, int mode);
246 static void sendtftp(struct testcase *test, const struct formats *pf);
248 static void recvtftp(struct testcase *test, const struct formats *pf);
341 static int readit(struct testcase *test, struct tftphdr **dpp,
351 read_ahead(test, convert); /* fill it */
361 static void read_ahead(struct testcase *test,
380 size_t copy_n = MIN(SEGSIZE, test->rcount);
381 memcpy(dp->th_data, test->rptr, copy_n);
384 test->rcount -= copy_n;
385 test->rptr += copy_n;
400 if(test->rcount) {
401 c = test->rptr[0];
402 test->rptr++;
403 test->rcount--;
421 static int writeit(struct testcase *test, struct tftphdr * volatile *dpp,
427 write_behind(test, convert); /* flush it */
439 static ssize_t write_behind(struct testcase *test, int convert)
453 if(!test->ofile) {
455 msnprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno);
457 test->ofile = open(outfile, O_CREAT|O_RDWR|O_BINARY, 0777);
459 test->ofile = open(outfile, O_CREAT|O_RDWR, 0777);
461 if(test->ofile == -1) {
477 return write(test->ofile, writebuf, count);
485 lseek(test->ofile, -1, SEEK_CUR); /* smash lf on top of the cr */
493 if(1 != write(test->ofile, &c, 1))
561 struct testcase test;
564 memset(&test, 0, sizeof(test));
825 memset(&test, 0, sizeof(test));
826 if(do_tftp(&test, tp, n) < 0)
828 free(test.buffer);
847 if(test.ofile > 0)
848 close(test.ofile);
889 static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
978 ecode = validate_access(test, filename, tp->th_opcode);
994 recvtftp(test, pf);
996 sendtftp(test, pf);
1017 logmsg(" Couldn't open test file %ld", req->testno);
1072 static int validate_access(struct testcase *test,
1085 test->buffer = strdup(weare);
1086 test->rptr = test->buffer; /* set read pointer */
1087 test->bufsize = count; /* set total count */
1088 test->rcount = count; /* set data left to read */
1118 logmsg("requested test number %ld part %ld", testno, partno);
1120 test->testno = testno;
1122 (void)parse_servercmd(test);
1132 logmsg("Couldn't open test file for test: %ld", testno);
1137 int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
1143 if(test->buffer) {
1144 test->rptr = test->buffer; /* set read pointer */
1145 test->bufsize = count; /* set total count */
1146 test->rcount = count; /* set data left to read */
1164 static void sendtftp(struct testcase *test, const struct formats *pf)
1178 size = readit(test, (struct tftphdr **)&sdp, pf->f_convert);
1189 if(test->writedelay) {
1190 logmsg("Pausing %d seconds before %d bytes", test->writedelay,
1192 wait_ms(1000*test->writedelay);
1201 read_ahead(test, pf->f_convert);
1245 static void recvtftp(struct testcase *test, const struct formats *pf)
1273 write_behind(test, pf->f_convert);
1305 size = writeit(test, &rdp, (int)(n - 4), pf->f_convert);
1314 write_behind(test, pf->f_convert);
1316 if(test->ofile > 0) {
1317 close(test->ofile);
1318 test->ofile = 0;
1343 if(test->ofile > 0) {
1344 close(test->ofile);
1345 test->ofile = 0;