]> granicus.if.org Git - pdns/commitdiff
make test-schema exit(1) on failure; catch setNotified exception
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 18 Jul 2019 18:36:10 +0000 (20:36 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 25 Jul 2019 11:44:56 +0000 (13:44 +0200)
pdns/pdnsutil.cc

index c421219b707ff4dc52f122f8eb577829da3a6435..69adc32fad6e2c2ffcce371feb76e317755d3f1a 100644 (file)
@@ -1776,6 +1776,7 @@ void testSchema(DNSSECKeeper& dk, const DNSName& zone)
   cout<<"Note: test-schema will try to create the zone, but it will not remove it."<<endl;
   cout<<"Please clean up after this."<<endl;
   cout<<endl;
+  cout<<"If this test reports an error and aborts, please check your database schema."<<endl;
   cout<<"Constructing UeberBackend"<<endl;
   UeberBackend B("default");
   cout<<"Picking first backend - if this is not what you want, edit launch line!"<<endl;
@@ -1817,13 +1818,13 @@ void testSchema(DNSSECKeeper& dk, const DNSName& zone)
     if(db->get(rrthrowaway)) // should not touch rr but don't assume anything
     {
       cout<<"Expected one record, got multiple, aborting"<<endl;
-      return;
+      exit(EXIT_FAILURE);
     }
     int size=rrget.content.size();
     if(size != 302)
     {
       cout<<"Expected 302 bytes, got "<<size<<", aborting"<<endl;
-      return;
+      exit(EXIT_FAILURE);
     }
   }
   cout<<"[+] content field is over 255 bytes"<<endl;
@@ -1860,25 +1861,33 @@ void testSchema(DNSSECKeeper& dk, const DNSName& zone)
   if(before != DNSName("_underscore")+zone)
   {
     cout<<"before is wrong, got '"<<before.toString()<<"', expected '_underscore."<<zone.toString()<<"', aborting"<<endl;
-    return;
+    exit(EXIT_FAILURE);
   }
   if(after != zone)
   {
     cout<<"after is wrong, got '"<<after.toString()<<"', expected '"<<zone.toString()<<"', aborting"<<endl;
-    return;
+    exit(EXIT_FAILURE);
   }
   cout<<"[+] ordername sorting is correct for names starting with _"<<endl;
   cout<<"Setting low notified serial"<<endl;
   db->setNotified(di.id, 500);
   db->getDomainInfo(zone, di);
   if(di.notified_serial != 500) {
-    cout<<"[-] Set serial 500, got back "<<di.notified_serial<<endl;
+    cout<<"[-] Set serial 500, got back "<<di.notified_serial<<", aborting"<<endl;
+    exit(EXIT_FAILURE);
   }
   cout<<"Setting serial that needs 32 bits"<<endl;
-  db->setNotified(di.id, 2147484148);
+  try {
+    db->setNotified(di.id, 2147484148);
+  } catch(const PDNSException &pe) {
+    cout<<"While setting serial, got error: "<<pe.reason<<endl;
+    cout<<"aborting"<<endl;
+    exit(EXIT_FAILURE);
+  }
   db->getDomainInfo(zone, di);
   if(di.notified_serial != 2147484148) {
-    cout<<"[-] Set serial 2147484148, got back "<<di.notified_serial<<endl;
+    cout<<"[-] Set serial 2147484148, got back "<<di.notified_serial<<", aborting"<<endl;
+    exit(EXIT_FAILURE);
   } else {
     cout<<"[+] Big serials work correctly"<<endl;
   }