10 #include <sys/types.h>
15 #ifdef HAVE_SYS_SYSCALL_H
16 #include <sys/syscall.h>
22 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
24 static void test_uwrap_syscall_setgroups32(void **state)
26 gid_t glist[] = { 100, 200, 300, 400, 500 };
30 (void) state; /* unused */
32 rc = syscall(SYS_setgroups32, ARRAY_SIZE(glist), glist);
33 assert_int_equal(rc, 0);
35 rc = getgroups(ARRAY_SIZE(rlist), rlist);
36 assert_int_equal(rc, 5);
38 assert_memory_equal(glist, rlist, sizeof(glist));
40 /* Drop all supplementary groups. This is often done by daemons */
41 memset(rlist, 0, sizeof(rlist));
42 rc = syscall(SYS_setgroups32, 0, NULL);
43 assert_int_equal(rc, 0);
45 rc = getgroups(ARRAY_SIZE(rlist), rlist);
46 assert_int_equal(rc, 0);
48 assert_int_equal(rlist[0], 0);
54 const struct CMUnitTest uwrap_tests[] = {
55 cmocka_unit_test(test_uwrap_syscall_setgroups32),
58 rc = cmocka_run_group_tests(uwrap_tests, NULL, NULL);