Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
67712f8b
提交
67712f8b
4月 24, 2012
创建
作者:
Austin Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
usertests: Overlapping/partial VM test
上级
23fcf62b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
98 行增加
和
0 行删除
+98
-0
usertests.cc
bin/usertests.cc
+98
-0
没有找到文件。
bin/usertests.cc
浏览文件 @
67712f8b
...
@@ -8,11 +8,23 @@
...
@@ -8,11 +8,23 @@
#include <sys/mman.h>
#include <sys/mman.h>
#include <utility>
char
buf
[
2048
];
char
buf
[
2048
];
char
name
[
3
];
char
name
[
3
];
const
char
*
echoargv
[]
=
{
"echo"
,
"ALL"
,
"TESTS"
,
"PASSED"
,
0
};
const
char
*
echoargv
[]
=
{
"echo"
,
"ALL"
,
"TESTS"
,
"PASSED"
,
0
};
int
stdout
=
1
;
int
stdout
=
1
;
// Random number generator for randomized tests
static
u64
rseed
;
u64
rnd
(
void
)
{
rseed
=
rseed
*
6364136223846793005
+
1442695040888963407
;
return
rseed
;
}
// simple file system tests
// simple file system tests
void
void
...
@@ -1741,6 +1753,91 @@ unmappedtest(void)
...
@@ -1741,6 +1753,91 @@ unmappedtest(void)
printf
(
"unmappedtest ok
\n
"
);
printf
(
"unmappedtest ok
\n
"
);
}
}
bool
test_fault
(
char
*
p
)
{
int
fds
[
2
],
pid
;
char
buf
=
0
;
if
(
pipe
(
fds
)
!=
0
)
die
(
"test_fault: pipe failed"
);
if
((
pid
=
fork
(
0
))
<
0
)
die
(
"test_fault: fork failed"
);
if
(
pid
==
0
)
{
close
(
fds
[
0
]);
*
p
=
0x42
;
if
(
write
(
fds
[
1
],
&
buf
,
1
)
!=
1
)
die
(
"test_fault: write failed"
);
exit
();
}
close
(
fds
[
1
]);
bool
faulted
=
(
read
(
fds
[
0
],
&
buf
,
1
)
<
1
);
wait
();
close
(
fds
[
0
]);
return
faulted
;
}
void
vmoverlap
(
void
)
{
printf
(
"vmoverlap
\n
"
);
char
*
base
=
(
char
*
)
0x1000
;
char
map
[
10
]
=
{};
int
mapn
=
1
;
rseed
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
int
op
=
i
%
20
>=
10
;
int
lo
=
rnd
()
%
10
,
hi
=
rnd
()
%
10
;
if
(
lo
>
hi
)
std
::
swap
(
lo
,
hi
);
if
(
lo
==
hi
)
continue
;
if
(
op
==
0
)
{
// Map
void
*
res
=
mmap
(
base
+
lo
*
4096
,
(
hi
-
lo
)
*
4096
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_FIXED
|
MAP_ANONYMOUS
,
-
1
,
0
);
if
(
res
==
MAP_FAILED
)
die
(
"vmoverlap: mmap failed"
);
}
else
{
// Unmap
int
res
=
munmap
(
base
+
lo
*
4096
,
(
hi
-
lo
)
*
4096
);
if
(
res
<
0
)
die
(
"vmoverlap: munmap failed"
);
}
for
(
int
i
=
lo
;
i
<
hi
;
i
++
)
{
if
(
op
==
0
)
{
// Check that it zeroed the range
if
(
base
[
i
*
4096
]
!=
0
)
die
(
"did not zero mapped-over region"
);
// Fill it in
base
[
i
*
4096
]
=
mapn
;
// Update the expected mapping
map
[
i
]
=
mapn
;
}
else
{
// Update the expected mapping
map
[
i
]
=
0
;
}
}
// Check entire mapping
for
(
int
i
=
0
;
i
<
sizeof
(
map
)
/
sizeof
(
map
[
0
]);
i
++
)
{
if
(
map
[
i
]
&&
base
[
i
*
4096
]
!=
map
[
i
])
die
(
"page outside of mapped-over region changed"
);
else
if
(
!
map
[
i
]
&&
!
test_fault
(
&
base
[
i
*
4096
]))
die
(
"expected fault"
);
}
}
munmap
(
base
,
10
*
4096
);
printf
(
"vmoverlap ok
\n
"
);
}
static
int
nenabled
;
static
int
nenabled
;
static
char
**
enabled
;
static
char
**
enabled
;
...
@@ -1782,6 +1879,7 @@ main(int argc, char *argv[])
...
@@ -1782,6 +1879,7 @@ main(int argc, char *argv[])
// we should be able to grow a user process to consume all phys mem
// we should be able to grow a user process to consume all phys mem
TEST
(
unmappedtest
);
TEST
(
unmappedtest
);
TEST
(
vmoverlap
);
TEST
(
validatetest
);
TEST
(
validatetest
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论