syscalls/setgroups: moved compat_16.h to ../utils. This header will be common for all 16-bit syscalls definitions.
Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmansk...@oracle.com> --- testcases/kernel/syscalls/setgroups/compat_16.h | 85 --------------------- testcases/kernel/syscalls/setgroups/setgroups01.c | 5 +- testcases/kernel/syscalls/setgroups/setgroups02.c | 4 +- testcases/kernel/syscalls/setgroups/setgroups03.c | 2 +- testcases/kernel/syscalls/setgroups/setgroups04.c | 2 +- testcases/kernel/syscalls/utils/compat_16.h | 58 ++++++++++++++ 6 files changed, 65 insertions(+), 91 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 <yam...@redhat.com> */ - -#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..d5ecc16 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups01.c +++ b/testcases/kernel/syscalls/setgroups/setgroups01.c @@ -158,7 +158,7 @@ int main(int ac, char **av) /* * Call setgroups(2) */ - TEST(SETGROUPS(ngrps, list)); + TEST(SETGROUPS(cleanup, ngrps, list)); /* check return code */ if (TEST_RETURN == -1) { @@ -202,7 +202,8 @@ void setup() TEST_PAUSE; - if ((ngrps = GETGROUPS(len, list)) == -1) { + ngrps = GETGROUPS(cleanup, len, list); + if (ngrps == -1) { 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..eb9272e 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups02.c +++ b/testcases/kernel/syscalls/setgroups/setgroups02.c @@ -105,7 +105,7 @@ int main(int ac, char **av) * Call setgroups() to set supplimentary group IDs of * the calling super-user process to gid of TESTUSER. */ - TEST(SETGROUPS(gidsetsize, groups_list)); + TEST(SETGROUPS(cleanup, gidsetsize, groups_list)); if (TEST_RETURN == -1) { tst_resm(TFAIL, "setgroups(%d, groups_list) Failed, " @@ -125,7 +125,7 @@ int main(int ac, char **av) * supp. gids of TESTUSER. */ groups_list[0] = '\0'; - if (GETGROUPS(gidsetsize, groups_list) < 0) { + if (GETGROUPS(cleanup, gidsetsize, groups_list) < 0) { 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..723050d 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups03.c +++ b/testcases/kernel/syscalls/setgroups/setgroups03.c @@ -145,7 +145,7 @@ int main(int ac, char **av) * verify that it fails with -1 return value and * sets appropriate errno. */ - TEST(SETGROUPS(gidsetsize, groups_list)); + TEST(SETGROUPS(cleanup, gidsetsize, groups_list)); if (TEST_RETURN != -1) { tst_resm(TFAIL, "setgroups(%d) returned %ld, " diff --git a/testcases/kernel/syscalls/setgroups/setgroups04.c b/testcases/kernel/syscalls/setgroups/setgroups04.c index 5932b4e..953d406 100644 --- a/testcases/kernel/syscalls/setgroups/setgroups04.c +++ b/testcases/kernel/syscalls/setgroups/setgroups04.c @@ -111,7 +111,7 @@ int main(int ac, char **av) * verify that it fails with -1 return value and * sets appropriate errno. */ - TEST(SETGROUPS(gidsetsize, sbrk(0))); + TEST(SETGROUPS(cleanup, gidsetsize, sbrk(0))); if (TEST_RETURN != -1) { tst_resm(TFAIL, "setgroups() returned %ld, " diff --git a/testcases/kernel/syscalls/utils/compat_16.h b/testcases/kernel/syscalls/utils/compat_16.h new file mode 100644 index 0000000..fab8e47 --- /dev/null +++ b/testcases/kernel/syscalls/utils/compat_16.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) Red Hat Inc., 2008 + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * + * 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 <yam...@redhat.com> */ + +#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_sys_name32 defined it + * means that __NR_sys_name is a 16-bit version of + * sys_name() syscall + */ +#ifdef TST_USE_COMPAT16_SYSCALL +# define LTP_CREATE_SYSCALL(sys_name, cleanup, ...) \ + if (__NR_##sys_name##32 != __LTP__NR_INVALID_SYSCALL) { \ + return ltp_syscall(__NR_##sys_name, ##__VA_ARGS__); \ + } else { \ + tst_brkm(TCONF, cleanup, \ + "16-bit version of %s() is not supported on your " \ + "platform", #sys_name); \ + } +#else +# define LTP_CREATE_SYSCALL(sys_name, cleanup, ...) \ + return sys_name(__VA_ARGS__) +#endif + +int SETGROUPS(void (cleanup)(void), size_t gidsetsize, GID_T *list) +{ + LTP_CREATE_SYSCALL(setgroups, cleanup, gidsetsize, list); +} + +int GETGROUPS(void (cleanup)(void), size_t gidsetsize, GID_T *list) +{ + LTP_CREATE_SYSCALL(getgroups, cleanup, 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=58041391&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list