-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zdtm/static: test the offset migration of ELF files
Signed-off-by: Michal Clapinski <[email protected]>
- Loading branch information
1 parent
e867e59
commit cd11de3
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <fcntl.h> | ||
|
||
#include "zdtmtst.h" | ||
#include "lock.h" | ||
|
||
const char *test_doc = "Check that criu properly restores offsets on ELF files"; | ||
const char *test_author = "Michal Clapinski <[email protected]>"; | ||
|
||
void check_offset(int fd) | ||
{ | ||
int offset = lseek(fd, 0, SEEK_CUR); | ||
if (offset < 0) { | ||
fail("lseek"); | ||
exit(1); | ||
} | ||
if (offset != 0) { | ||
fail("wrong offset; expected: 0, got: %d", offset); | ||
exit(1); | ||
} | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int fd; | ||
|
||
test_init(argc, argv); | ||
|
||
fd = open("/proc/self/exe", O_RDONLY); | ||
if (fd < 0) { | ||
fail("open"); | ||
exit(1); | ||
} | ||
check_offset(fd); | ||
|
||
test_daemon(); | ||
test_waitsig(); | ||
|
||
check_offset(fd); | ||
|
||
pass(); | ||
return 0; | ||
} |