[PATCH 2/3] tests: add shmxt.test

Dmitry V. Levin ldv at altlinux.org
Mon Apr 18 02:15:30 UTC 2016


On Tue, Apr 12, 2016 at 02:57:46PM +0800, Fei Jie wrote:
[...]
> --- /dev/null
> +++ b/tests/shmxt.c
> @@ -0,0 +1,27 @@
> +#include "tests.h"
> +#include <errno.h>
> +#include <stdio.h>
> +#include <sys/shm.h>
> +
> +int
> +main(void)
> +{
> +	int id = shmget(IPC_PRIVATE, 1, 0600);
> +	if (id < 0)
> +		perror_msg_and_fail("shmget");

There are kernels built without CONFIG_SYSVIPC enabled,
so this error shouldn't be treated as fatal.

> +	void *shmaddr = shmat(id, NULL, 0);

Please also test some SHM_* flags decoding.

> +	if (shmaddr == (void *)(-1))
> +		perror_msg_and_fail("shmat");

All resources allocated by shmget must be explicitly released,
see e.g. tests/ipc_shm.c


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160418/aab7207b/attachment.bin>


More information about the Strace-devel mailing list