fix usertests to correctly test what happens when you call
exec() with arguments that don't fit on a single page.
This commit is contained in:
parent
15997d5849
commit
5a23692444
4 changed files with 26 additions and 13 deletions
4
entry.S
4
entry.S
|
@ -54,10 +54,10 @@ entry:
|
||||||
# Set up the stack pointer.
|
# Set up the stack pointer.
|
||||||
movl $(stack + STACK), %esp
|
movl $(stack + STACK), %esp
|
||||||
|
|
||||||
# Call main(), which switches to executing at
|
# Jump to main(), and switch to executing at
|
||||||
# high addresses. The indirect call is needed because
|
# high addresses. The indirect call is needed because
|
||||||
# the assembler produces a PC-relative instruction
|
# the assembler produces a PC-relative instruction
|
||||||
# for a direct call.
|
# for a direct jump.
|
||||||
mov $main, %eax
|
mov $main, %eax
|
||||||
jmp *%eax
|
jmp *%eax
|
||||||
|
|
||||||
|
|
2
proc.c
2
proc.c
|
@ -49,7 +49,7 @@ found:
|
||||||
p->pid = nextpid++;
|
p->pid = nextpid++;
|
||||||
release(&ptable.lock);
|
release(&ptable.lock);
|
||||||
|
|
||||||
// Allocate kernel stack if possible.
|
// Allocate kernel stack.
|
||||||
if((p->kstack = kalloc()) == 0){
|
if((p->kstack = kalloc()) == 0){
|
||||||
p->state = UNUSED;
|
p->state = UNUSED;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
28
usertests.c
28
usertests.c
|
@ -1508,30 +1508,41 @@ bsstest(void)
|
||||||
printf(stdout, "bss test ok\n");
|
printf(stdout, "bss test ok\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// does exec do something sensible if the arguments
|
// does exec return an error if the arguments
|
||||||
// are larger than a page?
|
// are larger than a page? or does it write
|
||||||
|
// below the stack and wreck the instructions/data?
|
||||||
void
|
void
|
||||||
bigargtest(void)
|
bigargtest(void)
|
||||||
{
|
{
|
||||||
int pid, ppid;
|
int pid, ppid, fd;
|
||||||
|
|
||||||
|
unlink("bigarg-ok");
|
||||||
ppid = getpid();
|
ppid = getpid();
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if(pid == 0){
|
if(pid == 0){
|
||||||
char *args[32+1];
|
static char *args[MAXARG];
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 32; i++)
|
for(i = 0; i < MAXARG-1; i++)
|
||||||
args[i] = "bigargs test: failed\n ";
|
args[i] = "bigargs test: failed\n ";
|
||||||
args[32] = 0;
|
args[MAXARG-1] = 0;
|
||||||
printf(stdout, "bigarg test\n");
|
printf(stdout, "bigarg test %d\n", (MAXARG-1)*strlen(args[0]));
|
||||||
exec("echo", args);
|
exec("echo", args);
|
||||||
printf(stdout, "bigarg test ok\n");
|
printf(stdout, "bigarg test ok\n");
|
||||||
|
fd = open("bigarg-ok", O_CREATE);
|
||||||
|
close(fd);
|
||||||
exit();
|
exit();
|
||||||
} else if(pid < 0){
|
} else if(pid < 0){
|
||||||
printf(stdout, "bigargtest: fork failed\n");
|
printf(stdout, "bigargtest: fork failed\n");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
wait();
|
wait();
|
||||||
|
fd = open("bigarg-ok", 0);
|
||||||
|
if(fd < 0){
|
||||||
|
printf(stdout, "bigarg test failed!\n");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
unlink("bigarg-ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
// what happens when the file system runs out of blocks?
|
// what happens when the file system runs out of blocks?
|
||||||
|
@ -1606,6 +1617,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
close(open("usertests.ran", O_CREATE));
|
close(open("usertests.ran", O_CREATE));
|
||||||
|
|
||||||
|
bigargtest();
|
||||||
bigwrite();
|
bigwrite();
|
||||||
bigargtest();
|
bigargtest();
|
||||||
bsstest();
|
bsstest();
|
||||||
|
|
3
vm.c
3
vm.c
|
@ -68,7 +68,8 @@ walkpgdir(pde_t *pgdir, const void *va, char* (*alloc)(void))
|
||||||
// physical addresses starting at pa. va and size might not
|
// physical addresses starting at pa. va and size might not
|
||||||
// be page-aligned.
|
// be page-aligned.
|
||||||
static int
|
static int
|
||||||
mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm, char* (*alloc)(void))
|
mappages(pde_t *pgdir, void *va, uint size, uint pa,
|
||||||
|
int perm, char* (*alloc)(void))
|
||||||
{
|
{
|
||||||
char *a, *last;
|
char *a, *last;
|
||||||
pte_t *pte;
|
pte_t *pte;
|
||||||
|
|
Loading…
Reference in a new issue