You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
(16) |
Apr
(25) |
May
(8) |
Jun
(22) |
Jul
(71) |
Aug
(36) |
Sep
(22) |
Oct
(31) |
Nov
(88) |
Dec
(40) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(128) |
Feb
(35) |
Mar
(28) |
Apr
(33) |
May
(18) |
Jun
(8) |
Jul
(21) |
Aug
(18) |
Sep
(6) |
Oct
(19) |
Nov
(12) |
Dec
(44) |
2012 |
Jan
(31) |
Feb
(48) |
Mar
(31) |
Apr
(11) |
May
(13) |
Jun
(15) |
Jul
(13) |
Aug
(18) |
Sep
(7) |
Oct
(25) |
Nov
(21) |
Dec
(13) |
2013 |
Jan
(17) |
Feb
(18) |
Mar
(21) |
Apr
(35) |
May
(30) |
Jun
(4) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(30) |
Nov
(13) |
Dec
|
From: Cyril H. <su...@li...> - 2013-02-14 17:56:25
|
The branch, master, has been updated via 3eca5e3f01d5807c4919f47fcfec4b4155dc04e4 (commit) from 0d0c695c8c6657710d1a8ecb4f1264dcd405276b (commit) - Log ----------------------------------------------------------------- commit 3eca5e3f01d5807c4919f47fcfec4b4155dc04e4 Author: Cyril Hrubis <ch...@su...> Date: Thu Feb 14 18:06:06 2013 +0100 openposix/.../pthread_cond_timedwait: 2-2, 2-3 Fix rare segfaults. The retval passed to pthread_join() is a pointer to integer which is wrong as on 64 bit platform sizeof(void*) == 8 while sizeof(int) == 4. The pthread_exit() then rewrites part of the stack of the main process which may cause segfault. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: .../interfaces/pthread_cond_timedwait/2-2.c | 14 +++++++------- .../interfaces/pthread_cond_timedwait/2-3.c | 13 ++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-2.c index 714c5c7..d9b5b8a 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-2.c @@ -73,10 +73,10 @@ void *t1_func(void *arg) } } -int main() +int main(void) { pthread_t thread1; - int th_ret; + void *th_ret; if (pthread_mutex_init(&td.mutex, NULL) != 0) { fprintf(stderr, "Fail to initialize mutex\n"); @@ -110,16 +110,16 @@ int main() alarm(INTERVAL); /* Wait for the thread to return. */ - if (pthread_join(thread1, (void *)&th_ret) != 0) { + if (pthread_join(thread1, &th_ret) != 0) { fprintf(stderr, "Could not join the thread.\n"); return PTS_UNRESOLVED; } - if (th_ret == PTS_PASS) { + if ((int)th_ret == PTS_PASS) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED\n"); - return PTS_FAIL; } + + printf("Test FAILED\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c index cf07116..257b6f8 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-3.c @@ -64,10 +64,11 @@ void *t1_func(void *arg) } } -int main() +int main(void) { pthread_t thread1; - int rc, th_ret; + int rc; + void *th_ret; if (pthread_mutex_init(&td.mutex, NULL) != 0) { fprintf(stderr, "Fail to initialize mutex\n"); @@ -107,12 +108,14 @@ int main() return PTS_UNRESOLVED; } - if (th_ret == PTS_PASS) { + switch ((int)th_ret) { + case PTS_PASS: printf("Test PASSED\n"); return PTS_PASS; - } else if (th_ret == PTS_FAIL) { + case PTS_FAIL: printf("Test FAILED\n"); return PTS_FAIL; - } else + default: return PTS_UNRESOLVED; + } } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-02-13 14:56:26
|
The branch, master, has been updated via 0d0c695c8c6657710d1a8ecb4f1264dcd405276b (commit) via 94452c49a48ad49eb2ab2956b92207cf4863eb33 (commit) from 7d01f97592d9fc5b8735b20960a4462cccfba507 (commit) - Log ----------------------------------------------------------------- commit 0d0c695c8c6657710d1a8ecb4f1264dcd405276b Author: Markos Chandras <mar...@im...> Date: Wed Feb 13 13:19:05 2013 +0000 open11.c: Define _GNU_SOURCE which is required for O_DIRECTORY O_DIRECTORY is only available if _GNU_SOURCE is defined in uClibc toolchains: Signed-off-by: Markos Chandras <mar...@im...> commit 94452c49a48ad49eb2ab2956b92207cf4863eb33 Author: Cyril Hrubis <ch...@su...> Date: Wed Feb 13 15:04:40 2013 +0100 Revert "syscalls/open11.c: Add ifdefs around O_DIRECTORY" This reverts commit 7d01f97592d9fc5b8735b20960a4462cccfba507. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/open/open11.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/open/open11.c b/testcases/kernel/syscalls/open/open11.c index a042130..8803bb1 100644 --- a/testcases/kernel/syscalls/open/open11.c +++ b/testcases/kernel/syscalls/open/open11.c @@ -59,6 +59,7 @@ * but should not oops or hang */ +#define _GNU_SOURCE #include "config.h" #include <sys/types.h> #include <sys/stat.h> @@ -154,7 +155,6 @@ struct test_case tc[] = { .mode = 0755, .err = EISDIR, }, -#ifdef O_DIRECTORY { /* open regular file O_DIRECTORY */ .desc = "Open regular file O_DIRECTORY, expect ENOTDIR", .path = T_REG_EMPTY, @@ -162,7 +162,6 @@ struct test_case tc[] = { .mode = 0644, .err = ENOTDIR, }, -#endif /* O_DIRECTORY */ /* * Test open(2) hard link */ hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-02-12 14:56:29
|
The branch, master, has been updated via 7d01f97592d9fc5b8735b20960a4462cccfba507 (commit) from a62b53febaa0a236c00a502c79c8e9ac0f3b468e (commit) - Log ----------------------------------------------------------------- commit 7d01f97592d9fc5b8735b20960a4462cccfba507 Author: Cyril Hrubis <ch...@su...> Date: Tue Feb 12 14:45:34 2013 +0100 syscalls/open11.c: Add ifdefs around O_DIRECTORY Fixes build on systems with older glibc headers. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/open/open11.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/syscalls/open/open11.c b/testcases/kernel/syscalls/open/open11.c index ce2ff46..a042130 100644 --- a/testcases/kernel/syscalls/open/open11.c +++ b/testcases/kernel/syscalls/open/open11.c @@ -154,6 +154,7 @@ struct test_case tc[] = { .mode = 0755, .err = EISDIR, }, +#ifdef O_DIRECTORY { /* open regular file O_DIRECTORY */ .desc = "Open regular file O_DIRECTORY, expect ENOTDIR", .path = T_REG_EMPTY, @@ -161,6 +162,7 @@ struct test_case tc[] = { .mode = 0644, .err = ENOTDIR, }, +#endif /* O_DIRECTORY */ /* * Test open(2) hard link */ hooks/post-receive -- ltp |
From: Mike F. <su...@li...> - 2013-02-09 00:42:17
|
The branch, master, has been updated via a62b53febaa0a236c00a502c79c8e9ac0f3b468e (commit) from 75201f160b9aa49af70d8f46fb1f087e63d603dd (commit) - Log ----------------------------------------------------------------- commit a62b53febaa0a236c00a502c79c8e9ac0f3b468e Author: Mike Frysinger <va...@ge...> Date: Fri Feb 8 19:33:22 2013 -0500 tomoyo: stop using sysctl() Recent kernel ports have started omitting this old syscall, and glibc makes it an error to try to include that header when it's unavailable. So convert over to reading/writing the /proc/sys/ paths directly. Signed-off-by: Mike Frysinger <va...@ge...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/security/tomoyo/include.h | 31 +++++++++++++++++++- .../kernel/security/tomoyo/tomoyo_file_test.c | 10 ++---- .../kernel/security/tomoyo/tomoyo_new_file_test.c | 18 ++++++------ 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/testcases/kernel/security/tomoyo/include.h b/testcases/kernel/security/tomoyo/include.h index 44d6f6a..fd1b19b 100644 --- a/testcases/kernel/security/tomoyo/include.h +++ b/testcases/kernel/security/tomoyo/include.h @@ -35,7 +35,6 @@ #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> -#include <sys/sysctl.h> #include <sys/time.h> #include <sys/timex.h> #include <sys/types.h> @@ -84,6 +83,36 @@ static inline int pivot_root(const char *new_root, const char *put_old) } #endif +/* The sysctl() wrapper is dead and newer arches omit it now. */ +static inline int write_sysctl(const char *path, const char *value) +{ + FILE *fp = fopen(path, "w"); + if (!fp) + return 1; + fputs(value, fp); + fclose(fp); + return 0; +} + +static inline int read_sysctl(const char *path, char *value, int len) +{ + char scratch[100]; + FILE *fp = fopen(path, "r"); + if (!fp) + return 1; + if (!value) { + value = scratch; + len = sizeof(scratch); + } + if (fgets(value, len, fp)) + /* ignore */; + fclose(fp); + return 0; +} + +/* Should be a fairly benign path to bang on. */ +#define TEST_SYSCTL_PATH "/proc/sys/net/ipv4/ip_local_port_range" + #define proc_policy_dir "/sys/kernel/security/tomoyo/" #define proc_policy_domain_policy "/sys/kernel/security/tomoyo/domain_policy" #define proc_policy_exception_policy "/sys/kernel/security/tomoyo/exception_policy" diff --git a/testcases/kernel/security/tomoyo/tomoyo_file_test.c b/testcases/kernel/security/tomoyo/tomoyo_file_test.c index fa2dec1..010802e 100644 --- a/testcases/kernel/security/tomoyo/tomoyo_file_test.c +++ b/testcases/kernel/security/tomoyo/tomoyo_file_test.c @@ -77,15 +77,11 @@ static void stage_file_test(void) { int fd; { - static int name[] = { CTL_NET, NET_IPV4, - NET_IPV4_LOCAL_PORT_RANGE - }; - int buffer[2] = { 32768, 61000 }; - size_t size = sizeof(buffer); + const char buffer[] = "32768 61000"; show_prompt("sysctl(READ)"); - show_result(sysctl(name, 3, buffer, &size, 0, 0)); + show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0)); show_prompt("sysctl(WRITE)"); - show_result(sysctl(name, 3, 0, 0, buffer, size)); + show_result(write_sysctl(TEST_SYSCTL_PATH, buffer)); } /* QUESTION: Is there a file which can be passed to uselib()? */ diff --git a/testcases/kernel/security/tomoyo/tomoyo_new_file_test.c b/testcases/kernel/security/tomoyo/tomoyo_new_file_test.c index 2ed021e..16427d2 100644 --- a/testcases/kernel/security/tomoyo/tomoyo_new_file_test.c +++ b/testcases/kernel/security/tomoyo/tomoyo_new_file_test.c @@ -90,9 +90,7 @@ static void mkfifo2(const char *pathname) static void stage_file_test(void) { - static int name[] = { CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE }; - int buffer[2] = { 32768, 61000 }; - size_t size = sizeof(buffer); + const char buffer[] = "32768 61000"; int pipe_fd[2] = { EOF, EOF }; int error = 0; int fd; @@ -127,21 +125,23 @@ static void stage_file_test(void) policy = "allow_read /proc/sys/net/ipv4/ip_local_port_range"; write_domain_policy(policy, 0); - show_result(sysctl(name, 3, buffer, &size, 0, 0), 1); + show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0), 1); write_domain_policy(policy, 1); - show_result(sysctl(name, 3, buffer, &size, 0, 0), 0); + show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0), 0); policy = "allow_write /proc/sys/net/ipv4/ip_local_port_range"; write_domain_policy(policy, 0); - show_result(sysctl(name, 3, 0, 0, buffer, size), 1); + show_result(write_sysctl(TEST_SYSCTL_PATH, buffer), 1); write_domain_policy(policy, 1); - show_result(sysctl(name, 3, 0, 0, buffer, size), 0); + show_result(write_sysctl(TEST_SYSCTL_PATH, buffer), 0); policy = "allow_read/write /proc/sys/net/ipv4/ip_local_port_range"; write_domain_policy(policy, 0); - show_result(sysctl(name, 3, buffer, &size, buffer, size), 1); + show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0) && + write_sysctl(TEST_SYSCTL_PATH, buffer), 1); write_domain_policy(policy, 1); - show_result(sysctl(name, 3, buffer, &size, buffer, size), 0); + show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0) && + write_sysctl(TEST_SYSCTL_PATH, buffer), 0); policy = "allow_read /bin/true"; write_domain_policy(policy, 0); hooks/post-receive -- ltp |
From: Mike F. <su...@li...> - 2013-02-08 22:13:53
|
The branch, master, has been updated via 75201f160b9aa49af70d8f46fb1f087e63d603dd (commit) from a60edf1089d273faef33a6a0e099531507007cf7 (commit) - Log ----------------------------------------------------------------- commit 75201f160b9aa49af70d8f46fb1f087e63d603dd Author: Mike Frysinger <va...@ge...> Date: Fri Feb 8 17:12:41 2013 -0500 syscalls/sysctl: check if __NR_sysctl is defined Recent kernel ports have started omitting this old syscall, so if it isn't defined, just display a normal TCONF message. Signed-off-by: Mike Frysinger <va...@ge...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/sysctl/sysctl01.c | 15 +++++++++++++++ testcases/kernel/syscalls/sysctl/sysctl03.c | 15 +++++++++++++++ testcases/kernel/syscalls/sysctl/sysctl04.c | 15 +++++++++++++++ testcases/kernel/syscalls/sysctl/sysctl05.c | 15 +++++++++++++++ 4 files changed, 60 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/syscalls/sysctl/sysctl01.c b/testcases/kernel/syscalls/sysctl/sysctl01.c index ed2d067..cc2817e 100644 --- a/testcases/kernel/syscalls/sysctl/sysctl01.c +++ b/testcases/kernel/syscalls/sysctl/sysctl01.c @@ -53,6 +53,10 @@ #include <linux/sysctl.h> char *TCID = "sysctl01"; + +/* This is an older/deprecated syscall that newer arches are omitting */ +#ifdef __NR_sysctl + int TST_TOTAL = 3; static int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp, @@ -194,3 +198,14 @@ void cleanup() TEST_CLEANUP; } + +#else +int TST_TOTAL = 0; /* Total number of test cases. */ + +int main() +{ + + tst_resm(TCONF, "This test needs a kernel that has sysctl syscall."); + tst_exit(); +} +#endif diff --git a/testcases/kernel/syscalls/sysctl/sysctl03.c b/testcases/kernel/syscalls/sysctl/sysctl03.c index 09713d7..6caaa72 100644 --- a/testcases/kernel/syscalls/sysctl/sysctl03.c +++ b/testcases/kernel/syscalls/sysctl/sysctl03.c @@ -73,6 +73,10 @@ #include <pwd.h> char *TCID = "sysctl03"; + +/* This is an older/deprecated syscall that newer arches are omitting */ +#ifdef __NR_sysctl + int TST_TOTAL = 2; int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp, @@ -213,3 +217,14 @@ void cleanup(void) { TEST_CLEANUP; } + +#else +int TST_TOTAL = 0; /* Total number of test cases. */ + +int main() +{ + + tst_resm(TCONF, "This test needs a kernel that has sysctl syscall."); + tst_exit(); +} +#endif diff --git a/testcases/kernel/syscalls/sysctl/sysctl04.c b/testcases/kernel/syscalls/sysctl/sysctl04.c index 3e41418..bda1020 100644 --- a/testcases/kernel/syscalls/sysctl/sysctl04.c +++ b/testcases/kernel/syscalls/sysctl/sysctl04.c @@ -54,6 +54,10 @@ #include <linux/sysctl.h> char *TCID = "sysctl04"; + +/* This is an older/deprecated syscall that newer arches are omitting */ +#ifdef __NR_sysctl + int TST_TOTAL = 2; int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp, @@ -166,3 +170,14 @@ void cleanup() TEST_CLEANUP; } + +#else +int TST_TOTAL = 0; /* Total number of test cases. */ + +int main() +{ + + tst_resm(TCONF, "This test needs a kernel that has sysctl syscall."); + tst_exit(); +} +#endif diff --git a/testcases/kernel/syscalls/sysctl/sysctl05.c b/testcases/kernel/syscalls/sysctl/sysctl05.c index 4ec4e20..e06ad6e 100644 --- a/testcases/kernel/syscalls/sysctl/sysctl05.c +++ b/testcases/kernel/syscalls/sysctl/sysctl05.c @@ -56,6 +56,10 @@ #include <errno.h> char *TCID = "sysctl05"; + +/* This is an older/deprecated syscall that newer arches are omitting */ +#ifdef __NR_sysctl + int TST_TOTAL = 2; int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp, @@ -193,3 +197,14 @@ void cleanup() TEST_CLEANUP; } + +#else +int TST_TOTAL = 0; /* Total number of test cases. */ + +int main() +{ + + tst_resm(TCONF, "This test needs a kernel that has sysctl syscall."); + tst_exit(); +} +#endif hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-02-06 06:56:19
|
The branch, master, has been updated via a60edf1089d273faef33a6a0e099531507007cf7 (commit) from 64c5621e219e30d420d5602643fedcb3e3ff710f (commit) - Log ----------------------------------------------------------------- commit a60edf1089d273faef33a6a0e099531507007cf7 Author: Wanlong Gao <gao...@cn...> Date: Wed Feb 6 14:06:20 2013 +0800 syscall: add open11 to gitignore Add open/open11 to gitignore. Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/.gitignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore index 003c5d0..d661159 100644 --- a/testcases/kernel/syscalls/.gitignore +++ b/testcases/kernel/syscalls/.gitignore @@ -578,6 +578,7 @@ /open/open08 /open/open09 /open/open10 +/open/open11 /openat/openat01 /pathconf/pathconf01 /pause/pause01 hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-02-05 12:56:20
|
The branch, master, has been updated via 64c5621e219e30d420d5602643fedcb3e3ff710f (commit) from 4d1cf776b9134f0e592c67d4355ed207bf50d903 (commit) - Log ----------------------------------------------------------------- commit 64c5621e219e30d420d5602643fedcb3e3ff710f Author: Yan Lei <yan...@cn...> Date: Tue Feb 5 15:33:05 2013 +0800 fix race at exit by checking if write completed The same issue as: commit 352358cd9f69f6e8296cc201b14bae938287796e Author: Jan Stancek <jst...@re...> Date: Mon, 28 Jan 2013 11:36:48 +0100 aio_fsync/2-1.c: fix race at exit, check if write completed This patch waits for aio_fsync to complete and after that checks that previously queued write is also completed. Signed-off-by: Yan Lei <yan...@cn...> Acked-by: Jan Stancek <jst...@re...> ----------------------------------------------------------------------- Summary of changes: .../conformance/interfaces/aio_fsync/3-1.c | 26 ++++++++++++++++--- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/3-1.c index f30f472..6f0098d 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/3-1.c @@ -27,7 +27,7 @@ int main() { char tmpfname[256]; char buf[BUF_SIZE]; - int fd; + int fd, ret; struct aiocb aiocb_write; struct aiocb aiocb_fsync; @@ -62,10 +62,28 @@ int main() printf(TNAME " Error at aio_fsync(): %s\n", strerror(errno)); exit(PTS_FAIL); } + /* wait for aio_fsync */ + do { + usleep(10000); + ret = aio_error(&aiocb_fsync); + } while (ret == EINPROGRESS); - close(fd); + ret = aio_return(&aiocb_fsync); + if (ret) { + printf(TNAME " Error at aio_return(): %d (%s)\n", + ret, strerror(errno)); + close(fd); + return PTS_FAIL; + } - /* we didn't check if the operation is really performed */ + /* check that aio_write is completed at this point */ + ret = aio_error(&aiocb_write); + if (ret == EINPROGRESS) { + printf(TNAME " aiocb_write still in progress\n"); + close(fd); + return PTS_FAIL; + } - return PTS_UNTESTED; + close(fd); + return PTS_PASS; } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-02-05 07:56:38
|
The branch, master, has been updated via 4d1cf776b9134f0e592c67d4355ed207bf50d903 (commit) via 4582b9c13a7e2b610b3b7cead3f1c0930468b5ff (commit) via 40e9ee3e258dbdc7c957c94e3205d44c7480477b (commit) via 78d42779bb87102d5dd1fd2441c9928d543b5839 (commit) via 32b27f93d536eeccaec2f7586931ee765cae4525 (commit) via b4f038d8087f4c8eb1b0a3c95cb09cf211989fc9 (commit) via 68f73c342c58e570beb15217c57b69dec1c280b7 (commit) via 777588e5b5948a712adc0cafe591f32d9190e1d4 (commit) via 001ce03e83d4f7918307eb7cd57b6721c200e0b5 (commit) via b2c141f68823c9d7968ced2221f75a90b14fdebd (commit) from 4d7e1881df9b25812be790e1d1016cfe8c0b5755 (commit) - Log ----------------------------------------------------------------- commit 4d1cf776b9134f0e592c67d4355ed207bf50d903 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open10: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit 4582b9c13a7e2b610b3b7cead3f1c0930468b5ff Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open09: rework test case Rework this test case. Signed-off-by: Wanlong Gao <gao...@cn...> commit 40e9ee3e258dbdc7c957c94e3205d44c7480477b Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open08: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit 78d42779bb87102d5dd1fd2441c9928d543b5839 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open07: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit 32b27f93d536eeccaec2f7586931ee765cae4525 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open06: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit b4f038d8087f4c8eb1b0a3c95cb09cf211989fc9 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open05: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit 68f73c342c58e570beb15217c57b69dec1c280b7 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open04: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit 777588e5b5948a712adc0cafe591f32d9190e1d4 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open03: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit 001ce03e83d4f7918307eb7cd57b6721c200e0b5 Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open02: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> commit b2c141f68823c9d7968ced2221f75a90b14fdebd Author: Wanlong Gao <gao...@cn...> Date: Mon Feb 4 17:11:18 2013 +0800 open01: code cleanups Cleanup the coding style. Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/open/open01.c | 42 ++---- testcases/kernel/syscalls/open/open02.c | 33 ++---- testcases/kernel/syscalls/open/open03.c | 141 ++------------------- testcases/kernel/syscalls/open/open04.c | 74 +++-------- testcases/kernel/syscalls/open/open05.c | 72 ++++-------- testcases/kernel/syscalls/open/open06.c | 57 ++------- testcases/kernel/syscalls/open/open07.c | 136 +++++++++----------- testcases/kernel/syscalls/open/open08.c | 113 +++++++---------- testcases/kernel/syscalls/open/open09.c | 137 +++++++++----------- testcases/kernel/syscalls/open/open10.c | 210 ++++++++++++------------------- 10 files changed, 336 insertions(+), 679 deletions(-) diff --git a/testcases/kernel/syscalls/open/open01.c b/testcases/kernel/syscalls/open/open01.c index 0d5c384..fe8be43 100644 --- a/testcases/kernel/syscalls/open/open01.c +++ b/testcases/kernel/syscalls/open/open01.c @@ -59,10 +59,10 @@ char *TCID = "open01"; int TST_TOTAL = 1; -char pfilname[40] = ""; +static char pfilname[40] = ""; -void cleanup(void); -void setup(void); +static void cleanup(void); +static void setup(void); int main(int ac, char **av) { @@ -76,11 +76,11 @@ int main(int ac, char **av) /* * parse standard command line options */ - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - setup(); /* global setup for test */ + setup(); /* * check looping state if -i option given on the command line @@ -91,7 +91,8 @@ int main(int ac, char **av) /* test #1 */ TEST(open(pfilname, O_RDWR | O_CREAT, 01444)); - if ((fildes = TEST_RETURN) == -1) { + fildes = TEST_RETURN; + if (fildes == -1) { tst_resm(TFAIL, "Cannot open %s", pfilname); continue; } @@ -134,27 +135,21 @@ int main(int ac, char **av) } /* clean up things is case we are looping */ - if (close(fildes) == -1) { + if (close(fildes) == -1) tst_brkm(TBROK, cleanup, "close #1 failed"); - } - if (unlink(pfilname) == -1) { + if (unlink(pfilname) == -1) tst_brkm(TBROK, cleanup, "can't remove file"); - } - if (close(TEST_RETURN) == -1) { + if (close(TEST_RETURN) == -1) tst_brkm(TBROK, cleanup, "close #2 failed"); - } } - cleanup(); + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { umask(0); @@ -167,18 +162,9 @@ void setup(void) sprintf(pfilname, "open3.%d", getpid()); } -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit. - */ -void cleanup(void) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open02.c b/testcases/kernel/syscalls/open/open02.c index 22dff85..877ac65 100644 --- a/testcases/kernel/syscalls/open/open02.c +++ b/testcases/kernel/syscalls/open/open02.c @@ -53,12 +53,12 @@ char *TCID = "open02"; int TST_TOTAL = 1; -char pfilname[40] = ""; +static char pfilname[40] = ""; -int exp_enos[] = { ENOENT, 0 }; +static int exp_enos[] = { ENOENT, 0 }; -void cleanup(void); -void setup(void); +static void cleanup(void); +static void setup(void); int main(int ac, char **av) { @@ -68,11 +68,11 @@ int main(int ac, char **av) /* * parse standard command line options */ - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - setup(); /* global setup for test */ + setup(); TEST_EXP_ENOS(exp_enos); @@ -98,15 +98,12 @@ int main(int ac, char **av) tst_resm(TPASS, "open returned ENOENT"); } } - cleanup(); + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { umask(0); @@ -119,18 +116,8 @@ void setup(void) sprintf(pfilname, "./open3.%d", getpid()); } -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit. - */ -void cleanup(void) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open03.c b/testcases/kernel/syscalls/open/open03.c index 3446e3c..b47d8a4 100644 --- a/testcases/kernel/syscalls/open/open03.c +++ b/testcases/kernel/syscalls/open/open03.c @@ -23,91 +23,7 @@ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, * Mountain View, CA 94043, or: * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ - * */ -/* $Id: open03.c,v 1.6 2009/08/28 13:35:01 vapier Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : open03 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for open(2) - * - * PARENT DOCUMENT : xxxtds01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : William Roske - * - * CO-PILOT : Dave Fenner - * - * DATE STARTED : 03/30/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) open(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - * - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the open(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * open(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ #include <sys/types.h> #include <sys/fcntl.h> @@ -117,59 +33,42 @@ #include "test.h" #include "usctest.h" -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); -char *TCID = "open03"; /* Test program identifier. */ -int TST_TOTAL = 1; /* Total number of test cases. */ +char *TCID = "open03"; +int TST_TOTAL = 1; -int exp_enos[] = { 0, 0 }; +static int exp_enos[] = { 0, 0 }; -char fname[255]; -int fd; +static char fname[255]; +static int fd; int main(int ac, char **av) { int lc; char *msg; - /*************************************************************** - * parse standard options - ***************************************************************/ - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - /*************************************************************** - * perform global setup for test - ***************************************************************/ setup(); /* set the expected errnos... */ TEST_EXP_ENOS(exp_enos); - /*************************************************************** - * check looping state if -c option given - ***************************************************************/ for (lc = 0; TEST_LOOPING(lc); lc++) { - Tst_count = 0; - /* - * Call open(2) - */ TEST(open(fname, O_RDWR | O_CREAT, 0700)); - fd = TEST_RETURN; - /* check return code */ if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL | TTERRNO, "open(%s,O_RDWR|O_CREAT,0700) failed", fname); } else { - /*************************************************************** - * only perform functional verification if flag set (-f not given) - ***************************************************************/ if (STD_FUNCTIONAL_TEST) { /* No Verification test, yet... */ tst_resm(TPASS, @@ -186,20 +85,12 @@ int main(int ac, char **av) } } - /*************************************************************** - * cleanup and exit - ***************************************************************/ cleanup(); tst_exit(); - } -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; @@ -209,18 +100,8 @@ void setup() sprintf(fname, "tfile_%d", getpid()); } -/*************************************************************** - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - ***************************************************************/ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open04.c b/testcases/kernel/syscalls/open/open04.c index 9bc7f65..0eb00ed 100644 --- a/testcases/kernel/syscalls/open/open04.c +++ b/testcases/kernel/syscalls/open/open04.c @@ -18,9 +18,6 @@ */ /* - * NAME - * open04.c - * * DESCRIPTION * Testcase to check that open(2) sets EMFILE if a process opens files * more than its descriptor size @@ -30,23 +27,8 @@ * Use open(2) for creating files till the descriptor table becomes full. * These open(2)s should succeed. Finally use open(2) to open another * file. This attempt should fail with EMFILE. - * - * USAGE: <for command-line> - * open04 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * NONE - * */ + #include <stdio.h> #include <errno.h> #include <fcntl.h> @@ -57,31 +39,30 @@ char *TCID = "open04"; int TST_TOTAL = 1; -int fd, ifile, mypid, first; -int nfile; -int *buf; -char fname[40]; +static int fd, ifile, mypid, first; +static int nfile; +static int *buf; +static char fname[40]; -int exp_enos[] = { EMFILE, 0 }; +static int exp_enos[] = { EMFILE, 0 }; -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { int lc; char *msg; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); TEST_EXP_ENOS(exp_enos); for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ Tst_count = 0; TEST(open(fname, O_RDWR | O_CREAT, 0777)); @@ -93,25 +74,20 @@ int main(int ac, char **av) TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO != EMFILE) { + if (TEST_ERRNO != EMFILE) tst_resm(TFAIL, "Expected EMFILE, got %d", TEST_ERRNO); - } else { + else tst_resm(TPASS, "call returned expected EMFILE error"); - } } + close(first); close(fd); cleanup(); tst_exit(); - } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; @@ -123,22 +99,23 @@ void setup() nfile = getdtablesize(); sprintf(fname, "open04.%d", mypid); - if ((first = fd = open(fname, O_RDWR | O_CREAT, 0777)) == -1) { + first = fd = open(fname, O_RDWR | O_CREAT, 0777); + if (first == -1) tst_brkm(TBROK, cleanup, "Cannot open first file"); - } close(fd); close(first); unlink(fname); /* Allocate memory for stat and ustat structure variables */ - if ((buf = (int *)malloc(sizeof(int) * nfile - first)) == NULL) { + buf = malloc(sizeof(int) * nfile - first); + if (buf == NULL) tst_brkm(TBROK, NULL, "Failed to allocate Memory"); - } for (ifile = first; ifile <= nfile; ifile++) { sprintf(fname, "open04.%d.%d", ifile, mypid); - if ((fd = open(fname, O_RDWR | O_CREAT, 0777)) == -1) { + fd = open(fname, O_RDWR | O_CREAT, 0777); + if (fd == -1) { if (errno != EMFILE) { tst_brkm(TBROK, cleanup, "Expected EMFILE got " "%d", errno); @@ -149,16 +126,8 @@ void setup() } } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ close(first); TEST_CLEANUP; @@ -171,5 +140,4 @@ void cleanup() /* delete the test directory created in setup() */ tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open05.c b/testcases/kernel/syscalls/open/open05.c index 491eaff..b18f29d 100644 --- a/testcases/kernel/syscalls/open/open05.c +++ b/testcases/kernel/syscalls/open/open05.c @@ -18,28 +18,14 @@ */ /* - * NAME - * open05.c - * * DESCRIPTION * Testcase to check open(2) sets errno to EACCES correctly. * * ALGORITHM * Create a file owned by root with no read permission for other users. * Attempt to open it as ltpuser(1). The attempt should fail with EACCES. - * - * USAGE: <for command-line> - * open05 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * * RESTRICTION * Must run test as root. - * */ #include <errno.h> #include <pwd.h> @@ -50,20 +36,20 @@ #include "test.h" #include "usctest.h" -char user1name[] = "nobody"; +static char user1name[] = "nobody"; char *TCID = "open05"; int TST_TOTAL = 1; extern struct passwd *my_getpwnam(char *); -char fname[20]; -struct passwd *nobody; -int fd; +static char fname[20]; +static struct passwd *nobody; +static int fd; -int exp_enos[] = { EACCES, 0 }; +static int exp_enos[] = { EACCES, 0 }; -void cleanup(void); -void setup(void); +static void cleanup(void); +static void setup(void); int main(int ac, char **av) { @@ -72,24 +58,23 @@ int main(int ac, char **av) int e_code, status, retval = 0; pid_t pid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); TEST_EXP_ENOS(exp_enos); for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ Tst_count = 0; - if ((pid = FORK_OR_VFORK()) == -1) { + pid = FORK_OR_VFORK(); + if (pid == -1) tst_brkm(TBROK, cleanup, "fork() failed"); - } - if (pid == 0) { /* child */ + if (pid == 0) { if (seteuid(nobody->pw_uid) == -1) { tst_resm(TWARN, "seteuid() failed, errno: %d", errno); @@ -114,37 +99,33 @@ int main(int ac, char **av) } /* set the id back to root */ - if (seteuid(0) == -1) { + if (seteuid(0) == -1) tst_resm(TWARN, "seteuid(0) failed"); - } + exit(retval); - } else { /* parent */ + } else { /* wait for the child to finish */ wait(&status); /* make sure the child returned a good exit status */ e_code = status >> 8; - if ((e_code != 0) || (retval != 0)) { + if ((e_code != 0) || (retval != 0)) tst_resm(TFAIL, "Failures reported above"); - } close(fd); cleanup(); } } + tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { /* test must be run as root */ - if (geteuid() != 0) { + if (geteuid() != 0) tst_brkm(TBROK, NULL, "Must run test as root"); - } tst_sig(FORK, DEF_HANDLER, cleanup); @@ -157,26 +138,17 @@ void setup() nobody = my_getpwnam(user1name); - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) { + fd = open(fname, O_RDWR | O_CREAT, 0700); + if (fd == -1) tst_brkm(TBROK, cleanup, "open() failed, errno: %d", errno); - } } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; unlink(fname); /* delete the test directory created in setup() */ tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open06.c b/testcases/kernel/syscalls/open/open06.c index db9f9c4..fc6c093 100644 --- a/testcases/kernel/syscalls/open/open06.c +++ b/testcases/kernel/syscalls/open/open06.c @@ -18,9 +18,6 @@ */ /* - * NAME - * open06.c - * * DESCRIPTION * Testcase to check open(2) sets errno to ENXIO correctly. * @@ -28,21 +25,6 @@ * Create a named pipe using mknod(2). Attempt to * open(2) the pipe for writing. The open(2) should * fail with ENXIO. - * - * USAGE: <for command-line> - * open06 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * NONE */ #include <sys/types.h> #include <sys/stat.h> @@ -55,29 +37,27 @@ char *TCID = "open06"; int TST_TOTAL = 1; -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); -char fname[100] = "fifo"; +static char fname[100] = "fifo"; -int exp_enos[] = { ENXIO, 0 }; +static int exp_enos[] = { ENXIO, 0 }; int main(int ac, char **av) { int lc; char *msg; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); TEST_EXP_ENOS(exp_enos); for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ Tst_count = 0; TEST(open(fname, O_NONBLOCK | O_WRONLY)); @@ -88,27 +68,22 @@ int main(int ac, char **av) TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO != ENXIO) { + if (TEST_ERRNO != ENXIO) tst_resm(TFAIL, "Expected ENXIO got %d", TEST_ERRNO); - } else { + else tst_resm(TPASS, "call returned expected ENXIO error"); - } } + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; - /* make a temporary directory and cd to it */ tst_tmpdir(); sprintf(fname, "%s.%d", fname, getpid()); @@ -117,21 +92,11 @@ void setup() tst_brkm(TBROK, cleanup, "mknod FAILED"); } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; unlink(fname); - /* delete the test directory created in setup() */ tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open07.c b/testcases/kernel/syscalls/open/open07.c index e652132..373691a 100644 --- a/testcases/kernel/syscalls/open/open07.c +++ b/testcases/kernel/syscalls/open/open07.c @@ -40,7 +40,7 @@ * 4. Create a symbolic link to a symbolically linked directory, and call * open(O_NOFOLLOW). Check that it returns ELOOP. * - * 5. Create a symbolic link to a directory, and call + * 5. Create a symbolic link to a directory, and call * open("link/", O_NOFOLLOW). Check that it succeeds. * * USAGE: <for command-line> @@ -67,21 +67,22 @@ #include "test.h" #include "usctest.h" -void setup(void); -void cleanup(void); -void setupfunc_test1(); -void setupfunc_test2(); -void setupfunc_test3(); -void setupfunc_test4(); -void setupfunc_test5(); +static void setup(void); +static void cleanup(void); +static void setupfunc_test1(); +static void setupfunc_test2(); +static void setupfunc_test3(); +static void setupfunc_test4(); +static void setupfunc_test5(); char *TCID = "open07"; int TST_TOTAL = 5; -int fd1, fd2; -int exp_enos[] = { ELOOP, 0 }; +static int fd1, fd2; -struct test_case_t { +static int exp_enos[] = { ELOOP, 0 }; + +static struct test_case_t { char *desc; char filename[100]; int flags; @@ -89,19 +90,17 @@ struct test_case_t { void (*setupfunc) (); int exp_errno; } TC[] = { - { - "Test for ELOOP on f2: f1 -> f2", { - }, O_NOFOLLOW, 00700, setupfunc_test1, ELOOP}, { - "Test for ELOOP on d2: d1 -> d2", { - }, O_NOFOLLOW, 00700, setupfunc_test2, ELOOP}, { - "Test for ELOOP on f3: f1 -> f2 -> f3", { - }, O_NOFOLLOW, 00700, setupfunc_test3, ELOOP}, { - "Test for ELOOP on d3: d1 -> d2 -> d3", { - }, O_NOFOLLOW, 00700, setupfunc_test4, ELOOP}, { - "Test for success on d2: d1 -> d2", { - }, O_NOFOLLOW, 00700, setupfunc_test5, 0}, { - NULL, { - }, 0, 0, NULL, 0} + {"Test for ELOOP on f2: f1 -> f2", {}, + O_NOFOLLOW, 00700, setupfunc_test1, ELOOP}, + {"Test for ELOOP on d2: d1 -> d2", {}, + O_NOFOLLOW, 00700, setupfunc_test2, ELOOP}, + {"Test for ELOOP on f3: f1 -> f2 -> f3", {}, + O_NOFOLLOW, 00700, setupfunc_test3, ELOOP}, + {"Test for ELOOP on d3: d1 -> d2 -> d3", {}, + O_NOFOLLOW, 00700, setupfunc_test4, ELOOP}, + {"Test for success on d2: d1 -> d2", {}, + O_NOFOLLOW, 00700, setupfunc_test5, 0}, + {NULL, {}, 0, 0, NULL, 0} }; int main(int ac, char **av) @@ -110,9 +109,9 @@ int main(int ac, char **av) char *msg; int i; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); @@ -120,19 +119,14 @@ int main(int ac, char **av) /* run the setup routines for the individual tests */ for (i = 0; i < TST_TOTAL; i++) { - if (TC[i].setupfunc != NULL) { + if (TC[i].setupfunc != NULL) TC[i].setupfunc(); - } } - /* The following loop checks looping state if -i option given */ for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ Tst_count = 0; for (i = 0; TC[i].desc != NULL; ++i) { - TEST(open(TC[i].filename, TC[i].flags, TC[i].mode)); if (TC[i].exp_errno != 0) { @@ -161,102 +155,103 @@ int main(int ac, char **av) "expected"); } } + if (TEST_RETURN != -1) close(TEST_RETURN); } } + cleanup(); tst_exit(); } -void setupfunc_test1() +static void setupfunc_test1() { char file1[100], file2[100]; sprintf(file1, "open03.1.%d", getpid()); sprintf(file2, "open03.2.%d", getpid()); - if ((fd1 = creat(file1, 00700)) < 0) { + fd1 = creat(file1, 00700); + if (fd1 < 0) tst_brkm(TBROK, cleanup, "creat(2) failed: errno: %d", errno); - } - if (symlink(file1, file2) < 0) { + + if (symlink(file1, file2) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } + strcpy(TC[0].filename, file2); } -void setupfunc_test2() +static void setupfunc_test2() { char file1[100], file2[100]; sprintf(file1, "open03.3.%d", getpid()); sprintf(file2, "open03.4.%d", getpid()); - if (mkdir(file1, 00700) < 0) { + if (mkdir(file1, 00700) < 0) tst_brkm(TBROK, cleanup, "mkdir(2) failed: errno: %d", errno); - } - if (symlink(file1, file2) < 0) { + + if (symlink(file1, file2) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } + strcpy(TC[1].filename, file2); } -void setupfunc_test3() +static void setupfunc_test3() { char file1[100], file2[100], file3[100]; sprintf(file1, "open03.5.%d", getpid()); sprintf(file2, "open03.6.%d", getpid()); sprintf(file3, "open03.7.%d", getpid()); - if ((fd2 = creat(file1, 00700)) < 0) { + fd2 = creat(file1, 00700); + if (fd2 < 0) tst_brkm(TBROK, cleanup, "creat(2) failed: errno: %d", errno); - } - if (symlink(file1, file2) < 0) { + + if (symlink(file1, file2) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } - if (symlink(file2, file3) < 0) { + + if (symlink(file2, file3) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } + strcpy(TC[2].filename, file3); } -void setupfunc_test4() +static void setupfunc_test4() { char file1[100], file2[100], file3[100]; sprintf(file1, "open03.8.%d", getpid()); sprintf(file2, "open03.9.%d", getpid()); sprintf(file3, "open03.10.%d", getpid()); - if (mkdir(file1, 00700) < 0) { + if (mkdir(file1, 00700) < 0) tst_brkm(TBROK, cleanup, "mkdir(2) failed: errno: %d", errno); - } - if (symlink(file1, file2) < 0) { + + if (symlink(file1, file2) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } - if (symlink(file2, file3) < 0) { + + if (symlink(file2, file3) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } + strcpy(TC[3].filename, file3); } -void setupfunc_test5() +static void setupfunc_test5() { char file1[100], file2[100]; sprintf(file1, "open11.3.%d", getpid()); sprintf(file2, "open12.4.%d", getpid()); - if (mkdir(file1, 00700) < 0) { + if (mkdir(file1, 00700) < 0) tst_brkm(TBROK, cleanup, "mkdir(2) failed: errno: %d", errno); - } - if (symlink(file1, file2) < 0) { + + if (symlink(file1, file2) < 0) tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d", errno); - } + strcpy(TC[4].filename, file2); strcat(TC[4].filename, "/"); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { umask(0); @@ -267,20 +262,11 @@ void setup(void) tst_tmpdir(); } -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void cleanup(void) +static void cleanup(void) { - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ TEST_CLEANUP; close(fd1); close(fd2); tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open08.c b/testcases/kernel/syscalls/open/open08.c index 754f2dd..0e94d92 100644 --- a/testcases/kernel/syscalls/open/open08.c +++ b/testcases/kernel/syscalls/open/open08.c @@ -1,7 +1,22 @@ /* - * NAME - * open08.c + * Copyright (c) 2013 Wanlong Gao <gao...@cn...> * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* * DESCRIPTION * Check for the following errors: * 1. EEXIST @@ -30,22 +45,8 @@ * 6. Attempt to pass an invalid pathname with an address pointing outside * the address space of the process, as the argument to open(), and * expect to get EFAULT. - * - * USAGE: <for command-line> - * open08 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None */ + #define _GNU_SOURCE /* for O_DIRECTORY */ #include <sys/types.h> #include <sys/stat.h> @@ -58,37 +59,35 @@ #include "test.h" #include "usctest.h" -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); char *TCID = "open08"; -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; +static char nobody_uid[] = "nobody"; +static struct passwd *ltpuser; -int exp_enos[] = { EEXIST, EISDIR, ENOTDIR, ENAMETOOLONG, EACCES, EFAULT, 0 }; +static int exp_enos[] = {EEXIST, EISDIR, ENOTDIR, ENAMETOOLONG, + EACCES, EFAULT, 0}; -char *bad_addr = 0; +static char *bad_addr; -char filename[40] = ""; -char fname[] = "/bin/cat"; /* test executable to open */ -char bad_file[] = - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; +static char filename[40] = ""; +static char fname[] = "/bin/cat"; +static char bad_file[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; -struct test_case_t { +static struct test_case_t { char *fname; int flags; int error; } TC[] = { - { - filename, O_CREAT | O_EXCL, EEXIST}, { - "/tmp", O_RDWR, EISDIR}, { - filename, O_DIRECTORY, ENOTDIR}, { - bad_file, O_RDWR, ENAMETOOLONG}, { - fname, O_WRONLY, EACCES}, + {filename, O_CREAT | O_EXCL, EEXIST}, + {"/tmp", O_RDWR, EISDIR}, + {filename, O_DIRECTORY, ENOTDIR}, + {bad_file, O_RDWR, ENAMETOOLONG}, + {fname, O_WRONLY, EACCES}, #if !defined(UCLINUX) - { - (char *)-1, O_CREAT, EFAULT} + {(char *)-1, O_CREAT, EFAULT} #endif }; @@ -100,24 +99,18 @@ int main(int ac, char **av) char *msg; int i; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); - /* set up the expected errnos */ TEST_EXP_ENOS(exp_enos); - /* The following loop checks looping state if -i option given */ for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ Tst_count = 0; - /* loop through the test cases */ for (i = 0; i < TST_TOTAL; i++) { - TEST(open(TC[i].fname, TC[i].flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); @@ -139,15 +132,12 @@ int main(int ac, char **av) } } } - cleanup(); + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { int fildes; @@ -158,9 +148,9 @@ void setup(void) TEST_PAUSE; /* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { + if (geteuid() != 0) tst_brkm(TBROK, NULL, "Test must be run as root"); - } + ltpuser = getpwnam(nobody_uid); if (setgid(ltpuser->pw_gid) == -1) { tst_brkm(TBROK | TERRNO, NULL, "setgid(%d) failed", @@ -174,33 +164,24 @@ void setup(void) sprintf(filename, "open3.%d", getpid()); - if ((fildes = creat(filename, 0600)) == -1) { + fildes = creat(filename, 0600); + if (fildes == -1) tst_brkm(TBROK, cleanup, "Can't creat %s", filename); - } + close(fildes); #if !defined(UCLINUX) bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0); - if (bad_addr == MAP_FAILED) { + if (bad_addr == MAP_FAILED) tst_brkm(TBROK, cleanup, "mmap failed"); - } + TC[5].fname = bad_addr; #endif } -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void cleanup(void) +static void cleanup(void) { - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ TEST_CLEANUP; - tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/open/open09.c b/testcases/kernel/syscalls/open/open09.c index d9564be..e5a3dbe 100644 --- a/testcases/kernel/syscalls/open/open09.c +++ b/testcases/kernel/syscalls/open/open09.c @@ -1,6 +1,6 @@ /* - * * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2013 Wanlong Gao <gao...@cn...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,18 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* Ported from SPIE, section2/iosuite/open1.c, by Airong Zhang */ - -/*====================================================================== - =================== TESTPLAN SEGMENT =================== ->KEYS: < open() ->WHAT: < Does a read on a file opened with oflag = O_WRONLY return -1? - < Does a write on a file opened with oflag = O_RDONLY return -1? ->HOW: < Open a file with O_WRONLY, test for -1 to pass - < Open a file with O_RDONLY, test for -1 to pass ->BUGS: < DUMMY functions used in BSD ->AUTHOR:< PERENNIAL -======================================================================*/ +/* + * Description: + * 1. open an O_WRONLY file, test if read failed. + * 2. open an O_RDONLY file, test if write failed. + */ #include <sys/types.h> #include <sys/stat.h> @@ -38,16 +31,16 @@ #include "usctest.h" char *TCID = "open09"; -int TST_TOTAL = 1; -int local_flag; +int TST_TOTAL = 2; #define PASSED 1 #define FAILED 0 -char progname[] = "open09()"; -char tempfile[40] = ""; +static char tempfile[40] = ""; + +static void setup(void); +static void cleanup(void); -/*--------------------------------------------------------------------*/ int main(int ac, char *av[]) { int fildes; @@ -56,76 +49,66 @@ int main(int ac, char *av[]) int lc; char *msg; - int fail_count = 0; - - /* - * parse standard options - */ - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { - tst_resm(TBROK, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - tst_tmpdir(); - local_flag = PASSED; - sprintf(tempfile, "open09.%d", getpid()); -/*--------------------------------------------------------------------*/ + + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + + setup(); + for (lc = 0; TEST_LOOPING(lc); lc++) { - local_flag = PASSED; - //block0: - if ((fildes = creat(tempfile, 0600)) == -1) { - tst_resm(TBROK, "\t\t\tcan't create '%s'", tempfile); - tst_exit(); - } else { - close(fildes); - if ((fildes = open(tempfile, 1)) == -1) { - tst_resm(TFAIL, "\t\t\topen failed"); - tst_exit(); - } - } + fildes = open(tempfile, O_WRONLY); + if (fildes == -1) + tst_brkm(TFAIL, cleanup, "\t\t\topen failed"); + ret = read(fildes, pbuf, 1); - if (ret != -1) { + if (ret != -1) tst_resm(TFAIL, "read should not succeed"); - local_flag = FAILED; - } - close(fildes); + else + tst_resm(TPASS, "Test passed in O_WRONLY."); - if (local_flag == PASSED) { - tst_resm(TPASS, "Test passed in block0."); - } else { - tst_resm(TFAIL, "Test failed in block0."); - fail_count++; - } + close(fildes); - local_flag = PASSED; - /*--------------------------------------------------------------------*/ - //block1: - if ((fildes = open(tempfile, 0)) == -1) { + fildes = open(tempfile, O_RDONLY); + if (fildes == -1) { tst_resm(TFAIL, "\t\t\topen failed"); - local_flag = FAILED; } else { ret = write(fildes, pbuf, 1); - if (ret != -1) { - tst_resm(TFAIL, "writeshould not succeed"); - local_flag = FAILED; - } + if (ret != -1) + tst_resm(TFAIL, "write should not succeed"); + else + tst_resm(TPASS, "Test passed in O_RDONLY."); } close(fildes); - if (local_flag == PASSED) { - tst_resm(TPASS, "Test passed in block1."); - } else { - tst_resm(TFAIL, "Test failed in block1."); - fail_count++; - } - /*--------------------------------------------------------------------*/ - unlink(tempfile); - tst_rmdir(); + } - if (fail_count == 0) { - tst_resm(TPASS, "Test passed."); - } else { - tst_resm(TFAIL, "Test failed due to above failures."); - } - } /* end for */ + cleanup(); tst_exit(); } + +static void setup(void) +{ + int fildes; + + tst_sig(NOFORK, DEF_HANDLER, cleanup); + TEST_PAUSE; + tst_tmpdir(); + + sprintf(tempfile, "open09.%d", getpid()); + + fildes = creat(tempfile, 0600); + if (fildes == -1) { + tst_brkm(TBROK, cleanup, "\t\t\tcan't create '%s'", + tempfile); + } else { + close(fildes); + } +} + +static void cleanup(void) +{ + TEST_CLEANUP; + unlink(tempfile); + tst_rmdir(); +} diff --git a/testcases/kernel/syscalls/open/open10.c b/testcases/kernel/syscalls/open/open10.c index 6888203..275299e 100644 --- a/testcases/kernel/syscalls/open/open10.c +++ b/testcases/kernel/syscalls/open/open10.c @@ -18,14 +18,9 @@ */ /* - * NAME - * open10.c - Verifies that the group ID and setgid bit are - * set correctly when a new file is created using open. - * (ported from SPIE, section2/iosuite/open5.c, by - * Airong Zhang) - * - * CALLS - * open + * Description: + * Verifies that the group ID and setgid bit are + * set correctly when a new file is created using open. * * ALGORITHM * Create two directories, one with the group ID of this process @@ -37,15 +32,9 @@ * As root, create a file with the setgid bit on in the * directory with the setgid bit. * This tests the SVID3 create group semantics. - * - * USAGE - * open10 - * - * RESTRICTIONS - * */ -#include <stdio.h> /* needed by testhead.h */ +#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/fcntl.h> @@ -57,15 +46,13 @@ char *TCID = "open10"; int TST_TOTAL = 1; -int local_flag; +static int local_flag; #define PASSED 1 #define FAILED 0 -int local_flag; - -#define MODE_RWX S_IRWXU | S_IRWXG | S_IRWXO -#define MODE_SGID S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO +#define MODE_RWX (S_IRWXU | S_IRWXG | S_IRWXO) +#define MODE_SGID (S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO) #define DIR_A_TEMP "open10.testdir.A.%d" #define DIR_B_TEMP "open10.testdir.B.%d" #define SETGID "setgid" @@ -73,34 +60,9 @@ int local_flag; #define ROOT_SETGID "root_setgid" #define MSGSIZE 150 -void cleanup(void); - -char progname[] = "open10()"; +static void setup(void); +static void cleanup(void); -int issu() -{ - - int uid; - - uid = (-1); - uid = geteuid(); - - if (uid == (-1)) { - fprintf(stderr, "geteuid: failed in issu()"); - return (-1); - } - - if (uid == 0) { - return 0; - } else { - fprintf(stderr, "*** NOT SUPERUSER must be root %s\n", - progname); - return (uid); - } - return 0; -} - -/*--------------------------------------------------------------*/ int main(int ac, char *av[]) { int ret; @@ -118,21 +80,13 @@ int main(int ac, char *av[]) char *msg; int fail_count = 0; - /* - * parse standard options - */ - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - tst_tmpdir(); + setup(); - if (issu() != 0) { - tst_resm(TINFO, "Must be root to run this test."); - cleanup(); - } for (lc = 0; TEST_LOOPING(lc); lc++) { - local_flag = PASSED; save_myuid = getuid(); @@ -146,46 +100,45 @@ int main(int ac, char *av[]) sprintf(root_setgid_B, "%s/%s", DIR_B, ROOT_SETGID); /* Get the uid of user1 */ - if ((user1 = getpwnam("nobody")) == NULL) { + user1 = getpwnam("nobody"); + if (user1 == NULL) tst_brkm(TBROK, cleanup, "nobody not in /etc/passwd"); - } + user1_uid = user1->pw_uid; /* * Get the group IDs of group1 and group2. */ - if ((group = getgrnam("nobody")) == NULL) { - if ((group = getgrnam("nogroup")) == NULL) { + group = getgrnam("nobody"); + if (group == NULL) { + group = getgrnam("nogroup"); + if (group == NULL) { tst_brkm(TBROK, cleanup, "nobody/nogroup not in /etc/group"); } } group1_gid = group->gr_gid; - if ((group = getgrnam("bin")) == NULL) { + group = getgrnam("bin"); + if (group == NULL) tst_brkm(TBROK, cleanup, "bin not in /etc/group"); - } - group2_gid = group->gr_gid; - /*--------------------------------------------------------------*/ - /* Block0: Set up the parent directories */ - /*--------------------------------------------------------------*/ - //block0: + group2_gid = group->gr_gid; /* * Create a directory with group id the same as this process * and with no setgid bit. */ - if ((ret = mkdir(DIR_A, MODE_RWX)) < 0) { + if (mkdir(DIR_A, MODE_RWX) < 0) { tst_resm(TFAIL | TERRNO, "mkdir(%s) failed", DIR_A); local_flag = FAILED; } - if ((ret = chown(DIR_A, user1_uid, group2_gid)) < 0) { + if (chown(DIR_A, user1_uid, group2_gid) < 0) { tst_resm(TFAIL | TERRNO, "chown(%s) failed", DIR_A); local_flag = FAILED; } - if ((ret = stat(DIR_A, &buf)) < 0) { + if (stat(DIR_A, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", DIR_A); local_flag = FAILED; } @@ -208,22 +161,22 @@ int main(int ac, char *av[]) * Create a directory with group id different from that of * this process and with the setgid bit set. */ - if ((ret = mkdir(DIR_B, MODE_RWX)) < 0) { + if (mkdir(DIR_B, MODE_RWX) < 0) { tst_resm(TFAIL | TERRNO, "mkdir(%s) failed", DIR_B); local_flag = FAILED; } - if ((ret = chown(DIR_B, user1_uid, group2_gid)) < 0) { + if (chown(DIR_B, user1_uid, group2_gid) < 0) { tst_resm(TFAIL | TERRNO, "chown(%s) failed", DIR_B); local_flag = FAILED; } - if ((ret = chmod(DIR_B, MODE_SGID)) < 0) { + if (chmod(DIR_B, MODE_SGID) < 0) { tst_resm(TFAIL | TERRNO, "chmod(%s) failed", DIR_B); local_flag = FAILED; } - if ((ret = stat(DIR_B, &buf)) < 0) { + if (stat(DIR_B, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", DIR_B); local_flag = FAILED; } @@ -252,26 +205,21 @@ int main(int ac, char *av[]) local_flag = PASSED; - /*--------------------------------------------------------------*/ - /* Block1: Create two files in testdir.A, one with the setgid */ - /* bit set in the creation modes and the other without. */ - /* Both should inherit the group ID of the process and */ - /* maintain the setgid bit as specified in the creation */ - /* modes. */ - /*--------------------------------------------------------------*/ - //block1: - /* - * Now become user1, group1 + * Create two files in testdir.A, one with the setgid + * bit set in the creation modes and the other without. + * Both should inherit the group ID of the process and + * maintain the setgid bit as specified in the creation + * modes. */ - if ((ret = setgid(group1_gid)) < 0) { + if (setgid(group1_gid) < 0) { tst_resm(TINFO, "Unable to set process group ID to group1"); } - if ((ret = setreuid(-1, user1_uid)) < 0) { + if (setreuid(-1, user1_uid) < 0) tst_resm(TINFO, "Unable to set process uid to user1"); - } + mygid = getgid(); /* @@ -284,7 +232,7 @@ int main(int ac, char *av[]) } close(ret); - if ((ret = stat(nosetgid_A, &buf)) < 0) { + if (stat(nosetgid_A, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", nosetgid_A); local_flag = FAILED; } @@ -313,7 +261,7 @@ int main(int ac, char *av[]) } close(ret); - if ((ret = stat(setgid_A, &buf)) < 0) { + if (stat(setgid_A, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", setgid_A); local_flag = FAILED; } @@ -342,15 +290,13 @@ int main(int ac, char *av[]) local_flag = PASSED; - /*--------------------------------------------------------------*/ - /* Block2: Create two files in testdir.B, one with the setgid */ - /* bit set in the creation modes and the other without. */ - /* Both should inherit the group ID of the parent */ - /* directory, group2. Either file should have the segid */ - /* bit set in the modes. */ - /*--------------------------------------------------------------*/ - //block2: - + /* + * Create two files in testdir.B, one with the setgid + * bit set in the creation modes and the other without. + * Both should inherit the group ID of the parent + * directory, group2. Either file should have the segid + * bit set in the modes. + */ /* * Create the file with setgid not set */ @@ -361,7 +307,7 @@ int main(int ac, char *av[]) } close(ret); - if ((ret = stat(nosetgid_B, &buf)) < 0) { + if (stat(nosetgid_B, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", nosetgid_B); local_flag = FAILED; } @@ -391,7 +337,7 @@ int main(int ac, char *av[]) } close(ret); - if ((ret = stat(setgid_B, &buf)) < 0) { + if (stat(setgid_B, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", setgid_B); local_flag = FAILED; } @@ -420,31 +366,30 @@ int main(int ac, char *av[]) local_flag = PASSED; - /*--------------------------------------------------------------*/ - /* Block3: Create a file in testdir.B, with the setgid bit set */ - /* in the creation modes and do so as root. The file */ - /* should inherit the group ID of the parent directory, */ - /* group2 and should have the setgid bit set. */ - /*--------------------------------------------------------------*/ - //block3: + /* + * Create a file in testdir.B, with the setgid bit set + * in the creation modes and do so as root. The file + * should inherit the group ID of the parent directory, + * group2 and should have the setgid bit set. + */ /* Become root again */ - if ((ret = setreuid(-1, save_myuid)) < 0) { + if (setreuid(-1, save_myuid) < 0) { tst_resm(TFAIL | TERRNO, "Changing back to root failed"); local_flag = FAILED; } /* Create the file with setgid set */ - if ((ret = open(root_setgid_B, O_CREAT | O_EXCL | O_RDWR, - MODE_SGID)) < 0) { + ret = open(root_setgid_B, O_CREAT | O_EXCL | O_RDWR, MODE_SGID); + if (ret < 0) { tst_resm(TFAIL | TERRNO, "open(%s) failed", root_setgid_B); local_flag = FAILED; } close(ret); - if ((ret = stat(root_setgid_B, &buf)) < 0) { + if (stat(root_setgid_B, &buf) < 0) { tst_resm(TFAIL | TERRNO, "stat(%s) failed", root_setgid_B); local_flag = FAILED; @@ -472,27 +417,27 @@ int main(int ac, char *av[]) fail_count++; } - /*--------------------------------------------------------------*/ - /* Clean up any files created by test before call to anyfail. */ - /* Remove the directories. */ - /*--------------------------------------------------------------*/ - if ((ret = unlink(setgid_A)) < 0) + /* + * Clean up any files created by test before call to anyfail. + * Remove the directories. + */ + if (unlink(setgid_A) < 0) tst_resm(TWARN | TERRNO, "unlink(%s) failed", setgid_A); - if ((ret = unlink(nosetgid_A)) < 0) + if (unlink(nosetgid_A) < 0) tst_resm(TWARN | TERRNO, "unlink(%s) failed", nosetgid_A); - if ((ret = rmdir(DIR_A)) < 0) + if (rmdir(DIR_A) < 0) tst_resm(TWARN | TERRNO, "rmdir(%s) failed", DIR_A); - if ((ret = unlink(setgid_B)) < 0) + if (unlink(setgid_B) < 0) tst_resm(TWARN | TERRNO, "unlink(%s) failed", setgid_B); - if ((ret = unlink(root_setgid_B)) < 0) + if (unlink(root_setgid_B) < 0) tst_resm(TWARN | TERRNO, "unlink(%s) failed", root_setgid_B); - if ((ret = unlink(nosetgid_B)) < 0) + if (unlink(nosetgid_B) < 0) tst_resm(TWARN | TERRNO, "unlink(%s) failed", nosetgid_B); - if ((ret = rmdir(DIR_B)) < 0) + if (rmdir(DIR_B) < 0) tst_resm(TWARN | TERRNO, "rmdir(%s) failed", DIR_B); if (fail_count == 0) { @@ -503,18 +448,21 @@ int main(int ac, char *av[]) } } + cleanup(); tst_exit(); } -void cleanup(void) +static void setup(void) { - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; + tst_require_root(NULL); + tst_sig(NOFORK, DEF_HANDLER, cleanup); + TEST_PAUSE; + tst_tmpdir(); +} +static void cleanup(void) +{ + TEST_CLEANUP; tst_rmdir(); - } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-02-04 05:56:35
|
The branch, master, has been updated via 4d7e1881df9b25812be790e1d1016cfe8c0b5755 (commit) from 352358cd9f69f6e8296cc201b14bae938287796e (commit) - Log ----------------------------------------------------------------- commit 4d7e1881df9b25812be790e1d1016cfe8c0b5755 Author: Eryu Guan <eg...@re...> Date: Mon Feb 4 11:22:12 2013 +0800 syscalls/open11: new open(2) test case In addition to existing open(2) tests, add more basic tests and make sure open(2) works and handles error conditions correctly. There are 28 test cases: 1. Open regular file O_RDONLY 2. Open regular file O_WRONLY 3. Open regular file O_RDWR 4. Open regular file O_RDWR | O_SYNC 5. Open regular file O_RDWR | O_TRUNC 6. Open dir O_RDONLY 7. Open dir O_RDWR, expect EISDIR 8. Open regular file O_DIRECTORY, expect ENOTDIR 9. Open hard link file O_RDONLY 10. Open hard link file O_WRONLY 11. Open hard link file O_RDWR 12. Open sym link file O_RDONLY 13. Open sym link file O_WRONLY 14. Open sym link file O_RDWR 15. Open sym link dir O_RDONLY 16. Open sym link dir O_WRONLY, expect EISDIR 17. Open sym link dir O_RDWR, expect EISDIR 18. Open device special file O_RDONLY 19. Open device special file O_WRONLY 20. Open device special file O_RDWR 21. Open non-existing regular file in existing dir 22. Open link file O_RDONLY | O_CREAT 23. Open symlink file O_RDONLY | O_CREAT 24. Open regular file O_RDONLY | O_CREAT 25. Open symlink dir O_RDONLY | O_CREAT, expect EISDIR 26. Open dir O_RDONLY | O_CREAT, expect EISDIR 27. Open regular file O_RDONLY | O_TRUNC, behaviour is undefined but should not oops or hang 28. Open regular file(non-empty) O_RDONLY | O_TRUNC, behaviour is undefined but should not oops or hang Signed-off-by: Eryu Guan <eg...@re...> Acked-by: Wanlong Gao <gao...@cn...> Reviewed-by: Caspar Zhang <ca...@ca...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: runtest/ltplite | 1 + runtest/stress.part3 | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/open/open11.c | 424 +++++++++++++++++++++++++++++++ 4 files changed, 427 insertions(+), 0 deletions(-) create mode 100644 testcases/kernel/syscalls/open/open11.c diff --git a/runtest/ltplite b/runtest/ltplite index 95774da..35cbd44 100644 --- a/runtest/ltplite +++ b/runtest/ltplite @@ -539,6 +539,7 @@ open07 open07 open08 open08 open09 open09 open10 open10 +open11 open11 mincore01 mincore01 #mincore02 mincore02 currently hangs and does not exit correctly diff --git a/runtest/stress.part3 b/runtest/stress.part3 index 99eeddc..f3c4287 100644 --- a/runtest/stress.part3 +++ b/runtest/stress.part3 @@ -461,6 +461,7 @@ open07 open07 open08 open08 open09 open09 open10 open10 +open11 open11 pathconf01 pathconf01 diff --git a/runtest/syscalls b/runtest/syscalls index e2f6b84..db5a075 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -680,6 +680,7 @@ open07 open07 open08 open08 open09 open09 open10 open10 +open11 open11 #openat test cases openat01 openat01 diff --git a/testcases/kernel/syscalls/open/open11.c b/testcases/kernel/syscalls/open/open11.c new file mode 100644 index 0000000..ce2ff46 --- /dev/null +++ b/testcases/kernel/syscalls/open/open11.c @@ -0,0 +1,424 @@ +/* + * Copyright (C) 2013 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it + * is free of the rightful claim of any third person regarding + * infringement or the like. Any license provided herein, whether + * implied or otherwise, applies only to this software file. Patent + * licenses, if any, provided herein do not apply to combinations of + * this program with other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/* + * Basic tests for open(2) and make sure open(2) works and handles error + * conditions correctly. + * + * There are 28 test cases: + * 1. Open regular file O_RDONLY + * 2. Open regular file O_WRONLY + * 3. Open regular file O_RDWR + * 4. Open regular file O_RDWR | O_SYNC + * 5. Open regular file O_RDWR | O_TRUNC + * 6. Open dir O_RDONLY + * 7. Open dir O_RDWR, expect EISDIR + * 8. Open regular file O_DIRECTORY, expect ENOTDIR + * 9. Open hard link file O_RDONLY + * 10. Open hard link file O_WRONLY + * 11. Open hard link file O_RDWR + * 12. Open sym link file O_RDONLY + * 13. Open sym link file O_WRONLY + * 14. Open sym link file O_RDWR + * 15. Open sym link dir O_RDONLY + * 16. Open sym link dir O_WRONLY, expect EISDIR + * 17. Open sym link dir O_RDWR, expect EISDIR + * 18. Open device special file O_RDONLY + * 19. Open device special file O_WRONLY + * 20. Open device special file O_RDWR + * 21. Open non-existing regular file in existing dir + * 22. Open link file O_RDONLY | O_CREAT + * 23. Open symlink file O_RDONLY | O_CREAT + * 24. Open regular file O_RDONLY | O_CREAT + * 25. Open symlink dir O_RDONLY | O_CREAT, expect EISDIR + * 26. Open dir O_RDONLY | O_CREAT, expect EISDIR + * 27. Open regular file O_RDONLY | O_TRUNC, behaviour is undefined but should + * not oops or hang + * 28. Open regular file(non-empty) O_RDONLY | O_TRUNC, behaviour is undefined + * but should not oops or hang + */ + +#include "config.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "test.h" +#include "usctest.h" + +char *TCID = "open11"; + +/* Define test files */ +#define T_REG "t_reg" /* regular file with content */ +#define T_REG_EMPTY "t_reg_empty" /* empty regular file */ +#define T_LINK_REG "t_link_reg" /* hard link to T_REG */ +#define T_NEW_REG "t_new_reg" /* new regular file to be created */ +#define T_SYMLINK_REG "t_symlink_reg" /* symlink to T_REG */ +#define T_DIR "t_dir" /* test dir */ +#define T_SYMLINK_DIR "t_symlink_dir" /* symlink to T_DIR */ +#define T_DEV "t_dev" /* test device special file */ + +#define T_MSG "this is a test string" + +static void setup(void); +static void cleanup(void); + +struct test_case { + char *desc; + char *path; + int flags; + mode_t mode; + int err; +}; +struct test_case tc[] = { + /* + * Test open(2) regular file + */ + { /* open regular file O_RDONLY */ + .desc = "Open regular file O_RDONLY", + .path = T_REG_EMPTY, + .flags = O_RDONLY, + .mode = 0644, + .err = 0, + }, + { /* open regular file O_WRONLY */ + .desc = "Open regular file O_WRONLY", + .path = T_REG_EMPTY, + .flags = O_WRONLY, + .mode = 0644, + .err = 0, + }, + { /* open regular file O_RDWR */ + .desc = "Open regular file O_RDWR", + .path = T_REG_EMPTY, + .flags = O_RDWR, + .mode = 0644, + .err = 0, + }, + { /* open regular file O_RDWR | O_SYNC*/ + .desc = "Open regular file O_RDWR | O_SYNC", + .path = T_REG_EMPTY, + .flags = O_RDWR | O_SYNC, + .mode = 0644, + .err = 0, + }, + { /* open regular file O_RDWR | O_TRUNC */ + .desc = "Open regular file O_RDWR | O_TRUNC", + .path = T_REG_EMPTY, + .flags = O_RDWR | O_TRUNC, + .mode = 0644, + .err = 0, + }, + /* + * Test open(2) directory + */ + { /* open dir O_RDONLY */ + .desc = "Open dir O_RDONLY", + .path = T_DIR, + .flags = O_RDONLY, + .mode = 0755, + .err = 0, + }, + { /* open dir O_RDWR */ + .desc = "Open dir O_RDWR, expect EISDIR", + .path = T_DIR, + .flags = O_RDWR, + .mode = 0755, + .err = EISDIR, + }, + { /* open regular file O_DIRECTORY */ + .desc = "Open regular file O_DIRECTORY, expect ENOTDIR", + .path = T_REG_EMPTY, + .flags = O_RDONLY | O_DIRECTORY, + .mode = 0644, + .err = ENOTDIR, + }, + /* + * Test open(2) hard link + */ + { /* open hard link file O_RDONLY */ + .desc = "Open hard link file O_RDONLY", + .path = T_LINK_REG, + .flags = O_RDONLY, + .mode = 0644, + .err = 0, + }, + { /* open hard link file O_WRONLY */ + .desc = "Open hard link file O_WRONLY", + .path = T_LINK_REG, + .flags = O_WRONLY, + .mode = 0644, + .err = 0, + }, + { /* open hard link file O_RDWR */ + .desc = "Open hard link file O_RDWR", + .path = T_LINK_REG, + .flags = O_RDWR, + .mode = 0644, + .err = 0, + }, + /* + * Test open(2) sym link + */ + { /* open sym link file O_RDONLY */ + .desc = "Open sym link file O_RDONLY", + .path = T_SYMLINK_REG, + .flags = O_RDONLY, + .mode = 0644, + .err = 0, + }, + { /* open sym link file O_WRONLY */ + .desc = "Open sym link file O_WRONLY", + .path = T_SYMLINK_REG, + .flags = O_WRONLY, + .mode = 0644, + .err = 0, + }, + { /* open sym link file O_RDWR */ + .desc = "Open sym link file O_RDWR", + .path = T_SYMLINK_REG, + .flags = O_RDWR, + .mode = 0644, + .err = 0, + }, + { /* open sym link dir O_RDONLY */ + .desc = "Open sym link dir O_RDONLY", + .path = T_SYMLINK_DIR, + .flags = O_RDONLY, + .mode = 0644, + .err = 0, + }, + { /* open sym link dir O_WRONLY */ + .desc = "Open sym link dir O_WRONLY, expect EISDIR", + .path = T_SYMLINK_DIR, + .flags = O_WRONLY, + .mode = 0644, + .err = EISDIR, + }, + { /* open sym link dir O_RDWR */ + .desc = "Open sym link dir O_RDWR, expect EISDIR", + .path = T_SYMLINK_DIR, + .flags = O_RDWR, + .mode = 0644, + .err = EISDIR, + }, + /* + * Test open(2) device special + */ + { /* open device special file O_RDONLY */ + .desc = "Open device special file O_RDONLY", + .path = T_DEV, + .flags = O_RDONLY, + .mode = 0644, + .err = 0, + }, + { /* open device special file O_WRONLY */ + .desc = "Open device special file O_WRONLY", + .path = T_DEV, + .flags = O_WRONLY, + .mode = 0644, + .err = 0, + }, + { /* open device special file O_RDWR */ + .desc = "Open device special file O_RDWR", + .path = T_DEV, + .flags = O_RDWR, + .mode = 0644, + .err = 0, + }, + /* + * Test open(2) non-existing file + */ + { /* open non-existing regular file in existing dir */ + .desc = "Open non-existing regular file in existing dir", + .path = T_DIR"/"T_NEW_REG, + .flags = O_RDWR | O_CREAT, + .mode = 0644, + .err = 0, + }, + /* + * test open(2) with O_CREAT + */ + { /* open hard link file O_RDONLY | O_CREAT */ + .desc = "Open link file O_RDONLY | O_CREAT", + .path = T_LINK_REG, + .flags = O_RDONLY | O_CREAT, + .mode = 0644, + .err = 0, + }, + { /* open sym link file O_RDONLY | O_CREAT */ + .desc = "Open symlink file O_RDONLY | O_CREAT", + .path = T_SYMLINK_REG, + .flags = O_RDONLY | O_CREAT, + .mode = 0644, + .err = 0, + }, + { /* open regular file O_RDONLY | O_CREAT */ + .desc = "Open regular file O_RDONLY | O_CREAT", + .path = T_REG_EMPTY, + .flags = O_RDONLY | O_CREAT, + .mode = 0644, + .err = 0, + }, + { /* open symlink dir O_RDONLY | O_CREAT */ + .desc = "Open symlink dir O_RDONLY | O_CREAT, expect EISDIR", + .path = T_SYMLINK_DIR, + .flags = O_RDONLY | O_CREAT, + .mode = 0644, + .err = EISDIR, + }, + { /* open dir O_RDONLY | O_CREAT */ + .desc = "Open dir O_RDONLY | O_CREAT, expect EISDIR", + .path = T_DIR, + .flags = O_RDONLY | O_CREAT, + .mode = 0644, + .err = EISDIR, + }, + /* + * Other random open(2) tests + */ + { /* open regular file O_RDONLY | O_TRUNC */ + .desc = "Open regular file O_RDONLY | O_TRUNC, " + "behaviour is undefined but should not oops or hang", + .path = T_REG_EMPTY, + .flags = O_RDONLY | O_TRUNC, + .mode = 0644, + .err = -1, + }, + { /* open regular(non-empty) file O_RDONLY | O_TRUNC */ + .desc = "Open regular file(non-empty) O_RDONLY | O_TRUNC, " + "behaviour is undefined but should not oops or hang", + .path = T_REG, + .flags = O_RDONLY | O_TRUNC, + .mode = 0644, + .err = -1, + }, +}; + +int TST_TOTAL = sizeof(tc) / sizeof(tc[0]); + +int main(int argc, char *argv[]) +{ + int lc; + int i; + int fd; + int ret; + char *msg; + + msg = parse_opts(argc, argv, NULL, NULL); + if (msg != NULL) + tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); + + setup(); + + for (lc = 0; TEST_LOOPING(lc); lc++) { + for (i = 0; i < TST_TOTAL; i++) { + TEST(open(tc[i].path, tc[i].flags, tc[i].mode)); + fd = TEST_RETURN; + + if (tc[i].err == -1 || TEST_ERRNO == tc[i].err) { + tst_resm(TPASS, "%s", tc[i].desc); + } else { + tst_resm(TFAIL | TTERRNO, + "%s - expected errno %d - Got", + tc[i].desc, tc[i].err); + } + if (fd > 0) { + ret = close(fd); + if (ret < 0) + tst_resm(TWARN, "%s - close failed: %s", + tc[i].desc, strerror(errno)); + } + } + } + + cleanup(); + tst_exit(); +} + +static void setup(void) +{ + int fd; + int ret; + + tst_require_root(NULL); + + tst_tmpdir(); + + /* Create test files */ + fd = open(T_REG, O_WRONLY | O_CREAT, 0644); + if (fd == -1) + tst_brkm(TBROK | TERRNO, cleanup, "Create %s failed", T_REG); + ret = write(fd, T_MSG, sizeof(T_MSG)); + if (ret == -1) { + close(fd); + tst_brkm(TBROK | TERRNO, cleanup, "Write %s failed", T_REG); + } + close(fd); + + fd = creat(T_REG_EMPTY, 0644); + if (fd == -1) + tst_brkm(TBROK | TERRNO, cleanup, "Create %s failed", + T_REG_EMPTY); + close(fd); + + ret = link(T_REG, T_LINK_REG); + if (ret == -1) + tst_brkm(TBROK | TERRNO, cleanup, "Hard link %s -> %s failed", + T_REG, T_LINK_REG); + + ret = symlink(T_REG, T_SYMLINK_REG); + if (ret == -1) + tst_brkm(TBROK | TERRNO, cleanup, "Symlink %s -> %s failed", + T_REG, T_SYMLINK_REG); + + ret = mkdir(T_DIR, 0755); + if (ret == -1) + tst_brkm(TBROK | TERRNO, cleanup, "mkdir %s failed", T_DIR); + + ret = symlink(T_DIR, T_SYMLINK_DIR); + if (ret == -1) + tst_brkm(TBROK | TERRNO, cleanup, "Symlink %s -> %s failed", + T_DIR, T_SYMLINK_DIR); + + ret = mknod(T_DEV, S_IFCHR, makedev(1, 5)); + if (ret == -1) + tst_brkm(TBROK | TERRNO, cleanup, "Create char dev %s failed", + T_DEV); + + TEST_PAUSE; +} + +static void cleanup(void) +{ + TEST_CLEANUP; + tst_rmdir(); +} hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-30 01:56:24
|
The branch, master, has been updated via 352358cd9f69f6e8296cc201b14bae938287796e (commit) from ed2416779e8359259ddee1b94d8bdd1274dd681e (commit) - Log ----------------------------------------------------------------- commit 352358cd9f69f6e8296cc201b14bae938287796e Author: Jan Stancek <jst...@re...> Date: Mon Jan 28 11:36:48 2013 +0100 aio_fsync/2-1.c: fix race at exit, check if write completed This is same issue as: commit 4558bfae923a715ac78b5b3d3ecdfa16f9424808 Author: Jan Stancek <jst...@re...> Date: Wed Dec 5 12:49:47 2012 +0100 aio_read/7-1.c: fix race at exit This patch waits for aio_fsync to complete and after that checks that previously queued write is also completed. Signed-off-by: Jan Stancek <jst...@re...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: .../conformance/interfaces/aio_fsync/2-1.c | 26 ++++++++++++++++--- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/2-1.c index a534513..09da565 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_fsync/2-1.c @@ -27,7 +27,7 @@ int main(void) { char tmpfname[256]; char buf[BUF_SIZE]; - int fd; + int fd, ret; struct aiocb aiocb_write; struct aiocb aiocb_fsync; @@ -63,9 +63,27 @@ int main(void) exit(PTS_FAIL); } - close(fd); + /* wait for aio_fsync */ + do { + usleep(10000); + ret = aio_error(&aiocb_fsync); + } while (ret == EINPROGRESS); - /* we didn't check if the operation is really performed */ + ret = aio_return(&aiocb_fsync); + if (ret) { + printf(TNAME " Error at aio_return(): %d (%s)\n", + ret, strerror(errno)); + close(fd); + return PTS_FAIL; + } - return PTS_UNTESTED; + /* check that aio_write is completed at this point */ + ret = aio_error(&aiocb_write); + if (ret == EINPROGRESS) { + printf(TNAME " aiocb_write still in progress\n"); + close(fd); + return PTS_FAIL; + } + close(fd); + return PTS_PASS; } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-22 02:56:26
|
The branch, master, has been updated via ed2416779e8359259ddee1b94d8bdd1274dd681e (commit) from 123bb3de31a26dc667d4e7340e19e0189fb209c2 (commit) - Log ----------------------------------------------------------------- commit ed2416779e8359259ddee1b94d8bdd1274dd681e Author: Zhouping Liu <zl...@re...> Date: Tue Jan 22 10:00:42 2013 +0800 syscalls/sendmsg01: using 'ip' command to replace 'ifconfig' 'ip' tools is more general than 'ifconfig', and there are some distros don't support to install 'ifconfig' tools under default, which will cause such below error: sh: ifconfig: command not found sendmsg01 1 TBROK : ifconfig failed to bring up loop back device sendmsg01 2 TBROK : Remaining cases broken the patch displaced 'ifconfig' using 'ip', and also the case need root permission and to check capture unexpected signal. Now, Try 'ip' first and fallback to 'ifconfig' if 'ip' has failed. Signed-off-by: Zhouping Liu <zl...@re...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/sendmsg/sendmsg01.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c index e1424ca..2a1b2c9 100644 --- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c +++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c @@ -573,6 +573,9 @@ static void setup(void) { int ret = 0; + + tst_require_root(NULL); + tst_sig(FORK, DEF_HANDLER, cleanup); TEST_PAUSE; /* initialize sockaddr's */ @@ -586,13 +589,16 @@ static void setup(void) strcpy(sun1.sun_path, tmpsunpath); /* this test will fail or in some cases hang if no eth or lo is - * configured, so making sure in setup that atleast lo is up + * configured, so making sure in setup that at least lo is up */ - ret = system("ifconfig lo up 127.0.0.1"); + ret = system("ip link set lo up"); if (WEXITSTATUS(ret) != 0) { - tst_brkm(TBROK, cleanup, - "ifconfig failed to bring up loop back device"); - tst_exit(); + ret = system("ifconfig lo up 127.0.0.1"); + if (WEXITSTATUS(ret) != 0) { + tst_brkm(TBROK, cleanup, + "ip/ifconfig failed to bring up loop back device"); + tst_exit(); + } } pid = start_server(&sin1, &sun1); @@ -607,7 +613,6 @@ static void cleanup(void) unlink(tmpsunpath); TEST_CLEANUP; tst_rmdir(); - } static void setup0(void) hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-21 15:56:26
|
The branch, master, has been updated via 123bb3de31a26dc667d4e7340e19e0189fb209c2 (commit) from 8cb84446e476fe942811ba6998a40410c8a944c3 (commit) - Log ----------------------------------------------------------------- commit 123bb3de31a26dc667d4e7340e19e0189fb209c2 Author: Cyril Hrubis <ch...@su...> Date: Mon Jan 21 16:11:26 2013 +0100 syscalls/mremap05: Fix build. Make use of allredy existing HAVE_MREMAP_FIXED macro from config.h. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/mremap/mremap05.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/syscalls/mremap/mremap05.c b/testcases/kernel/syscalls/mremap/mremap05.c index e037be4..07ec49f 100644 --- a/testcases/kernel/syscalls/mremap/mremap05.c +++ b/testcases/kernel/syscalls/mremap/mremap05.c @@ -36,6 +36,7 @@ */ #define _GNU_SOURCE +#include "config.h" #include <sys/mman.h> #include <errno.h> #include <unistd.h> @@ -44,6 +45,8 @@ char *TCID = "mremap05"; +#ifdef HAVE_MREMAP_FIXED + struct test_case_t { char *old_address; char *new_address; @@ -241,3 +244,12 @@ static void cleanup(void) { TEST_CLEANUP; } + +#else + +int main(void) +{ + tst_brkm(TCONF, NULL, "MREMAP_FIXED not present in <sys/mman.h>"); +} + +#endif /* HAVE_MREMAP_FIXED */ hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-21 14:56:30
|
The branch, master, has been updated via 8cb84446e476fe942811ba6998a40410c8a944c3 (commit) via a60ac737cadaacd6c709f1bd7c051de663cd9fc5 (commit) from 385d792b3c1e196c47ddb8a60069886c123c788f (commit) - Log ----------------------------------------------------------------- commit 8cb84446e476fe942811ba6998a40410c8a944c3 Author: Sedat Dilek <sed...@gm...> Date: Mon Jan 21 14:52:38 2013 +0100 doc: Add mini-howto-building-ltp-from-git.txt Signed-off-by: Sedat Dilek <sed...@gm...> commit a60ac737cadaacd6c709f1bd7c051de663cd9fc5 Author: Cyril Hrubis <ch...@su...> Date: Wed Jun 20 17:14:57 2012 +0200 Fix realtime build. Signed-off-by: Cyril Hrubis <ch...@su...> Signed-off-by: Sedat Dilek <sed...@gm...> ----------------------------------------------------------------------- Summary of changes: doc/mini-howto-building-ltp-from-git.txt | 62 ++++++++++++++++++++++++++++++ testcases/realtime/lib/Makefile | 5 +- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 doc/mini-howto-building-ltp-from-git.txt diff --git a/doc/mini-howto-building-ltp-from-git.txt b/doc/mini-howto-building-ltp-from-git.txt new file mode 100644 index 0000000..28825c2 --- /dev/null +++ b/doc/mini-howto-building-ltp-from-git.txt @@ -0,0 +1,62 @@ +Mini-Howto: Building LTP from Git +================================= + +****************************************************************************** +The following document briefly describes the single steps to build LTP from +the Git repository located at GitHub. +The instructions here were tested on a Ubuntu/precise Linux system (feel free +to adapt to your distribution). + +Changelog: + * Initial version: Sedat Dilek <sed...@gm...> + * Embedded comments from Cyril Hrubis <ch...@su...> +****************************************************************************** + +# Export language settings + +export LANG=C +export LC_ALL=C + +# Set some useful variables (adapt if you dislike) + +WORKING_DIR="$HOME/src/ltp" + +PREFIX="/opt/ltp" + +GIT_URL="https://github.com/linux-test-project/ltp.git" + +MAKE_JOBS=$(getconf _NPROCESSORS_ONLN) + +BUILD_LOG_FILE="build-log.txt" +INSTALL_LOG_FILE="install-log.txt" + +# PREREQS on Ubuntu (package-list is incomplete and may vary for other distros) + +sudo apt-get install build-essential +sudo apt-get install autoconf automake autotools-dev m4 +sudo apt-get install git +sudo apt-get install linux-headers-$(uname -r) +sudo apt-get install libaio-dev libattr1-dev libcap-dev + +# Working directory + +mkdir -p $WORKING_DIR +cd $WORKING_DIR + +# Get the LTP source + +git clone $GIT_URL ltp-git + +# Configure LTP + +cd ltp-git/ +make autotools +./configure --prefix=$PREFIX + +# Start building LTP + +make -j$MAKE_JOBS 2>&1 | tee ../$BUILD_LOG_FILE + +# Install LTP (requires superuser privileges) + +sudo make install 2>&1 | tee ../$INSTALL_LOG_FILE diff --git a/testcases/realtime/lib/Makefile b/testcases/realtime/lib/Makefile index 8860549..fc4784b 100644 --- a/testcases/realtime/lib/Makefile +++ b/testcases/realtime/lib/Makefile @@ -2,6 +2,7 @@ # realtime/lib Makefile. # # Copyright (C) 2009, Cisco Systems Inc. +# Copyright (C) 2012 Cyril Hrubis <ch...@su...> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,9 +23,9 @@ top_srcdir ?= ../../.. -include $(top_srcdir)/../config.mk +include $(top_srcdir)/include/mk/env_pre.mk -CFLAGS += -D_GNU_SOURCE +CFLAGS += -D_GNU_SOURCE -I../include/ LDLIBS += -lpthread -lrt -lm hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-16 15:56:27
|
The branch, master, has been updated via 385d792b3c1e196c47ddb8a60069886c123c788f (commit) from 6fb981fc87e5f818f10dc2cd59b5d952b31b2397 (commit) - Log ----------------------------------------------------------------- commit 385d792b3c1e196c47ddb8a60069886c123c788f Author: Sedat Dilek <sed...@gm...> Date: Wed Jan 16 15:54:15 2013 +0100 flock/flock01.c: Trivial: Fix spelling of "succeed" While grepping for "succeeded" in my LTP-lite results I noticed the different spelling. According to my spell-checker integrated in Firefox v18.x the word "succeed" is written with double "e" correctly. Signed-off-by: Sedat Dilek <sed...@gm...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/flock/flock01.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c index 9bf4db3..be2e249 100644 --- a/testcases/kernel/syscalls/flock/flock01.c +++ b/testcases/kernel/syscalls/flock/flock01.c @@ -31,7 +31,7 @@ * (See the parse_opts(3) man page). * * DESCRIPTION - * Test to verify flock(2) succeds with all kind of locks. + * Test to verify flock(2) succeeds with all kind of locks. * Intends to provide a limited exposure of system call. * $ * Setup: @@ -126,7 +126,7 @@ int main(int argc, char **argv) continue; /*next loop for MTKERNEL */ } else { tst_resm(TPASS, - "flock() succeded with %s, returned error number=%d", + "flock() succeeded with %s, returned error number=%d", test_cases[i].opt, TEST_ERRNO); } hooks/post-receive -- ltp |
From: <ch...@su...> - 2013-01-16 14:56:56
|
Hi! > >> diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c > >> index 9bf4db3..be2e249 100644 > >> --- a/testcases/kernel/syscalls/flock/flock01.c > >> +++ b/testcases/kernel/syscalls/flock/flock01.c > >> @@ -31,7 +31,7 @@ > >> * (See the parse_opts(3) man page). > >> * > >> * DESCRIPTION > >> - * Test to verify flock(2) succeds with all kind of locks. > >> + * Test to verify flock(2) succeeds with all kind of locks. > >> * Intends to provide a limited exposure of system call. > >> * $ > >> * Setup: > >> @@ -126,7 +126,7 @@ int main(int argc, char **argv) > >> continue; /*next loop for MTKERNEL */ > >> } else { > >> tst_resm(TPASS, > >> - "flock() succeded with %s, returned error number=%d", > >> + "flock() succeeded with %s, returned error number=%d", > >> test_cases[i].opt, TEST_ERRNO); > >> } > >> > > > > This is not the list you are looking for. The ltp-list is right place to > > send patches. The ltp-commits is list where git post commit hook sends > > info about applied patches. > > > > Argh, don't kill that n00b. I will resend to the correct ML, sorry. No problem ;). -- Cyril Hrubis ch...@su... |
From: Sedat D. <sed...@gm...> - 2013-01-16 14:53:43
|
On Wed, Jan 16, 2013 at 3:52 PM, <ch...@su...> wrote: > Hi! >> Signed-off-by: Sedat Dilek <sed...@gm...> >> --- >> testcases/kernel/syscalls/flock/flock01.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c >> index 9bf4db3..be2e249 100644 >> --- a/testcases/kernel/syscalls/flock/flock01.c >> +++ b/testcases/kernel/syscalls/flock/flock01.c >> @@ -31,7 +31,7 @@ >> * (See the parse_opts(3) man page). >> * >> * DESCRIPTION >> - * Test to verify flock(2) succeds with all kind of locks. >> + * Test to verify flock(2) succeeds with all kind of locks. >> * Intends to provide a limited exposure of system call. >> * $ >> * Setup: >> @@ -126,7 +126,7 @@ int main(int argc, char **argv) >> continue; /*next loop for MTKERNEL */ >> } else { >> tst_resm(TPASS, >> - "flock() succeded with %s, returned error number=%d", >> + "flock() succeeded with %s, returned error number=%d", >> test_cases[i].opt, TEST_ERRNO); >> } >> > > This is not the list you are looking for. The ltp-list is right place to > send patches. The ltp-commits is list where git post commit hook sends > info about applied patches. > Argh, don't kill that n00b. I will resend to the correct ML, sorry. - Sedat - > -- > Cyril Hrubis > ch...@su... |
From: <ch...@su...> - 2013-01-16 14:52:28
|
Hi! > Signed-off-by: Sedat Dilek <sed...@gm...> > --- > testcases/kernel/syscalls/flock/flock01.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c > index 9bf4db3..be2e249 100644 > --- a/testcases/kernel/syscalls/flock/flock01.c > +++ b/testcases/kernel/syscalls/flock/flock01.c > @@ -31,7 +31,7 @@ > * (See the parse_opts(3) man page). > * > * DESCRIPTION > - * Test to verify flock(2) succeds with all kind of locks. > + * Test to verify flock(2) succeeds with all kind of locks. > * Intends to provide a limited exposure of system call. > * $ > * Setup: > @@ -126,7 +126,7 @@ int main(int argc, char **argv) > continue; /*next loop for MTKERNEL */ > } else { > tst_resm(TPASS, > - "flock() succeded with %s, returned error number=%d", > + "flock() succeeded with %s, returned error number=%d", > test_cases[i].opt, TEST_ERRNO); > } > This is not the list you are looking for. The ltp-list is right place to send patches. The ltp-commits is list where git post commit hook sends info about applied patches. -- Cyril Hrubis ch...@su... |
From: Sedat D. <sed...@gm...> - 2013-01-16 13:58:17
|
While grepping for "succeeded" in my LTP-lite results I noticed the different spelling. According to my spell-checker integrated in Firefox v18.x the word "succeed" is written with double "e" correctly. Signed-off-by: Sedat Dilek <sed...@gm...> --- testcases/kernel/syscalls/flock/flock01.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c index 9bf4db3..be2e249 100644 --- a/testcases/kernel/syscalls/flock/flock01.c +++ b/testcases/kernel/syscalls/flock/flock01.c @@ -31,7 +31,7 @@ * (See the parse_opts(3) man page). * * DESCRIPTION - * Test to verify flock(2) succeds with all kind of locks. + * Test to verify flock(2) succeeds with all kind of locks. * Intends to provide a limited exposure of system call. * $ * Setup: @@ -126,7 +126,7 @@ int main(int argc, char **argv) continue; /*next loop for MTKERNEL */ } else { tst_resm(TPASS, - "flock() succeded with %s, returned error number=%d", + "flock() succeeded with %s, returned error number=%d", test_cases[i].opt, TEST_ERRNO); } -- 1.8.1.1 |
From: Cyril H. <su...@li...> - 2013-01-16 07:56:29
|
The branch, master, has been updated via 6fb981fc87e5f818f10dc2cd59b5d952b31b2397 (commit) from f23ce9103c082ce7c8640836fe6245a4e3413ba8 (commit) - Log ----------------------------------------------------------------- commit 6fb981fc87e5f818f10dc2cd59b5d952b31b2397 Author: Zhouping Liu <zl...@re...> Date: Wed Jan 9 19:58:23 2013 +0800 numa/numa01.sh: fixed errors under noncontinuous numa nodes list The previous code numa01.sh thought all NUMA system had continuous numa nodes list, and node id started from 0, but in fact it does not. There are lots of system contains noncontinuous numa nodes list e.g: # numactl --hardware available: 4 nodes (0,2,4,7) node 0 cpus: 0 4 8 12 16 20 24 28 node 0 size: 4061 MB node 0 free: 3756 MB node 2 cpus: 1 5 9 13 17 21 25 29 node 2 size: 4096 MB node 2 free: 3196 MB node 4 cpus: 2 6 10 14 18 22 26 30 node 4 size: 4096 MB node 4 free: 3885 MB node 7 cpus: 3 7 11 15 19 23 27 31 node 7 size: 4095 MB node 7 free: 3947 MB node distances: node 0 2 4 7 0: 10 20 20 20 2: 20 10 20 20 4: 20 20 10 20 7: 20 20 20 10 in such discontinuous nodes system, numa01.sh would fail with such error log: libnuma: Warning: node argument 1 is out of range The patch fixed it, and removed some useless/redundancy val/func, such as 'max_node' val and 'getmax' func, also make some cleanup. Signed-off-by: Zhouping Liu <zl...@re...> Acked-by: Wanlong Gao <gao...@cn...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/numa/numa01.sh | 179 +++++++++++++------------------------- 1 files changed, 61 insertions(+), 118 deletions(-) mode change 100644 => 100755 testcases/kernel/numa/numa01.sh diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh old mode 100644 new mode 100755 index 6ad8b11..19a8f71 --- a/testcases/kernel/numa/numa01.sh +++ b/testcases/kernel/numa/numa01.sh @@ -68,49 +68,6 @@ chk_ifexists() return $RC } - - -# Function: getmax -# -# Description: - Returns the maximum available nodes if success. -# -# Input: - o/p of numactl --hardware command which is expected in the format -# shown below -# available: 2 nodes (0-1) -# node 0 size: 7808 MB -# node 0 free: 7457 MB -# node 1 size: 5807 MB -# node 1 free: 5731 MB -# node distances: -# node 0 1 -# 0: 10 20 -# 1: 20 10 -# -# Return: - zero on success. -# - non-zero on failure. -getmax() -{ - numactl --hardware > $LTPTMP/avail_nodes - - RC=$(awk '{ if ( NR == 1 ) {print $1;} }' $LTPTMP/avail_nodes) - if [ $RC = "available:" ] - then - RC=$(awk '{ if ( NR == 1 ) {print $3;} }' $LTPTMP/avail_nodes) - if [ $RC = "nodes" ] - then - RC=$(awk '{ if ( NR == 1 ) {print $2;} }' $LTPTMP/avail_nodes) - return 0; - else - tst_brkm TBROK NULL "the field nodes in the o/p of numactl --hardware seems to be different" - fi - else - tst_brkm TBROK NULL "the field available in the o/p of numactl --hardware seems to be different" - fi - return 1; -} - - - # Function: extract_numastat # # Description: - extract the value of given row,column from the numastat output . @@ -187,9 +144,6 @@ init() export TCID="Initnuma" export TST_COUNT=0 - # Max. no. of Nodes - max_node=0 - # Page Size page_size=0 @@ -233,18 +187,6 @@ init() chk_ifexists INIT kill || return $RC RC=0 - # set max_node - getmax || return 1 - max_node=$RC - - if [ $max_node -eq 1 ] - then - tst_resm TCONF "non-NUMA aware kernel is running or your machine does not support numa policy or - your machine is not a NUMA machine" - exit 0 - fi - - RC=0 #Set pagesize support_numa $PRT_PG_SIZE > $LTPTMP/numaarg || RC=$? if [ $RC -ne 0 ] @@ -292,7 +234,6 @@ test01() Prev_value=0 # extracted from the numastat o/p Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ PAGESIZE - Node_num=0 col=0 MB=$[1024*1024] @@ -300,13 +241,12 @@ test01() Exp_incr=$[$MB/$page_size] COUNTER=1 - while [ $COUNTER -le $max_node ]; do - Node_num=$[$COUNTER-1] #Node numbers start from 0 + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p numastat > $LTPTMP/numalog extract_numastat local_node $local_node $col || return 1 Prev_value=$RC - numactl --cpunodebind=$Node_num --membind=$Node_num support_numa $ALLOC_1MB + numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB numastat > $LTPTMP/numalog extract_numastat local_node $local_node $col || return 1 Curr_value=$RC @@ -314,7 +254,7 @@ test01() if [ $RC -lt $Exp_incr ] then tst_resm TFAIL \ - "Test #1: NUMA hit and localnode increase in node$Node_num is less than expected" + "Test #1: NUMA hit and localnode increase in node$node is less than expected" return 1 fi COUNTER=$[$COUNTER+1] @@ -340,7 +280,6 @@ test02() Prev_value=0 # extracted from the numastat o/p Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ PAGESIZE - Node_num=0 col=0 MB=$[1024*1024] @@ -348,29 +287,28 @@ test02() Exp_incr=$[$MB/$page_size] COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do - if [ $max_node -eq 1 ] + if [ $total_nodes -eq 1 ] then tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine" return 1 fi - Node_num=$[$COUNTER-1] #Node numbers start from 0 - - if [ $COUNTER -eq $max_node ] #wrap up for last node + if [ $COUNTER -eq $total_nodes ] #wrap up for last node then - Preferred_node=0 + Preferred_node=`echo $nodes_list | cut -d ' ' -f 1` col=2 #column represents node0 in numastat o/p else - Preferred_node=$[$Node_num+1] #always next node is preferred node + # always next node is preferred node + Preferred_node=`echo $nodes_list | cut -d ' ' -f $[COUNTER+1]` col=$[$COUNTER+2] #Preferred Node number in numastat o/p fi numastat > $LTPTMP/numalog extract_numastat other_node $other_node $col || return 1 Prev_value=$RC - numactl --cpunodebind=$Node_num --preferred=$Preferred_node support_numa $ALLOC_1MB + numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $ALLOC_1MB sleep 2s #In RHEL collection of statistics takes more time. numastat > $LTPTMP/numalog extract_numastat other_node $other_node $col || return 1 @@ -379,7 +317,7 @@ test02() if [ $RC -lt $Exp_incr ] then tst_resm TFAIL \ - "Test #2: NUMA hit and othernode increase in node$Node_num is less than expected" + "Test #2: NUMA hit and othernode increase in node$node is less than expected" return 1 fi COUNTER=$[$COUNTER+1] @@ -405,19 +343,18 @@ test03() declare -a parray # array contains previous value of all nodes Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) - Node_num=0 col=0 MB=$[1024*1024] # Increase in numastat o/p is interms of pages Exp_incr=$[$MB/$page_size] # Pages will be allocated using round robin on nodes. - Exp_incr=$[$Exp_incr/$max_node] + Exp_incr=$[$Exp_incr/$total_nodes] # Check whether the pages are equally distributed among available nodes numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p extract_numastat interleave_hit $interleave_hit $col || return 1 Prev_value=$RC @@ -430,16 +367,15 @@ test03() numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p - Node_num=$[$COUNTER-1] #Node numbers start from 0 extract_numastat interleave_hit $interleave_hit $col || return 1 Curr_value=$RC comparelog ${parray[$COUNTER]} $Curr_value if [ $RC -lt $Exp_incr ] then tst_resm TFAIL \ - "Test #3: NUMA interleave hit in node$Node_num is less than expected" + "Test #3: NUMA interleave hit in node$node is less than expected" return 1 fi COUNTER=$[$COUNTER+1] @@ -511,7 +447,6 @@ test05() Prev_value=0 # extracted from the numastat o/p Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ PAGESIZE - Node_num=0 col=0 MB=$[1024*1024] @@ -519,13 +454,12 @@ test05() Exp_incr=$[$MB/$page_size] COUNTER=1 - while [ $COUNTER -le $max_node ]; do - Node_num=$[$COUNTER-1] #Node numbers start from 0 + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p numastat > $LTPTMP/numalog extract_numastat local_node $local_node $col || return 1 Prev_value=$RC - numactl --cpunodebind=$Node_num --localalloc support_numa $ALLOC_1MB + numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB numastat > $LTPTMP/numalog extract_numastat local_node $local_node $col || return 1 Curr_value=$RC @@ -533,7 +467,7 @@ test05() if [ $RC -lt $Exp_incr ] then tst_resm TFAIL \ - "Test #5: NUMA hit and localnode increase in node$Node_num is less than expected" + "Test #5: NUMA hit and localnode increase in node$node is less than expected" return 1 fi COUNTER=$[$COUNTER+1] @@ -560,19 +494,18 @@ test06() declare -a parray # array contains previous value of all nodes Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) - Node_num=0 col=0 MB=$[1024*1024] # Increase in numastat o/p is interms of pages Exp_incr=$[$MB/$page_size] # Pages will be allocated using round robin on nodes. - Exp_incr=$[$Exp_incr/$max_node] + Exp_incr=$[$Exp_incr/$total_nodes] # Check whether the pages are equally distributed among available nodes numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p extract_numastat numa_hit $numa_hit $col || return 1 Prev_value=$RC @@ -585,16 +518,15 @@ test06() numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p - Node_num=$[$COUNTER-1] #Node numbers start from 0 extract_numastat numa_hit $numa_hit $col || return 1 Curr_value=$RC comparelog ${parray[$COUNTER]} $Curr_value if [ $RC -lt $Exp_incr ] then tst_resm TFAIL \ - "Test #6: NUMA numa_hit for shm file numa_shm in node$Node_num is less than expected" + "Test #6: NUMA numa_hit for shm file numa_shm in node$node is less than expected" return 1 fi COUNTER=$[$COUNTER+1] @@ -626,19 +558,18 @@ test07() declare -a parray # array contains previous value of all nodes Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) - Node_num=0 col=0 msize=1000 KB=1024 # Increase in numastat o/p is interms of pages Exp_incr=$[($KB * $msize)/$page_size] # Pages will be allocated using round robin on nodes. - Exp_incr=$[$Exp_incr/$max_node] + Exp_incr=$[$Exp_incr/$total_nodes] # Check whether the pages are equally distributed among available nodes numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -lt $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p extract_numastat interleave_hit $interleave_hit $col || return 1 Prev_value=$RC @@ -646,16 +577,14 @@ test07() COUNTER=$[$COUNTER+1] done - numademo -c msize > $LTPTMP/demolog sleep 2s #In RHEL collection of statistics takes more time. numastat > $LTPTMP/numalog COUNTER=1 x=0 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p - Node_num=$[$COUNTER-1] #Node numbers start from 0 extract_numastat interleave_hit $interleave_hit $col || return 1 Curr_value=$RC comparelog ${parray[$COUNTER]} $Curr_value @@ -693,19 +622,18 @@ test08() declare -a parray # array contains previous value of all nodes Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) - Node_num=0 col=0 MB=$[1024*1024] # Increase in numastat o/p is interms of pages Exp_incr=$[$MB/$page_size] # Pages will be allocated using round robin on nodes. - Exp_incr=$[$Exp_incr/$max_node] + Exp_incr=$[$Exp_incr/$total_nodes] # Check whether the pages are equally distributed among available nodes numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo $nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p extract_numastat interleave_hit $interleave_hit $col || return 1 Prev_value=$RC @@ -717,16 +645,15 @@ test08() numastat > $LTPTMP/numalog COUNTER=1 - while [ $COUNTER -le $max_node ]; do + for node in `echo #nodes_list`; do col=$[$COUNTER+1] #Node number in numastat o/p - Node_num=$[$COUNTER-1] #Node numbers start from 0 extract_numastat interleave_hit $interleave_hit $col || return 1 Curr_value=$RC comparelog ${parray[$COUNTER]} $Curr_value if [ $RC -lt $Exp_incr ] then tst_resm TFAIL \ - "Test #8: NUMA interleave hit in node$Node_num is less than expected" + "Test #8: NUMA interleave hit in node$node is less than expected" return 1 fi COUNTER=$[$COUNTER+1] @@ -763,13 +690,12 @@ test09() Prev_value=0 # extracted from the numastat o/p Curr_value=0 # Current value extracted from numastat o/p Exp_incr=0 # 1 MB/ PAGESIZE - Node_num=0 col=0 MB=$[1024*1024] # Increase in numastat o/p is interms of pages Exp_incr=$[$MB/$page_size] - numactl --hardware > $LTPTMP/avail_nodes + numactl --hardware > $LTPTMP/avail_nodes RC=$(awk '{ if ( NR == 1 ) {print $1;} }' $LTPTMP/avail_nodes) if [ $RC = "available:" ] then @@ -797,34 +723,38 @@ test010() { TCID=numa10 TST_COUNT=10 + RC=0 + Prev_value=0 + Curr_value=0 - while [ $COUNTER -le $max_node ]; do + COUNTER=1 + for node in `echo $nodes_list`; do - if [ $max_node -eq 1 ] - then + if [ $total_nodes -eq 1 ] + then tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine" return 1 fi - col=2 #column represents node0 in numastat o/p - numnodes=$(ls /sys/devices/system/node | grep -Ec "node[0-9]*") - Preferred_node=$[$[$numnodes/2]-1] - col=$[$Preferred_node+2] + if [ $COUNTER -eq $total_nodes ]; then + Preferred_node=`echo $nodes_list | cut -d ' ' -f 1` + col=2 + else + Preferred_node=`echo $nodes_list | cut -d ' ' -f $[$COUNTER+1]` + col=$[$COUNTER+2] + fi + numastat > $LTPTMP/numalog extract_numastat other_node $other_node $col || return 1 Prev_value=$RC - #echo $Preferred_node - #numactl --cpunodebind=$Preferred_node --localalloc support_numa $ALLOC_1MB - #numactl --preferred=$Preferred_node support_numa $ALLOC_1MB - numactl --preferred=$Preferred_node support_numa $PAUSE & + numactl --preferred=$node support_numa $PAUSE & pid=$! - migratepages $pid $Preferred_node $[$Preferred_node + 1] + migratepages $pid $node $Preferred_node numastat > $LTPTMP/numalog extract_numastat other_node $other_node $col || return 1 Curr_value=$RC kill -INT $pid - if [ $RC -lt $Prev_value ] - then + if [ $RC -lt $Prev_value ]; then tst_resm TFAIL \ "Test #10: NUMA migratepages is not working fine" return 1 @@ -855,6 +785,19 @@ test010() exit $RC fi + total_nodes=0 # total no. of numa nodes + # all availiable nodes id list + nodes_list=`numactl --show | grep nodebind | cut -d ':' -f 2` + for node in `echo $nodes_list`; do + total_nodes=$[$total_nodes+1] + done + tst_resm TINFO "The system contains $total_nodes nodes: $nodes_list" + if [ $total_nodes -le 1 ]; then + tst_resm TCONF "your machine does not support numa policy or + your machine is not a NUMA machine" + exit 0 + fi + # call each testcases sequentially COUNT=1 while [ $COUNT -le $no_of_test ]; do hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-14 01:56:31
|
The branch, master, has been updated via f23ce9103c082ce7c8640836fe6245a4e3413ba8 (commit) via f2dc27765cab64159a15364848ec8b1e88b40c5c (commit) via 64b777a1ec73f2224ab6d1e469b6368bb58c8666 (commit) from b56a2cde6cfdb9e9a69dbe773a97ed877d3f0180 (commit) - Log ----------------------------------------------------------------- commit f23ce9103c082ce7c8640836fe6245a4e3413ba8 Author: Zhouping Liu <zl...@re...> Date: Fri Jan 4 14:12:10 2013 +0800 mm/include: removed the global var 'memory' we don't use the global var 'memory' any more, so removed it, and changed local var 'memory_new' as 'memory'. Signed-off-by: Zhouping Liu <zl...@re...> Acked-by: Wanlong Gao <gao...@cn...> Signed-off-by: Wanlong Gao <gao...@cn...> commit f2dc27765cab64159a15364848ec8b1e88b40c5c Author: Zhouping Liu <zl...@re...> Date: Fri Jan 4 14:12:09 2013 +0800 mm/lib: rewrote create_same_memory() create_same_memory() was too large and contained lots of duplicated codes, and it's a little hard-coding, so that it's not easy to read and extend it for new case. I splited it for five sub-functions: ksm_child_memset(); create_ksm_child(); stop_ksm_children(); resume_ksm_children(); create_smae_memory(); Also I intruduced a data struct to control the mergeable data: struct ksm_merge_data { char data; int mergeable_size; }; Signed-off-by: Zhouping Liu <zl...@re...> Acked-by: Wanlong Gao <gao...@cn...> Signed-off-by: Wanlong Gao <gao...@cn...> commit 64b777a1ec73f2224ab6d1e469b6368bb58c8666 Author: Yan Lei <yan...@cn...> Date: Fri Jan 11 09:15:25 2013 +0800 mmap/32-1: add \n in the end of output Add \n in the end of output to tidy up the output. Signed-off-by: Yan Lei <yan...@cn...> Reviewed-by: Caspar Zhang <ca...@ca...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/mem/include/_private.h | 2 +- testcases/kernel/mem/include/mem.h | 5 - testcases/kernel/mem/lib/mem.c | 425 ++++++++------------ .../conformance/interfaces/mmap/32-1.c | 2 +- 4 files changed, 171 insertions(+), 263 deletions(-) diff --git a/testcases/kernel/mem/include/_private.h b/testcases/kernel/mem/include/_private.h index 71164f5..d34d417 100644 --- a/testcases/kernel/mem/include/_private.h +++ b/testcases/kernel/mem/include/_private.h @@ -11,7 +11,7 @@ static void _check(char *path, long int value); static void _group_check(int run, int pages_shared, int pages_sharing, int pages_volatile, int pages_unshared, int sleep_millisecs, int pages_to_scan); -static void _verify(char value, int proc, int start, int end, +static void _verify(char **memory, char value, int proc, int start, int end, int start2, int end2); /* cpuset/memcg */ diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h index 16a65db..1233493 100644 --- a/testcases/kernel/mem/include/mem.h +++ b/testcases/kernel/mem/include/mem.h @@ -36,11 +36,6 @@ void testoom(int mempolicy, int lite, int numa); #define PATH_SHMMAX "/proc/sys/kernel/shmmax" -/* - * memory pointer to identify per process, MB unit, and byte like - * memory[process No.][MB unit No.][byte No.]. - */ -char ***memory; void write_memcg(void); void create_same_memory(int size, int num, int unit); int opt_num, opt_size, opt_unit; diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index f095fe1..a827b25 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -200,8 +200,8 @@ static void _group_check(int run, int pages_shared, int pages_sharing, _check("pages_to_scan", pages_to_scan); } -static void _verify(char value, int proc, int start, int end, - int start2, int end2) +static void _verify(char **memory, char value, int proc, + int start, int end, int start2, int end2) { int i, j; void *s = NULL; @@ -212,14 +212,14 @@ static void _verify(char value, int proc, int start, int end, tst_resm(TINFO, "child %d verifies memory content.", proc); memset(s, value, (end - start) * (end2 - start2)); - if (memcmp(memory[proc][start], s, (end - start) * (end2 - start2)) + if (memcmp(memory[start], s, (end - start) * (end2 - start2)) != 0) for (j = start; j < end; j++) for (i = start2; i < end2; i++) - if (memory[proc][j][i] != value) + if (memory[j][i] != value) tst_resm(TFAIL, "child %d has %c at " "%d,%d,%d.", - proc, memory[proc][j][i], proc, + proc, memory[j][i], proc, j, i); free(s); } @@ -235,299 +235,212 @@ void write_memcg(void) write_file(MEMCG_PATH_NEW "/tasks", buf); } -void create_same_memory(int size, int num, int unit) +static struct ksm_merge_data { + char data; + int mergeable_size; +}; + +static void ksm_child_memset(int child_num, int size, int total_unit, + struct ksm_merge_data ksm_merge_data, char **memory) { - char buf[BUFSIZ]; - int i, j, k; - int status; - int *child; - long ps, pages; + int i, j; + int unit = size / total_unit; - ps = sysconf(_SC_PAGE_SIZE); - pages = 1024 * 1024 / ps; + tst_resm(TINFO, "child %d continues...", child_num); - child = malloc(num); - if (child == NULL) - tst_brkm(TBROK | TERRNO, cleanup, "malloc"); + if (ksm_merge_data.mergeable_size == size * MB) { + tst_resm(TINFO, "child %d allocates %d MB filled with '%c'", + child_num, size, ksm_merge_data.data); - memory = malloc(num * sizeof(**memory)); - if (memory == NULL) - tst_brkm(TBROK | TERRNO, cleanup, "malloc"); + } else { + tst_resm(TINFO, "child %d allocates %d MB filled with '%c'" + " except one page with 'e'", + child_num, size, ksm_merge_data.data); + } - /* Don't call cleanup in those children. Instead, do a cleanup from the - parent after fetched children's status. */ - switch (child[0] = fork()) { - case -1: - tst_brkm(TBROK | TERRNO, cleanup, "fork"); - case 0: - tst_resm(TINFO, "child 0 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - - tst_resm(TINFO, "child 0 continues..."); - tst_resm(TINFO, "child 0 allocates %d MB filled with 'c'.", - size); - memory[0] = malloc(size / unit * sizeof(*memory)); - if (memory[0] == NULL) - tst_brkm(TBROK | TERRNO, tst_exit, "malloc"); - for (j = 0; j * unit < size; j++) { - memory[0][j] = mmap(NULL, unit * MB, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - if (memory[0][j] == MAP_FAILED) - tst_brkm(TBROK | TERRNO, tst_exit, "mmap"); + for (j = 0; j < total_unit; j++) { + for (i = 0; i < unit * MB; i++) + memory[j][i] = ksm_merge_data.data; + } + + /* if it contains unshared page, then set 'e' char + * at the end of the last page + */ + if (ksm_merge_data.mergeable_size < size * MB) + memory[j-1][i-1] = 'e'; +} +static void create_ksm_child(int child_num, int size, int unit, + struct ksm_merge_data *ksm_merge_data) +{ + int j, total_unit; + char **memory; + + /* The total units in all */ + total_unit = size / unit; + + /* Apply for the space for memory */ + memory = (char **)malloc(total_unit * sizeof(char *)); + for (j = 0; j < total_unit; j++) { + memory[j] = mmap(NULL, unit * MB, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (memory[j] == MAP_FAILED) + tst_brkm(TBROK|TERRNO, tst_exit, "mmap"); #ifdef HAVE_MADV_MERGEABLE - if (madvise(memory[0][j], unit * MB, MADV_MERGEABLE) - == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "madvise"); + if (madvise(memory[j], unit * MB, MADV_MERGEABLE) == -1) + tst_brkm(TBROK|TERRNO, tst_exit, "madvise"); #endif - for (i = 0; i < unit * MB; i++) - memory[0][j][i] = 'c'; - } - tst_resm(TINFO, "child 0 stops."); + } + + tst_resm(TINFO, "child %d stops.", child_num); + if (raise(SIGSTOP) == -1) + tst_brkm(TBROK|TERRNO, tst_exit, "kill"); + fflush(stdout); + + for (j = 0; j < 4; j++) { + + ksm_child_memset(child_num, size, total_unit, + ksm_merge_data[j], memory); + + fflush(stdout); + + tst_resm(TINFO, "child %d stops.", child_num); if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - - tst_resm(TINFO, "child 0 continues..."); - _verify('c', 0, 0, size / unit, 0, unit * MB); - tst_resm(TINFO, "child 0 changes memory content to 'd'."); - for (j = 0; j < size / unit; j++) { - for (i = 0; i < unit * MB; i++) - memory[0][j][i] = 'd'; + tst_brkm(TBROK|TERRNO, tst_exit, "kill"); + + if (ksm_merge_data[j].mergeable_size < size * MB) { + _verify(memory, 'e', child_num, total_unit - 1, + total_unit, unit * MB - 1, unit * MB); + _verify(memory, ksm_merge_data[j].data, child_num, + 0, total_unit, 0, unit * MB - 1); + } else { + _verify(memory, ksm_merge_data[j].data, child_num, + 0, total_unit, 0, unit * MB); } - /* Unmerge. */ - tst_resm(TINFO, "child 0 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); + } - tst_resm(TINFO, "child 0 continues..."); - _verify('d', 0, 0, size / unit, 0, unit * MB); - /* Stop. */ - tst_resm(TINFO, "child 0 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child 0 continues..."); - exit(0); + tst_resm(TINFO, "child %d finished.", child_num); +} + +static void stop_ksm_children(int *child, int num) +{ + int k, status; + + tst_resm(TINFO, "wait for all children to stop."); + for (k = 0; k < num; k++) { + if (waitpid(child[k], &status, WUNTRACED) == -1) + tst_brkm(TBROK|TERRNO, cleanup, "waitpid"); + if (!WIFSTOPPED(status)) + tst_brkm(TBROK, cleanup, "child %d was not stopped", k); } - switch (child[1] = fork()) { - case -1: - tst_brkm(TBROK | TERRNO, cleanup, "fork"); - case 0: - tst_resm(TINFO, "child 1 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child 1 continues..."); - tst_resm(TINFO, "child 1 allocates %d MB filled with 'a'.", - size); - memory[1] = malloc(size / unit * sizeof(*memory)); - if (memory[1] == NULL) - tst_brkm(TBROK | TERRNO, tst_exit, "malloc"); - for (j = 0; j < size / unit; j++) { - memory[1][j] = mmap(NULL, unit * MB, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - if (memory[1][j] == MAP_FAILED) - tst_brkm(TBROK | TERRNO, tst_exit, "mmap"); -#ifdef HAVE_MADV_MERGEABLE - if (madvise(memory[1][j], unit * MB, MADV_MERGEABLE) - == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "madvise"); -#endif - for (i = 0; i < unit * MB; i++) - memory[1][j][i] = 'a'; - } - tst_resm(TINFO, "child 1 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child 1 continues..."); - _verify('a', 1, 0, size / unit, 0, unit * MB); - tst_resm(TINFO, "child 1 changes memory content to 'b'."); - for (j = 0; j < size / unit; j++) { - for (i = 0; i < unit * MB; i++) - memory[1][j][i] = 'b'; - } - tst_resm(TINFO, "child 1 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child 1 continues..."); - _verify('b', 1, 0, size / unit, 0, unit * MB); - tst_resm(TINFO, "child 1 changes memory content to 'd'"); - for (j = 0; j < size / unit; j++) { - for (i = 0; i < unit * MB; i++) - memory[1][j][i] = 'd'; - } - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); +} - tst_resm(TINFO, "child 1 continues..."); - _verify('d', 1, 0, size / unit, 0, unit * MB); - tst_resm(TINFO, "child 1 changes one page to 'e'."); - memory[1][size / unit - 1][unit * MB - 1] = 'e'; +static void resume_ksm_children(int *child, int num) +{ + int k, status; - /* Unmerge. */ - tst_resm(TINFO, "child 1 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child 1 continues..."); - _verify('e', 1, size / unit - 1, size / unit, - unit * MB - 1, unit * MB); - _verify('d', 1, 0, size / unit - 1, 0, unit * MB - 1); - - /* Stop. */ - tst_resm(TINFO, "child 1 stops."); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child 1 continues..."); - exit(0); + tst_resm(TINFO, "resume all children."); + for (k = 0; k < num; k++) { + if (kill(child[k], SIGCONT) == -1) + tst_brkm(TBROK|TERRNO, cleanup, "kill child[%d]", k); } - for (k = 2; k < num; k++) { - switch (child[k] = fork()) { + fflush(stdout); +} + +void create_same_memory(int size, int num, int unit) +{ + char buf[BUFSIZ]; + int i, j, status, *child; + unsigned long ps, pages; + struct ksm_merge_data **ksm_data; + + struct ksm_merge_data ksm_data0[] = { + {'c', size*MB}, {'c', size*MB}, {'d', size*MB}, {'d', size*MB}, + }; + struct ksm_merge_data ksm_data1[] = { + {'a', size*MB}, {'b', size*MB}, {'d', size*MB}, {'d', size*MB-1}, + }; + struct ksm_merge_data ksm_data2[] = { + {'a', size*MB}, {'a', size*MB}, {'d', size*MB}, {'d', size*MB}, + }; + + ps = sysconf(_SC_PAGE_SIZE); + pages = MB / ps; + + ksm_data = (struct ksm_merge_data **)malloc + ((num - 3) * sizeof(struct ksm_merge_data *)); + /* Since from third child, the data is same with the first child's */ + for (i = 0; i < num - 3; i++) { + ksm_data[i] = (struct ksm_merge_data *)malloc + (4 * sizeof(struct ksm_merge_data)); + for (j = 0; j < 4; j++) { + ksm_data[i][j].data = ksm_data0[j].data; + ksm_data[i][j].mergeable_size = + ksm_data0[j].mergeable_size; + } + } + + child = (int *)malloc(num * sizeof(int)); + if (child == NULL) + tst_brkm(TBROK | TERRNO, cleanup, "malloc"); + + for (i = 0; i < num; i++) { + fflush(stdout); + switch (child[i] = fork()) { case -1: - tst_brkm(TBROK | TERRNO, cleanup, "fork"); + tst_brkm(TBROK|TERRNO, cleanup, "fork"); case 0: - tst_resm(TINFO, "child %d stops.", k); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child %d continues...", k); - tst_resm(TINFO, "child %d allocates %d " - "MB filled with 'a'.", k, size); - memory[k] = malloc(size / unit * sizeof(*memory)); - if (memory[k] == NULL) - tst_brkm(TBROK | TERRNO, tst_exit, "malloc"); - for (j = 0; j < size / unit; j++) { - memory[k][j] = mmap(NULL, unit * MB, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS - | MAP_PRIVATE, -1, 0); - if (memory[k][j] == MAP_FAILED) - tst_brkm(TBROK | TERRNO, cleanup, - "mmap"); -#ifdef HAVE_MADV_MERGEABLE - if (madvise(memory[k][j], unit * MB, - MADV_MERGEABLE) == -1) - tst_brkm(TBROK | TERRNO, cleanup, - "madvise"); -#endif - for (i = 0; i < unit * MB; i++) - memory[k][j][i] = 'a'; + if (i == 0) { + create_ksm_child(i, size, unit, ksm_data0); + exit(0); + } else if (i == 1) { + create_ksm_child(i, size, unit, ksm_data1); + exit(0); + } else if (i == 2) { + create_ksm_child(i, size, unit, ksm_data2); + exit(0); + } else { + create_ksm_child(i, size, unit, ksm_data[i-3]); + exit(0); } - tst_resm(TINFO, "child %d stops.", k); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child %d continues...", k); - tst_resm(TINFO, "child %d changes memory content to " - "'d'", k); - for (j = 0; j < size / unit; j++) { - for (i = 0; i < unit * MB; i++) - memory[k][j][i] = 'd'; - } - /* Unmerge. */ - tst_resm(TINFO, "child %d stops.", k); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child %d continues...", k); - - /* Stop. */ - tst_resm(TINFO, "child %d stops.", k); - if (raise(SIGSTOP) == -1) - tst_brkm(TBROK | TERRNO, tst_exit, "kill"); - tst_resm(TINFO, "child %d continues...", k); - exit(0); } } + + stop_ksm_children(child, num); + tst_resm(TINFO, "KSM merging..."); write_file(PATH_KSM "run", "1"); snprintf(buf, BUFSIZ, "%ld", size * pages * num); write_file(PATH_KSM "pages_to_scan", buf); write_file(PATH_KSM "sleep_millisecs", "0"); - tst_resm(TINFO, "wait for all children to stop."); - for (k = 0; k < num; k++) { - if (waitpid(child[k], &status, WUNTRACED) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "waitpid"); - if (!WIFSTOPPED(status)) - tst_brkm(TBROK, cleanup, "child %d was not stopped.", - k); - } - tst_resm(TINFO, "resume all children."); - for (k = 0; k < num; k++) { - if (kill(child[k], SIGCONT) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "kill child[%d]", k); - } + resume_ksm_children(child, num); _group_check(1, 2, size * num * pages - 2, 0, 0, 0, size * pages * num); - tst_resm(TINFO, "wait for child 1 to stop."); - if (waitpid(child[1], &status, WUNTRACED) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "waitpid"); - if (!WIFSTOPPED(status)) - tst_brkm(TBROK, cleanup, "child 1 was not stopped."); - - /* Child 1 changes all pages to 'b'. */ - tst_resm(TINFO, "resume child 1."); - if (kill(child[1], SIGCONT) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "kill"); + stop_ksm_children(child, num); + resume_ksm_children(child, num); _group_check(1, 3, size * num * pages - 3, 0, 0, 0, size * pages * num); - tst_resm(TINFO, "wait for child 1 to stop."); - if (waitpid(child[1], &status, WUNTRACED) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "waitpid"); - if (!WIFSTOPPED(status)) - tst_brkm(TBROK, cleanup, "child 1 was not stopped."); - - /* All children change pages to 'd'. */ - tst_resm(TINFO, "resume all children."); - for (k = 0; k < num; k++) { - if (kill(child[k], SIGCONT) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "kill child[%d]", k); - } + stop_ksm_children(child, num); + resume_ksm_children(child, num); _group_check(1, 1, size * num * pages - 1, 0, 0, 0, size * pages * num); - tst_resm(TINFO, "wait for all children to stop."); - for (k = 0; k < num; k++) { - if (waitpid(child[k], &status, WUNTRACED) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "waitpid"); - if (!WIFSTOPPED(status)) - tst_brkm(TBROK, cleanup, "child %d was not stopped.", - k); - } - /* Child 1 changes pages to 'e'. */ - tst_resm(TINFO, "resume child 1."); - if (kill(child[1], SIGCONT) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "kill"); + stop_ksm_children(child, num); + resume_ksm_children(child, num); _group_check(1, 1, size * num * pages - 2, 0, 1, 0, size * pages * num); - tst_resm(TINFO, "wait for child 1 to stop."); - if (waitpid(child[1], &status, WUNTRACED) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "waitpid"); - if (!WIFSTOPPED(status)) - tst_brkm(TBROK, cleanup, "child 1 was not stopped."); + stop_ksm_children(child, num); - tst_resm(TINFO, "resume all children."); - for (k = 0; k < num; k++) { - if (kill(child[k], SIGCONT) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "kill child[%d]", k); - } tst_resm(TINFO, "KSM unmerging..."); write_file(PATH_KSM "run", "2"); + + resume_ksm_children(child, num); _group_check(2, 0, 0, 0, 0, 0, size * pages * num); - tst_resm(TINFO, "wait for all children to stop."); - for (k = 0; k < num; k++) { - if (waitpid(child[k], &status, WUNTRACED) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "waitpid"); - if (!WIFSTOPPED(status)) - tst_brkm(TBROK, cleanup, "child %d was not stopped.", - k); - } - tst_resm(TINFO, "resume all children."); - for (k = 0; k < num; k++) { - if (kill(child[k], SIGCONT) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "kill child[%d]", k); - } tst_resm(TINFO, "stop KSM."); write_file(PATH_KSM "run", "0"); _group_check(0, 0, 0, 0, 0, 0, size * pages * num); + while (waitpid(-1, &status, WUNTRACED | WCONTINUED) > 0) if (WEXITSTATUS(status) != 0) tst_resm(TFAIL, "child exit status is %d", diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mmap/32-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mmap/32-1.c index fbefa7b..5828ed2 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mmap/32-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mmap/32-1.c @@ -48,7 +48,7 @@ int main(void) } if (pa == MAP_FAILED) - printf("Test FAILED: Expected EINVAL got %s", strerror(errno)); + printf("Test FAILED: Expected EINVAL got %s\n", strerror(errno)); else printf("Test FAILED: mmap() succedded unexpectedly\n"); hooks/post-receive -- ltp |
From: shubham <sh...@li...> - 2013-01-09 14:34:47
|
On 01/09/2013 06:12 PM, ch...@su... wrote: > Hi! >> Summary of changes: >> VERSION | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/VERSION b/VERSION >> index 384fc2b..3faeef2 100644 >> --- a/VERSION >> +++ b/VERSION >> @@ -1 +1 @@ >> -20120903 >> +20130109 > Ah, you commited it into the sf.net git repo. Remeber the github gets > synced to sf.net not the other way. I've fixed that manually. Please > change your release script to use github. > Sure Cyril. Next time I'll add tag only to github. |
From: <ch...@su...> - 2013-01-09 12:41:54
|
Hi! > Summary of changes: > VERSION | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/VERSION b/VERSION > index 384fc2b..3faeef2 100644 > --- a/VERSION > +++ b/VERSION > @@ -1 +1 @@ > -20120903 > +20130109 Ah, you commited it into the sf.net git repo. Remeber the github gets synced to sf.net not the other way. I've fixed that manually. Please change your release script to use github. -- Cyril Hrubis ch...@su... |
From: Shubham G. <su...@li...> - 2013-01-09 09:33:04
|
The branch, master, has been updated via b56a2cde6cfdb9e9a69dbe773a97ed877d3f0180 (commit) from 45192246690d9c8389f48602dfeb8877d40094bc (commit) - Log ----------------------------------------------------------------- commit b56a2cde6cfdb9e9a69dbe773a97ed877d3f0180 Author: shubham <sh...@oc...> Date: Wed Jan 9 14:56:27 2013 +0530 LTP 20130109 ----------------------------------------------------------------------- Summary of changes: VERSION | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/VERSION b/VERSION index 384fc2b..3faeef2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -20120903 +20130109 hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-01-08 05:56:39
|
The branch, master, has been updated via 45192246690d9c8389f48602dfeb8877d40094bc (commit) from 506c2ddfb5aec45f41396c4f3cbb99d17e5b2a48 (commit) - Log ----------------------------------------------------------------- commit 45192246690d9c8389f48602dfeb8877d40094bc Author: Monson Shao <js...@re...> Date: Tue Jan 8 11:34:44 2013 +0800 containers: delete redundant newline in tst_resm() Some output strings in tst_resm() have ending newline but some have not, and it causes disordered blank line in logfile. Deleting all ending newline makes it uniform and good to read. Signed-off-by: Monson Shao <js...@re...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/containers/mqns/mqns_01.c | 16 +++++----- testcases/kernel/containers/mqns/mqns_02.c | 18 +++++----- testcases/kernel/containers/mqns/mqns_04.c | 24 +++++++------- testcases/kernel/containers/netns/par_chld_ipv6.c | 10 +++--- .../kernel/containers/netns/two_children_ns.c | 10 +++--- testcases/kernel/containers/pidns/pidns01.c | 4 +- testcases/kernel/containers/pidns/pidns05.c | 10 +++--- testcases/kernel/containers/pidns/pidns16.c | 4 +- testcases/kernel/containers/sysvipc/mesgq_nstest.c | 16 +++++----- testcases/kernel/containers/sysvipc/sem_nstest.c | 20 ++++++------ testcases/kernel/containers/sysvipc/semtest_2ns.c | 34 ++++++++++---------- testcases/kernel/containers/sysvipc/shmnstest.c | 16 +++++----- testcases/kernel/containers/utsname/utstest.c | 32 +++++++++--------- 13 files changed, 107 insertions(+), 107 deletions(-) diff --git a/testcases/kernel/containers/mqns/mqns_01.c b/testcases/kernel/containers/mqns/mqns_01.c index cd7c05f..5bdabf1 100644 --- a/testcases/kernel/containers/mqns/mqns_01.c +++ b/testcases/kernel/containers/mqns/mqns_01.c @@ -84,11 +84,11 @@ int main(int argc, char *argv[]) if (argc == 2 && strcmp(argv[1], "-clone") == 0) { tst_resm(TINFO, - "Testing posix mq namespaces through clone(2).\n"); + "Testing posix mq namespaces through clone(2)."); use_clone = T_CLONE; } else tst_resm(TINFO, - "Testing posix mq namespaces through unshare(2).\n"); + "Testing posix mq namespaces through unshare(2)."); if (pipe(p1) == -1 || pipe(p2) == -1) { tst_brkm(TBROK | TERRNO, NULL, "pipe failed"); @@ -99,15 +99,15 @@ int main(int argc, char *argv[]) NULL); if (mqd == -1) { perror("mq_open"); - tst_resm(TFAIL, "mq_open failed\n"); + tst_resm(TFAIL, "mq_open failed"); tst_exit(); } - tst_resm(TINFO, "Checking namespaces isolation from parent to child\n"); + tst_resm(TINFO, "Checking namespaces isolation from parent to child"); /* fire off the test */ r = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_mqueue, NULL); if (r < 0) { - tst_resm(TFAIL, "failed clone/unshare\n"); + tst_resm(TFAIL, "failed clone/unshare"); mq_close(mqd); syscall(__NR_mq_unlink, NOSLASH_MQ1); tst_exit(); @@ -121,11 +121,11 @@ int main(int argc, char *argv[]) tst_resm(TBROK | TERRNO, "read(p2[0], buf, ...) failed"); else { if (!strcmp(buf, "exists")) { - tst_resm(TFAIL, "child process found mqueue\n"); + tst_resm(TFAIL, "child process found mqueue"); } else if (!strcmp(buf, "notfnd")) { - tst_resm(TPASS, "child process didn't find mqueue\n"); + tst_resm(TPASS, "child process didn't find mqueue"); } else { - tst_resm(TFAIL, "UNKNOWN RESULT\n"); + tst_resm(TFAIL, "UNKNOWN RESULT"); } } diff --git a/testcases/kernel/containers/mqns/mqns_02.c b/testcases/kernel/containers/mqns/mqns_02.c index 932ce3c..65cff40 100644 --- a/testcases/kernel/containers/mqns/mqns_02.c +++ b/testcases/kernel/containers/mqns/mqns_02.c @@ -26,7 +26,7 @@ * Check that mq1 is not readable from father * * Changelog: -* Dec 16: accomodate new mqns semantics (Serge Hallyn) +* Dec 16: accomodate new mqns semantics (Serge Hallyn) ***************************************************************************/ @@ -117,11 +117,11 @@ int main(int argc, char *argv[]) if (argc == 2 && strcmp(argv[1], "-clone") == 0) { tst_resm(TINFO, - "Testing posix mq namespaces through clone(2).\n"); + "Testing posix mq namespaces through clone(2)."); use_clone = T_CLONE; } else tst_resm(TINFO, - "Testing posix mq namespaces through unshare(2).\n"); + "Testing posix mq namespaces through unshare(2)."); if (pipe(p1) == -1 || pipe(p2) == -1) { tst_brkm(TBROK | TERRNO, NULL, "pipe"); @@ -130,10 +130,10 @@ int main(int argc, char *argv[]) /* fire off the test */ r = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_mqueue, NULL); if (r < 0) { - tst_brkm(TFAIL, NULL, "failed clone/unshare\n"); + tst_brkm(TFAIL, NULL, "failed clone/unshare"); } - tst_resm(TINFO, "Checking namespaces isolation (child to parent)\n"); + tst_resm(TINFO, "Checking namespaces isolation (child to parent)"); close(p1[0]); close(p2[1]); @@ -144,19 +144,19 @@ int main(int argc, char *argv[]) if (read(p2[0], buf, 7) < 0) { tst_resm(TBROK | TERRNO, "read(p2[0], ..) failed"); } else if (!strcmp(buf, "mqfail")) { - tst_resm(TFAIL, "child process could not create mqueue\n"); + tst_resm(TFAIL, "child process could not create mqueue"); umount(DEV_MQUEUE); } else if (strcmp(buf, "mqopen")) { - tst_resm(TFAIL, "child process could not create mqueue\n"); + tst_resm(TFAIL, "child process could not create mqueue"); umount(DEV_MQUEUE); } else { mqd = syscall(__NR_mq_open, NOSLASH_MQ1, O_RDONLY); if (mqd == -1) { tst_resm(TPASS, - "Parent process can't see the mqueue\n"); + "Parent process can't see the mqueue"); } else { tst_resm(TFAIL | TERRNO, - "Parent process found mqueue\n"); + "Parent process found mqueue"); mq_close(mqd); } if (write(p1[1], "cont", 5) < 0) { diff --git a/testcases/kernel/containers/mqns/mqns_04.c b/testcases/kernel/containers/mqns/mqns_04.c index c883544..3ecf3e5 100644 --- a/testcases/kernel/containers/mqns/mqns_04.c +++ b/testcases/kernel/containers/mqns/mqns_04.c @@ -94,11 +94,11 @@ int main(int argc, char *argv[]) if (argc == 2 && strcmp(argv[1], "-clone") == 0) { tst_resm(TINFO, - "Testing posix mq namespaces through clone(2).\n"); + "Testing posix mq namespaces through clone(2)."); use_clone = T_CLONE; } else tst_resm(TINFO, - "Testing posix mq namespaces through unshare(2).\n"); + "Testing posix mq namespaces through unshare(2)."); if (pipe(p1) == -1) { perror("pipe"); @@ -111,12 +111,12 @@ int main(int argc, char *argv[]) mkdir(DEV_MQUEUE2, 0755); - tst_resm(TINFO, "Checking mqueue filesystem lifetime\n"); + tst_resm(TINFO, "Checking mqueue filesystem lifetime"); /* fire off the test */ rc = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_mqueue, NULL); if (rc < 0) { - tst_resm(TFAIL, "failed clone/unshare\n"); + tst_resm(TFAIL, "failed clone/unshare"); goto fail; } @@ -126,10 +126,10 @@ int main(int argc, char *argv[]) read(p2[0], buf, 7); if (!strcmp(buf, "mqfail")) { - tst_resm(TFAIL, "child process could not create mqueue\n"); + tst_resm(TFAIL, "child process could not create mqueue"); goto fail; } else if (!strcmp(buf, "mount")) { - tst_resm(TFAIL, "child process could not mount mqueue\n"); + tst_resm(TFAIL, "child process could not mount mqueue"); goto fail; } @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) if (rc == -1) { perror("stat"); write(p1[1], "go", 3); - tst_resm(TFAIL, "parent could not see child's created mq\n"); + tst_resm(TFAIL, "parent could not see child's created mq"); goto fail; } write(p1[1], "go", 3); @@ -145,29 +145,29 @@ int main(int argc, char *argv[]) rc = wait(&status); if (rc == -1) { perror("wait"); - tst_resm(TFAIL, "error while parent waited on child to exit\n"); + tst_resm(TFAIL, "error while parent waited on child to exit"); goto fail; } if (!WIFEXITED(status)) { - tst_resm(TFAIL, "Child did not exit normally (status %d)\n", + tst_resm(TFAIL, "Child did not exit normally (status %d)", status); goto fail; } rc = stat(FNAM1, &statbuf); if (rc == -1) { tst_resm(TFAIL, - "parent's view of child's mq died with child\n"); + "parent's view of child's mq died with child"); goto fail; } rc = creat(FNAM2, 0755); if (rc != -1) { tst_resm(TFAIL, - "parent was able to create a file in dead child's mqfs\n"); + "parent was able to create a file in dead child's mqfs"); goto fail; } - tst_resm(TPASS, "Child mqueue fs still visible for parent\n"); + tst_resm(TPASS, "Child mqueue fs still visible for parent"); fail: umount(DEV_MQUEUE2); diff --git a/testcases/kernel/containers/netns/par_chld_ipv6.c b/testcases/kernel/containers/netns/par_chld_ipv6.c index c4b54ae..f0d17ba 100644 --- a/testcases/kernel/containers/netns/par_chld_ipv6.c +++ b/testcases/kernel/containers/netns/par_chld_ipv6.c @@ -65,9 +65,9 @@ int main() ltproot = getenv("LTPROOT"); if (!ltproot) { - tst_resm(TINFO, "LTPROOT env variable is not set\n"); + tst_resm(TINFO, "LTPROOT env variable is not set"); tst_resm(TINFO, - "Please set LTPROOT and re-run the test.. Thankyou\n"); + "Please set LTPROOT and re-run the test.. Thankyou"); return -1; } @@ -89,7 +89,7 @@ int main() if (ret < 0) { perror("unshare"); tst_resm(TFAIL, - "Error:Unshare syscall failed for network namespace\n"); + "Error:Unshare syscall failed for network namespace"); return 1; } #else @@ -104,7 +104,7 @@ int main() if (ret == -1 || status != 0) { tst_resm(TFAIL, "Error: While running the IPv6 tests between \ -parent & child NS\n"); +parent & child NS"); fflush(stdout); exit(1); } @@ -113,7 +113,7 @@ parent & child NS\n"); ret = waitpid(pid, &status, __WALL); status = WEXITSTATUS(status); if (status != 0 || ret == -1) { - tst_resm(TFAIL, "waitpid() returns %d, errno %d\n", ret, + tst_resm(TFAIL, "waitpid() returns %d, errno %d", ret, errno); status = errno; } diff --git a/testcases/kernel/containers/netns/two_children_ns.c b/testcases/kernel/containers/netns/two_children_ns.c index 2e8834d..235d9c4 100644 --- a/testcases/kernel/containers/netns/two_children_ns.c +++ b/testcases/kernel/containers/netns/two_children_ns.c @@ -73,9 +73,9 @@ int main() ltproot = getenv("LTPROOT"); if (!ltproot) { - tst_resm(TINFO, "LTPROOT env variable is not set\n"); + tst_resm(TINFO, "LTPROOT env variable is not set"); tst_resm(TINFO, - "Please set LTPROOT and re-run the test.. Thankyou\n"); + "Please set LTPROOT and re-run the test.. Thankyou"); return -1; } @@ -105,7 +105,7 @@ int main() if (ret < 0) { perror("Unshare"); tst_resm(TFAIL, - "Error:Unshare syscall failed for network namespace\n"); + "Error:Unshare syscall failed for network namespace"); return ret; } #endif @@ -117,7 +117,7 @@ int main() status = WEXITSTATUS(ret); if (ret == -1 || status != 0) { tst_resm(TFAIL, - "Error while running the scripts\n"); + "Error while running the scripts"); exit(status); } } @@ -128,7 +128,7 @@ int main() ret = waitpid(pid[i], &status, __WALL); status = WEXITSTATUS(status); if (status != 0 || ret == -1) { - tst_resm(TFAIL, "waitpid() returns %d, errno %d\n", ret, + tst_resm(TFAIL, "waitpid() returns %d, errno %d", ret, status); fflush(stdout); exit(status); diff --git a/testcases/kernel/containers/pidns/pidns01.c b/testcases/kernel/containers/pidns/pidns01.c index 97322fb..02b4251 100644 --- a/testcases/kernel/containers/pidns/pidns01.c +++ b/testcases/kernel/containers/pidns/pidns01.c @@ -42,7 +42,7 @@ * * History: * -* FLAG DATE NAME DESCRIPTION +* FLAG DATE NAME DESCRIPTION * 27/12/07 RISHIKESH K RAJAK <ris...@in...> Created this test * *******************************************************************************************/ @@ -75,7 +75,7 @@ int child_fn1(void *ttype) cpid = getpid(); ppid = getppid(); - tst_resm(TINFO, "PIDNS test is running inside container\n"); + tst_resm(TINFO, "PIDNS test is running inside container"); if (cpid == CHILD_PID && ppid == PARENT_PID) { printf("Got expected cpid and ppid\n"); exit_val = 0; diff --git a/testcases/kernel/containers/pidns/pidns05.c b/testcases/kernel/containers/pidns/pidns05.c index a2181a1..e70031d 100644 --- a/testcases/kernel/containers/pidns/pidns05.c +++ b/testcases/kernel/containers/pidns/pidns05.c @@ -35,8 +35,8 @@ * * History: * -* FLAG DATE NAME DESCRIPTION -* 31/10/08 Veerendra C <vec...@in...> Verifies killing of NestedCont's +* FLAG DATE NAME DESCRIPTION +* 31/10/08 Veerendra C <vec...@in...> Verifies killing of NestedCont's * *******************************************************************************/ #define _GNU_SOURCE 1 @@ -75,7 +75,7 @@ int max_pid(void) fscanf(fp, "%d", &ret); fclose(fp); } else { - tst_resm(TBROK, "Cannot open /proc/sys/kernel/pid_max \n"); + tst_resm(TBROK, "Cannot open /proc/sys/kernel/pid_max"); ret = -1; } return ret; @@ -178,11 +178,11 @@ void kill_nested_containers() } if (status == 0) - tst_resm(TPASS, "The number of containers killed are %d\n", + tst_resm(TPASS, "The number of containers killed are %d", orig_count - new_count); else tst_resm(TFAIL, "Failed to kill the sub-containers of " - "the container %d\n", pids[MAX_DEPTH - 3]); + "the container %d", pids[MAX_DEPTH - 3]); /* Loops through the containers created to exit from sleep() */ for (i = 0; i < MAX_DEPTH; i++) { diff --git a/testcases/kernel/containers/pidns/pidns16.c b/testcases/kernel/containers/pidns/pidns16.c index 3a077c9..70548e8 100644 --- a/testcases/kernel/containers/pidns/pidns16.c +++ b/testcases/kernel/containers/pidns/pidns16.c @@ -20,7 +20,7 @@ * * - from the parent process and also inside a container * * - Where init has defined a custom handler for USR1 * * - Should call the handler and -* * - Verify whether the signal handler is called from the proper process. +* * - Verify whether the signal handler is called from the proper process. * * * * Description: * * Create PID namespace container. @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) if ((WIFEXITED(status)) && (WEXITSTATUS(status) == 10)) tst_resm(TPASS, "container init continued successfuly, " - "after handling signal -USR1\n"); + "after handling signal -USR1"); else tst_resm(TFAIL, "c-init failed to continue after " "passing kill -USR1"); diff --git a/testcases/kernel/containers/sysvipc/mesgq_nstest.c b/testcases/kernel/containers/sysvipc/mesgq_nstest.c index c318a65..5e5a74f 100644 --- a/testcases/kernel/containers/sysvipc/mesgq_nstest.c +++ b/testcases/kernel/containers/sysvipc/mesgq_nstest.c @@ -17,7 +17,7 @@ * * In Parent Process , create mesgq with key 154326L * Now create container by passing 1 of the flag values.. -* Flag = clone, clone(CLONE_NEWIPC), or unshare(CLONE_NEWIPC) +* Flag = clone, clone(CLONE_NEWIPC), or unshare(CLONE_NEWIPC) * In cloned process, try to access the created mesgq * Test PASS: If the mesgq is readable when flag is None. * Test FAIL: If the mesgq is readable when flag is Unshare or Clone. @@ -57,7 +57,7 @@ void mesgq_read(id) if (n == -1) perror("msgrcv"), tst_exit(); - tst_resm(TINFO, "Mesg read of %d bytes; Type %ld: Msg: %.*s\n", + tst_resm(TINFO, "Mesg read of %d bytes; Type %ld: Msg: %.*s", n, msg.mtype, n, msg.mtext); } @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) char buf[7]; if (argc != 2) { - tst_resm(TFAIL, "Usage: %s <clone|unshare|none>\n", argv[0]); + tst_resm(TFAIL, "Usage: %s <clone|unshare|none>", argv[0]); tst_resm(TFAIL, " where clone, unshare, or fork specifies" " unshare method."); tst_exit(); @@ -130,11 +130,11 @@ int main(int argc, char *argv[]) if (n == -1) perror("msgsnd"), tst_exit(); - tst_resm(TINFO, "mesgq namespaces test : %s\n", tsttype); + tst_resm(TINFO, "mesgq namespaces test : %s", tsttype); /* fire off the test */ ret = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_mesgq, NULL); if (ret < 0) { - tst_resm(TFAIL, "%s failed\n", tsttype); + tst_resm(TFAIL, "%s failed", tsttype); tst_exit(); } @@ -146,15 +146,15 @@ int main(int argc, char *argv[]) if (strcmp(buf, "exists") == 0) { if (use_clone == T_NONE) tst_resm(TPASS, "Plain cloned process found mesgq " - "inside container\n"); + "inside container"); else tst_resm(TFAIL, - "%s: Container init process found mesgq\n", + "%s: Container init process found mesgq", tsttype); } else { if (use_clone == T_NONE) tst_resm(TFAIL, - "Plain cloned process didn't find mesgq\n"); + "Plain cloned process didn't find mesgq"); else tst_resm(TPASS, "%s: Container didn't find mesgq", tsttype); diff --git a/testcases/kernel/containers/sysvipc/sem_nstest.c b/testcases/kernel/containers/sysvipc/sem_nstest.c index 305ca55..2405b24 100644 --- a/testcases/kernel/containers/sysvipc/sem_nstest.c +++ b/testcases/kernel/containers/sysvipc/sem_nstest.c @@ -17,7 +17,7 @@ * * In Parent Process , create semaphore with key 154326L * Now create container by passing 1 of the below flag values.. -* clone(NONE), clone(CLONE_NEWIPC), or unshare(CLONE_NEWIPC) +* clone(NONE), clone(CLONE_NEWIPC), or unshare(CLONE_NEWIPC) * In cloned process, try to access the created semaphore * Test PASS: If the semaphore is readable when flag is None. * Test FAIL: If the semaphore is readable when flag is Unshare or Clone. @@ -57,7 +57,7 @@ int check_semaphore(void *vtest) write(p2[1], "notfnd", 7); else { write(p2[1], "exists", 7); - tst_resm(TINFO, "PID %d: Fetched existing semaphore..id = %d\n", + tst_resm(TINFO, "PID %d: Fetched existing semaphore..id = %d", getpid(), id); } tst_exit(); @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) char buf[7]; if (argc != 2) { - tst_resm(TFAIL, "Usage: %s <clone| unshare| none>\n", argv[0]); + tst_resm(TFAIL, "Usage: %s <clone| unshare| none>", argv[0]); tst_resm(TFAIL, " where clone, unshare, or fork specifies" " unshare method."); tst_exit(); @@ -102,24 +102,24 @@ int main(int argc, char *argv[]) perror("Semaphore create"); if (errno != EEXIST) { perror("semget failure"); - tst_resm(TBROK, "Semaphore creation failed\n"); + tst_resm(TBROK, "Semaphore creation failed"); tst_exit(); } id = semget(MY_KEY, 1, 0); if (id == -1) { perror("Semaphore create"); - tst_resm(TBROK, "Semaphore operation failed\n"); + tst_resm(TBROK, "Semaphore operation failed"); tst_exit(); } } - tst_resm(TINFO, "Semaphore namespaces Isolation test : %s\n", tsttype); + tst_resm(TINFO, "Semaphore namespaces Isolation test : %s", tsttype); /* fire off the test */ ret = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_semaphore, NULL); if (ret < 0) { - tst_resm(TFAIL, "%s failed\n", tsttype); + tst_resm(TFAIL, "%s failed", tsttype); tst_exit(); } @@ -131,15 +131,15 @@ int main(int argc, char *argv[]) if (strcmp(buf, "exists") == 0) { if (use_clone == T_NONE) tst_resm(TPASS, "Plain cloned process found semaphore " - "inside container\n"); + "inside container"); else tst_resm(TFAIL, - "%s: Container init process found semaphore\n", + "%s: Container init process found semaphore", tsttype); } else { if (use_clone == T_NONE) tst_resm(TFAIL, - "Plain cloned process didn't find semaphore\n"); + "Plain cloned process didn't find semaphore"); else tst_resm(TPASS, "%s: Container didn't find semaphore", tsttype); diff --git a/testcases/kernel/containers/sysvipc/semtest_2ns.c b/testcases/kernel/containers/sysvipc/semtest_2ns.c index f80f6dc..d9afc25 100644 --- a/testcases/kernel/containers/sysvipc/semtest_2ns.c +++ b/testcases/kernel/containers/sysvipc/semtest_2ns.c @@ -25,14 +25,14 @@ * In Cont1, create semaphore with key 124326L * In Cont2, try to access the semaphore created in Cont1. * PASS : -* If flag = None and the semaphore is accessible in Cont2. +* If flag = None and the semaphore is accessible in Cont2. * If flag = unshare/clone and the semaphore is not accessible in Cont2. -* If semaphore is not accessible in Cont2, creates new semaphore with +* If semaphore is not accessible in Cont2, creates new semaphore with * the same key to double check isloation in IPCNS. * * FAIL : -* If flag = none and the semaphore is not accessible. -* If flag = unshare/clone and semaphore is accessible in Cont2. +* If flag = none and the semaphore is not accessible. +* If flag = unshare/clone and semaphore is accessible in Cont2. * If the new semaphore creation Fails. ***************************************************************************/ @@ -74,14 +74,14 @@ void sem_lock(int id) /* Checking the semlock and simulating as if the crit-sec is updated */ if (semop(id, &semop_lock[0], 2) < 0) { perror("sem lock error"); - tst_resm(TBROK, "semop failed\n"); + tst_resm(TBROK, "semop failed"); tst_exit(); } - tst_resm(TINFO, "Sem1: File locked, Critical section is updated...\n"); + tst_resm(TINFO, "Sem1: File locked, Critical section is updated..."); sleep(2); if (semop(id, &semop_unlock[0], 1) < 0) { perror("sem unlock error"); - tst_resm(TBROK, "semop failed\n"); + tst_resm(TBROK, "semop failed"); tst_exit(); } } @@ -100,13 +100,13 @@ int check_sem1(void *vtest) perror("Semaphore create"); if (errno != EEXIST) { perror("semget failure"); - tst_resm(TBROK, "semget failure\n"); + tst_resm(TBROK, "semget failure"); tst_exit(); } id1 = semget(MY_KEY, 1, 0); if (id1 == -1) { perror("Semaphore create"); - tst_resm(TBROK, "semget failure\n"); + tst_resm(TBROK, "semget failure"); tst_exit(); } } @@ -141,7 +141,7 @@ int check_sem2(void *vtest) perror("Semaphore create"); if (errno != EEXIST) { perror("semget failure"); - tst_resm(TBROK, "semget failure\n"); + tst_resm(TBROK, "semget failure"); } } else tst_resm(TINFO, @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) if (argc != 2) { tst_resm(TINFO, "Usage: %s <clone| unshare| none>", argv[0]); tst_resm(TINFO, " where clone, unshare, or fork specifies" - " unshare method.\n"); + " unshare method."); tst_exit(); } @@ -190,13 +190,13 @@ int main(int argc, char *argv[]) /* Create 2 containers */ ret = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_sem1, NULL); if (ret < 0) { - tst_resm(TFAIL, "clone/unshare failed\n"); + tst_resm(TFAIL, "clone/unshare failed"); tst_exit(); } ret = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_sem2, NULL); if (ret < 0) { - tst_resm(TFAIL, "clone/unshare failed\n"); + tst_resm(TFAIL, "clone/unshare failed"); tst_exit(); } close(p2[1]); @@ -206,17 +206,17 @@ int main(int argc, char *argv[]) if (use_clone == T_NONE) tst_resm(TPASS, "Plain cloned process able to access the semaphore " - "created\n"); + "created"); else tst_resm(TFAIL, "%s : In namespace2 found the semaphore " - "created in Namespace1\n", tsttype); + "created in Namespace1", tsttype); else if (use_clone == T_NONE) - tst_resm(TFAIL, "Plain cloned process didn't find semaphore\n"); + tst_resm(TFAIL, "Plain cloned process didn't find semaphore"); else tst_resm(TPASS, "%s : In namespace2 unable to access the semaphore " - "created in Namespace1\n", tsttype); + "created in Namespace1", tsttype); /* Delete the semaphore */ id = semget(MY_KEY, 1, 0); diff --git a/testcases/kernel/containers/sysvipc/shmnstest.c b/testcases/kernel/containers/sysvipc/shmnstest.c index 3ceaefa..2188183 100644 --- a/testcases/kernel/containers/sysvipc/shmnstest.c +++ b/testcases/kernel/containers/sysvipc/shmnstest.c @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) char buf[7]; if (argc != 2) { - tst_resm(TFAIL, "Usage: %s <clone|unshare|none>\n", argv[0]); + tst_resm(TFAIL, "Usage: %s <clone|unshare|none>", argv[0]); tst_resm(TFAIL, " where clone, unshare, or fork specifies unshare method."); tst_exit(); @@ -98,15 +98,15 @@ int main(int argc, char *argv[]) id = shmget(TESTKEY, 100, IPC_CREAT); if (id == -1) { perror("shmget"); - tst_resm(TFAIL, "shmget failed\n"); + tst_resm(TFAIL, "shmget failed"); tst_exit(); } - tst_resm(TINFO, "shmid namespaces test : %s\n", tsttype); + tst_resm(TINFO, "shmid namespaces test : %s", tsttype); /* fire off the test */ r = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_shmid, NULL); if (r < 0) { - tst_resm(TFAIL, "%s failed\n", tsttype); + tst_resm(TFAIL, "%s failed", tsttype); tst_exit(); } @@ -116,16 +116,16 @@ int main(int argc, char *argv[]) read(p2[0], buf, 7); if (strcmp(buf, "exists") == 0) { if (use_clone == T_NONE) - tst_resm(TPASS, "plain cloned process found shmid\n"); + tst_resm(TPASS, "plain cloned process found shmid"); else - tst_resm(TFAIL, "%s: child process found shmid\n", + tst_resm(TFAIL, "%s: child process found shmid", tsttype); } else { if (use_clone == T_NONE) tst_resm(TFAIL, - "plain cloned process didn't find shmid\n"); + "plain cloned process didn't find shmid"); else - tst_resm(TPASS, "%s: child process didn't find shmid\n", + tst_resm(TPASS, "%s: child process didn't find shmid", tsttype); } diff --git a/testcases/kernel/containers/utsname/utstest.c b/testcases/kernel/containers/utsname/utstest.c index 727488c..a399605 100644 --- a/testcases/kernel/containers/utsname/utstest.c +++ b/testcases/kernel/containers/utsname/utstest.c @@ -109,10 +109,10 @@ int P1(void *vtest) zeroize(rhostname); len = read(p1fd[0], rhostname, HLEN); if (strcmp(hostname, rhostname) == 0) { - tst_resm(TPASS, "test 1 (%s): success\n", tsttype); + tst_resm(TPASS, "test 1 (%s): success", tsttype); tst_exit(); } - tst_resm(TFAIL, "test 1 (%s): hostname 1 %s, hostname 2 %s\n", + tst_resm(TFAIL, "test 1 (%s): hostname 1 %s, hostname 2 %s", tsttype, hostname, rhostname); tst_exit(); case 2: @@ -128,10 +128,10 @@ int P1(void *vtest) zeroize(rhostname); len = read(p1fd[0], rhostname, HLEN); if (strcmp(newhostname, rhostname) == 0) { - tst_resm(TPASS, "test 2 (%s): success\n", tsttype); + tst_resm(TPASS, "test 2 (%s): success", tsttype); tst_exit(); } - tst_resm(TFAIL, "test 2 (%s) hostname 1 %s, hostname 2 %s\n", + tst_resm(TFAIL, "test 2 (%s) hostname 1 %s, hostname 2 %s", tsttype, newhostname, rhostname); tst_exit(); case 3: @@ -149,16 +149,16 @@ int P1(void *vtest) len = read(p1fd[0], rhostname, HLEN); if (strcmp(newhostname, rhostname) == 0) { tst_resm(TFAIL, - "test 3 (%s): hostname 1 %s, hostname 2 %s, these should have been different\n", + "test 3 (%s): hostname 1 %s, hostname 2 %s, these should have been different", tsttype, newhostname, rhostname); tst_exit(); } if (strcmp(hostname, rhostname) == 0) { - tst_resm(TPASS, "test 3 (%s): success\n", tsttype); + tst_resm(TPASS, "test 3 (%s): success", tsttype); tst_exit(); } tst_resm(TFAIL, - "test 3 (%s): hostname 1 %s, hostname 2 %s, should have been same\n", + "test 3 (%s): hostname 1 %s, hostname 2 %s, should have been same", tsttype, hostname, rhostname); tst_exit(); @@ -170,7 +170,7 @@ int P1(void *vtest) gethostname(newhostname, HLEN); if (strcmp(hostname, newhostname) != 0) { tst_resm(TFAIL, - "test 4 (%s): hostname 1 %s, hostname 2 %s, should be same\n", + "test 4 (%s): hostname 1 %s, hostname 2 %s, should be same", tsttype, hostname, newhostname); tst_exit(); } @@ -180,7 +180,7 @@ int P1(void *vtest) tsttype, hostname, rhostname); tst_exit(); } - tst_resm(TPASS, "test 4 (%s): successful\n", tsttype); + tst_resm(TPASS, "test 4 (%s): successful", tsttype); tst_exit(); case 5: write(p2fd[1], "1", 1); /* tell p2 to go ahead and sethostname */ @@ -189,7 +189,7 @@ int P1(void *vtest) gethostname(newhostname, HLEN); if (strcmp(rhostname, newhostname) != 0) { tst_resm(TFAIL, - "test 5 (%s): hostnames %s and %s should be same\n", + "test 5 (%s): hostnames %s and %s should be same", tsttype, rhostname, newhostname); tst_exit(); } @@ -233,7 +233,7 @@ int P2(void *vtest) len = read(p2fd[0], hostname, 1); } if (hostname[0] == '0') { - tst_resm(TPASS, "P2: P1 claims error\n"); + tst_resm(TPASS, "P2: P1 claims error"); tst_exit(); exit(0); } @@ -243,7 +243,7 @@ int P2(void *vtest) write(p1fd[1], newhostname, strlen(newhostname)); break; default: - tst_resm(TFAIL, "undefined test: %d\n", testnum); + tst_resm(TFAIL, "undefined test: %d", testnum); break; } tst_exit(); @@ -259,11 +259,11 @@ int main(int argc, char *argv[]) void *vtest; if (argc != 3) { - tst_resm(TFAIL, "Usage: %s <clone|unshare> <testnum>\n", + tst_resm(TFAIL, "Usage: %s <clone|unshare> <testnum>", argv[0]); tst_resm(TFAIL, " where clone or unshare specifies unshare method,"); - tst_resm(TFAIL, " and testnum is between 1 and 5 inclusive\n"); + tst_resm(TFAIL, " and testnum is between 1 and 5 inclusive"); exit(2); } if (pipe(p1fd) == -1) { @@ -302,7 +302,7 @@ int main(int argc, char *argv[]) } if (pid == 0) { if (!drop_root()) { - tst_resm(TFAIL, "failed to drop root.\n"); + tst_resm(TFAIL, "failed to drop root."); tst_exit(); exit(1); } @@ -316,7 +316,7 @@ int main(int argc, char *argv[]) break; default: tst_resm(TFAIL, - "testnum should be between 1 and 5 inclusive.\n"); + "testnum should be between 1 and 5 inclusive."); break; } hooks/post-receive -- ltp |
From: Mike F. <su...@li...> - 2013-01-05 04:26:30
|
The branch, master, has been updated via 506c2ddfb5aec45f41396c4f3cbb99d17e5b2a48 (commit) via e04a8ee5668ef13a5670b5c0a0e0150abcf4ed38 (commit) from 38bf6cde3f7b91ed25aeebaae3a1f64664a4b0d4 (commit) - Log ----------------------------------------------------------------- commit 506c2ddfb5aec45f41396c4f3cbb99d17e5b2a48 Author: Mike Frysinger <va...@ge...> Date: Fri Jan 4 23:25:53 2013 -0500 ignore gdb state files Signed-off-by: Mike Frysinger <va...@ge...> commit e04a8ee5668ef13a5670b5c0a0e0150abcf4ed38 Author: Mike Frysinger <va...@ge...> Date: Fri Jan 4 23:23:59 2013 -0500 cpuid: optimize x86 & fix x86_64 truncation Use xchg on x86 to avoid needing to use an intermediate register and shave off one instruction. Skip the whole thing on x86_64 to avoid truncating the top 32bits of the rbx reg due to moving things around with ebx/etc... Signed-off-by: Mike Frysinger <va...@ge...> ----------------------------------------------------------------------- Summary of changes: .gitignore | 2 ++ include/ltp_cpuid.h | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c9f5637..7904fba 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ CVS *.obj *.gdb core +.gdb_history +.gdbinit lib*.a /aclocal.m4 diff --git a/include/ltp_cpuid.h b/include/ltp_cpuid.h index 9052e29..6bd5537 100644 --- a/include/ltp_cpuid.h +++ b/include/ltp_cpuid.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. + * Copyright (c) 2012-2013 The Chromium OS Authors. All rights reserved. * * Licensed under the BSD 3-clause. */ @@ -13,13 +13,17 @@ static inline void cpuid(unsigned int info, unsigned int *eax, unsigned int *ebx #if defined(__i386__) || defined(__x86_64__) unsigned int _eax = info, _ebx, _ecx, _edx; asm volatile( - "mov %%ebx, %%edi;" // save ebx (for PIC) +# ifdef __i386__ + "xchg %%ebx, %%esi;" /* save ebx (for PIC) */ "cpuid;" - "mov %%ebx, %%esi;" // pass to caller - "mov %%edi, %%ebx;" // restore ebx - : "+a" (_eax), "=S" (_ebx), "=c" (_ecx), "=d" (_edx) - : /* inputs: eax is handled above */ - : "edi" /* clobbers: we hit edi directly */ + "xchg %%esi, %%ebx;" /* restore ebx & pass to caller */ + : "=S" (_ebx), +# else + "cpuid;" + : "=b" (_ebx), +# endif + "+a" (_eax), "=c" (_ecx), "=d" (_edx) + : /* inputs: eax is handled above */ ); if (eax) *eax = _eax; if (ebx) *ebx = _ebx; hooks/post-receive -- ltp |