Add s to many printf statements that expect it (thanks Cece Chu)

Add dirtest to the list of tests
This commit is contained in:
Frans Kaashoek 2020-10-02 07:51:15 -04:00
parent 6750608824
commit 8ffdfad990

View file

@ -543,11 +543,11 @@ writetest(char *s)
}
for(i = 0; i < N; i++){
if(write(fd, "aaaaaaaaaa", SZ) != SZ){
printf("%s: error: write aa %d new file failed\n", i);
printf("%s: error: write aa %d new file failed\n", s, i);
exit(1);
}
if(write(fd, "bbbbbbbbbb", SZ) != SZ){
printf("%s: error: write bb %d new file failed\n", i);
printf("%s: error: write bb %d new file failed\n", s, i);
exit(1);
}
}
@ -584,7 +584,7 @@ writebig(char *s)
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
if(write(fd, buf, BSIZE) != BSIZE){
printf("%s: error: write big file failed\n", i);
printf("%s: error: write big file failed\n", s, i);
exit(1);
}
}
@ -602,16 +602,16 @@ writebig(char *s)
i = read(fd, buf, BSIZE);
if(i == 0){
if(n == MAXFILE - 1){
printf("%s: read only %d blocks from big", n);
printf("%s: read only %d blocks from big", s, n);
exit(1);
}
break;
} else if(i != BSIZE){
printf("%s: read failed %d\n", i);
printf("%s: read failed %d\n", s, i);
exit(1);
}
if(((int*)buf)[0] != n){
printf("%s: read content of block %d is %d\n",
printf("%s: read content of block %d is %d\n", s,
n, ((int*)buf)[0]);
exit(1);
}
@ -648,8 +648,6 @@ createtest(char *s)
void dirtest(char *s)
{
printf("mkdir test\n");
if(mkdir("dir0") < 0){
printf("%s: mkdir failed\n", s);
exit(1);
@ -669,7 +667,6 @@ void dirtest(char *s)
printf("%s: unlink dir0 failed\n", s);
exit(1);
}
printf("%s: mkdir test ok\n");
}
void
@ -791,7 +788,7 @@ preempt(char *s)
pid1 = fork();
if(pid1 < 0) {
printf("%s: fork failed");
printf("%s: fork failed", s);
exit(1);
}
if(pid1 == 0)
@ -816,7 +813,7 @@ preempt(char *s)
if(pid3 == 0){
close(pfds[0]);
if(write(pfds[1], "x", 1) != 1)
printf("%s: preempt write error");
printf("%s: preempt write error", s);
close(pfds[1]);
for(;;)
;
@ -824,7 +821,7 @@ preempt(char *s)
close(pfds[1]);
if(read(pfds[0], buf, sizeof(buf)) != 1){
printf("%s: preempt read error");
printf("%s: preempt read error", s);
return;
}
close(pfds[0]);
@ -2098,7 +2095,7 @@ sbrkmuch(char *s)
}
c = sbrk(0);
if(c != a - PGSIZE){
printf("%s: sbrk deallocation produced wrong address, a %x c %x\n", a, c);
printf("%s: sbrk deallocation produced wrong address, a %x c %x\n", s, a, c);
exit(1);
}
@ -2106,7 +2103,7 @@ sbrkmuch(char *s)
a = sbrk(0);
c = sbrk(PGSIZE);
if(c != a || sbrk(0) != a + PGSIZE){
printf("%s: sbrk re-allocation failed, a %x c %x\n", a, c);
printf("%s: sbrk re-allocation failed, a %x c %x\n", s, a, c);
exit(1);
}
if(*lastaddr == 99){
@ -2118,7 +2115,7 @@ sbrkmuch(char *s)
a = sbrk(0);
c = sbrk(-(sbrk(0) - oldbrk));
if(c != a){
printf("%s: sbrk downsize failed, a %x c %x\n", a, c);
printf("%s: sbrk downsize failed, a %x c %x\n", s, a, c);
exit(1);
}
}
@ -2137,7 +2134,7 @@ kernmem(char *s)
exit(1);
}
if(pid == 0){
printf("%s: oops could read %x = %x\n", a, *a);
printf("%s: oops could read %x = %x\n", s, a, *a);
exit(1);
}
int xstatus;
@ -2208,7 +2205,7 @@ sbrkfail(char *s)
}
// print n so the compiler doesn't optimize away
// the for loop.
printf("%s: allocate a lot of memory succeeded %d\n", n);
printf("%s: allocate a lot of memory succeeded %d\n", s, n);
exit(1);
}
wait(&xstatus);
@ -2330,10 +2327,10 @@ fsfull()
name[3] = '0' + (nfiles % 100) / 10;
name[4] = '0' + (nfiles % 10);
name[5] = '\0';
printf("%s: writing %s\n", name);
printf("writing %s\n", name);
int fd = open(name, O_CREATE|O_RDWR);
if(fd < 0){
printf("%s: open %s failed\n", name);
printf("open %s failed\n", name);
break;
}
int total = 0;
@ -2344,7 +2341,7 @@ fsfull()
total += cc;
fsblocks++;
}
printf("%s: wrote %d bytes\n", total);
printf("wrote %d bytes\n", total);
close(fd);
if(total == 0)
break;
@ -2398,7 +2395,7 @@ stacktest(char *s)
char *sp = (char *) r_sp();
sp -= PGSIZE;
// the *sp should cause a trap.
printf("%s: stacktest: read below stack %p\n", *sp);
printf("%s: stacktest: read below stack %p\n", s, *sp);
exit(1);
} else if(pid < 0){
printf("%s: fork failed\n", s);
@ -2713,6 +2710,7 @@ main(int argc, char *argv[])
{subdir, "subdir"},
{fourfiles, "fourfiles"},
{sharedfd, "sharedfd"},
{dirtest, "dirtest"},
{exectest, "exectest"},
{bigargtest, "bigargtest"},
{bigwrite, "bigwrite"},