syscalls/setgroups: moved compat_16.h to ../utils. This header will be common for all 16-bit syscalls definitions.
Signed-off-by: Stanislav Kholmanskikh <[email protected]> --- testcases/kernel/syscalls/setgroups/compat_16.h | 85 --------------------- testcases/kernel/syscalls/setgroups/setgroups01.c | 6 ++ testcases/kernel/syscalls/setgroups/setgroups02.c | 7 ++ testcases/kernel/syscalls/setgroups/setgroups03.c | 8 ++ testcases/kernel/syscalls/setgroups/setgroups04.c | 7 ++ testcases/kernel/syscalls/utils/compat_16.h | 61 +++++++++++++++ 6 files changed, 89 insertions(+), 85 deletions(-) delete mode 100644 testcases/kernel/syscalls/setgroups/compat_16.h create mode 100644 testcases/kernel/syscalls/utils/compat_16.h diff --git a/testcases/kernel/syscalls/setgroups/compat_16.h b/testcases/kernel/syscalls/setgroups/compat_16.h deleted file mode 100644 index 0de4e78..0000000 --- a/testcases/kernel/syscalls/setgroups/compat_16.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Copyright (c) Red Hat Inc., 2008 - * - * 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 - */ - -/* Author: Masatake YAMATO <[email protected]> */ - -#ifndef __SETGROUPS_COMPAT_16_H__ -#define __SETGROUPS_COMPAT_16_H__ - -#include "compat_gid.h" -#include "linux_syscall_numbers.h" - - -/* For avoiding circular dependency. */ -extern void cleanup(void); - -#ifdef TST_USE_COMPAT16_SYSCALL - -long -SETGROUPS(size_t gidsetsize, GID_T *list) -{ - return ltp_syscall(__NR_setgroups, gidsetsize, list); -} - -int -GETGROUPS(int size16, GID_T *list16) -{ - int r; - int i; - - gid_t *list32; - - list32 = malloc(size16 * sizeof(gid_t)); - if (list32 == NULL) - tst_brkm(TBROK, NULL, "malloc failed to alloc %zu errno " - " %d ", size16 * sizeof(gid_t), errno); - - r = getgroups(size16, list32); - if (r < 0) - goto out; - - for (i = 0; i < r; i++) { - if (!GID_SIZE_CHECK(list32[i])) - tst_brkm(TBROK, - cleanup, - "gid returned from getgroups is too large for testing setgroups32"); - list16[i] = (GID_T)list32[i]; - } - - out: - free(list32); - return r; -} - -#else -int -SETGROUPS(size_t size, const GID_T *list) -{ - return setgroups(size, list); -} - -int -GETGROUPS(int size, GID_T *list) -{ - return getgroups(size, list); -} - -#endif /* TST_USE_COMPAT16_SYSCALL */ - -#endif /* __SETGROUPS_COMPAT_16_H__ */ diff --git a/testcases/kernel/syscalls/setgroups/setgroups01.c b/testcases/kernel/syscalls/setgroups/setgroups01.c index 9d70612..4c7dceb 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups01.c +++ b/testcases/kernel/syscalls/setgroups/setgroups01.c @@ -162,6 +162,9 @@ int main(int ac, char **av) /* check return code */ if (TEST_RETURN == -1) { + if (TEST_ERRNO == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(setgroups, cleanup); + TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL, "setgroups(%d, list) Failed, errno=%d : %s", @@ -203,6 +206,9 @@ void setup() TEST_PAUSE; if ((ngrps = GETGROUPS(len, list)) == -1) { + if (errno == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(getgroups, cleanup); + tst_brkm(TBROK, cleanup, "getgroups(%d, list) Failure. errno=%d : %s", len, errno, strerror(errno)); diff --git a/testcases/kernel/syscalls/setgroups/setgroups02.c b/testcases/kernel/syscalls/setgroups/setgroups02.c index 6829f24..7ac787b 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups02.c +++ b/testcases/kernel/syscalls/setgroups/setgroups02.c @@ -108,6 +108,9 @@ int main(int ac, char **av) TEST(SETGROUPS(gidsetsize, groups_list)); if (TEST_RETURN == -1) { + if (TEST_ERRNO == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(setgroups, cleanup); + tst_resm(TFAIL, "setgroups(%d, groups_list) Failed, " "errno=%d : %s", gidsetsize, TEST_ERRNO, strerror(TEST_ERRNO)); @@ -126,6 +129,10 @@ int main(int ac, char **av) */ groups_list[0] = '\0'; if (GETGROUPS(gidsetsize, groups_list) < 0) { + if (errno == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(getgroups, + cleanup); + tst_brkm(TFAIL, cleanup, "getgroups() Fails, " "error=%d", errno); } diff --git a/testcases/kernel/syscalls/setgroups/setgroups03.c b/testcases/kernel/syscalls/setgroups/setgroups03.c index 8245c2a..d5137a5 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups03.c +++ b/testcases/kernel/syscalls/setgroups/setgroups03.c @@ -148,6 +148,10 @@ int main(int ac, char **av) TEST(SETGROUPS(gidsetsize, groups_list)); if (TEST_RETURN != -1) { + if (TEST_ERRNO == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(setgroups, + cleanup); + tst_resm(TFAIL, "setgroups(%d) returned %ld, " "expected -1, errno=%d", gidsetsize, TEST_RETURN, Test_cases[i].exp_errno); @@ -161,6 +165,10 @@ int main(int ac, char **av) "setgroups(%d) fails, %s, errno=%d", gidsetsize, test_desc, TEST_ERRNO); } else { + if (TEST_ERRNO == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(setgroups, + cleanup); + tst_resm(TFAIL, "setgroups(%d) fails, %s, " "errno=%d, expected errno=%d", gidsetsize, test_desc, TEST_ERRNO, diff --git a/testcases/kernel/syscalls/setgroups/setgroups04.c b/testcases/kernel/syscalls/setgroups/setgroups04.c index 5932b4e..d270199 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups04.c +++ b/testcases/kernel/syscalls/setgroups/setgroups04.c @@ -114,6 +114,9 @@ int main(int ac, char **av) TEST(SETGROUPS(gidsetsize, sbrk(0))); if (TEST_RETURN != -1) { + if (TEST_ERRNO == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(setgroups, cleanup); + tst_resm(TFAIL, "setgroups() returned %ld, " "expected -1, errno=%d", TEST_RETURN, exp_enos[0]); @@ -126,6 +129,10 @@ int main(int ac, char **av) "setgroups() fails with expected " "error EFAULT errno:%d", TEST_ERRNO); } else { + if (TEST_ERRNO == ENOSYS) + LTP_NO_COMPAT16_SYSCALL(setgroups, + cleanup); + tst_resm(TFAIL, "setgroups() fails, %s, " "errno=%d, expected errno=%d", test_desc, TEST_ERRNO, exp_enos[0]); diff --git a/testcases/kernel/syscalls/utils/compat_16.h b/testcases/kernel/syscalls/utils/compat_16.h new file mode 100644 index 0000000..a359326 --- /dev/null +++ b/testcases/kernel/syscalls/utils/compat_16.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) Red Hat Inc., 2008 + * + * 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 + */ + +/* Author: Masatake YAMATO <[email protected]> */ + +#ifndef __LTP_COMPAT_16_H__ +#define __LTP_COMPAT_16_H__ + +#include <errno.h> +#include "compat_gid.h" +#include "linux_syscall_numbers.h" + +/* If the platform has __NR_scall32 defined it + * means that __NR_scall is a 16-bit version of + * scall() syscall + */ +#ifdef TST_USE_COMPAT16_SYSCALL +# define LTP_CREATE_SYSCALL(sys_name, ...) \ + if (__NR_##sys_name##32 != __LTP__NR_INVALID_SYSCALL) { \ + return ltp_syscall(__NR_##sys_name, ##__VA_ARGS__); \ + } else { \ + errno = ENOSYS; \ + return -1; \ + } +#else +# define LTP_CREATE_SYSCALL(sys_name, ...) \ + return sys_name(__VA_ARGS__) +#endif + +#define LTP_NO_COMPAT16_SYSCALL(sys_name, cleanup) \ + tst_brkm(TCONF, cleanup,\ + "16-bit version of %s() is not supported on your platform", \ + #sys_name) + +int SETGROUPS(size_t gidsetsize, GID_T *list) +{ + LTP_CREATE_SYSCALL(setgroups, gidsetsize, list); +} + +int GETGROUPS(size_t gidsetsize, GID_T *list) +{ + LTP_CREATE_SYSCALL(getgroups, gidsetsize, list); +} + +#endif /* __LTP_COMPAT_16_H__ */ + -- 1.7.1 ------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
