2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <exec/types.h>
7 #include <dos/dosextens.h>
9 #include <proto/exec.h>
10 #include <proto/dos.h>
15 void hexdump(UBYTE
*buf
, int size
) {
19 for (i
= 0; i
< size
; i
+= CHUNK
) {
22 count
= ((size
-i
) > CHUNK
? CHUNK
: size
-i
);
24 for (j
= 0; j
< count
; j
++) {
25 if (j
== CHUNK
/ 2) fputc(' ', stdout
);
26 printf("%02x ", buf
[i
+j
]);
29 for (j
= count
; j
< CHUNK
; j
++) {
30 if (j
== CHUNK
/ 2) fputc(' ', stdout
);
38 int round1(char *filename
) {
44 fputs("\nround 1: 1024 buffers of 1024 bytes each\n\n", stdout
);
46 fh
= Open(filename
, MODE_NEWFILE
);
48 printf("couldn't open '%s' for write (%ld)\n", filename
, (long)IoErr());
52 printf("opened '%s' for write\n", filename
);
54 fputs("writing... ", stdout
);
57 for (n
= 0; n
< 1024; n
++) {
58 for (i
= 0; i
< 1024; i
++)
59 buf
[i
] = (i
+ n
) & 0xff;
61 bytes
= Write(fh
, buf
, 1024);
63 printf("buffer %d: error (%ld)\n", n
, (long)IoErr());
69 printf("buffer %d: short write! error is %ld\n", n
, (long)IoErr());
75 fputs("1024 buffers written\n", stdout
);
79 fh
= Open(filename
, MODE_OLDFILE
);
81 printf("couldn't open '%s' for read (%ld)\n", filename
, (long)IoErr());
85 printf("opened '%s' for read\n", filename
);
87 fputs("reading... ", stdout
);
90 for (n
= 0; n
< 1024; n
++) {
91 bytes
= Read(fh
, buf
, 1024);
93 printf("buffer %d: error (%ld)\n", n
, (long)IoErr());
98 printf("buffer %d: short read! error is %ld\n", n
, (long)IoErr());
103 for (i
= 0; i
< 1024; i
++)
104 if (buf
[i
] != ((i
+ n
) & 0xff)) {
105 printf("buffer %d: verify error!\n file pos %d, expected 0x%02x, got 0x%02x\n", n
, n
* 1024 + i
, ((i
+ n
) & 0xff), buf
[i
]);
106 printf("buffer dump (0x%02x bytes):\n", 1024);
113 fputs("1024 buffers read and verified\n", stdout
);
117 DeleteFile(filename
);
119 fputs("cleaned up\n", stdout
);
124 int round2(char *filename
) {
130 fputs("\nround 2: 8192 buffers, increasing length from 0-1023 bytes\n\n", stdout
);
132 fh
= Open(filename
, MODE_NEWFILE
);
134 printf("couldn't open '%s' for write (%ld)\n", filename
, (long)IoErr());
138 printf("opened '%s' for write\n", filename
);
140 fputs("writing... ", stdout
);
143 for (n
= 0; n
< 8192; n
++) {
144 for (i
= 0; i
< (n
& 1023); i
++)
145 buf
[i
] = (i
+ n
) & 0xff;
147 bytes
= Write(fh
, buf
, (n
& 1023));
149 printf("buffer %d: error (%ld)\n", n
, (long)IoErr());
154 if (bytes
< (n
& 1023)) {
155 printf("buffer %d: short write! error is %ld\n", n
, (long)IoErr());
161 fputs("1024 buffers written\n", stdout
);
165 fh
= Open(filename
, MODE_OLDFILE
);
167 printf("couldn't open '%s' for read (%ld)\n", filename
, (long)IoErr());
171 printf("opened '%s' for read\n", filename
);
173 fputs("reading... ", stdout
);
176 for (n
= 0; n
< 8192; n
++) {
177 bytes
= Read(fh
, buf
, (n
& 1023));
179 printf("buffer %d: error (%ld)\n", n
, (long)IoErr());
183 if (bytes
< (n
& 1023)) {
184 printf("buffer %d: short read! error is %ld\n", n
, (long)IoErr());
189 for (i
= 0; i
< (n
& 1023); i
++)
190 if (buf
[i
] != ((i
+ n
) & 0xff)) {
191 printf("buffer %d: verify error!\n file pos %d, expected 0x%02x, got 0x%02x\n", n
, n
* (n
& 1023) + i
, ((i
+ n
) & 0xff), buf
[i
]);
192 printf("buffer dump (0x%02x bytes):\n", (n
& 1023));
199 fputs("8192 buffers read and verified\n", stdout
);
203 //DeleteFile(filename);
205 fputs("cleaned up\n", stdout
);
210 int main(int argc
, char **argv
) {
212 printf("usage: %s filename\n", argv
[0]);
216 if (round1(argv
[1]) || round2(argv
[1]))