[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ltp-cvs
Subject:    [Ltp-cvs] ltp/testcases/open_posix_testsuite/conformance/interfaces/aio_error 1-1.c,NONE,1.1 2-1.c,N
From:       Robert Williamson <robbiew () users ! sourceforge ! net>
Date:       2004-12-20 17:04:20
Message-ID: E1CgQxI-00082h-PQ () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/ltp/ltp/testcases/open_posix_testsuite/conformance/interfaces/aio_error
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30688/conformance/interfaces/aio_error

Added Files:
	1-1.c 2-1.c 3-1.c assertions.xml coverage.txt 
Log Message:
Update to Version 1.5.0


--- NEW FILE: coverage.txt ---
this file defines the coverage for the aio_error() function testing.

Assertion	Covered?
1		YES
2		YES
3		YES

--- NEW FILE: assertions.xml ---
<assertions>
	<assertion id="1" tag="ref:XSH6TC2:4016:4017">
	The aio_error() function shall return the error status (errno)
	associated with tha aiobcp argument.
	</assertion>
	<assertion id="2" tag="ref:XSH6TC2:4019:4020">
	It the operations has not yet completed, [EINPROGRESS] shall be
	returned.
	</assertion>
	<assertion id="3" tag="ref:XSH6TC2:4028:4029">
	aio_error() shall fail if:
	[EINVAL] The aiocbp argument does not refer to an asynchronous 
	operation whose return status has not yet been retrieved.
	</assertion>
</assertions>

--- NEW FILE: 1-1.c ---
/*
 * Copyright (c) 2004, IBM Corporation. All rights reserved.
 * Created by:  Laurent.Vivier@bull.net
 * This file is licensed under the GPL license.  For the full content
 * of this license, see the COPYING file at the top level of this 
 * source tree.
 */

/*
 * assertion:
 *
 *	The aio_error() function shall return the error status (errno)
 *	associated with tha aiobcp argument.
 *
 * method:
 *
 *	execute aio_write()
 *	and check result with aio_error()
 *
 */

#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <aio.h>

#include "posixtest.h"

#define TNAME "aio_error/1-1.c"

int main()
{
	char tmpfname[256];
#define BUF_SIZE 111
	char buf[BUF_SIZE];
	int fd;
	struct aiocb aiocb;

#if _POSIX_ASYNCHRONOUS_IO != 200112L
	return PTS_UNSUPPORTED;
#endif

	snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_aio_error_1_1_%d", 
		  getpid());
	unlink(tmpfname);
	fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
		  S_IRUSR | S_IWUSR);
	if (fd == -1)
	{
		printf(TNAME " Error at open(): %s\n",
		       strerror(errno));
		return PTS_UNRESOLVED;
	}

	unlink(tmpfname);

	memset(buf, 0xaa, BUF_SIZE);
	memset(&aiocb, 0, sizeof(aiocb));
	aiocb.aio_fildes = fd;
	aiocb.aio_buf = buf;
	aiocb.aio_nbytes = BUF_SIZE;

	if (aio_write(&aiocb) == -1)
	{
		printf(TNAME " Error at aio_write(): %s\n",
		       strerror(errno));
		return PTS_FAIL;
	}

	while(aio_error(&aiocb) == EINPROGRESS);

	if (aio_error(&aiocb) != 0)
	{
		printf(TNAME " Error at aio_error(): %s\n",
		       strerror(errno));
		return PTS_FAIL;
	}
	
	close(fd);
	printf ("Test PASSED\n");
	return PTS_PASS;
}

--- NEW FILE: 2-1.c ---
/*
 * Copyright (c) 2004, IBM Corporation. All rights reserved.
 * Created by:  Laurent.Vivier@bull.net
 * This file is licensed under the GPL license.  For the full content
 * of this license, see the COPYING file at the top level of this 
 * source tree.
 */

/*
 * assertion:
 *
 *	It the operations has not yet completed, [EINPROGRESS] shall be
 *	returned.
 *
 * method:
 *
 *	queue a lot of aio_write() to a given fildes.
 *	then check if at least on is EINPROGRESS
 *	if yes, result is pass otherwise unresolved
 *
 */

#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <malloc.h>
#include <aio.h>

#include "posixtest.h"

#define TNAME "aio_error/2-1.c"

#define BUF_NB		128
#define BUF_SIZE	1024

int main()
{
	char tmpfname[256];
	int fd;
	struct aiocb *aiocb[BUF_NB];
	int i;
	int ret;

#if _POSIX_ASYNCHRONOUS_IO != 200112L
	return PTS_UNSUPPORTED;
#endif

	snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_aio_error_2_1_%d", 
		  getpid());
	unlink(tmpfname);
	fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
		  S_IRUSR | S_IWUSR);
	if (fd == -1)
	{
		printf(TNAME " Error at open(): %s\n",
		       strerror(errno));
		return PTS_UNRESOLVED;
	}

	unlink(tmpfname);

	/* create AIO req */

	for (i = 0; i < BUF_NB; i++)
	{
		aiocb[i] = malloc(sizeof(struct aiocb));
		if (aiocb[i] == NULL)
		{
			printf(TNAME " Error at malloc(): %s\n",
		       		strerror(errno));
			return PTS_UNRESOLVED;
		}
		aiocb[i]->aio_fildes = fd;
		aiocb[i]->aio_buf = malloc(BUF_SIZE);
		if (aiocb[i]->aio_buf == NULL)
		{
			printf(TNAME " Error at malloc(): %s\n",
		       		strerror(errno));
			return PTS_UNRESOLVED;
		}
		aiocb[i]->aio_nbytes = BUF_SIZE;
		aiocb[i]->aio_offset = 0;
		aiocb[i]->aio_sigevent.sigev_notify = SIGEV_NONE;

		if (aio_write(aiocb[i]) == -1)
		{
			printf(TNAME " loop %d: Error at aio_write(): %s\n",
			       i, strerror(errno));
			return PTS_FAIL;
		}
	}

	ret = PTS_UNRESOLVED;
	for (i = 0; i < BUF_NB; i++)
	{
		if (aio_error(aiocb[i]) == EINPROGRESS)
		{
			ret = PTS_PASS;
			break;
		}
	}

	return ret;
}

--- NEW FILE: 3-1.c ---
/*
 * Copyright (c) 2004, IBM Corporation. All rights reserved.
 * Created by:  Laurent.Vivier@bull.net
 * This file is licensed under the GPL license.  For the full content
 * of this license, see the COPYING file at the top level of this 
 * source tree.
 */

/*
 * assertion:
 *
 *	aio_error() shall fail if:
 *	[EINVAL] The aiocbp argument does not refer to an asynchronous
 *	operation whose return status has not yet been retrieved.
 *
 * method:
 *
 *	call aio_error() with an invalid aiocbp
 *
 */

#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <aio.h>

#include "posixtest.h"

#define TNAME "aio_error/3-1.c"

int main()
{
	struct aiocb bad;
	int ret;

#if _POSIX_ASYNCHRONOUS_IO != 200112L
	return PTS_UNSUPPORTED;
#endif

	ret = aio_error(&bad);
	if (ret != -1)
	{
		printf(TNAME " bad aio_error return value; %d\n", ret);
		return PTS_FAIL;
	}

	if (errno != EINVAL)
	{
		printf(TNAME " errno is not EINVAL %s\n", strerror(errno));
		return PTS_FAIL;
	}


	printf ("Test PASSED\n");
	return PTS_PASS;
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Ltp-cvs mailing list
Ltp-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic