def run():
    outBase = os.path.join(utils.findSixHome(), 'regression_files', 'six.sidd')

    # Make siddLegend
    binDir = os.path.join(utils.installPath(), 'bin')
    legendNameBase = 'siddLegend'
    print('Creating SIDDs with legends')

    # This only does version 1.0 currently
    call([
        utils.executableName(os.path.join(binDir, 'test_create_sidd_legend')),
        legendNameBase
    ])

    outdir = os.path.join(outBase, '1.0.0')
    moveToOutputDir([
        '{}_blocked.nitf'.format(legendNameBase),
        '{}_unblocked.nitf'.format(legendNameBase)
    ], outdir)

    # Make the rest of SIDDs through test_create_sidd_from_mem
    argToOutput = {
        '--lut Color': 'siddWithColorLUT.nitf',
        '--lut Mono': 'siddWithMonoLUT.nitf',
        '--lut None': 'siddWithNoLUT.nitf',
        '--multipleImages': 'siddMultipleImages.nitf',
        '--multipleSegments': 'siddMultipleSegments.nitf'
    }

    for version in ['1.0.0', '2.0.0']:
        outdir = os.path.join(outBase, version)
        for arg in argToOutput.keys():
            print('Creating file {}'.format(argToOutput[arg]))
            if '--lut' in arg:
                call([
                    utils.executableName(
                        os.path.join(binDir, 'test_create_sidd_from_mem')),
                    '--lut',
                    arg.split(' ')[1], '--version', version, argToOutput[arg]
                ])
            else:
                call([
                    utils.executableName(
                        os.path.join(binDir, 'test_create_sidd_from_mem')),
                    arg, '--version', version, argToOutput[arg]
                ])

        moveToOutputDir(argToOutput.values(), outdir)
Example #2
0
def roundTripSix(pathname):
    return call([
        utils.executableName(os.path.join(binDir, 'round_trip_six')),
        '--version',
        extractVersionNumber(pathname), pathname,
        roundTrippedName(pathname)
    ]) == 0
Example #3
0
def validate(pathname):
    check_valid_six = utils.executableName(
        os.path.join(binDir, 'check_valid_six'))

    return (
        call([check_valid_six, pathname], stdout=open(os.devnull, 'w')) == 0
        and call([check_valid_six, roundTrippedName(pathname)],
                 stdout=open(os.devnull, 'w'))) == 0
def runTests(testDir, testName, *args):
    argList = [utils.executableName(os.path.join(testDir, testName))]
    argList.extend(args)
    result = call(argList, stdout=subprocess.PIPE)

    if result == 0:
        print('Passed')
        return True
    print('Failed')
    return False
Example #5
0
def run():
    install = utils.installPath()
    unitTestDir = os.path.join(install, 'unittests')
    childDirs = os.listdir(unitTestDir)
    success = True
    for childDir in childDirs:
        for test in os.listdir(os.path.join(unitTestDir, childDir)):
            print(os.path.join(unitTestDir, childDir, test))
            if call([utils.executableName(os.path.join(unitTestDir, childDir, test))]) != 0:
                success = False

    return success
def run():
    outdir = os.path.join(utils.findSixHome(),
                          'regression_files', 'six.sidd')
    if not os.path.isdir(outdir):
        os.makedirs(outdir)

    # Make siddLegend
    binDir = os.path.join(utils.installPath(), 'bin')
    legendNameBase = 'siddLegend'
    print('Creating SIDDs with legends')

    call([utils.executableName(os.path.join(binDir, 'test_create_sidd_legend')),
          legendNameBase])

    moveToOutputDir(['{}_blocked.nitf'.format(legendNameBase),
                     '{}_unblocked.nitf'.format(legendNameBase)],
                    outdir)

    # Make the rest of SIDDs through test_create_sidd_from_mem
    argToOutput = {
        '--lut Color'        : 'siddWithColorLUT.nitf',
        '--lut Mono'         : 'siddWithMonoLUT.nitf',
        '--lut None'         : 'siddWithNoLUT.nitf',
        '--multipleImages'   : 'siddMultipleImages.nitf',
        '--multipleSegments' : 'siddMultipleSegments.nitf'
        }

    for arg in argToOutput.keys():
        print('Creating file {}'.format(argToOutput[arg]))
        if '--lut' in arg:
            call([utils.executableName(os.path.join(binDir,
                    'test_create_sidd_from_mem')), '--lut', arg.split(' ')[1],
                    argToOutput[arg]], stdout = open(os.devnull, 'w'))
        else:
            call([utils.executableName(os.path.join(binDir,
                    'test_create_sidd_from_mem')), arg, argToOutput[arg]],
                     stdout = open(os.devnull, 'w'))

    moveToOutputDir(argToOutput.values(), outdir)
