Dump backtrace in case of SIGABRT, SIGSEGV YAZ-787
[yaz-moved-to-github.git] / ztest / ztest.c
index b7807d9..cc7736d 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
  * See the file LICENSE for details.
  */
 /** \file
@@ -33,6 +33,7 @@
 #include <yaz/diagbib1.h>
 #include <yaz/otherinfo.h>
 #include <yaz/facet.h>
+#include <yaz/backtrace.h>
 
 #include "ztest.h"
 
@@ -944,6 +945,21 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
             return 0;
         }
     }
+    else if (!oid_oidcmp(oid, yaz_oid_recsyn_json))
+    {
+        if ((cp = dummy_json_record(r->number, r->stream, esn)))
+        {
+            r->len = strlen(cp);
+            r->record = cp;
+            r->schema = "info:srw/schema/1/marcxml-1.1";
+        }
+        else
+        {
+            r->errcode = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
+            r->surrogate_flag = 1;
+            return 0;
+        }
+    }
     else
     {
         char buf[OID_STR_MAX];
@@ -1143,6 +1159,8 @@ void bend_close(void *handle)
 
 int main(int argc, char **argv)
 {
+    yaz_enable_panic_backtrace(argv[0]);
+
     return statserv_main(argc, argv, bend_init, bend_close);
 }
 /*