Re: libtool utilization with tests/helpers/libpreload-time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 05, 2007 at 05:32:49PM -0400, Mike Frysinger wrote:
> can someone enlighten me as to the point of the libpreload-time helper library 

 I use the library for some cal tests (see tests/ts-cal-*).

> for tests ?  this is the only consumer of libtool in the project, so if it 
> could be replaced in favor of something else, we could scrub the libtool 
> aspects of util-linux ...

 Agree, I'll use a "cal_test" binary rather than the library.
 The library is overkill ;-)

    Karel

.. something like:


diff --git a/misc-utils/Makefile.am b/misc-utils/Makefile.am
index a9ea5ef..794be49 100644
--- a/misc-utils/Makefile.am
+++ b/misc-utils/Makefile.am
@@ -74,3 +74,9 @@ install-exec-hook::
 endif
 
 endif
+
+noinst_PROGRAMS = cal_test
+cal_test_SOURCES = cal.c
+cal_test_CPPFLAGS = -DTEST_CAL $(AM_CPPFLAGS)
+cal_test_LDADD = $(cal_LDADD)
+
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index dc5848a..f5ede93 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -351,7 +351,16 @@ main(int argc, char **argv) {
 			errx(1, _("illegal year value: use 1-9999"));
 		break;
 	case 0:
-		time(&now);
+	{
+#ifdef TEST_CAL
+		char *e = getenv("TEST_TIME");
+
+		if (e && isdigit((unsigned char) *e))
+			now = atol(e);
+		else
+#endif
+			time(&now);
+	}
 		local_time = localtime(&now);
 		if (isatty(1))
 			day = local_time->tm_yday + 1;


-- 
 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

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux