Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Main
Synchronet
Commits
e1b686cc
Commit
e1b686cc
authored
21 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Fix some error messages, skip tests with unveriviable results
clean up SUCCESS/!FAILURE messages
parent
7170028b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/wraptest.c
+27
-20
27 additions, 20 deletions
src/xpdev/wraptest.c
with
27 additions
and
20 deletions
src/xpdev/wraptest.c
+
27
−
20
View file @
e1b686cc
...
...
@@ -47,6 +47,7 @@ int main()
thread_data_t
thread_data
;
int
fd
;
int
fd2
;
int
canrelock
=
0
;
/* Show platform details */
DESCRIBE_COMPILER
(
compiler
);
...
...
@@ -94,11 +95,13 @@ int main()
}
write
(
fd
,
"lock testing
\n
"
,
LOCK_LEN
);
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
)
==
0
)
printf
(
"lock() succeeds
\n
"
);
printf
(
"
SUCCESS:
lock() succeeds
\n
"
);
else
printf
(
"!FAILURE lock() non-functional (or file already locked)
\n
"
);
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
)
==
0
)
printf
(
"!FAILURE: Subsequent lock of region was allowed
\n
"
);
printf
(
"!FAILURE: lock() non-functional (or file already locked)
\n
"
);
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
)
==
0
)
{
printf
(
"!FAILURE: Subsequent lock of region was allowed (will skip some tests)
\n
"
);
canrelock
=
1
;
}
if
(
_beginthread
(
lock_test_thread
/* entry point */
...
...
@@ -108,29 +111,33 @@ int main()
printf
(
"_beginthread failed
\n
"
);
else
SLEEP
(
1000
);
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
))
printf
(
"Locks in first thread survive open()/close() in other thread
\n
"
);
else
printf
(
"!FAILURE lock() in first thread lost by open()/close() in other thread
\n
"
);
if
(
lock
(
fd
,
LOCK_OFFSET
+
LOCK_LEN
+
1
,
LOCK_LEN
))
printf
(
"!FAILURE file locking
\n
"
);
else
printf
(
"SUCCESS! Record locking
\n
"
);
if
(
canrelock
)
printf
(
"?? Skipping some tests due to inability to detect own locks
\n
"
);
else
{
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
))
printf
(
"SUCCESS: Locks in first thread survive open()/close() in other thread
\n
"
);
else
printf
(
"!FAILURE: lock() in first thread lost by open()/close() in other thread
\n
"
);
if
(
lock
(
fd
,
LOCK_OFFSET
+
LOCK_LEN
+
1
,
LOCK_LEN
))
printf
(
"!FAILURE: file locking
\n
"
);
else
printf
(
"SUCCESS: Record locking
\n
"
);
}
if
((
fd2
=
sopen
(
LOCK_FNAME
,
O_RDWR
,
SH_DENYRW
))
==-
1
)
{
printf
(
"SUCCESS
!
Cannot reopen SH_DENYRW while lock is held
\n
"
);
printf
(
"SUCCESS
:
Cannot reopen SH_DENYRW while lock is held
\n
"
);
close
(
fd2
);
}
else
{
printf
(
"!FAILURE can reopen SH_DENYRW while lock is held
\n
"
);
printf
(
"!FAILURE
:
can reopen SH_DENYRW while lock is held
\n
"
);
}
if
(
unlock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
))
printf
(
"!FAILURE unlock() non-functional
\n
"
);
printf
(
"!FAILURE
:
unlock() non-functional
\n
"
);
if
(
lock
(
fd
,
LOCK_OFFSET
+
LOCK_LEN
+
1
,
LOCK_LEN
))
printf
(
"SUCCESS
!
Cannot re-lock after non-overlapping unlock()
\n
"
);
printf
(
"SUCCESS
:
Cannot re-lock after non-overlapping unlock()
\n
"
);
else
printf
(
"!FAILURE can re-lock after non-overlappping unlock()
\n
"
);
printf
(
"!FAILURE
:
can re-lock after non-overlappping unlock()
\n
"
);
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
))
printf
(
"!FAILURE cannot re-lock unlocked area
\n
"
);
printf
(
"!FAILURE
:
cannot re-lock unlocked area
\n
"
);
close
(
fd
);
/* getch test */
...
...
@@ -292,11 +299,11 @@ static void lock_test_thread(void* arg)
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
)
==
0
)
printf
(
"!FAILURE: Lock not effective between threads
\n
"
);
else
printf
(
"Locks effective between threads
\n
"
);
printf
(
"
SUCCESS:
Locks effective between threads
\n
"
);
close
(
fd
);
fd
=
sopen
(
LOCK_FNAME
,
O_RDWR
,
SH_DENYNO
);
if
(
lock
(
fd
,
LOCK_OFFSET
,
LOCK_LEN
))
printf
(
"Locks survive file open()/close() in other thread
\n
"
);
printf
(
"
SUCCESS:
Locks survive file open()/close() in other thread
\n
"
);
else
printf
(
"!FAILURE: Locks do not survive file open()/close() in other thread
\n
"
);
close
(
fd
);
...
...
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