File: fd_offset.c

package info (click to toggle)
criu 4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,500 kB
  • sloc: ansic: 139,280; python: 7,484; sh: 3,824; java: 2,799; makefile: 2,659; asm: 1,137; perl: 206; xml: 117; exp: 45
file content (42 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 <mclapinski@google.com>";

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;
}