Lines Matching refs:test

233 static void read_ahead(struct testcase *test, int convert);
235 static ssize_t write_behind(struct testcase *test, int convert);
239 static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size);
241 static int validate_access(struct testcase *test,
244 static void sendtftp(struct testcase *test, const struct formats *pf);
246 static void recvtftp(struct testcase *test, const struct formats *pf);
342 static int readit(struct testcase *test, struct tftphdr **dpp, in readit() argument
352 read_ahead(test, convert); /* fill it */ in readit()
362 static void read_ahead(struct testcase *test, in read_ahead() argument
381 size_t copy_n = MIN(SEGSIZE, test->rcount); in read_ahead()
382 memcpy(dp->th_data, test->rptr, copy_n); in read_ahead()
385 test->rcount -= copy_n; in read_ahead()
386 test->rptr += copy_n; in read_ahead()
401 if(test->rcount) { in read_ahead()
402 c = test->rptr[0]; in read_ahead()
403 test->rptr++; in read_ahead()
404 test->rcount--; in read_ahead()
422 static int writeit(struct testcase *test, struct tftphdr * volatile *dpp, in writeit() argument
428 write_behind(test, convert); /* flush it */ in writeit()
440 static ssize_t write_behind(struct testcase *test, int convert) in write_behind() argument
454 if(!test->ofile) { in write_behind()
456 msnprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno); in write_behind()
458 test->ofile = open(outfile, O_CREAT|O_RDWR|O_BINARY, 0777); in write_behind()
460 test->ofile = open(outfile, O_CREAT|O_RDWR, 0777); in write_behind()
462 if(test->ofile == -1) { in write_behind()
478 return write(test->ofile, writebuf, count); in write_behind()
486 lseek(test->ofile, -1, SEEK_CUR); /* smash lf on top of the cr */ in write_behind()
494 if(1 != write(test->ofile, &c, 1)) in write_behind()
562 struct testcase test; in main() local
565 memset(&test, 0, sizeof(test)); in main()
826 memset(&test, 0, sizeof(test)); in main()
827 if(do_tftp(&test, tp, n) < 0) in main()
829 free(test.buffer); in main()
848 if(test.ofile > 0) in main()
849 close(test.ofile); in main()
890 static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) in do_tftp() argument
979 ecode = validate_access(test, filename, tp->th_opcode); in do_tftp()
995 recvtftp(test, pf); in do_tftp()
997 sendtftp(test, pf); in do_tftp()
1073 static int validate_access(struct testcase *test, in validate_access() argument
1086 test->buffer = strdup(weare); in validate_access()
1087 test->rptr = test->buffer; /* set read pointer */ in validate_access()
1088 test->bufsize = count; /* set total count */ in validate_access()
1089 test->rcount = count; /* set data left to read */ in validate_access()
1121 test->testno = testno; in validate_access()
1123 (void)parse_servercmd(test); in validate_access()
1138 int error = getpart(&test->buffer, &count, "reply", partbuf, stream); in validate_access()
1144 if(test->buffer) { in validate_access()
1145 test->rptr = test->buffer; /* set read pointer */ in validate_access()
1146 test->bufsize = count; /* set total count */ in validate_access()
1147 test->rcount = count; /* set data left to read */ in validate_access()
1165 static void sendtftp(struct testcase *test, const struct formats *pf) in sendtftp() argument
1179 size = readit(test, (struct tftphdr **)&sdp, pf->f_convert); in sendtftp()
1190 if(test->writedelay) { in sendtftp()
1191 logmsg("Pausing %d seconds before %d bytes", test->writedelay, in sendtftp()
1193 wait_ms(1000*test->writedelay); in sendtftp()
1202 read_ahead(test, pf->f_convert); in sendtftp()
1246 static void recvtftp(struct testcase *test, const struct formats *pf) in recvtftp() argument
1274 write_behind(test, pf->f_convert); in recvtftp()
1306 size = writeit(test, &rdp, (int)(n - 4), pf->f_convert); in recvtftp()
1315 write_behind(test, pf->f_convert); in recvtftp()
1317 if(test->ofile > 0) { in recvtftp()
1318 close(test->ofile); in recvtftp()
1319 test->ofile = 0; in recvtftp()
1343 if(test->ofile > 0) { in recvtftp()
1344 close(test->ofile); in recvtftp()
1345 test->ofile = 0; in recvtftp()