build-sys: split test cases in lib/ into their own files

In order to avoid compiling the same source files twice, with and
without the TEST_PROGRAM define.

Tested that the build still works and that `make distcheck` works as
expected.

Tested that the test_* programs in lib/ keep working. (Though they are
not really invoked by `make check` and in particular test_nsutils is
quite useless, test_fileutils also quite poor.)

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
This commit is contained in:
Filipe Brandenburger
2015-05-01 17:43:51 -07:00
parent 04d96fe136
commit b56fd9d358
7 changed files with 68 additions and 45 deletions

View File

@ -60,17 +60,3 @@ double strtod_or_err(const char *str, const char *errmesg)
error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
return 0;
}
#ifdef TEST_PROGRAM
int main(int argc, char *argv[])
{
if (argc < 2) {
error(EXIT_FAILURE, 0, "no arguments");
} else if (argc < 3) {
printf("%ld\n", strtol_or_err(argv[1], "strtol_or_err"));
} else {
printf("%lf\n", strtod_or_err(argv[2], "strtod_or_err"));
}
return EXIT_SUCCESS;
}
#endif /* TEST_PROGRAM */