Project

General

Profile

Bug #6474 » port-test.c

a minimal test case - Josef Sipek, 2015-11-23 10:53 PM

 
1
#include <port.h>
2
#include <poll.h>
3
#include <ucred.h>
4
#include <unistd.h>
5
#include <errno.h>
6
#include <stdio.h>
7

    
8
int main(int argc, char **argv)
9
{
10
	ucred_t *ucred;
11
	port_event_t ev;
12
	uint_t nget;
13
	int port;
14
	int ret;
15

    
16
	port = port_create();
17

    
18
	fprintf(stderr, "port = %d, errno = %d\n", port, errno);
19

    
20
	ret = port_associate(port, PORT_SOURCE_FD, 0, POLLIN, NULL);
21

    
22
	fprintf(stderr, "ret = %d, errno = %d\n", ret, errno);
23

    
24
	ret = getpeerucred(0, &ucred);
25

    
26
	fprintf(stderr, "ret = %d, errno = %d\n", ret, errno);
27
	fprintf(stderr, "ucred = %p\n", ucred);
28

    
29
	nget = 1;
30
	ret = port_getn(port, &ev, 1, &nget, NULL);
31

    
32
	fprintf(stderr, "ret = %d, errno = %d\n", ret, errno);
33
	fprintf(stderr, "ev.portev_source = %u\n", ev.portev_source);
34
	fprintf(stderr, "ev.portev_events = %u\n", ev.portev_events);
35
	fprintf(stderr, "ev.portev_object = %u\n", ev.portev_object);
36
	fprintf(stderr, "ev.portev_user = %p\n", ev.portev_user);
37

    
38
	close(port);
39

    
40
	return 0;
41
}
(1-1/2)