autobuild: run ldb tests with TDB_NO_FSYNC=1
[kai/samba-autobuild/.git] / script / bisect-test.py
index 843c80dccf4bb6b2b3bdd225bbc73069185e3dd8..e4daa8c2c12b2442c33f23c371b1cba12c66dd5c 100755 (executable)
@@ -9,16 +9,24 @@ import os, tempfile, sys
 from optparse import OptionParser
 
 parser = OptionParser()
-parser.add_option("", "--tests", help="list of tests to run", default='')
-parser.add_option("", "--good", help="known good revision (default HEAD)", default='HEAD')
-parser.add_option("", "--bad", help="known bad revision (default HEAD~100)", default='HEAD~100')
-parser.add_option("", "--skip-build-errors", help="skip revision where make fails", default=False)
+parser.add_option("", "--good", help="known good revision (default HEAD~100)", default='HEAD~100')
+parser.add_option("", "--bad", help="known bad revision (default HEAD)", default='HEAD')
+parser.add_option("", "--skip-build-errors", help="skip revision where make fails",
+                  action='store_true', default=False)
 parser.add_option("", "--autogen", help="run autogen before each build",action="store_true", default=False)
+parser.add_option("", "--autogen-command", help="command to use for autogen (default ./autogen.sh)",
+                  type='str', default="./autogen.sh")
 parser.add_option("", "--configure", help="run configure.developer before each build",
     action="store_true", default=False)
+parser.add_option("", "--configure-command", help="the command for configure (default ./configure.developer)",
+                  type='str', default="./configure.developer")
+parser.add_option("", "--build-command", help="the command to build the tree (default 'make -j')",
+                  type='str', default="make -j")
+parser.add_option("", "--test-command", help="the command to test the tree (default 'make test')",
+                  type='str', default="make test")
 parser.add_option("", "--clean", help="run make clean before each build",
-    action="store_true", default=False)
-parser.add_option("-j", "", help="use make -j N", dest='N', type='int', action="store", default=1)
+                  action="store_true", default=False)
+
 
 (opts, args) = parser.parse_args()
 
@@ -50,16 +58,17 @@ f = tempfile.NamedTemporaryFile(delete=False)
 f.write("set -x\n")
 f.write("cd %s || exit 125\n" % cwd)
 if opts.autogen:
-    f.write("./autogen.sh || exit 125\n")
+    f.write("%s || exit 125\n" % opts.autogen_command)
 if opts.configure:
-    f.write("./configure.developer || exit 125\n")
+    f.write("%s || exit 125\n" % opts.configure_command)
 if opts.clean:
     f.write("make clean || exit 125\n")
 if opts.skip_build_errors:
-    f.write("make -j %u || exit 125\n" % opts.N)
+    build_err = 125
 else:
-    f.write("make -j %u || exit 1\n" % opts.N)
-f.write("make -j %u test TESTS='%s' FAIL_IMMEDIATELY=1 || exit 1\n" % (opts.N, opts.tests))
+    build_err = 1
+f.write("%s || exit %u\n" % (opts.build_command, build_err))
+f.write("%s || exit 1\n" % opts.test_command)
 f.write("exit 0\n")
 f.close()
 
@@ -72,7 +81,7 @@ def cleanup():
 ret = -1
 try:
     run_cmd("git bisect reset", dir=gitroot, show=False, checkfail=False)
-    run_cmd("git bisect start %s %s --" % (opts.good, opts.bad), dir=gitroot)
+    run_cmd("git bisect start %s %s --" % (opts.bad, opts.good), dir=gitroot)
     ret = run_cmd("git bisect run bash %s" % f.name, dir=gitroot, show=True, checkfail=False)
 except KeyboardInterrupt:
     print("Cleaning up")
@@ -81,5 +90,6 @@ except Exception, reason:
     print("Failed bisect: %s" % reason)
     cleanup()
 
+run_cmd("git bisect reset", dir=gitroot)
 os.unlink(f.name)
 sys.exit(ret)