Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
3d5f21ee
Commit
3d5f21ee
authored
17 years ago
by
rtm
Browse files
Options
Downloads
Patches
Plain Diff
test concurrent open/unlink of same file (ok)
test files with holes (not ok)
parent
68ae4cc1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
usertests.c
+89
-3
89 additions, 3 deletions
usertests.c
with
89 additions
and
3 deletions
usertests.c
+
89
−
3
View file @
3d5f21ee
...
...
@@ -138,6 +138,76 @@ writetest1(void)
printf
(
stdout
,
"big files ok
\n
"
);
}
void
writetest2
(
void
)
{
int
fd
,
fd1
,
n
;
printf
(
stdout
,
"files with holes
\n
"
);
fd
=
open
(
"hole"
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
printf
(
stdout
,
"error: creat hole failed!
\n
"
);
exit
();
}
buf
[
0
]
=
1
;
if
(
write
(
fd
,
buf
,
512
)
!=
512
)
{
printf
(
stdout
,
"error: write hole file failed
\n
"
);
exit
();
}
// now truncate, while fd is still open
fd1
=
open
(
"hole"
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
printf
(
stdout
,
"error: 2nd creat hole failed!
\n
"
);
exit
();
}
close
(
fd1
);
// now write another block, should be 2nd in file
buf
[
0
]
=
2
;
if
(
write
(
fd
,
buf
,
512
)
!=
512
)
{
printf
(
stdout
,
"error: 2nd write hole file failed
\n
"
);
exit
();
}
close
(
fd
);
fd
=
open
(
"hole"
,
O_RDONLY
);
if
(
fd
<
0
){
printf
(
stdout
,
"error: open hole failed!
\n
"
);
exit
();
}
n
=
read
(
fd
,
buf
,
512
);
if
(
n
!=
512
){
printf
(
stdout
,
"error: 1st hole read failed
\n
"
);
exit
();
}
if
(
buf
[
0
]
!=
0
){
printf
(
stdout
,
"error: 1st hole block didn't have zeros
\n
"
);
exit
();
}
n
=
read
(
fd
,
buf
,
512
);
if
(
n
!=
512
){
printf
(
stdout
,
"error: 2nd hole read failed
\n
"
);
exit
();
}
if
(
buf
[
0
]
!=
1
){
printf
(
stdout
,
"error: 2nd hole block wrong content
\n
"
);
exit
();
}
close
(
fd
);
if
(
unlink
(
"hole"
)
<
0
)
{
printf
(
stdout
,
"unlink hole failed
\n
"
);
exit
();
}
printf
(
stdout
,
"hole files ok
\n
"
);
}
void
createtest
(
void
)
{
...
...
@@ -461,7 +531,7 @@ twofiles(void)
printf
(
1
,
"twofiles ok
\n
"
);
}
// two processes create and delete files in same directory
// two processes create and delete
different
files in same directory
void
createdelete
(
void
)
{
...
...
@@ -647,7 +717,7 @@ linktest(void)
printf
(
1
,
"linktest ok
\n
"
);
}
// test concurrent create of the same file
// test concurrent create
and unlink
of the same file
void
concreate
(
void
)
{
...
...
@@ -713,7 +783,22 @@ concreate(void)
for
(
i
=
0
;
i
<
40
;
i
++
){
file
[
1
]
=
'0'
+
i
;
unlink
(
file
);
pid
=
fork
();
if
(
pid
<
0
){
printf
(
1
,
"fork failed
\n
"
);
exit
();
}
if
(((
i
%
3
)
==
0
&&
pid
==
0
)
||
((
i
%
3
)
==
1
&&
pid
!=
0
)){
fd
=
open
(
file
,
0
);
close
(
fd
);
}
else
{
unlink
(
file
);
}
if
(
pid
==
0
)
exit
();
else
wait
();
}
printf
(
1
,
"concreate ok
\n
"
);
...
...
@@ -1095,6 +1180,7 @@ main(int argc, char *argv[])
opentest
();
writetest
();
writetest1
();
writetest2
();
createtest
();
mem
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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