Esempio n. 1
0
def runCsmTests():
    pathKey = None
    if platform.system() == 'Windows':
        pathKey = 'PATH'
    else:
        pathKey = 'LD_LIBRARY_PATH'
    os.environ[pathKey] = (os.environ[pathKey] + os.pathsep +
                           os.path.join(utils.installPath(), 'lib'))

    nitfPathname = os.path.join(utils.findSixHome(), 'croppedNitfs')
    sicdPathname = os.path.join(nitfPathname, 'SICD')
    siddPathname = os.path.join(nitfPathname, 'SIDD')
    testRunner = CppTestRunner(os.path.join(utils.installPath(), 'bin'))

    if os.path.exists(sicdPathname):
        for sicd in os.listdir(sicdPathname):
            sicd = os.path.join(sicdPathname, sicd)
            if not testRunner.run('test_sicd_csm', sicd):
                return False

    if os.path.exists(siddPathname):
        for sidd in os.listdir(siddPathname):
            sidd = os.path.join(siddPathname, sidd)
            if not testRunner.run('test_sidd_csm', sidd):
                return False
    return True
Esempio n. 2
0
def run():
    schemaPath = os.path.join(utils.installPath(), 'conf', 'schema', 'six')

    # SIX tests
    testsDir = os.path.join(utils.findSixHome(), 'six', 'modules', 'python',
                            'six', 'tests')
    sixRunner = PythonTestRunner(testsDir)
    result = sixRunner.run('testDateTime.py')

    # SICD tests
    testsDir = os.path.join(utils.findSixHome(), 'six', 'modules', 'python',
                            'six.sicd', 'tests')
    sampleNITF = os.path.join(utils.findSixHome(), 'regression_files',
                              'six.sicd', 'sicd_1.2.0(RMA)RMAT.nitf')
    sicdRunner = PythonTestRunner(testsDir)
    result = (result and sicdRunner.run('test_streaming_sicd_write.py')
              and sicdRunner.run('test_read_region.py')
              and sicdRunner.run('test_read_sicd_xml.py', sampleNITF)
              and sicdRunner.run('test_six_sicd.py', sampleNITF)
              and sicdRunner.run('test_create_sicd_xml.py', '-v', '1.2.0')
              and sicdRunner.run('sicd_to_sio.py', sampleNITF, schemaPath)
              and sicdRunner.run('test_read_complex_data.py', sampleNITF))

    # CPHD tests
    cphd03Pathname = createSampleCPHD()
    testsDir = os.path.join(utils.findSixHome(), 'six', 'modules', 'python',
                            'cphd03', 'tests')
    cphd03Runner = PythonTestRunner(testsDir)
    result = result and cphd03Runner.run('test_round_trip_cphd.py',
                                         cphd03Pathname, 'out.cphd')
    os.remove(cphd03Pathname)

    return result
Esempio n. 3
0
def runSIDDTests():
    testDir = os.path.join(utils.installPath(), 'tests', 'six.sidd')
    inputFiles = os.listdir(os.path.join(
        utils.findSixHome(), 'regression_files', 'six.sidd', '2.0.0'))
    passed = True
    for pathname in inputFiles:
        passed = passed and runTests(testDir, 'test_read_and_write_lut',
                os.path.join(utils.findSixHome(), 'regression_files',
                'six.sidd', '2.0.0', pathname))
    return passed
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
0
def runSICDTests():
    testDir = os.path.join(utils.installPath(), 'tests', 'six.sicd')

    success = runTests(testDir, 'test_add_additional_des', getSampleSicdXML())
    success = runTests(testDir, 'test_mesh_roundtrip') and success
    success = runTests(testDir, 'test_mesh_polyfit') and success

    # Need it for just this test
    os.environ['NITF_PLUGIN_PATH'] = os.environ['NITF_PLUGIN_PATH_REAL']
    success = runTests(testDir, 'test_read_sicd_with_extra_des',
                       getSampleSicdXML()) and success
    del os.environ['NITF_PLUGIN_PATH']

    return success
Esempio n. 7
0
def createSampleCPHD():
    programPathname = os.path.join(utils.installPath(), 'tests', 'cphd03',
                                   'test_cphd_write_simple')
    if not os.path.exists(programPathname):
        programPathname += '.exe'
    if not os.path.exists(programPathname):
        raise IOError('Unable to find ' + programPathname)
    cphd03Handle, cphd03Pathname = tempfile.mkstemp()
    os.close(cphd03Handle)
    os.remove(cphd03Pathname)
    success = subprocess.check_call([programPathname, cphd03Pathname])
    if success != 0:
        raise OSError('An error occured while executing ' + programPathname)
    return cphd03Pathname
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)
Esempio n. 9
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
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)
Esempio n. 11
0
def runSICDTests():
    # Make sure plugins installed properly
    nitfPluginPath = os.environ['NITF_PLUGIN_PATH_REAL']

    if (not os.path.exists(nitfPluginPath) or
            not any(plugin.startswith('PIAIMB') for plugin in
                    os.listdir(nitfPluginPath))):
        print('Could not find NITF plugins. Please re-install with '
                'the following command.')
        print('python waf install --target=PIAIMB')
        sys.exit(1)
    testDir = os.path.join(utils.installPath(), 'tests', 'six.sicd')

    success = runTests(testDir, 'test_add_additional_des', getSampleSicdXML())

    # Need it for just this test
    os.environ['NITF_PLUGIN_PATH'] = os.environ['NITF_PLUGIN_PATH_REAL']
    success = success and runTests(testDir, 'test_read_sicd_with_extra_des',
            getSampleSicdXML())
    del os.environ['NITF_PLUGIN_PATH']

    return success
Esempio n. 12
0
def run():
    # SICD tests
    testsDir = os.path.join(utils.findSixHome(), 'six',
            'modules', 'python', 'six.sicd', 'tests')
    sampleNITF = os.path.join(utils.findSixHome(), 'regression_files',
            'six.sicd', 'sicd_1.2.0(RMA)RMAT.nitf')
    schemaPath = os.path.join(utils.installPath(), 'conf', 'schema', 'six')

    sicdRunner = PythonTestRunner(testsDir)
    result = (sicdRunner.run('test_streaming_sicd_write.py') and
        sicdRunner.run('test_read_region.py') and
        sicdRunner.run('test_read_sicd_xml.py', sampleNITF) and
        sicdRunner.run('test_six_sicd.py', sampleNITF) and
        sicdRunner.run('test_create_sicd_xml.py', '-v', '1.2.0') and
        sicdRunner.run('sicd_to_sio.py', sampleNITF, schemaPath))

    # SIX tests
    testsDir = os.path.join(utils.findSixHome(), 'six',
            'modules', 'python', 'six', 'tests')
    sixRunner = PythonTestRunner(testsDir)
    result = result and sixRunner.run('testDateTime.py');

    return result
Esempio n. 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')

    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
Esempio n. 14
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not,
# see <http://www.gnu.org/licenses/>.
#

import glob
import os
import re
import utils

from subprocess import call

binDir = os.path.join(utils.installPath(), 'bin')


def extractVersionNumber(pathname):
    versionPattern = '^\d\.\d\.\d$'

    candidateVersions = os.path.normpath(pathname).split(os.path.sep)
    for candidate in candidateVersions:
        if re.match(versionPattern, candidate):
            return candidate

    raise Exception('Unable to find version in path ' + pathanem)


def roundTrippedName(pathname):
    return os.path.basename(pathname.replace('.nitf', '_rt.nitf'))
Esempio n. 15
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
Esempio n. 16
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