The start_up routine sets an upper-limit on CPU seconds so that
[idzebra-moved-to-github.git] / test / api / testlib.c
index e960d0d..d80ab13 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: testlib.c,v 1.19 2005-05-09 12:03:59 adam Exp $
+/* $Id: testlib.c,v 1.22 2005-06-14 20:02:30 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -22,6 +22,12 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 /** testlib - utilities for the api tests */
 
+#include <sys/time.h>
+#include <sys/resource.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 #include <assert.h>
 #include <yaz/log.h>
 #include <yaz/pquery.h>
@@ -34,6 +40,7 @@ int log_level=0; /* not static, t*.c may use it */
 
 void start_log(int argc, char **argv)
 {
+    int cmd_level = 0;
     char logname[2048];
     if (!argv) 
         return;
@@ -41,9 +48,11 @@ void start_log(int argc, char **argv)
         return;
     sprintf(logname, "%s.log", argv[0]);
     yaz_log_init_file(logname);
-    log_level = yaz_log_mask_str_x(argv[0],0);
-    yaz_log_init_level(YLOG_DEFAULT_LEVEL | log_level);
-    yaz_log(log_level,"starting %s",argv[0]);
+    log_level = yaz_log_mask_str_x(argv[0], 0);
+    if (argc >= 2)
+       cmd_level |= yaz_log_mask_str_x(argv[1], 0);
+    yaz_log_init_level(YLOG_DEFAULT_LEVEL | log_level | cmd_level);
+    yaz_log(log_level, "starting %s", argv[0]);
 }
 
 /** 
@@ -56,6 +65,10 @@ void start_log(int argc, char **argv)
  */
 ZebraService start_up(char *cfgname, int argc, char **argv)
 {
+    struct rlimit rlim;
+    rlim.rlim_cur = 20;
+    rlim.rlim_max = 20;
+    setrlimit(RLIMIT_CPU, &rlim);
     nmem_init();
     start_log(argc, argv);
     return start_service(cfgname);