-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusertests.asm
11852 lines (11218 loc) · 403 KB
/
usertests.asm
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
_usertests: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
return randstate;
}
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 0c sub $0xc,%esp
printf(1, "usertests starting\n");
11: 68 2a 59 00 00 push $0x592a
16: 6a 01 push $0x1
18: e8 f3 39 00 00 call 3a10 <printf>
if(open("usertests.ran", 0) >= 0){
1d: 5a pop %edx
1e: 59 pop %ecx
1f: 6a 00 push $0x0
21: 68 3e 59 00 00 push $0x593e
26: e8 b7 38 00 00 call 38e2 <open>
2b: 83 c4 10 add $0x10,%esp
2e: 85 c0 test %eax,%eax
30: 78 14 js 46 <main+0x46>
printf(1, "already ran user tests -- rebuild fs.img\n");
32: 83 ec 08 sub $0x8,%esp
35: 68 a8 60 00 00 push $0x60a8
3a: 6a 01 push $0x1
3c: e8 cf 39 00 00 call 3a10 <printf>
exit();
41: e8 5c 38 00 00 call 38a2 <exit>
}
close(open("usertests.ran", O_CREATE));
46: 50 push %eax
47: 50 push %eax
48: 68 00 02 00 00 push $0x200
4d: 68 3e 59 00 00 push $0x593e
52: e8 8b 38 00 00 call 38e2 <open>
57: 89 04 24 mov %eax,(%esp)
5a: e8 6b 38 00 00 call 38ca <close>
argptest();
5f: e8 6c 35 00 00 call 35d0 <argptest>
createdelete();
64: e8 87 11 00 00 call 11f0 <createdelete>
linkunlink();
69: e8 42 1a 00 00 call 1ab0 <linkunlink>
concreate();
6e: e8 2d 17 00 00 call 17a0 <concreate>
fourfiles();
73: e8 88 0f 00 00 call 1000 <fourfiles>
sharedfd();
78: e8 c3 0d 00 00 call e40 <sharedfd>
bigargtest();
7d: e8 ee 31 00 00 call 3270 <bigargtest>
bigwrite();
82: e8 49 23 00 00 call 23d0 <bigwrite>
bigargtest();
87: e8 e4 31 00 00 call 3270 <bigargtest>
bsstest();
8c: e8 6f 31 00 00 call 3200 <bsstest>
sbrktest();
91: e8 8a 2c 00 00 call 2d20 <sbrktest>
validatetest();
96: e8 b5 30 00 00 call 3150 <validatetest>
opentest();
9b: e8 50 03 00 00 call 3f0 <opentest>
writetest();
a0: e8 db 03 00 00 call 480 <writetest>
writetest1();
a5: e8 b6 05 00 00 call 660 <writetest1>
createtest();
aa: e8 81 07 00 00 call 830 <createtest>
openiputtest();
af: e8 3c 02 00 00 call 2f0 <openiputtest>
exitiputtest();
b4: e8 47 01 00 00 call 200 <exitiputtest>
iputtest();
b9: e8 62 00 00 00 call 120 <iputtest>
mem();
be: e8 ad 0c 00 00 call d70 <mem>
pipe1();
c3: e8 48 09 00 00 call a10 <pipe1>
preempt();
c8: e8 d3 0a 00 00 call ba0 <preempt>
exitwait();
cd: e8 0e 0c 00 00 call ce0 <exitwait>
rmdot();
d2: e8 e9 26 00 00 call 27c0 <rmdot>
fourteen();
d7: e8 a4 25 00 00 call 2680 <fourteen>
bigfile();
dc: e8 cf 23 00 00 call 24b0 <bigfile>
subdir();
e1: e8 0a 1c 00 00 call 1cf0 <subdir>
linktest();
e6: e8 a5 14 00 00 call 1590 <linktest>
unlinkread();
eb: e8 10 13 00 00 call 1400 <unlinkread>
dirfile();
f0: e8 4b 28 00 00 call 2940 <dirfile>
iref();
f5: e8 46 2a 00 00 call 2b40 <iref>
forktest();
fa: e8 61 2b 00 00 call 2c60 <forktest>
bigdir(); // slow
ff: e8 bc 1a 00 00 call 1bc0 <bigdir>
uio();
104: e8 57 34 00 00 call 3560 <uio>
exectest();
109: e8 b2 08 00 00 call 9c0 <exectest>
exit();
10e: e8 8f 37 00 00 call 38a2 <exit>
113: 66 90 xchg %ax,%ax
115: 66 90 xchg %ax,%ax
117: 66 90 xchg %ax,%ax
119: 66 90 xchg %ax,%ax
11b: 66 90 xchg %ax,%ax
11d: 66 90 xchg %ax,%ax
11f: 90 nop
00000120 <iputtest>:
int stdout = 1;
// does chdir() call iput(p->cwd) in a transaction?
void
iputtest(void)
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 83 ec 10 sub $0x10,%esp
printf(stdout, "iput test\n");
126: 68 d0 49 00 00 push $0x49d0
12b: ff 35 a0 71 00 00 pushl 0x71a0
131: e8 da 38 00 00 call 3a10 <printf>
if(mkdir("iputdir") < 0){
136: c7 04 24 63 49 00 00 movl $0x4963,(%esp)
13d: e8 c8 37 00 00 call 390a <mkdir>
142: 83 c4 10 add $0x10,%esp
145: 85 c0 test %eax,%eax
147: 78 58 js 1a1 <iputtest+0x81>
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
149: 83 ec 0c sub $0xc,%esp
14c: 68 63 49 00 00 push $0x4963
151: e8 bc 37 00 00 call 3912 <chdir>
156: 83 c4 10 add $0x10,%esp
159: 85 c0 test %eax,%eax
15b: 0f 88 85 00 00 00 js 1e6 <iputtest+0xc6>
printf(stdout, "chdir iputdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
161: 83 ec 0c sub $0xc,%esp
164: 68 60 49 00 00 push $0x4960
169: e8 84 37 00 00 call 38f2 <unlink>
16e: 83 c4 10 add $0x10,%esp
171: 85 c0 test %eax,%eax
173: 78 5a js 1cf <iputtest+0xaf>
printf(stdout, "unlink ../iputdir failed\n");
exit();
}
if(chdir("/") < 0){
175: 83 ec 0c sub $0xc,%esp
178: 68 85 49 00 00 push $0x4985
17d: e8 90 37 00 00 call 3912 <chdir>
182: 83 c4 10 add $0x10,%esp
185: 85 c0 test %eax,%eax
187: 78 2f js 1b8 <iputtest+0x98>
printf(stdout, "chdir / failed\n");
exit();
}
printf(stdout, "iput test ok\n");
189: 83 ec 08 sub $0x8,%esp
18c: 68 08 4a 00 00 push $0x4a08
191: ff 35 a0 71 00 00 pushl 0x71a0
197: e8 74 38 00 00 call 3a10 <printf>
}
19c: 83 c4 10 add $0x10,%esp
19f: c9 leave
1a0: c3 ret
iputtest(void)
{
printf(stdout, "iput test\n");
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
1a1: 50 push %eax
1a2: 50 push %eax
1a3: 68 3c 49 00 00 push $0x493c
1a8: ff 35 a0 71 00 00 pushl 0x71a0
1ae: e8 5d 38 00 00 call 3a10 <printf>
exit();
1b3: e8 ea 36 00 00 call 38a2 <exit>
if(unlink("../iputdir") < 0){
printf(stdout, "unlink ../iputdir failed\n");
exit();
}
if(chdir("/") < 0){
printf(stdout, "chdir / failed\n");
1b8: 50 push %eax
1b9: 50 push %eax
1ba: 68 87 49 00 00 push $0x4987
1bf: ff 35 a0 71 00 00 pushl 0x71a0
1c5: e8 46 38 00 00 call 3a10 <printf>
exit();
1ca: e8 d3 36 00 00 call 38a2 <exit>
if(chdir("iputdir") < 0){
printf(stdout, "chdir iputdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
printf(stdout, "unlink ../iputdir failed\n");
1cf: 52 push %edx
1d0: 52 push %edx
1d1: 68 6b 49 00 00 push $0x496b
1d6: ff 35 a0 71 00 00 pushl 0x71a0
1dc: e8 2f 38 00 00 call 3a10 <printf>
exit();
1e1: e8 bc 36 00 00 call 38a2 <exit>
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
printf(stdout, "chdir iputdir failed\n");
1e6: 51 push %ecx
1e7: 51 push %ecx
1e8: 68 4a 49 00 00 push $0x494a
1ed: ff 35 a0 71 00 00 pushl 0x71a0
1f3: e8 18 38 00 00 call 3a10 <printf>
exit();
1f8: e8 a5 36 00 00 call 38a2 <exit>
1fd: 8d 76 00 lea 0x0(%esi),%esi
00000200 <exitiputtest>:
}
// does exit() call iput(p->cwd) in a transaction?
void
exitiputtest(void)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 83 ec 10 sub $0x10,%esp
int pid;
printf(stdout, "exitiput test\n");
206: 68 97 49 00 00 push $0x4997
20b: ff 35 a0 71 00 00 pushl 0x71a0
211: e8 fa 37 00 00 call 3a10 <printf>
pid = fork();
216: e8 7f 36 00 00 call 389a <fork>
if(pid < 0){
21b: 83 c4 10 add $0x10,%esp
21e: 85 c0 test %eax,%eax
220: 0f 88 82 00 00 00 js 2a8 <exitiputtest+0xa8>
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
226: 75 48 jne 270 <exitiputtest+0x70>
if(mkdir("iputdir") < 0){
228: 83 ec 0c sub $0xc,%esp
22b: 68 63 49 00 00 push $0x4963
230: e8 d5 36 00 00 call 390a <mkdir>
235: 83 c4 10 add $0x10,%esp
238: 85 c0 test %eax,%eax
23a: 0f 88 96 00 00 00 js 2d6 <exitiputtest+0xd6>
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
240: 83 ec 0c sub $0xc,%esp
243: 68 63 49 00 00 push $0x4963
248: e8 c5 36 00 00 call 3912 <chdir>
24d: 83 c4 10 add $0x10,%esp
250: 85 c0 test %eax,%eax
252: 78 6b js 2bf <exitiputtest+0xbf>
printf(stdout, "child chdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
254: 83 ec 0c sub $0xc,%esp
257: 68 60 49 00 00 push $0x4960
25c: e8 91 36 00 00 call 38f2 <unlink>
261: 83 c4 10 add $0x10,%esp
264: 85 c0 test %eax,%eax
266: 78 28 js 290 <exitiputtest+0x90>
printf(stdout, "unlink ../iputdir failed\n");
exit();
}
exit();
268: e8 35 36 00 00 call 38a2 <exit>
26d: 8d 76 00 lea 0x0(%esi),%esi
}
wait();
270: e8 35 36 00 00 call 38aa <wait>
printf(stdout, "exitiput test ok\n");
275: 83 ec 08 sub $0x8,%esp
278: 68 ba 49 00 00 push $0x49ba
27d: ff 35 a0 71 00 00 pushl 0x71a0
283: e8 88 37 00 00 call 3a10 <printf>
}
288: 83 c4 10 add $0x10,%esp
28b: c9 leave
28c: c3 ret
28d: 8d 76 00 lea 0x0(%esi),%esi
if(chdir("iputdir") < 0){
printf(stdout, "child chdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
printf(stdout, "unlink ../iputdir failed\n");
290: 83 ec 08 sub $0x8,%esp
293: 68 6b 49 00 00 push $0x496b
298: ff 35 a0 71 00 00 pushl 0x71a0
29e: e8 6d 37 00 00 call 3a10 <printf>
exit();
2a3: e8 fa 35 00 00 call 38a2 <exit>
printf(stdout, "exitiput test\n");
pid = fork();
if(pid < 0){
printf(stdout, "fork failed\n");
2a8: 51 push %ecx
2a9: 51 push %ecx
2aa: 68 7d 58 00 00 push $0x587d
2af: ff 35 a0 71 00 00 pushl 0x71a0
2b5: e8 56 37 00 00 call 3a10 <printf>
exit();
2ba: e8 e3 35 00 00 call 38a2 <exit>
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
printf(stdout, "child chdir failed\n");
2bf: 50 push %eax
2c0: 50 push %eax
2c1: 68 a6 49 00 00 push $0x49a6
2c6: ff 35 a0 71 00 00 pushl 0x71a0
2cc: e8 3f 37 00 00 call 3a10 <printf>
exit();
2d1: e8 cc 35 00 00 call 38a2 <exit>
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
2d6: 52 push %edx
2d7: 52 push %edx
2d8: 68 3c 49 00 00 push $0x493c
2dd: ff 35 a0 71 00 00 pushl 0x71a0
2e3: e8 28 37 00 00 call 3a10 <printf>
exit();
2e8: e8 b5 35 00 00 call 38a2 <exit>
2ed: 8d 76 00 lea 0x0(%esi),%esi
000002f0 <openiputtest>:
// for(i = 0; i < 10000; i++)
// yield();
// }
void
openiputtest(void)
{
2f0: 55 push %ebp
2f1: 89 e5 mov %esp,%ebp
2f3: 83 ec 10 sub $0x10,%esp
int pid;
printf(stdout, "openiput test\n");
2f6: 68 cc 49 00 00 push $0x49cc
2fb: ff 35 a0 71 00 00 pushl 0x71a0
301: e8 0a 37 00 00 call 3a10 <printf>
if(mkdir("oidir") < 0){
306: c7 04 24 db 49 00 00 movl $0x49db,(%esp)
30d: e8 f8 35 00 00 call 390a <mkdir>
312: 83 c4 10 add $0x10,%esp
315: 85 c0 test %eax,%eax
317: 0f 88 88 00 00 00 js 3a5 <openiputtest+0xb5>
printf(stdout, "mkdir oidir failed\n");
exit();
}
pid = fork();
31d: e8 78 35 00 00 call 389a <fork>
if(pid < 0){
322: 85 c0 test %eax,%eax
324: 0f 88 92 00 00 00 js 3bc <openiputtest+0xcc>
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
32a: 75 34 jne 360 <openiputtest+0x70>
int fd = open("oidir", O_RDWR);
32c: 83 ec 08 sub $0x8,%esp
32f: 6a 02 push $0x2
331: 68 db 49 00 00 push $0x49db
336: e8 a7 35 00 00 call 38e2 <open>
if(fd >= 0){
33b: 83 c4 10 add $0x10,%esp
33e: 85 c0 test %eax,%eax
340: 78 5e js 3a0 <openiputtest+0xb0>
printf(stdout, "open directory for write succeeded\n");
342: 83 ec 08 sub $0x8,%esp
345: 68 60 59 00 00 push $0x5960
34a: ff 35 a0 71 00 00 pushl 0x71a0
350: e8 bb 36 00 00 call 3a10 <printf>
exit();
355: e8 48 35 00 00 call 38a2 <exit>
35a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
}
exit();
}
sleep(1);
360: 83 ec 0c sub $0xc,%esp
363: 6a 01 push $0x1
365: e8 c8 35 00 00 call 3932 <sleep>
if(unlink("oidir") != 0){
36a: c7 04 24 db 49 00 00 movl $0x49db,(%esp)
371: e8 7c 35 00 00 call 38f2 <unlink>
376: 83 c4 10 add $0x10,%esp
379: 85 c0 test %eax,%eax
37b: 75 56 jne 3d3 <openiputtest+0xe3>
printf(stdout, "unlink failed\n");
exit();
}
wait();
37d: e8 28 35 00 00 call 38aa <wait>
printf(stdout, "openiput test ok\n");
382: 83 ec 08 sub $0x8,%esp
385: 68 04 4a 00 00 push $0x4a04
38a: ff 35 a0 71 00 00 pushl 0x71a0
390: e8 7b 36 00 00 call 3a10 <printf>
395: 83 c4 10 add $0x10,%esp
}
398: c9 leave
399: c3 ret
39a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
int fd = open("oidir", O_RDWR);
if(fd >= 0){
printf(stdout, "open directory for write succeeded\n");
exit();
}
exit();
3a0: e8 fd 34 00 00 call 38a2 <exit>
{
int pid;
printf(stdout, "openiput test\n");
if(mkdir("oidir") < 0){
printf(stdout, "mkdir oidir failed\n");
3a5: 51 push %ecx
3a6: 51 push %ecx
3a7: 68 e1 49 00 00 push $0x49e1
3ac: ff 35 a0 71 00 00 pushl 0x71a0
3b2: e8 59 36 00 00 call 3a10 <printf>
exit();
3b7: e8 e6 34 00 00 call 38a2 <exit>
}
pid = fork();
if(pid < 0){
printf(stdout, "fork failed\n");
3bc: 52 push %edx
3bd: 52 push %edx
3be: 68 7d 58 00 00 push $0x587d
3c3: ff 35 a0 71 00 00 pushl 0x71a0
3c9: e8 42 36 00 00 call 3a10 <printf>
exit();
3ce: e8 cf 34 00 00 call 38a2 <exit>
}
exit();
}
sleep(1);
if(unlink("oidir") != 0){
printf(stdout, "unlink failed\n");
3d3: 50 push %eax
3d4: 50 push %eax
3d5: 68 f5 49 00 00 push $0x49f5
3da: ff 35 a0 71 00 00 pushl 0x71a0
3e0: e8 2b 36 00 00 call 3a10 <printf>
exit();
3e5: e8 b8 34 00 00 call 38a2 <exit>
3ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000003f0 <opentest>:
// simple file system tests
void
opentest(void)
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 83 ec 10 sub $0x10,%esp
int fd;
printf(stdout, "open test\n");
3f6: 68 16 4a 00 00 push $0x4a16
3fb: ff 35 a0 71 00 00 pushl 0x71a0
401: e8 0a 36 00 00 call 3a10 <printf>
fd = open("echo", 0);
406: 58 pop %eax
407: 5a pop %edx
408: 6a 00 push $0x0
40a: 68 21 4a 00 00 push $0x4a21
40f: e8 ce 34 00 00 call 38e2 <open>
if(fd < 0){
414: 83 c4 10 add $0x10,%esp
417: 85 c0 test %eax,%eax
419: 78 36 js 451 <opentest+0x61>
printf(stdout, "open echo failed!\n");
exit();
}
close(fd);
41b: 83 ec 0c sub $0xc,%esp
41e: 50 push %eax
41f: e8 a6 34 00 00 call 38ca <close>
fd = open("doesnotexist", 0);
424: 5a pop %edx
425: 59 pop %ecx
426: 6a 00 push $0x0
428: 68 39 4a 00 00 push $0x4a39
42d: e8 b0 34 00 00 call 38e2 <open>
if(fd >= 0){
432: 83 c4 10 add $0x10,%esp
435: 85 c0 test %eax,%eax
437: 79 2f jns 468 <opentest+0x78>
printf(stdout, "open doesnotexist succeeded!\n");
exit();
}
printf(stdout, "open test ok\n");
439: 83 ec 08 sub $0x8,%esp
43c: 68 64 4a 00 00 push $0x4a64
441: ff 35 a0 71 00 00 pushl 0x71a0
447: e8 c4 35 00 00 call 3a10 <printf>
}
44c: 83 c4 10 add $0x10,%esp
44f: c9 leave
450: c3 ret
int fd;
printf(stdout, "open test\n");
fd = open("echo", 0);
if(fd < 0){
printf(stdout, "open echo failed!\n");
451: 50 push %eax
452: 50 push %eax
453: 68 26 4a 00 00 push $0x4a26
458: ff 35 a0 71 00 00 pushl 0x71a0
45e: e8 ad 35 00 00 call 3a10 <printf>
exit();
463: e8 3a 34 00 00 call 38a2 <exit>
}
close(fd);
fd = open("doesnotexist", 0);
if(fd >= 0){
printf(stdout, "open doesnotexist succeeded!\n");
468: 50 push %eax
469: 50 push %eax
46a: 68 46 4a 00 00 push $0x4a46
46f: ff 35 a0 71 00 00 pushl 0x71a0
475: e8 96 35 00 00 call 3a10 <printf>
exit();
47a: e8 23 34 00 00 call 38a2 <exit>
47f: 90 nop
00000480 <writetest>:
printf(stdout, "open test ok\n");
}
void
writetest(void)
{
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 56 push %esi
484: 53 push %ebx
int fd;
int i;
printf(stdout, "small file test\n");
485: 83 ec 08 sub $0x8,%esp
488: 68 72 4a 00 00 push $0x4a72
48d: ff 35 a0 71 00 00 pushl 0x71a0
493: e8 78 35 00 00 call 3a10 <printf>
fd = open("small", O_CREATE|O_RDWR);
498: 59 pop %ecx
499: 5b pop %ebx
49a: 68 02 02 00 00 push $0x202
49f: 68 83 4a 00 00 push $0x4a83
4a4: e8 39 34 00 00 call 38e2 <open>
if(fd >= 0){
4a9: 83 c4 10 add $0x10,%esp
4ac: 85 c0 test %eax,%eax
4ae: 0f 88 8b 01 00 00 js 63f <writetest+0x1bf>
printf(stdout, "creat small succeeded; ok\n");
4b4: 83 ec 08 sub $0x8,%esp
4b7: 89 c6 mov %eax,%esi
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
4b9: 31 db xor %ebx,%ebx
int i;
printf(stdout, "small file test\n");
fd = open("small", O_CREATE|O_RDWR);
if(fd >= 0){
printf(stdout, "creat small succeeded; ok\n");
4bb: 68 89 4a 00 00 push $0x4a89
4c0: ff 35 a0 71 00 00 pushl 0x71a0
4c6: e8 45 35 00 00 call 3a10 <printf>
4cb: 83 c4 10 add $0x10,%esp
4ce: 66 90 xchg %ax,%ax
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
if(write(fd, "aaaaaaaaaa", 10) != 10){
4d0: 83 ec 04 sub $0x4,%esp
4d3: 6a 0a push $0xa
4d5: 68 c0 4a 00 00 push $0x4ac0
4da: 56 push %esi
4db: e8 e2 33 00 00 call 38c2 <write>
4e0: 83 c4 10 add $0x10,%esp
4e3: 83 f8 0a cmp $0xa,%eax
4e6: 0f 85 d9 00 00 00 jne 5c5 <writetest+0x145>
printf(stdout, "error: write aa %d new file failed\n", i);
exit();
}
if(write(fd, "bbbbbbbbbb", 10) != 10){
4ec: 83 ec 04 sub $0x4,%esp
4ef: 6a 0a push $0xa
4f1: 68 cb 4a 00 00 push $0x4acb
4f6: 56 push %esi
4f7: e8 c6 33 00 00 call 38c2 <write>
4fc: 83 c4 10 add $0x10,%esp
4ff: 83 f8 0a cmp $0xa,%eax
502: 0f 85 d6 00 00 00 jne 5de <writetest+0x15e>
printf(stdout, "creat small succeeded; ok\n");
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
508: 83 c3 01 add $0x1,%ebx
50b: 83 fb 64 cmp $0x64,%ebx
50e: 75 c0 jne 4d0 <writetest+0x50>
if(write(fd, "bbbbbbbbbb", 10) != 10){
printf(stdout, "error: write bb %d new file failed\n", i);
exit();
}
}
printf(stdout, "writes ok\n");
510: 83 ec 08 sub $0x8,%esp
513: 68 d6 4a 00 00 push $0x4ad6
518: ff 35 a0 71 00 00 pushl 0x71a0
51e: e8 ed 34 00 00 call 3a10 <printf>
close(fd);
523: 89 34 24 mov %esi,(%esp)
526: e8 9f 33 00 00 call 38ca <close>
fd = open("small", O_RDONLY);
52b: 58 pop %eax
52c: 5a pop %edx
52d: 6a 00 push $0x0
52f: 68 83 4a 00 00 push $0x4a83
534: e8 a9 33 00 00 call 38e2 <open>
if(fd >= 0){
539: 83 c4 10 add $0x10,%esp
53c: 85 c0 test %eax,%eax
exit();
}
}
printf(stdout, "writes ok\n");
close(fd);
fd = open("small", O_RDONLY);
53e: 89 c3 mov %eax,%ebx
if(fd >= 0){
540: 0f 88 b1 00 00 00 js 5f7 <writetest+0x177>
printf(stdout, "open small succeeded ok\n");
546: 83 ec 08 sub $0x8,%esp
549: 68 e1 4a 00 00 push $0x4ae1
54e: ff 35 a0 71 00 00 pushl 0x71a0
554: e8 b7 34 00 00 call 3a10 <printf>
} else {
printf(stdout, "error: open small failed!\n");
exit();
}
i = read(fd, buf, 2000);
559: 83 c4 0c add $0xc,%esp
55c: 68 d0 07 00 00 push $0x7d0
561: 68 80 99 00 00 push $0x9980
566: 53 push %ebx
567: e8 4e 33 00 00 call 38ba <read>
if(i == 2000){
56c: 83 c4 10 add $0x10,%esp
56f: 3d d0 07 00 00 cmp $0x7d0,%eax
574: 0f 85 95 00 00 00 jne 60f <writetest+0x18f>
printf(stdout, "read succeeded ok\n");
57a: 83 ec 08 sub $0x8,%esp
57d: 68 15 4b 00 00 push $0x4b15
582: ff 35 a0 71 00 00 pushl 0x71a0
588: e8 83 34 00 00 call 3a10 <printf>
} else {
printf(stdout, "read failed\n");
exit();
}
close(fd);
58d: 89 1c 24 mov %ebx,(%esp)
590: e8 35 33 00 00 call 38ca <close>
if(unlink("small") < 0){
595: c7 04 24 83 4a 00 00 movl $0x4a83,(%esp)
59c: e8 51 33 00 00 call 38f2 <unlink>
5a1: 83 c4 10 add $0x10,%esp
5a4: 85 c0 test %eax,%eax
5a6: 78 7f js 627 <writetest+0x1a7>
printf(stdout, "unlink small failed\n");
exit();
}
printf(stdout, "small file test ok\n");
5a8: 83 ec 08 sub $0x8,%esp
5ab: 68 3d 4b 00 00 push $0x4b3d
5b0: ff 35 a0 71 00 00 pushl 0x71a0
5b6: e8 55 34 00 00 call 3a10 <printf>
}
5bb: 83 c4 10 add $0x10,%esp
5be: 8d 65 f8 lea -0x8(%ebp),%esp
5c1: 5b pop %ebx
5c2: 5e pop %esi
5c3: 5d pop %ebp
5c4: c3 ret
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
if(write(fd, "aaaaaaaaaa", 10) != 10){
printf(stdout, "error: write aa %d new file failed\n", i);
5c5: 83 ec 04 sub $0x4,%esp
5c8: 53 push %ebx
5c9: 68 84 59 00 00 push $0x5984
5ce: ff 35 a0 71 00 00 pushl 0x71a0
5d4: e8 37 34 00 00 call 3a10 <printf>
exit();
5d9: e8 c4 32 00 00 call 38a2 <exit>
}
if(write(fd, "bbbbbbbbbb", 10) != 10){
printf(stdout, "error: write bb %d new file failed\n", i);
5de: 83 ec 04 sub $0x4,%esp
5e1: 53 push %ebx
5e2: 68 a8 59 00 00 push $0x59a8
5e7: ff 35 a0 71 00 00 pushl 0x71a0
5ed: e8 1e 34 00 00 call 3a10 <printf>
exit();
5f2: e8 ab 32 00 00 call 38a2 <exit>
close(fd);
fd = open("small", O_RDONLY);
if(fd >= 0){
printf(stdout, "open small succeeded ok\n");
} else {
printf(stdout, "error: open small failed!\n");
5f7: 83 ec 08 sub $0x8,%esp
5fa: 68 fa 4a 00 00 push $0x4afa
5ff: ff 35 a0 71 00 00 pushl 0x71a0
605: e8 06 34 00 00 call 3a10 <printf>
exit();
60a: e8 93 32 00 00 call 38a2 <exit>
}
i = read(fd, buf, 2000);
if(i == 2000){
printf(stdout, "read succeeded ok\n");
} else {
printf(stdout, "read failed\n");
60f: 83 ec 08 sub $0x8,%esp
612: 68 41 4e 00 00 push $0x4e41
617: ff 35 a0 71 00 00 pushl 0x71a0
61d: e8 ee 33 00 00 call 3a10 <printf>
exit();
622: e8 7b 32 00 00 call 38a2 <exit>
}
close(fd);
if(unlink("small") < 0){
printf(stdout, "unlink small failed\n");
627: 83 ec 08 sub $0x8,%esp
62a: 68 28 4b 00 00 push $0x4b28
62f: ff 35 a0 71 00 00 pushl 0x71a0
635: e8 d6 33 00 00 call 3a10 <printf>
exit();
63a: e8 63 32 00 00 call 38a2 <exit>
printf(stdout, "small file test\n");
fd = open("small", O_CREATE|O_RDWR);
if(fd >= 0){
printf(stdout, "creat small succeeded; ok\n");
} else {
printf(stdout, "error: creat small failed!\n");
63f: 83 ec 08 sub $0x8,%esp
642: 68 a4 4a 00 00 push $0x4aa4
647: ff 35 a0 71 00 00 pushl 0x71a0
64d: e8 be 33 00 00 call 3a10 <printf>
exit();
652: e8 4b 32 00 00 call 38a2 <exit>
657: 89 f6 mov %esi,%esi
659: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000660 <writetest1>:
printf(stdout, "small file test ok\n");
}
void
writetest1(void)
{
660: 55 push %ebp
661: 89 e5 mov %esp,%ebp
663: 56 push %esi
664: 53 push %ebx
int i, fd, n;
printf(stdout, "big files test\n");
665: 83 ec 08 sub $0x8,%esp
668: 68 51 4b 00 00 push $0x4b51
66d: ff 35 a0 71 00 00 pushl 0x71a0
673: e8 98 33 00 00 call 3a10 <printf>
fd = open("big", O_CREATE|O_RDWR);
678: 59 pop %ecx
679: 5b pop %ebx
67a: 68 02 02 00 00 push $0x202
67f: 68 cb 4b 00 00 push $0x4bcb
684: e8 59 32 00 00 call 38e2 <open>
if(fd < 0){
689: 83 c4 10 add $0x10,%esp
68c: 85 c0 test %eax,%eax
68e: 0f 88 64 01 00 00 js 7f8 <writetest1+0x198>
694: 89 c6 mov %eax,%esi
696: 31 db xor %ebx,%ebx
698: 90 nop
699: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
exit();
}
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
if(write(fd, buf, 512) != 512){
6a0: 83 ec 04 sub $0x4,%esp
printf(stdout, "error: creat big failed!\n");
exit();
}
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
6a3: 89 1d 80 99 00 00 mov %ebx,0x9980
if(write(fd, buf, 512) != 512){
6a9: 68 00 02 00 00 push $0x200
6ae: 68 80 99 00 00 push $0x9980
6b3: 56 push %esi
6b4: e8 09 32 00 00 call 38c2 <write>
6b9: 83 c4 10 add $0x10,%esp
6bc: 3d 00 02 00 00 cmp $0x200,%eax
6c1: 0f 85 b3 00 00 00 jne 77a <writetest1+0x11a>
if(fd < 0){
printf(stdout, "error: creat big failed!\n");
exit();
}
for(i = 0; i < MAXFILE; i++){
6c7: 83 c3 01 add $0x1,%ebx
6ca: 81 fb 8c 00 00 00 cmp $0x8c,%ebx
6d0: 75 ce jne 6a0 <writetest1+0x40>
printf(stdout, "error: write big file failed\n", i);
exit();
}
}
close(fd);
6d2: 83 ec 0c sub $0xc,%esp
6d5: 56 push %esi
6d6: e8 ef 31 00 00 call 38ca <close>
fd = open("big", O_RDONLY);
6db: 58 pop %eax
6dc: 5a pop %edx
6dd: 6a 00 push $0x0
6df: 68 cb 4b 00 00 push $0x4bcb
6e4: e8 f9 31 00 00 call 38e2 <open>
if(fd < 0){
6e9: 83 c4 10 add $0x10,%esp
6ec: 85 c0 test %eax,%eax
}
}
close(fd);
fd = open("big", O_RDONLY);
6ee: 89 c6 mov %eax,%esi
if(fd < 0){
6f0: 0f 88 ea 00 00 00 js 7e0 <writetest1+0x180>
6f6: 31 db xor %ebx,%ebx
6f8: eb 1d jmp 717 <writetest1+0xb7>
6fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(n == MAXFILE - 1){
printf(stdout, "read only %d blocks from big", n);
exit();
}
break;
} else if(i != 512){
700: 3d 00 02 00 00 cmp $0x200,%eax
705: 0f 85 9f 00 00 00 jne 7aa <writetest1+0x14a>
printf(stdout, "read failed %d\n", i);
exit();
}
if(((int*)buf)[0] != n){
70b: a1 80 99 00 00 mov 0x9980,%eax
710: 39 c3 cmp %eax,%ebx
712: 75 7f jne 793 <writetest1+0x133>
printf(stdout, "read content of block %d is %d\n",
n, ((int*)buf)[0]);
exit();
}
n++;
714: 83 c3 01 add $0x1,%ebx
exit();
}
n = 0;
for(;;){
i = read(fd, buf, 512);
717: 83 ec 04 sub $0x4,%esp
71a: 68 00 02 00 00 push $0x200
71f: 68 80 99 00 00 push $0x9980
724: 56 push %esi
725: e8 90 31 00 00 call 38ba <read>
if(i == 0){
72a: 83 c4 10 add $0x10,%esp
72d: 85 c0 test %eax,%eax
72f: 75 cf jne 700 <writetest1+0xa0>
if(n == MAXFILE - 1){
731: 81 fb 8b 00 00 00 cmp $0x8b,%ebx
737: 0f 84 86 00 00 00 je 7c3 <writetest1+0x163>
n, ((int*)buf)[0]);
exit();
}
n++;
}
close(fd);
73d: 83 ec 0c sub $0xc,%esp
740: 56 push %esi
741: e8 84 31 00 00 call 38ca <close>
if(unlink("big") < 0){
746: c7 04 24 cb 4b 00 00 movl $0x4bcb,(%esp)
74d: e8 a0 31 00 00 call 38f2 <unlink>
752: 83 c4 10 add $0x10,%esp
755: 85 c0 test %eax,%eax
757: 0f 88 b3 00 00 00 js 810 <writetest1+0x1b0>
printf(stdout, "unlink big failed\n");
exit();
}
printf(stdout, "big files ok\n");
75d: 83 ec 08 sub $0x8,%esp
760: 68 f2 4b 00 00 push $0x4bf2
765: ff 35 a0 71 00 00 pushl 0x71a0
76b: e8 a0 32 00 00 call 3a10 <printf>
}
770: 83 c4 10 add $0x10,%esp
773: 8d 65 f8 lea -0x8(%ebp),%esp
776: 5b pop %ebx
777: 5e pop %esi
778: 5d pop %ebp
779: c3 ret
}
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;