-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestFS.pas
62 lines (55 loc) · 1.21 KB
/
TestFS.pas
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
unit TestFS;
INTERFACE
IMPLEMENTATION
USES ServerLoop,Chat,SysUtils,MemStream,NetAddr,opcode,Download,Store1,sha1;
type t=object
job:^tDownloadJob;
//procedure UserInput
procedure Periodic;
procedure Rekt;
procedure HardTimeout;
end;
procedure t.Periodic;
begin
write('TestFS: ',job^.state);
if job^.state>=stError then write(job^.error,'-',job^.error2);
writeln(' total=',job^.total,' done=',job^.done,' miss=',job^.missc);
if job^.state<>stActive then Rekt else
Shedule(800,@Periodic);
end;
procedure t.Rekt;
begin
writeln('TestFS: rekt');
Job^.Free;
UnShedule(@HardTimeout);
UnShedule(@Periodic);
FreeMem(@self,sizeof(self));
end;
procedure t.HardTimeout;
begin
writeln('TestFS: hardtimeout');
Rekt;
end;
procedure init;
var o:^t;
var oi:word;
var s:tMemoryStream;
const opt='-test-fs';
var fid:tFID;
begin
oi:=OptIndex(opt);
if oi>0 then begin
assert(OptParamCount(oi)=2,opt+'(rcpt:tNetAddr fid:sha1)');
fid:=tFID(paramstr(oi+2));
writeln('TestFS: rcpt '+paramstr(oi+1),' ',sha1print(fid));
new(o); with o^ do begin
//Shedule(15000,@HardTimeout);
Shedule(20,@Periodic);
job:=NewJob(paramstr(oi+1),fid);
if job^.state=stStop then job^.Start;
end;
end;
end;
BEGIN
init;
END.