From: Garrett C. <su...@li...> - 2010-10-21 11:58:06
|
The branch, master, has been updated via f969f69207a58373b181d6c657e3c6e60d137bac (commit) via bf531a8d54487b2666b2bb9ecdfef08f98ffc350 (commit) via 2a9ad0bdf07565bac32eeb02d2e01f78b41a32d1 (commit) from 519c4377e77e497ed2974f4f0b6fdea7029abcf7 (commit) - Log ----------------------------------------------------------------- commit f969f69207a58373b181d6c657e3c6e60d137bac Author: Garrett Cooper <yan...@gm...> Date: Thu Oct 21 04:01:24 2010 -0700 Improve command check. Signed-off-by: Garrett Cooper <yan...@gm...> commit bf531a8d54487b2666b2bb9ecdfef08f98ffc350 Author: Garrett Cooper <yan...@gm...> Date: Thu Oct 21 03:35:56 2010 -0700 Polish off some rough edges with previous fixup. 1. Add close(2) calls everywhere that I touched to consistently close file descriptors after use (even though the OS, which should be POSIX compliant, should clean up the file descriptors on exit). 2. Add a missing exit(3). Signed-off-by: Garrett Cooper <yan...@gm...> commit 2a9ad0bdf07565bac32eeb02d2e01f78b41a32d1 Author: Garrett Cooper <yan...@gm...> Date: Thu Oct 21 03:19:51 2010 -0700 Fix aio_return conformance testcases. The problem with the testcases is that the original writer assumed that the values were stored in the global errno instead of a value retrievable via aio_error, and ignored the following item in the POSIX spec that states: If the error status for the operation is equal to [EINPROGRESS], then the return status for the operation is undefined. Thus, the results were incorrect in some cases, as determined through testing by Mitani-san. Signed-off-by: Garrett Cooper <yan...@gm...> ----------------------------------------------------------------------- Summary of changes: testcases/lib/cmdlib.sh | 4 +- .../conformance/interfaces/aio_return/1-1.c | 23 ++++----- .../conformance/interfaces/aio_return/2-1.c | 42 ++++++++-------- .../conformance/interfaces/aio_return/3-1.c | 47 ++++++++---------- .../conformance/interfaces/aio_return/3-2.c | 42 ++++++++-------- .../conformance/interfaces/aio_return/4-1.c | 51 ++++++++++--------- 6 files changed, 103 insertions(+), 106 deletions(-) diff --git a/testcases/lib/cmdlib.sh b/testcases/lib/cmdlib.sh index 47bf5cc..6cd62f1 100644 --- a/testcases/lib/cmdlib.sh +++ b/testcases/lib/cmdlib.sh @@ -101,8 +101,8 @@ end_testcase() #============================================================================= exists() { - for cmd in "$@"; do - if ! type $cmd 2>&1 1>/dev/null; then + for cmd in $*; do + if ! type $cmd >/dev/null 2>&1; then end_testcase "$cmd: command not found" exit 1 fi diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c index bfc8e12..a01bc69 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c @@ -73,25 +73,22 @@ int main(void) exit(PTS_FAIL); } - do { - retval = aio_error(&aiocb); - if (retval == -1) { - close(fd); - printf(TNAME " Error at aio_error(): %s\n", - strerror(errno)); - exit(PTS_FAIL); - } - } while (retval == EINPROGRESS); - + while (aio_error(&aiocb) == EINPROGRESS) + sleep(1); retval = aio_return(&aiocb); - if (retval != BUF_SIZE) { + if (retval == -1) { close(fd); printf(TNAME " Error at aio_return(): %s\n", - strerror(errno)); + strerror(aio_error(&aiocb))); + exit(PTS_FAIL); + } else if (retval != BUF_SIZE) { + close(fd); + printf(TNAME "aio_return didn't return expected size: %d\n", + retval); exit(PTS_FAIL); } - + close(fd); printf("Test PASSED\n"); exit(PTS_PASS); diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/2-1.c index c363a00..4ac81e7 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/2-1.c @@ -67,36 +67,38 @@ int main(void) if (aio_write(&aiocb) == -1) { close(fd); printf(TNAME " Error at aio_write(): %s\n", - strerror(errno)); + strerror(aio_error(&aiocb))); exit(PTS_FAIL); } - do { - retval = aio_error(&aiocb); - if (retval == -1) { + while (aio_error(&aiocb) == EINPROGRESS) + sleep(1); + retval = aio_return(&aiocb); + + if (0 < retval) { + + if (retval != BUF_SIZE) { close(fd); - printf(TNAME " Error at aio_error(): %s\n", - strerror(errno)); + printf(TNAME " aio_return didn't return expected size: " + "%d\n", retval); exit(PTS_FAIL); } - } while (retval == EINPROGRESS); - retval = aio_return(&aiocb); - - if (retval != BUF_SIZE) { - close(fd); - printf(TNAME " Error at aio_return(): %s\n", - strerror(errno)); - exit(PTS_FAIL); - } + retval = aio_return(&aiocb); - retval = aio_return(&aiocb); + if (retval != -1) { + close(fd); + printf(TNAME " Second call to aio_return() should " + "return -1; aio_return() returned %d\n", + retval); + exit(PTS_FAIL); + } - if (retval != -1) { + } else { close(fd); - printf(TNAME " Second call to aio_return() should return -1 : %d\n", - retval); - exit(PTS_FAIL); + printf(TNAME " Error at aio_error(): %s\n", + strerror(aio_error(&aiocb))); + exit(PTS_UNRESOLVED); } close(fd); diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-1.c index 2dd9177..864132d 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-1.c @@ -72,26 +72,18 @@ int main(void) if (aio_write(&aiocb) == -1) { close(fd); printf(TNAME " Error at aio_write(): %s\n", - strerror(errno)); + strerror(aio_error(&aiocb))); exit(PTS_FAIL); } - do { - retval = aio_error(&aiocb); - if (retval == -1) { - close(fd); - printf(TNAME " Error at aio_error(): %s\n", - strerror(errno)); - exit(PTS_FAIL); - } - } while (retval == EINPROGRESS); - + while (aio_error(&aiocb) == EINPROGRESS) + sleep(1); retval = aio_return(&aiocb); - if (retval != BUF_SIZE) { + if (retval == -1) { close(fd); printf(TNAME " Error at aio_return(): %d, %s\n", retval, - strerror(errno)); + strerror(aio_error(&aiocb))); exit(PTS_FAIL); } @@ -103,27 +95,28 @@ int main(void) if (aio_write(&aiocb) == -1) { close(fd); printf(TNAME " Error at aio_write(): %s\n", - strerror(errno)); + strerror(aio_error(&aiocb))); exit(PTS_FAIL); } - do { - retval = aio_error(&aiocb); - if (retval == -1) { - close(fd); - printf(TNAME " Error at aio_error(): %s\n", - strerror(errno)); - exit(PTS_FAIL); - } - } while (retval == EINPROGRESS); - + while (aio_error(&aiocb) == EINPROGRESS) + sleep(1); retval = aio_return(&aiocb); - if (retval != BUF_SIZE / 2) { + if (retval == -1) { close(fd); - printf(TNAME " Error at aio_return(): %d, %s\n", retval, - strerror(errno)); + printf(TNAME " Error at aio_return(): %s\n", + strerror(aio_error(&aiocb))); exit(PTS_FAIL); + } else { + + if (retval != (BUF_SIZE / 2)) { + close(fd); + printf(TNAME " Error at aio_return(): %d, %s\n", + retval, strerror(aio_error(&aiocb))); + exit(PTS_FAIL); + } + } close(fd); diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-2.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-2.c index 8e018c2..c18e0ef 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-2.c @@ -70,35 +70,37 @@ int main(void) if (aio_write(&aiocb) == -1) { close(fd); printf(TNAME " Error at aio_write(): %s\n", - strerror(errno)); + strerror(aio_error(&aiocb))); exit(PTS_FAIL); } - do { - retval = aio_error(&aiocb); - if (retval == -1) { + while (aio_error(&aiocb) == EINPROGRESS) + sleep(1); + retval = aio_return(&aiocb); + + if (retval == -1) { + printf(TNAME " Error at aio_error(): %s\n", + strerror(aio_error(&aiocb))); + exit(PTS_UNRESOLVED); + } else { + + if (retval != BUF_SIZE) { close(fd); - printf(TNAME " Error at aio_error(): %s\n", - strerror(errno)); + printf(TNAME " Error at aio_return(): %d, %s\n", retval, + strerror(aio_error(&aiocb))); exit(PTS_FAIL); } - } while (retval == EINPROGRESS); - retval = aio_return(&aiocb); + retval = aio_return(&aiocb); - if (retval != BUF_SIZE) { - close(fd); - printf(TNAME " Error at aio_return(): %d, %s\n", retval, - strerror(errno)); - exit(PTS_FAIL); - } - - retval = aio_return(&aiocb); + if (retval != -1 && aio_error(&aiocb) != EINVAL) { + close(fd); + printf(TNAME " aio_return() should fail with (-1, %d); " + "failed with (%d, %d) instead\n", + EINVAL, retval, aio_error(&aiocb)); + exit(PTS_FAIL); + } - if ((retval != -1) && (errno != EINVAL)) { - close(fd); - printf(TNAME " aio_return() should fail\n"); - exit(PTS_FAIL); } close(fd); diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/4-1.c index f67a4fb..412dde0 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_return/4-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_return/4-1.c @@ -74,38 +74,41 @@ int main(void) exit(PTS_FAIL); } - do { - retval = aio_error( &aiocb); - if (retval == -1) { + while (aio_error(&aiocb) == EINPROGRESS) + sleep(1); + retval = aio_error(&aiocb); + + if (retval == 0) { + + memset(&aiocb2, 0, sizeof(struct aiocb)); + aiocb2.aio_fildes = fd; + aiocb2.aio_buf = buf; + aiocb2.aio_nbytes = BUF_SIZE; + + retval = aio_return(&aiocb2); + + if (retval != -1) { close(fd); - printf(TNAME " Error at aio_error(): %s\n", - strerror(errno)); + printf(TNAME " aio_return() should fail\n"); exit(PTS_FAIL); } - } while (retval == EINPROGRESS); - - memset(&aiocb2, 0, sizeof(struct aiocb)); - aiocb2.aio_fildes = fd; - aiocb2.aio_buf = buf; - aiocb2.aio_nbytes = BUF_SIZE; - retval = aio_return(&aiocb2); + retval = aio_return(&aiocb); + + if (retval != BUF_SIZE) { + close(fd); + printf(TNAME " Error at aio_return(): %d, %s\n", retval, + strerror(aio_error(&aiocb))); + exit(PTS_FAIL); + } - if (retval != -1) { + } else { close(fd); - printf(TNAME " aio_return() should fail\n"); - exit(PTS_FAIL); + printf(TNAME " Error at aio_error(): %s\n", + strerror(retval)); + exit(PTS_UNRESOLVED); } - - retval = aio_return(&aiocb); - if (retval != BUF_SIZE) { - close(fd); - printf(TNAME " Error at aio_return(): %d, %s\n", retval, - strerror(errno)); - exit(PTS_FAIL); - } - close(fd); printf("Test PASSED\n"); exit(PTS_PASS); hooks/post-receive -- ltp |