From: Filippo A. <fil...@st...> - 2012-02-15 08:27:58
|
[snip] > > static void inherit_fork(void); > > static void inherit_fork2(void); > > @@ -77,11 +78,23 @@ int main(int argc, char *argv[]) > > > > setup(); > > > > + if (argc > 2) > > + tst_brkm(TBROK, cleanup, " Too many arguments - Usage: %s > [factor]", argv[0]); > > + > > + if (argv[1]) > > + factor_nr = atoi(argv[1]); > > + > > + if (factor_nr == 0) > > + tst_brkm(TBROK, cleanup, "Input factor must be != 0"); > > Here I want to use an LTP way to pass parameters, i.e. use option_t and > parse_opts. > > Please take a look at getrusage03_child.c as example. I have seen that but, I haven't done because it needs to pass only one number. In any case I will follow your suggestion. > > > + > > + tst_resm(TINFO, "Using %d as factor allocation mamory!", > factor_nr); > > + > > for (lc = 0; TEST_LOOPING(lc); lc++) { > > Tst_count = 0; > > > > - tst_resm(TINFO, "allocate 100MB"); > > - consume(100); > > + size = 10 * factor_nr; > > + tst_resm(TINFO, "allocate %dMB", size); > > + consume(size); > > > > inherit_fork(); > > inherit_fork2(); > > @@ -123,17 +136,17 @@ static void inherit_fork(void) > > } > > > > /* Testcase #02: fork inherit (cont.) > > - * expect: initial.children ~= 100MB, child.children = 0 */ > > + * expect: initial.children ~= (10 * factor_nr)MB, child.children = > 0 */ > > static void inherit_fork2(void) > > { > > tst_resm(TINFO, "Testcase #02: fork inherit(cont.)"); > > > > SAFE_GETRUSAGE(cleanup, RUSAGE_CHILDREN, &ru); > > tst_resm(TINFO, "initial.children = %ld", ru.ru_maxrss); > > - if (is_in_delta(ru.ru_maxrss - 102400)) > > - tst_resm(TPASS, "initial.children ~= 100MB"); > > + if (is_in_delta(ru.ru_maxrss - (10240 * factor_nr))) > > + tst_resm(TPASS, "initial.children ~= %dMB", size); > > `size` in this function is not initialized? 'size' is globally defined, it is initialized in the main(). > > > else > > - tst_resm(TFAIL, "initial.children !~= 100MB"); > > + tst_resm(TFAIL, "initial.children !~= %dMB", size); > > > > switch (pid = fork()) { > > case -1: > > @@ -153,9 +166,11 @@ static void inherit_fork2(void) > > } > > Thanks for the review. Filippo. |