Skip to content

Commit 42c1c84

Browse files
mclapinskiavagin
authored andcommitted
zdtm/static: test the offset migration of ELF files
Signed-off-by: Michal Clapinski <[email protected]>
1 parent d9ca0c7 commit 42c1c84

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/zdtm/static/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ TST_NOFILE := \
269269
sigtrap \
270270
sigtrap01 \
271271
change_mnt_context \
272+
fd_offset \
272273
# jobctl00 \
273274
274275
PKG_CONFIG ?= pkg-config

test/zdtm/static/fd_offset.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <fcntl.h>
2+
3+
#include "zdtmtst.h"
4+
#include "lock.h"
5+
6+
const char *test_doc = "Check that criu properly restores offsets on ELF files";
7+
const char *test_author = "Michal Clapinski <[email protected]>";
8+
9+
void check_offset(int fd)
10+
{
11+
int offset = lseek(fd, 0, SEEK_CUR);
12+
if (offset < 0) {
13+
fail("lseek");
14+
exit(1);
15+
}
16+
if (offset != 0) {
17+
fail("wrong offset; expected: 0, got: %d", offset);
18+
exit(1);
19+
}
20+
}
21+
22+
int main(int argc, char **argv)
23+
{
24+
int fd;
25+
26+
test_init(argc, argv);
27+
28+
fd = open("/proc/self/exe", O_RDONLY);
29+
if (fd < 0) {
30+
fail("open");
31+
exit(1);
32+
}
33+
check_offset(fd);
34+
35+
test_daemon();
36+
test_waitsig();
37+
38+
check_offset(fd);
39+
40+
pass();
41+
return 0;
42+
}

0 commit comments

Comments
 (0)