Example #7
0
def run():
    install = utils.installPath()
    unitTestDir = os.path.join(install, 'unittests')
    childDirs = os.listdir(unitTestDir)
    for childDir in childDirs:
        for test in os.listdir(os.path.join(unitTestDir, childDir)):
            print(os.path.join(unitTestDir, childDir, test))
            testPathname = os.path.join(unitTestDir, childDir, test)
            if test.endswith('.py'):
                command = ['python', testPathname]
            else:
                command = [utils.executableName(testPathname)]
            if call(command) != 0:
                print('{} failed'.format(testPathname))
                return False

    return True
Example #8
0
def runCPHDTests(cphdDir):

    # Directory of CPHD1.0 schemas
    cphdSchemaDir = os.path.join(utils.findSixHome(), 'six', 'modules', 'c++',
                                 'cphd', 'conf', 'schema')

    # Init executable path
    os.environ['PATH'] = (os.environ['PATH'] + os.pathsep +
                          os.path.join(utils.installPath(), 'tests', 'cphd'))

    result = True
    # Run cphd test for each CPHD version
    for file in os.listdir(cphdDir):
        cphdPathname = os.path.join(cphdDir, file)

        # Generate CPHD1.0 output file
        writeCphd = utils.executableName('test_round_trip')
        success = subprocess.call(
            [writeCphd, cphdPathname, 'output.cphd', cphdSchemaDir],
            stdout=subprocess.PIPE)

        print('Running test_round_trip')

        if success != 0:
            if os.path.exists('output.cphd'):
                os.remove('output.cphd')
            print('Error running test_round_trip')
            return False

        # Check if CPHD1.0 input and output files match
        cphdRunner = CppTestRunner(
            os.path.join(utils.installPath(), 'tests', 'cphd'))
        result = result and cphdRunner.run('test_compare_cphd', cphdPathname,
                                           'output.cphd', cphdSchemaDir)

    # Remove output file after done
    if os.path.exists('output.cphd'):
        os.remove('output.cphd')

    return result
