|
From: Roman K. <rk...@sw...> - 2005-05-26 06:04:07
|
Hi,
I'm having the following problem with
testcases/kernel/syscalls/setgroups/setgroups03.c:
NGROUPS_MAX defined in limits.h is not the max number of groups in the
system, it the max number guaranteed. Thus, if the system actually
allows more, the test case doesn't produce the expected failure.
The right number is obtained through the call to
sysconf(_SC_NGROUPS_MAX). The attached patch fixes that.
Please consider applying.
Roman.
--- ltp-full-20050505/testcases/kernel/syscalls/setgroups/setgroups03.c.orig 2005-05-05 23:16:26.000000000 +0400
+++ ltp-full-20050505/testcases/kernel/syscalls/setgroups/setgroups03.c 2005-05-18 13:37:55.000000000 +0400
@@ -85,22 +85,23 @@
int TST_TOTAL=2; /* Total number of test conditions */
extern int Tst_count; /* Test Case counter for tst_* routines */
-gid_t groups_list[NGROUPS]; /* Array to hold gids for getgroups() */
int exp_enos[] = {EINVAL, EPERM, 0};
+gid_t *groups_list; /* Array to hold gids for getgroups() */
+
int setup1(); /* setup function to test error EPERM */
void setup(); /* setup function for the test */
void cleanup(); /* cleanup function for the test */
struct test_case_t { /* test case struct. to hold ref. test cond's*/
- size_t gsize;
+ size_t gsize_add;
int list;
char *desc;
int exp_errno;
int (*setupfunc)();
} Test_cases[] = {
- {NGROUPS_MAX+1, 1, "Size is > NGROUPS", EINVAL, NULL},
- {NGROUPS, 2, "Permission denied, not super-user", EPERM, setup1}
+ {1, 1, "Size is > sysconf(_SC_NGROUPS_MAX)", EINVAL, NULL},
+ {0, 2, "Permission denied, not super-user", EPERM, setup1}
};
int
@@ -111,12 +112,19 @@
int gidsetsize; /* total no. of groups */
int i; /* counter to test different test conditions */
char *test_desc; /* test specific error message */
-
+ int ngroups_max = sysconf(_SC_NGROUPS_MAX); /* max no. of groups in the current system */
+
/* Parse standard options given to run the test. */
msg = parse_opts(ac, av, (option_t *)NULL, NULL);
if (msg != (char *)NULL) {
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+
+ groups_list = malloc(ngroups_max * sizeof(gid_t));
+ if (groups_list == NULL) {
+ tst_brkm(TBROK, NULL, "malloc failed to alloc %d errno "
+ " %d ", ngroups_max * sizeof(gid_t), errno);
+ }
/* Perform global setup for test */
setup();
@@ -135,7 +143,7 @@
Test_cases[i].setupfunc();
}
- gidsetsize = Test_cases[i].gsize;
+ gidsetsize = ngroups_max + Test_cases[i].gsize_add;
test_desc = Test_cases[i].desc;
/*
|