From: Cyril H. <su...@li...> - 2013-10-23 14:51:19
|
The branch, master, has been updated via 6c5ad9bbf066eaf00fbe4aaecc5a2c727a28f14d (commit) via ecd42f7904cb7a2843ee8057a81213f360c68e2b (commit) via c26dd371acbd490b57bf7804371fef065de764ca (commit) via 11a84a6b532b9951a912c0d7a5be72846c33cb54 (commit) from 5ffe7cfe1bf70497ba5a015badc11e97b2003b5f (commit) - Log ----------------------------------------------------------------- commit 6c5ad9bbf066eaf00fbe4aaecc5a2c727a28f14d Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 23 16:17:07 2013 +0200 getcontext01: Cleanup. Add void, static where needed, removed unused comments. Signed-off-by: Cyril Hrubis <ch...@su...> commit ecd42f7904cb7a2843ee8057a81213f360c68e2b Author: Honggyu Kim <hon...@lg...> Date: Wed Oct 23 21:07:30 2013 +0900 getcontext01: check getcontext function in libc getcontext function is implemented depends on libc version and arch. Some libc version for specific arch does not implement getcontext yet. In that case, getcontext just sets errno to ENOSYS and returns -1. For example, getcontext is not implemented before libc-2.17 in ARM. Current test goes to TFAIL when lower version of libc is used in ARM. This patch sets the test as TCONF if libc does not implement getcontext. If ENOSYS is not set and -1 is returned, it goes to TFAIL as it was. Signed-off-by: Honggyu Kim <hon...@lg...> commit c26dd371acbd490b57bf7804371fef065de764ca Author: Jan Stancek <jst...@re...> Date: Thu Oct 17 12:48:46 2013 +0200 getrusage04: skip it on Xen Skip this test on Xen, as it is known to fail, presumably because Xen is not able to account virtual CPU time with same accuracy as on the real CPU. Signed-off-by: Jan Stancek <jst...@re...> Acked-by: Cyril Hrubis <ch...@su...> commit 11a84a6b532b9951a912c0d7a5be72846c33cb54 Author: Jan Stancek <jst...@re...> Date: Thu Oct 17 12:44:49 2013 +0200 lib: add tst_is_virt() The initial version supports only generic check for xen dom0/domU, but should allow to easily extend it for other types of checks, (e.g. KVM guest) if needed later. Signed-off-by: Jan Stancek <jst...@re...> Acked-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: include/test.h | 5 ++ .../migrate_pages_common.h => lib/tst_virt.c | 36 +++++++++--- .../kernel/syscalls/getcontext/getcontext01.c | 62 ++++++++------------ testcases/kernel/syscalls/getrusage/getrusage04.c | 3 + 4 files changed, 60 insertions(+), 46 deletions(-) copy testcases/kernel/syscalls/migrate_pages/migrate_pages_common.h => lib/tst_virt.c (64%) diff --git a/include/test.h b/include/test.h index d9eba31..94fc721 100644 --- a/include/test.h +++ b/include/test.h @@ -63,6 +63,9 @@ #define TRERRNO 0x300 /* Capture errno information from TEST_RETURN to output; useful for pthread-like APIs :). */ +/* virt types for tst_is_virt() */ +#define VIRT_XEN 1 /* xen dom0/domU */ + /* * Ensure that NUMSIGS is defined. * It should be defined in signal.h or sys/signal.h on @@ -189,6 +192,8 @@ int tst_is_cwd_ramfs(void); /* lib/tst_cwd_has_free.c */ int tst_cwd_has_free(int required_kib); +int tst_is_virt(int virt_type); + /* lib/self_exec.c */ void maybe_run_child(void (*child)(), char *fmt, ...); int self_exec(char *argv0, char *fmt, ...); diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages_common.h b/lib/tst_virt.c similarity index 64% copy from testcases/kernel/syscalls/migrate_pages/migrate_pages_common.h copy to lib/tst_virt.c index d821b07..0141c3d 100644 --- a/testcases/kernel/syscalls/migrate_pages/migrate_pages_common.h +++ b/lib/tst_virt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Linux Test Project, Inc. + * Copyright (C) 2013 Linux Test Project * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -22,12 +22,32 @@ * 02110-1301, USA. */ -#ifndef MIGRATE_PAGES_COMMON_H -#define MIGRATE_PAGES_COMMON_H +#include <unistd.h> +#include "test.h" -#define bitsperlong (8 * sizeof(unsigned long)) +static int is_xen(void) +{ + char hypervisor_type[3]; -void set_bit(unsigned long *b, unsigned int n, unsigned int v); -int check_ret(long expected_ret); -int check_errno(long expected_errno); -#endif + if (access("/proc/xen", F_OK) == 0) + return 1; + + if (access("/sys/hypervisor/type", F_OK) == 0) { + SAFE_FILE_SCANF(NULL, "/sys/hypervisor/type", "%3s", + hypervisor_type); + return strncmp("xen", hypervisor_type, + sizeof(hypervisor_type)) == 0; + } + + return 0; +} + +int tst_is_virt(int virt_type) +{ + switch (virt_type) { + case VIRT_XEN: + return is_xen(); + } + tst_brkm(TBROK, NULL, "invalid virt_type flag: %d", virt_type); + return 0; +} diff --git a/testcases/kernel/syscalls/getcontext/getcontext01.c b/testcases/kernel/syscalls/getcontext/getcontext01.c index 03b2df9..c854518 100644 --- a/testcases/kernel/syscalls/getcontext/getcontext01.c +++ b/testcases/kernel/syscalls/getcontext/getcontext01.c @@ -1,5 +1,6 @@ /* * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved. + * Author: Prashant P Yendigeri <pra...@wi...> * * 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 @@ -12,26 +13,7 @@ * 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. - * */ -/********************************************************** - * - * TEST IDENTIFIER : getcontext01 - * - * EXECUTED BY : root / superuser - * - * TEST TITLE : Basic tests for getcontext(2) - * - * TEST CASE TOTAL : 1 - * - * AUTHOR : Prashant P Yendigeri - * <pra...@wi...> - * - * DESCRIPTION - * This is a Phase I test for the getcontext(2) system call. - * It is intended to provide a limited exposure of the system call. - * - **********************************************************/ #include <features.h> @@ -47,60 +29,64 @@ char *TCID = "getcontext01"; #if !defined(__UCLIBC__) -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); int TST_TOTAL = 1; -int exp_enos[] = { 0 }; /* must be a 0 terminated list */ +static void test_getcontext(void) +{ + ucontext_t ptr; + + TEST(getcontext(&ptr)); + + if (TEST_RETURN == -1) { + if (errno == ENOSYS) + tst_resm(TCONF, "getcontext not implemented in libc"); + else + tst_resm(TFAIL | TTERRNO, "getcontext failed"); + } else if (TEST_RETURN == 0) { + tst_resm(TPASS, "getcontext passed"); + } else { + tst_resm(TFAIL, "Unexpected return value %li", TEST_RETURN); + } +} int main(int ac, char **av) { int lc; char *msg; - ucontext_t ptr; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); setup(); - TEST_EXP_ENOS(exp_enos); - for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; - TEST(getcontext(&ptr)); - - if (TEST_RETURN == -1) - tst_resm(TFAIL | TTERRNO, "getcontext failed"); - else if (TEST_RETURN >= 0) - tst_resm(TPASS, "getcontext passed"); - + test_getcontext(); } cleanup(); - tst_exit(); } -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; - } #else /* systems that dont support obsolete getcontext */ -int main() +int main(void) { tst_brkm(TCONF, NULL, "system doesn't have getcontext support"); } diff --git a/testcases/kernel/syscalls/getrusage/getrusage04.c b/testcases/kernel/syscalls/getrusage/getrusage04.c index 96e24a4..fa5fe2d 100644 --- a/testcases/kernel/syscalls/getrusage/getrusage04.c +++ b/testcases/kernel/syscalls/getrusage/getrusage04.c @@ -205,6 +205,9 @@ static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); + if (tst_is_virt(VIRT_XEN)) + tst_brkm(TCONF, NULL, "This testcase is not supported on Xen."); + BIAS_MAX = guess_timer_resolution(); TEST_PAUSE; hooks/post-receive -- ltp |