Example #9
0
def run(sourceDir):
    # If we don't run this before setting the paths, we won't be testing
    # the right things

    sicdDir = os.path.join(sourceDir, 'SICD')
    siddDir = os.path.join(sourceDir, 'SIDD')

    if sourceDir != '':
        os.environ["PATH"] = (os.environ["PATH"] + os.pathsep +
                              os.path.join(utils.installPath(), 'bin'))
        cropSicds = utils.executableName('crop_sicd')

        sicdPathname = os.path.join(sicdDir, os.listdir(sicdDir)[0])

        success = subprocess.call([
            cropSicds, '--start-row', '0', '--start-col', '0', '--num-rows',
            '10', '--num-cols', '10', sicdPathname, 'cropped.nitf'
        ],
                                  stdout=subprocess.PIPE)

        print("Running crop_sicd")
        if os.path.exists('cropped.nitf'):
            os.remove('cropped.nitf')
        if success != 0:
            print("Error running crop_sicd")
            return False

    utils.setPaths()

    if platform.system() != 'SunOS':
        if makeRegressionFiles.run() == False:
            print("Error generating regression files")
            return False

        if runPythonScripts.run() == False:
            print("Error running a python script")
            return False

        if checkNITFs.run() == False:
            print("test in checkNITFS.py failed")
            return False

        if runMiscTests.run() == False:
            # These tests should report their own errors
            return False
    else:
        print('Warning: skipping the bulk of the test suite, '
              'since Python modules are by default disabled on Solaris')

    sicdTestDir = os.path.join(utils.installPath(), 'tests', 'six.sicd')
    siddTestDir = os.path.join(utils.installPath(), 'tests', 'six.sidd')
    sampleTestDir = os.path.join(utils.installPath(), 'bin')

    sicdTestRunner = CppTestRunner(sicdTestDir)
    siddTestRunner = CppTestRunner(siddTestDir)
    sampleTestRunner = CppTestRunner(sampleTestDir)

    if os.path.exists(sicdDir) and os.path.exists(siddDir):
        sampleSicd = os.path.join(sicdDir, os.listdir(sicdDir)[0])
        sampleSidd = os.path.join(siddDir, os.listdir(siddDir)[0])
        if not sicdTestRunner.run('test_load_from_input_stream', sampleSicd):
            return False

        if not sicdTestRunner.run('test_streaming_write'):
            return False

        if not sicdTestRunner.run('test_sicd_byte_provider'):
            return False

        if not runCsmTests():
            return False

        if not (siddTestRunner.run('test_byte_swap')
                and siddTestRunner.run('test_geotiff')
                and siddTestRunner.run('test_check_blocking', sampleSidd) and
                siddTestRunner.run('test_sidd_blocking', utils.installPath())
                and siddTestRunner.run('test_sidd_byte_provider')):
            return False

        if not sampleTestRunner.run('test_large_offset'):
            return False

        if not sampleTestRunner.run(
                'test_create_sidd_with_compressed_byte_provider'):
            return False

    if runUnitTests.run() == False:
        print("Unit tests failed")
        return False

    print("All passed")
    return True
Example #10
0
 def createInvocation(self, pathname):
     return [utils.executableName(pathname)]
Example #11
0
def run(sourceDir):
    # If we don't run this before setting the paths, we won't be testing
    # the right things

    sicdDir = os.path.join(sourceDir, 'SICD')
    siddDir = os.path.join(sourceDir, 'SIDD')

    if sourceDir != '':
        os.environ["PATH"] = (os.environ["PATH"] + os.pathsep +
                os.path.join(utils.installPath(), 'bin'))
        cropSicds = utils.executableName('crop_sicd')

        sicdPathname = os.path.join(sicdDir, os.listdir(sicdDir)[0])

        success = subprocess.call([cropSicds,
                '--start-row', '0', '--start-col', '0',
                '--num-rows', '10', '--num-cols', '10',
                sicdPathname, 'cropped.nitf'],
                stdout=subprocess.PIPE)

        print("Running crop_sicd")
        if os.path.exists('cropped.nitf'):
            os.remove('cropped.nitf')
        if success != 0:
            print("Error running crop_sicd")
            return False

    utils.setPaths()

    if platform.system() != 'SunOS':
        if makeRegressionFiles.run() == False:
            print("Error generating regression files")
            return False

        if runPythonScripts.run() == False:
            print("Error running a python script")
            return False

        if checkNITFs.run() == False:
            print("test in checkNITFS.py failed")
            return False

        if runMiscTests.run() == False:
            # These tests should report their own errors
            return False
    else:
        print('Warning: skipping the bulk of the test suite, '
                'since Python modules are by default disabled on Solaris')

    sicdTestDir = os.path.join(utils.installPath(), 'tests', 'six.sicd')
    siddTestDir = os.path.join(utils.installPath(), 'tests', 'six.sidd')
    sampleTestDir = os.path.join(utils.installPath(), 'bin')

    newFiles = utils.installVts()

    sicdTestRunner = CppTestRunner(sicdTestDir)
    siddTestRunner = CppTestRunner(siddTestDir)
    sampleTestRunner = CppTestRunner(sampleTestDir)

    if os.path.exists(sicdDir) and os.path.exists(siddDir):
        sampleSicd = os.path.join(sicdDir, os.listdir(sicdDir)[0])
        if not sicdTestRunner.run('test_load_from_input_stream', sampleSicd):
            return False

        if not sicdTestRunner.run('test_streaming_write'):
            return False

        for nitf in os.listdir(sicdDir):
            nitf = os.path.join(sicdDir, nitf)
            if not sampleTestRunner.run('test_read_nitf_from_vts', nitf,
                    'out.nitf'):
                clean(newFiles)
                return False

        for nitf in os.listdir(siddDir):
            nitf = os.path.join(siddDir, nitf)
            if not sampleTestRunner.run('test_read_nitf_from_vts', nitf,
                    'out.nitf'):
                clean(newFiles)
                return False

        clean(newFiles)

        if not (siddTestRunner.run('test_byte_swap') and
                siddTestRunner.run('test_geotiff')):
            return False

    if runUnitTests.run() == False:
        print("Unit tests failed")
        return False

    print("All passed")
    return True
