Re: [PATCH] login-utils: Removed upper limit on passwd line size in is_local, added tests. | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
On Tue, Apr 08, 2008 at 12:54:01AM +0100, James Youngman wrote:
> On Tue, Apr 8, 2008 at 12:09 AM, Karel Zak <kzak@xxxxxxxxxx> wrote:
> > I really don't like this kind of test. We have the test/ directory
> > where you can store all test data. Your MAIN_TEST_XXX needs to
> > include really necessary _code_ only.
>
> I did it that way in order to keep the test data near the definitions
> of which tests should result in is_local returning zero and which
> non-zero. But if you prefer the data in a separate file, I can move
static int
is_local_in_file(const char *user, const char *filename)
{
....
}
int
is_local(const char *user)
{
return is_local_in_file(user, _PATH_PASSWD);
}
#ifdef MAIN_TEST_ISLOCAL
int main(int argc, char *argv[])
{
if (argc == 3 && is_local_in_file(argv[1], argv[2]))
printf("%s: found\n", argv[1]);
exit(0);
}
#endif
(6 lines!)
and in the test/ directory you can call:
$TS_CMD_ISLOCAL userfoo $TS_INPUT >> $TS_OUTPUT 2>&1
$TS_CMD_ISLOCAL userbar $TS_INPUT >> $TS_OUTPUT 2>&1
the scripts in the tests/ are able to generate diff between
expected and real test result. For more details see for example
tests/ts-login-checktty.
Please, resubmit the patch with fixed test. Your state machine
is probably than fgets() ...
> it. But for my information, _why_ don't you like this form of test?
I think that mix the real code with tests is dirty solution. The
result are huge and badly readable .c files, heterogenous tests on
many places, ...
I prefer all test on one place, same way (infrastructure) for all
tests and pretty readable .c files.
Karel
--
Karel Zak <kzak@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Site Home] [Netdev] [Ethernet Bridging] [Linux Wireless] [Kernel Newbies] [Memory] [Security] [Linux for Hams] [Netfilter] [Bugtraq] [Rubini] [Photo] [Yosemite] [Yosemite News] [MIPS Linux] [ARM Linux] [Linux RAID] [Linux Admin] [Samba] [Video 4 Linux] [Linux Resources]