From 1287f182167253c03e84fa6a934c7df38323ddeb Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 4 Jan 2024 01:51:56 +1300 Subject: [PATCH] perftest:ndr_pack_performance: remove irrelevant imports, options This includes removing the ANCIENT_SAMBA switch for pre-4.3, as nobody cares anymore and many tests would not run correctly anyway. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett BUG: https://bugzilla.samba.org/show_bug.cgi?id=15574 (cherry picked from commit ceb5389260c4469a8f03ee884325ca981c18a36a) --- .../dsdb/tests/python/ndr_pack_performance.py | 55 +------------------ 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/source4/dsdb/tests/python/ndr_pack_performance.py b/source4/dsdb/tests/python/ndr_pack_performance.py index 083abf6621f..c0c72cac99e 100644 --- a/source4/dsdb/tests/python/ndr_pack_performance.py +++ b/source4/dsdb/tests/python/ndr_pack_performance.py @@ -4,10 +4,7 @@ import optparse import sys sys.path.insert(0, 'bin/python') -import os import samba -import samba.getopt as options -import random import gzip # We try to use the test infrastructure of Samba 4.3+, but if it @@ -16,45 +13,13 @@ import gzip # # Don't copy this horror into ordinary tests -- it is special for # performance tests that want to apply to old versions. -try: - from samba.tests.subunitrun import SubunitOptions, TestProgram - ANCIENT_SAMBA = False -except ImportError: - ANCIENT_SAMBA = True - samba.ensure_external_module("testtools", "testtools") - samba.ensure_external_module("subunit", "subunit/python") - from subunit.run import SubunitTestRunner - import unittest + +from samba.tests.subunitrun import TestProgram from samba.ndr import ndr_pack, ndr_unpack from samba.dcerpc import security from samba.dcerpc import drsuapi -parser = optparse.OptionParser("ndr_pack_performance.py [options] ") -sambaopts = options.SambaOptions(parser) -parser.add_option_group(sambaopts) -parser.add_option_group(options.VersionOptions(parser)) - -if not ANCIENT_SAMBA: - subunitopts = SubunitOptions(parser) - parser.add_option_group(subunitopts) - -# use command line creds if available -credopts = options.CredentialsOptions(parser) -parser.add_option_group(credopts) -opts, args = parser.parse_args() - -if len(args) < 1: - parser.print_usage() - sys.exit(1) - -host = args[0] - -lp = sambaopts.get_loadparm() -creds = credopts.get_credentials(lp) - -random.seed(1) - BIG_SD_SDDL = ''.join( """O:S-1-5-21-3328325300-3937145445-4190589019-512G:S-1-5-2 @@ -246,18 +211,4 @@ class UserTests(samba.tests.TestCase): self._test_pack(desc, cycles=20) -if "://" not in host: - if os.path.isfile(host): - host = "tdb://%s" % host - else: - host = "ldap://%s" % host - - -if ANCIENT_SAMBA: - runner = SubunitTestRunner() - if not runner.run(unittest.TestLoader().loadTestsFromTestCase( - UserTests)).wasSuccessful(): - sys.exit(1) - sys.exit(0) -else: - TestProgram(module=__name__, opts=subunitopts) +TestProgram(module=__name__) -- 2.47.3