Example #12
0
def roundTripSix(pathname):
    return call([
        utils.executableName(os.path.join(binDir, 'round_trip_six')), pathname,
        roundTrippedName(pathname)
    ]) == 0
Example #13
0
def run(sourceDir):
    # If we don't run this before setting the paths, we won't be testing
    # the right things
    sicdDir = os.path.join(sourceDir, 'SICD')
    siddDir = os.path.join(sourceDir, 'SIDD')
    cphdDir = os.path.join(sourceDir, 'CPHD')

    if sourceDir != '':
        os.environ['PATH'] = (os.environ['PATH'] + os.pathsep +
                              os.path.join(utils.installPath(), 'bin'))
        cropSicds = utils.executableName('crop_sicd')

        sicdPathname = os.path.join(sicdDir, os.listdir(sicdDir)[0])

        success = subprocess.call([
            cropSicds, '--start-row', '0', '--start-col', '0', '--num-rows',
            '10', '--num-cols', '10', sicdPathname, 'cropped.nitf'
        ],
                                  stdout=subprocess.PIPE)

        print('Running crop_sicd')
        if os.path.exists('cropped.nitf'):
            os.remove('cropped.nitf')
        if success != 0:
            print('Error running crop_sicd')
            return False

    utils.setPaths()

    if makeRegressionFiles.run() == False:
        print('Error generating regression files')
        return False

    if runPythonScripts.run() == False:
        print('Error running a python script')
        return False

    if checkNITFs.run() == False:
        print('test in checkNITFS.py failed')
        return False

    if runMiscTests.run() == False:
        # These tests should report their own errors
        return False

    sicdTestDir = os.path.join(utils.installPath(), 'tests', 'six.sicd')
    siddTestDir = os.path.join(utils.installPath(), 'tests', 'six.sidd')
    sampleTestDir = os.path.join(utils.installPath(), 'bin')

    sicdTestRunner = CppTestRunner(sicdTestDir)
    siddTestRunner = CppTestRunner(siddTestDir)
    sampleTestRunner = CppTestRunner(sampleTestDir)

    if os.path.exists(sicdDir) and os.path.exists(siddDir):
        sampleSicd = os.path.join(sicdDir, os.listdir(sicdDir)[0])
        sampleSidd = os.path.join(siddDir, os.listdir(siddDir)[0])
        if not sicdTestRunner.run('test_load_from_input_stream', sampleSicd):
            return False

        if not sicdTestRunner.run('test_streaming_write'):
            return False

        if not runCsmTests():
            return False

        if not (siddTestRunner.run('test_byte_swap')
                and siddTestRunner.run('test_geotiff')
                and siddTestRunner.run('test_check_blocking', sampleSidd) and
                siddTestRunner.run('test_sidd_blocking', utils.installPath())):
            return False

        if not sampleTestRunner.run('test_large_offset'):
            return False

    if os.path.exists(cphdDir):
        if not runCPHDTests(cphdDir):
            return False

    if not runUnitTests.run():
        print('Unit tests failed')
        return False

    print('All passed')
    return True
Example #14
0
 def createInvocation(self, pathname):
     return [utils.executableName(pathname)]