def main(): # Command line options cmdParser = optparse.OptionParser() cmdParser.add_option("-r", action="store_true", dest="bNoClean", help="No clean build") cmdParser.add_option("-m", action="store_true", dest="bCheckMallocStats", help="Check malloc statistics") cmdParser.add_option("-t", action="append", dest="testsIncluded", help="Run specified tests", metavar="test") cmdParser.add_option("-u", action="store_true", dest="bUpdateExpected", help="Update expected output") cmdParser.add_option("--debug", action="store_true", dest="bDebug", help="Build debug binaries") (cmdOptions, cmdArgs) = cmdParser.parse_args() # The unittest directory unittestDir = os.path.dirname(sys.argv[0]) if not unittestDir: unittestDir = '.' # Create the test runner runner = unittest.TextTestRunner(verbosity=2) # Build test suite buildDirs = [] buildSuite = BuildSuite(unittestDir, buildDirs, None, not cmdOptions.bNoClean, cmdOptions.bDebug, cmdOptions.bUpdateExpected) if not runner.run(buildSuite).wasSuccessful(): return 1 # C unit test suite unittestSuite = UnittestSuite() unittestSuite.addTest(unittestDir, os.path.join("build", "unittest"), "unittest", cmdOptions.bCheckMallocStats, cmdOptions.bUpdateExpected) if not runner.run(unittestSuite).wasSuccessful(): return 1 # Success return 0
def main(): # Command line options cmdParser = optparse.OptionParser() cmdParser.add_option("-r", action="store_true", dest="bNoClean", help="No clean build") cmdParser.add_option("-m", action="store_true", dest="bCheckMallocStats", help="Check malloc statistics") cmdParser.add_option("-t", action="append", dest="testsIncluded", help="Run specified tests", metavar="test") cmdParser.add_option("-u", action="store_true", dest="bUpdateExpected", help="Update expected output") cmdParser.add_option("--debug", action="store_true", dest="bDebug", help="Build debug binaries") (cmdOptions, cmdArgs) = cmdParser.parse_args() # The unittest directory unittestDir = os.path.dirname(sys.argv[0]) if not unittestDir: unittestDir = '.' # Create the test runner runner = unittest.TextTestRunner(verbosity=2) # Build test suite buildDirs = (os.path.join("build", "libhdkcli"), os.path.join("build", "libhdkcli-c++"), os.path.join("build", "libhdkcli-logging"), os.path.join("build", "libhdkcli-c++-logging")) bWindowsPlatform = (platform.system() == 'Windows') bDarwinPlatform = (platform.system() == 'Darwin') # Build target (platform dependant) if bWindowsPlatform: buildTarget = "libhdkcli.dll" elif bDarwinPlatform: buildTarget = "libhdkcli.dylib" else: buildTarget = "libhdkcli.so" buildSuite = BuildSuite(unittestDir, buildDirs, buildTarget, not cmdOptions.bNoClean, cmdOptions.bDebug, cmdOptions.bUpdateExpected) if not runner.run(buildSuite).wasSuccessful(): return 1 # Location of the test definitions and parameters. dirTests = os.path.join(unittestDir, "tests") # Run the unittests for each target. unittestSuite = ClientUnittestSuite() for buildDir in ((os.path.join(unittestDir, "build", "unittest-logging")), (os.path.join(unittestDir, "build", "unittest-c++"))): unittestSuite.addTest(dirTests, buildDir, "unittest", cmdOptions.bCheckMallocStats, cmdOptions.bUpdateExpected, testsExplicit=cmdOptions.testsIncluded) # Only update expected results with gold (first build dir) if cmdOptions.bUpdateExpected: break if not runner.run(unittestSuite).wasSuccessful(): return 1 # Success return 0