Skip to content
Snippets Groups Projects
Commit dc4f0810 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Improved diagnostics.

Rev: src/modules/files/sendfiletest.pike:1.5
parent 02c4802d
No related branches found
No related tags found
No related merge requests found
#!/usr/local/bin/pike #!/usr/local/bin/pike
/* $Id: sendfiletest.pike,v 1.4 2000/10/07 11:34:28 grubba Exp $ */ /* $Id: sendfiletest.pike,v 1.5 2000/10/07 12:00:23 grubba Exp $ */
constant TEST_SIZE = 16384; constant TEST_SIZE = 16384;
...@@ -51,6 +51,27 @@ array(object(Stdio.File)) SocketPair() ...@@ -51,6 +51,27 @@ array(object(Stdio.File)) SocketPair()
return ({ sock1, sock2 }); return ({ sock1, sock2 });
} }
void Verify()
{
array(string) data = From("conftest.dst")->read()/TEST_SIZE;
int i;
for(i=0; i < sizeof(data); i++) {
if (data[i] != testdata) {
werror("Segment %d corrupted!\n", i);
int j;
for (j=0; j < TEST_SIZE; j++) {
if (data[i][j] != testdata[j]) {
werror("First corrupt byte at segment offset %d: 0x%02x != 0x%02x\n",
j, data[i][j], testdata[j]);
exit(1);
}
}
werror("Corrupt byte not found!\n");
exit(1);
}
}
}
/* /*
* The driver function. * The driver function.
*/ */
...@@ -113,12 +134,7 @@ void test2() ...@@ -113,12 +134,7 @@ void test2()
void test3() void test3()
{ {
/* Check that the testdata still is correct. */ Verify();
if (From("conftest.dst")->read() != testdata) {
werror("Data corruption!\n");
exit(1);
}
/* Try with a headers + file + trailers combo. */ /* Try with a headers + file + trailers combo. */
...@@ -131,12 +147,7 @@ void test3() ...@@ -131,12 +147,7 @@ void test3()
void test4() void test4()
{ {
/* Check that the testdata still is correct. */ Verify();
if (From("conftest.dst")->read() != testdata*3) {
werror("Data corruption!\n");
exit(1);
}
/* Try a loopback test. */ /* Try a loopback test. */
...@@ -164,12 +175,7 @@ void test5() ...@@ -164,12 +175,7 @@ void test5()
void test6() void test6()
{ {
/* Check that the testdata still is correct. */ Verify();
if (From("conftest.dst")->read() != testdata*5) {
werror("Data corruption!\n");
exit(1);
}
next(); next();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment