Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
shuailiang
xv6-k210
Commits
3f22a699
Commit
3f22a699
authored
8 months ago
by
shuailiang
Browse files
Options
Download
Patches
Plain Diff
add test array
parent
d133d28a
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xv6-user/init.c
+45
-6
xv6-user/init.c
with
45 additions
and
6 deletions
+45
-6
xv6-user/init.c
+
45
−
6
View file @
3f22a699
...
...
@@ -8,6 +8,42 @@
#include
"xv6-user/user.h"
char
*
argv
[]
=
{
0
};
char
*
tests
[]
=
{
"brk"
,
"chdir"
,
"close"
,
"dup"
,
"exit"
,
"fork"
,
"fstat"
,
"getcwd"
,
"getpid"
,
"open"
,
"pipe"
,
"read"
,
"wait"
,
"write"
,
"sleep"
,
"pipe"
,
"dup"
,
"dup2"
,
"openat"
,
"getdents"
,
"unlink"
,
"clone"
,
"execve"
,
"waitpid"
,
"gettimeofday"
,
"getppid"
,
"yield"
,
"mmap"
,
"munmap"
,
"times"
,
"uname"
,
"mkdir_"
,
};
int
counts
=
sizeof
(
tests
)
/
sizeof
((
tests
)[
0
]);
int
main
(
void
)
...
...
@@ -22,8 +58,9 @@ main(void)
dup
(
0
);
// stdout
dup
(
0
);
// stderr
for
(;;){
printf
(
"init: starting sh
\n
"
);
for
(
int
i
=
0
;
i
<
counts
;
i
++
)
{
// for(int i = 0;i < 1;i++) {
printf
(
"init: starting init
\n
"
);
pid
=
fork
();
if
(
pid
<
0
){
printf
(
"init: fork failed
\n
"
);
...
...
@@ -31,8 +68,9 @@ main(void)
}
if
(
pid
==
0
){
// exec("sh", argv);
exec
(
"riscv64/exit"
,
argv
);
printf
(
"init: exec sh failed
\n
"
);
exec
(
tests
[
i
],
argv
);
// exec("riscv64/exit", argv);
printf
(
"init: exec %s failed
\n
"
,
tests
[
i
]);
exit
(
1
);
}
for
(;;){
...
...
@@ -41,8 +79,6 @@ main(void)
wpid
=
wait
((
int
*
)
0
);
if
(
wpid
==
pid
){
// the shell exited; restart it.
printf
(
"
\n
--------qemu will shut down---------
\n
"
);
shutdown
();
break
;
}
else
if
(
wpid
<
0
){
printf
(
"init: wait returned an error
\n
"
);
...
...
@@ -51,5 +87,8 @@ main(void)
// it was a parentless process; do nothing.
}
}
}
printf
(
"
\n
--------qemu will shut down---------
\n
"
);
shutdown
();
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets