Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
1c265edd
Commit
1c265edd
authored
Feb 05, 2014
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zdtm: A bunch of test for various flavors of unlinked/opened/maped files
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
18a5c90c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
0 deletions
+263
-0
zdtm.sh
test/zdtm.sh
+3
-0
Makefile
test/zdtm/live/static/Makefile
+3
-0
unlink_mmap00.c
test/zdtm/live/static/unlink_mmap00.c
+78
-0
unlink_mmap01.c
test/zdtm/live/static/unlink_mmap01.c
+102
-0
unlink_mmap02.c
test/zdtm/live/static/unlink_mmap02.c
+77
-0
No files found.
test/zdtm.sh
View file @
1c265edd
...
...
@@ -61,6 +61,9 @@ static/selfexe00
static/unlink_fstat00
static/unlink_fstat02
static/unlink_fstat03
static/unlink_mmap00
static/unlink_mmap01
static/unlink_mmap02
static/eventfs00
static/signalfd00
static/inotify00
...
...
test/zdtm/live/static/Makefile
View file @
1c265edd
...
...
@@ -128,6 +128,9 @@ TST_FILE = \
fifo_wronly
\
unlink_fifo
\
unlink_fifo_wronly
\
unlink_mmap00
\
unlink_mmap01
\
unlink_mmap02
\
file_shared
\
file_append
\
cow01
\
...
...
test/zdtm/live/static/unlink_mmap00.c
0 → 100644
View file @
1c265edd
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Test mmaped and unlinked files"
;
char
*
filename
;
TEST_OPTION
(
filename
,
string
,
"file name"
,
1
);
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
static
void
touch_file_page
(
int
fd
,
unsigned
long
off
,
char
c
)
{
if
(
lseek
(
fd
,
off
,
SEEK_SET
)
!=
off
)
{
err
(
"Lseek fail"
);
exit
(
1
);
}
if
(
write
(
fd
,
&
c
,
1
)
!=
1
)
{
err
(
"Write fail"
);
exit
(
1
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
;
char
*
mem_a
,
*
mem_b
;
test_init
(
argc
,
argv
);
fd
=
open
(
filename
,
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0644
);
if
(
fd
<
0
)
{
err
(
"can't open file"
);
exit
(
1
);
}
touch_file_page
(
fd
,
0
,
'a'
);
touch_file_page
(
fd
,
PAGE_SIZE
,
'b'
);
touch_file_page
(
fd
,
2
*
PAGE_SIZE
-
1
,
'c'
);
/* for aligned file */
/* map with different prots to create 2 regions */
mem_a
=
mmap
(
NULL
,
PAGE_SIZE
,
PROT_READ
,
MAP_PRIVATE
|
MAP_FILE
,
fd
,
0
);
mem_b
=
mmap
(
NULL
,
PAGE_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_FILE
,
fd
,
PAGE_SIZE
);
if
(
mem_a
==
MAP_FAILED
||
mem_b
==
MAP_FAILED
)
{
err
(
"can't map file"
);
exit
(
1
);
}
if
(
unlink
(
filename
)
<
0
)
{
err
(
"can't unlink file"
);
exit
(
1
);
}
close
(
fd
);
test_daemon
();
test_waitsig
();
if
(
mem_a
[
0
]
!=
'a'
)
fail
(
"1st region fail"
);
else
if
(
mem_b
[
0
]
!=
'b'
||
mem_b
[
PAGE_SIZE
-
1
]
!=
'c'
)
fail
(
"2nd regin fail"
);
else
pass
();
return
0
;
}
test/zdtm/live/static/unlink_mmap01.c
0 → 100644
View file @
1c265edd
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <string.h>
#include <stdio.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Test mmaped and unlinked files (2, with hard links)"
;
char
*
filename
;
TEST_OPTION
(
filename
,
string
,
"file name"
,
1
);
static
char
linkname
[
4096
];
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
static
void
touch_file_page
(
int
fd
,
unsigned
long
off
,
char
c
)
{
if
(
lseek
(
fd
,
off
,
SEEK_SET
)
!=
off
)
{
err
(
"Lseek fail"
);
exit
(
1
);
}
if
(
write
(
fd
,
&
c
,
1
)
!=
1
)
{
err
(
"Write fail"
);
exit
(
1
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
;
char
*
mem_a
,
*
mem_b
;
test_init
(
argc
,
argv
);
fd
=
open
(
filename
,
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0644
);
if
(
fd
<
0
)
{
err
(
"can't open file"
);
exit
(
1
);
}
touch_file_page
(
fd
,
0
,
'a'
);
touch_file_page
(
fd
,
PAGE_SIZE
-
1
,
'b'
);
/* for aligned file */
mem_a
=
mmap
(
NULL
,
PAGE_SIZE
,
PROT_READ
,
MAP_PRIVATE
|
MAP_FILE
,
fd
,
0
);
if
(
mem_a
==
MAP_FAILED
)
{
err
(
"can't map file"
);
exit
(
1
);
}
sprintf
(
linkname
,
"%s.lnk"
,
filename
);
if
(
link
(
filename
,
linkname
))
{
err
(
"can't link file"
);
exit
(
1
);
}
if
(
unlink
(
filename
)
<
0
)
{
err
(
"can't unlink file"
);
exit
(
1
);
}
close
(
fd
);
fd
=
open
(
linkname
,
O_RDWR
);
if
(
fd
<
0
)
{
err
(
"can't open link"
);
exit
(
1
);
}
mem_b
=
mmap
(
NULL
,
PAGE_SIZE
,
PROT_READ
,
MAP_PRIVATE
|
MAP_FILE
,
fd
,
0
);
if
(
mem_b
==
MAP_FAILED
)
{
err
(
"can't map link"
);
exit
(
1
);
}
if
(
unlink
(
linkname
)
<
0
)
{
err
(
"can't unlink link"
);
exit
(
1
);
}
close
(
fd
);
test_daemon
();
test_waitsig
();
if
(
mem_a
[
0
]
!=
'a'
||
mem_a
[
PAGE_SIZE
-
1
]
!=
'b'
)
fail
(
"1st region fail"
);
else
if
(
mem_b
[
0
]
!=
'a'
||
mem_b
[
PAGE_SIZE
-
1
]
!=
'b'
)
fail
(
"2nd regin fail"
);
else
pass
();
return
0
;
}
test/zdtm/live/static/unlink_mmap02.c
0 → 100644
View file @
1c265edd
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Test mmaped, opened and unlinked files"
;
char
*
filename
;
TEST_OPTION
(
filename
,
string
,
"file name"
,
1
);
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
static
void
touch_file_page
(
int
fd
,
unsigned
long
off
,
char
c
)
{
if
(
lseek
(
fd
,
off
,
SEEK_SET
)
!=
off
)
{
err
(
"Lseek fail"
);
exit
(
1
);
}
if
(
write
(
fd
,
&
c
,
1
)
!=
1
)
{
err
(
"Write fail"
);
exit
(
1
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
;
char
*
mem_a
,
*
mem_b
;
test_init
(
argc
,
argv
);
fd
=
open
(
filename
,
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0644
);
if
(
fd
<
0
)
{
err
(
"can't open file"
);
exit
(
1
);
}
touch_file_page
(
fd
,
2
*
PAGE_SIZE
-
1
,
'c'
);
/* for aligned file */
/* map with different prots to create 2 regions */
mem_a
=
mmap
(
NULL
,
PAGE_SIZE
,
PROT_READ
,
MAP_PRIVATE
|
MAP_FILE
,
fd
,
0
);
mem_b
=
mmap
(
NULL
,
PAGE_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_FILE
,
fd
,
PAGE_SIZE
);
if
(
mem_a
==
MAP_FAILED
||
mem_b
==
MAP_FAILED
)
{
err
(
"can't map file"
);
exit
(
1
);
}
if
(
unlink
(
filename
)
<
0
)
{
err
(
"can't unlink file"
);
exit
(
1
);
}
test_daemon
();
test_waitsig
();
touch_file_page
(
fd
,
0
,
'a'
);
touch_file_page
(
fd
,
PAGE_SIZE
,
'b'
);
if
(
mem_a
[
0
]
!=
'a'
)
fail
(
"1st region fail"
);
else
if
(
mem_b
[
0
]
!=
'b'
||
mem_b
[
PAGE_SIZE
-
1
]
!=
'c'
)
fail
(
"2nd regin fail"
);
else
pass
();
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment