Esempio n. 1
0
class ShowTest(tests.TestCase):
    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_show(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, create.COMMAND, ['./a.out'])
        argv = ['0', '--profile-tool', 'pprof']
        self.assertCommandReturnValue(None, show.COMMAND, argv)
Esempio n. 2
0
class DeleteTest(tests.TestCase):
    """Tests for :any:`trial.delete`."""
    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_delete(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, create_command, ['./a.out'])
        stdout, stderr = self.assertCommandReturnValue(0, delete_command,
                                                       ['0'])
        self.assertIn('Deleted trial 0', stdout)
        self.assertFalse(stderr)

    def test_wrongnumber(self):
        self.reset_project_storage()
        _, stderr = self.assertNotCommandReturnValue(0, delete_command, ['-1'])
        self.assertIn('trial delete <trial_number> [arguments]', stderr)
        self.assertIn(
            'trial delete: error: No trial number -1 in the current experiment.',
            stderr)
Esempio n. 3
0
class ShowTest(tests.TestCase):
    
    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_show(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, create.COMMAND, ['./a.out'])
        argv = ['0', '--profile-tool', 'pprof']
        self.assertCommandReturnValue(None, show.COMMAND, argv)

    def test_multiple_trials(self):
        """Issue #240"""
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, create.COMMAND, ['./a.out'])
        self.assertCommandReturnValue(0, create.COMMAND, ['./a.out'])
        self.assertCommandReturnValue(0, create.COMMAND, ['./a.out'])
        argv = ['0', '2', '--profile-tool', 'pprof']
        stdout, stderr = self.assertCommandReturnValue(None, show.COMMAND, argv)
        self.assertFalse(stderr)
        self.assertIn('Current trial/metric directory: 0', stdout)
        self.assertIn('Current trial/metric directory: 2', stdout)
        self.assertNotIn('Current trial/metric directory: 1', stdout)
Esempio n. 4
0
class RenumberTest(tests.TestCase):
    """Tests for :any:`trial.renumber`."""
    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_newtrial(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
        self.assertCommandReturnValue(0, EDIT_COMMAND,
                                      ['0', '--description', 'desc0'])
        exp = Project.selected().experiment().eid
        old_path = Trial.controller(storage=PROJECT_STORAGE).search({
            'number':
            0,
            'experiment':
            exp
        })[0].get_data_files()['tau']
        self.assertTrue(os.path.exists(old_path),
                        "Data directory should exist after create")
        old_profile = os.path.join(old_path, "profile.0.0.0")
        self.assertTrue(os.path.exists(old_profile),
                        "Profile should exist after create")
        with open(old_profile, 'r') as f:
            old_profile_contents = f.read()
        num_trials_before = Trial.controller(storage=PROJECT_STORAGE).count()
        self.assertCommandReturnValue(0, RENUMBER_COMMAND, ['0', '--to', '1'])
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, [])
        self.assertIn('./a.out', stdout)
        self.assertIn('  1  ', stdout)
        self.assertIn('desc0', stdout)
        self.assertNotIn('  0  ', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)
        num_trials_after = Trial.controller(storage=PROJECT_STORAGE).count()
        self.assertEqual(num_trials_before, num_trials_after,
                         "Renumbering should not change number of trials")
        self.assertFalse(
            os.path.exists(old_path),
            "Data directory for old number should not exist after renumber")
        self.assertFalse(
            os.path.exists(os.path.join(old_path, "profile.0.0.0")),
            "Profile in old data directory should not exist after renumber")
        new_path = Trial.controller(storage=PROJECT_STORAGE).search({
            'number':
            1,
            'experiment':
            exp
        })[0].get_data_files()['tau']
        self.assertTrue(
            os.path.exists(new_path),
            "Data directory for new number should exist after renumber")
        new_profile = os.path.join(new_path, "profile.0.0.0")
        self.assertTrue(
            os.path.exists(new_profile),
            "Profile in data directory for new number should exist after renumber"
        )
        with open(new_profile, 'r') as f:
            new_profile_contents = f.read()
        self.assertEqual(old_profile_contents, new_profile_contents,
                         "Profiles should be identical after renumber")

    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_swaptrials(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        for i in xrange(3):
            self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
            self.assertCommandReturnValue(
                0, EDIT_COMMAND, [str(i), '--description',
                                  'desc%s' % i])
        self.assertCommandReturnValue(0, RENUMBER_COMMAND,
                                      ['0', '1', '2', '--to', '1', '2', '0'])
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, '0')
        self.assertIn('./a.out', stdout)
        self.assertIn('desc2', stdout)
        self.assertNotIn('desc0', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, '1')
        self.assertIn('./a.out', stdout)
        self.assertIn('desc0', stdout)
        self.assertNotIn('desc1', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, '2')
        self.assertIn('./a.out', stdout)
        self.assertIn('desc1', stdout)
        self.assertNotIn('desc2', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)
        trials = Trial.controller(storage=PROJECT_STORAGE).search()
        self.assertEqual(len(trials), 3,
                         "There should be three trials after renumber")
        for trial in trials:
            self.assertTrue(os.path.exists(trial.get_data_files()['tau']),
                            "Trial should have data directory")
            self.assertTrue(
                os.path.exists(
                    os.path.join(trial.get_data_files()['tau'],
                                 'profile.0.0.0')),
                "Trial should have profile in data directory")
            self.assertEqual(
                int(os.path.basename(trial.get_data_files()['tau'])),
                trial['number'],
                "Trial number should match data directory name after renumber")
Esempio n. 5
0
class CreateTest(tests.TestCase):
    """Tests for :any:`trial.create`."""
    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_create(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn('BEGIN targ1-app1', stdout)
        self.assertIn('END targ1-app1', stdout)
        self.assertIn('Trial 0 produced', stdout)
        self.assertIn('profile files', stdout)
        self.assertFalse(stderr)

    def test_h_arg(self):
        self.reset_project_storage()
        stdout, _ = self.assertCommandReturnValue(0, trial_create_cmd, ['-h'])
        self.assertIn('Show this help message and exit', stdout)

    def test_help_arg(self):
        self.reset_project_storage()
        stdout, _ = self.assertCommandReturnValue(0, trial_create_cmd,
                                                  ['--help'])
        self.assertIn('Show this help message and exit', stdout)

    def test_no_time_metric(self):
        self.reset_project_storage()
        argv = [
            'meas_no_time', '--metrics', 'PAPI_FP_INS', '--source-inst',
            'never'
        ]
        self.assertCommandReturnValue(0, measurement_create_cmd, argv)
        argv = [
            'exp2', '--target', 'targ1', '--application', 'app1',
            '--measurement', 'meas_no_time'
        ]
        self.assertCommandReturnValue(0, experiment_create_cmd, argv)
        self.assertCommandReturnValue(0, experiment_select_cmd, ['exp2'])
        self.assertManagedBuild(0, CC, [], 'hello.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("TAU_METRICS=TIME,", stdout)
        self.assertFalse(stderr)

    @tests.skipIf(HOST_OS is DARWIN, "Sampling not supported on Darwin")
    def test_heap_usage_memory_alloc_sample(self):
        """https://github.com/ParaToolsInc/taucmdr/issues/14"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd,
            ['sample', '--heap-usage', '--memory-alloc'])
        self.assertIn("Updated measurement 'sample'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['sample'])
        self.assertIn("Selected experiment 'targ1-app1-sample'", stdout)
        self.assertFalse(stderr)
        self.assertManagedBuild(0, CC, [], 'matmult.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("Trial 0 produced 1 profile files", stdout)
        self.assertIn("TAU_SHOW_MEMORY_FUNCTIONS=1", stdout)
        self.assertIn("TAU_TRACK_HEAP=1", stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData(
            "<attribute><name>TAU_SHOW_MEMORY_FUNCTIONS</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData(
            "<attribute><name>TAU_TRACK_HEAP</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData("Heap Memory Used (KB) at Entry")
        self.assertInLastTrialData("Heap Memory Used (KB) at Exit")
        self.assertInLastTrialData("compute_interchange")
        self.assertInLastTrialData("compute")
        # TAU bug: the dynamic malloc wrapper (e.g. tau_exec -memory) doesn't always capture malloc().
        #self.assertInLastTrialData("Heap Allocate")
        #self.assertInLastTrialData("malloc")

    def test_heap_usage_memory_alloc_profile(self):
        """https://github.com/ParaToolsInc/taucmdr/issues/14"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd,
            ['profile', '--heap-usage', '--memory-alloc'])
        self.assertIn("Updated measurement 'profile'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['profile'])
        self.assertIn("Selected experiment 'targ1-app1-profile'", stdout)
        self.assertFalse(stderr)
        meas = Project.selected().experiment().populate('measurement')
        self.assertTrue(meas['heap_usage'])
        self.assertTrue(meas['memory_alloc'])
        self.assertManagedBuild(0, CC, [], 'matmult.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("Trial 0 produced 1 profile files", stdout)
        self.assertIn("TAU_SHOW_MEMORY_FUNCTIONS=1", stdout)
        self.assertIn("TAU_TRACK_HEAP=1", stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData(
            "<attribute><name>TAU_SHOW_MEMORY_FUNCTIONS</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData(
            "<attribute><name>TAU_TRACK_HEAP</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData("Heap Memory Used (KB) at Entry")
        self.assertInLastTrialData("Heap Memory Used (KB) at Exit")
        self.assertInLastTrialData("Heap Allocate")
        self.assertInLastTrialData("compute_interchange")
        self.assertInLastTrialData("compute")
        self.assertInLastTrialData("malloc")

    def sample_resolution_helper(self, option):
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd, ['sample', '--sample-resolution', option])
        self.assertIn("Updated measurement 'sample'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['sample'])
        self.assertIn("Selected experiment 'targ1-app1-sample'", stdout)
        self.assertFalse(stderr)
        self.assertManagedBuild(0, CC, [], 'matmult.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("Trial 0 produced 1 profile files", stdout)
        self.assertIn("TAU_EBS_RESOLUTION=" + option, stdout)
        self.assertFalse(stderr)

    def test_sample_resolution_file(self):
        self.sample_resolution_helper('file')

    def test_sample_resolution_function(self):
        self.sample_resolution_helper('function')

    def test_sample_resolution_line(self):
        self.sample_resolution_helper('line')

    @tests.skipIf(HOST_OS is DARWIN, "Sampling not supported on Darwin")
    def test_system_load_sample(self):
        """Test TAU_TRACK_LOAD w/ sampling"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd, ['sample', '--system-load'])
        self.assertIn("Updated measurement 'sample'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['sample'])
        self.assertIn("Selected experiment 'targ1-app1-sample'", stdout)
        self.assertFalse(stderr)

    def test_system_load_profile(self):
        """Test TAU_TRACK_LOAD w/ profiling"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd, ['profile', '--system-load'])
        self.assertIn("Updated measurement 'profile'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['profile'])
        self.assertIn("Selected experiment 'targ1-app1-profile'", stdout)
        self.assertFalse(stderr)

    def test_tau_dir(self):
        """Test --tau_dir option"""
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        test_dir = os.getcwd()
        path = tempfile.mkdtemp()
        os.chdir(path)
        stdout, stderr = self.assertCommandReturnValue(
            0, trial_create_cmd, [test_dir + '/a.out', '--tau-dir', test_dir])
        self.assertIn('BEGIN targ1-app1', stdout)
        self.assertIn('END targ1-app1', stdout)
        self.assertIn('Trial 0 produced', stdout)
        self.assertIn('profile files', stdout)
        self.assertFalse(stderr)
        os.chdir(test_dir)
        shutil.rmtree(path)

    def test_description(self):
        """Test --description option"""
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(
            0, trial_create_cmd, ['--description', 'test desc', './a.out'])
        stdout, stderr = self.assertCommandReturnValue(0, trial_list_cmd, [])
        self.assertIn('test desc', stdout)

    @tests.skipUnless(util.which('python'),
                      "Python 2 or 3 required for this test")
    def test_run_python(self):
        self.reset_project_storage(
            ['--python', 'T', '--python-interpreter', 'python'])
        self.copy_testfile('firstprime.py')
        test_dir = os.getcwd()
        stdout, stderr = self.assertCommandReturnValue(
            0, trial_create_cmd,
            ['python', os.path.join(test_dir, 'firstprime.py')])
        self.assertIn('Trial 0 produced', stdout)
        self.assertIn('profile files', stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData("firstPrimeAfter")

    @tests.skipUnless(util.which('python2'), "Python 2 required for this test")
    def test_run_python2(self):
        self.reset_project_storage(
            ['--python', 'T', '--python-interpreter', 'python2'])
        self.copy_testfile('firstprime.py')
        test_dir = os.getcwd()
        stdout, stderr = self.assertCommandReturnValue(
            0, trial_create_cmd,
            ['python2', os.path.join(test_dir, 'firstprime.py')])
        self.assertIn('Trial 0 produced', stdout)
        self.assertIn('profile files', stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData("firstPrimeAfter")

    @tests.skipUnless(util.which('python3'), "Python 3 required for this test")
    def test_run_python3(self):
        self.reset_project_storage(
            ['--python', 'T', '--python-interpreter', 'python3'])
        self.copy_testfile('firstprime.py')
        test_dir = os.getcwd()
        stdout, stderr = self.assertCommandReturnValue(
            0, trial_create_cmd,
            ['python3', os.path.join(test_dir, 'firstprime.py')])
        self.assertIn('Trial 0 produced', stdout)
        self.assertIn('profile files', stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData("firstPrimeAfter")
Esempio n. 6
0
class CreateTest(tests.TestCase):
    """Tests for :any:`trial.create`."""
    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_create(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn('BEGIN targ1-app1', stdout)
        self.assertIn('END targ1-app1', stdout)
        self.assertIn('Trial 0 produced', stdout)
        self.assertIn('profile files', stdout)
        self.assertFalse(stderr)

    def test_h_arg(self):
        self.reset_project_storage()
        stdout, _ = self.assertCommandReturnValue(0, trial_create_cmd, ['-h'])
        self.assertIn('Show this help message and exit', stdout)

    def test_help_arg(self):
        self.reset_project_storage()
        stdout, _ = self.assertCommandReturnValue(0, trial_create_cmd,
                                                  ['--help'])
        self.assertIn('Show this help message and exit', stdout)

    def test_no_time_metric(self):
        self.reset_project_storage()
        argv = [
            'meas_no_time', '--metrics', 'PAPI_FP_INS', '--source-inst',
            'never'
        ]
        self.assertCommandReturnValue(0, measurement_create_cmd, argv)
        argv = [
            'exp2', '--target', 'targ1', '--application', 'app1',
            '--measurement', 'meas_no_time'
        ]
        self.assertCommandReturnValue(0, experiment_create_cmd, argv)
        self.assertCommandReturnValue(0, experiment_select_cmd, ['exp2'])
        self.assertManagedBuild(0, CC, [], 'hello.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("TAU_METRICS=TIME,", stdout)
        self.assertFalse(stderr)

    @tests.skipIf(HOST_OS is DARWIN, "Sampling not supported on Darwin")
    def test_heap_usage_memory_alloc_sample(self):
        """https://github.com/ParaToolsInc/taucmdr/issues/14"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd,
            ['sample', '--heap-usage', '--memory-alloc'])
        self.assertIn("Updated measurement 'sample'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['sample'])
        self.assertIn("Selected experiment 'targ1-app1-sample'", stdout)
        self.assertFalse(stderr)
        self.assertManagedBuild(0, CC, [], 'matmult.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("Trial 0 produced 1 profile files", stdout)
        self.assertIn("TAU_SHOW_MEMORY_FUNCTIONS=1", stdout)
        self.assertIn("TAU_TRACK_HEAP=1", stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData(
            "<attribute><name>TAU_SHOW_MEMORY_FUNCTIONS</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData(
            "<attribute><name>TAU_TRACK_HEAP</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData("Heap Memory Used (KB) at Entry")
        self.assertInLastTrialData("Heap Memory Used (KB) at Exit")
        self.assertInLastTrialData("compute_interchange")
        self.assertInLastTrialData("compute")
        # TAU bug: the dynamic malloc wrapper (e.g. tau_exec -memory) doesn't always capture malloc().
        #self.assertInLastTrialData("Heap Allocate")
        #self.assertInLastTrialData("malloc")

    def test_heap_usage_memory_alloc_profile(self):
        """https://github.com/ParaToolsInc/taucmdr/issues/14"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd,
            ['profile', '--heap-usage', '--memory-alloc'])
        self.assertIn("Updated measurement 'profile'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['profile'])
        self.assertIn("Selected experiment 'targ1-app1-profile'", stdout)
        self.assertFalse(stderr)
        meas = Project.selected().experiment().populate('measurement')
        self.assertTrue(meas['heap_usage'])
        self.assertTrue(meas['memory_alloc'])
        self.assertManagedBuild(0, CC, [], 'matmult.c')
        stdout, stderr = self.assertCommandReturnValue(0, trial_create_cmd,
                                                       ['./a.out'])
        self.assertIn("Trial 0 produced 1 profile files", stdout)
        self.assertIn("TAU_SHOW_MEMORY_FUNCTIONS=1", stdout)
        self.assertIn("TAU_TRACK_HEAP=1", stdout)
        self.assertFalse(stderr)
        self.assertInLastTrialData(
            "<attribute><name>TAU_SHOW_MEMORY_FUNCTIONS</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData(
            "<attribute><name>TAU_TRACK_HEAP</name><value>on</value></attribute>"
        )
        self.assertInLastTrialData("Heap Memory Used (KB) at Entry")
        self.assertInLastTrialData("Heap Memory Used (KB) at Exit")
        self.assertInLastTrialData("Heap Allocate")
        self.assertInLastTrialData("compute_interchange")
        self.assertInLastTrialData("compute")
        self.assertInLastTrialData("malloc")

    @tests.skipIf(HOST_OS is DARWIN, "Sampling not supported on Darwin")
    def test_system_load_sample(self):
        """Test TAU_TRACK_LOAD w/ sampling"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd, ['sample', '--system-load'])
        self.assertIn("Updated measurement 'sample'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['sample'])
        self.assertIn("Selected experiment 'targ1-app1-sample'", stdout)
        self.assertFalse(stderr)

    def test_system_load_profile(self):
        """Test TAU_TRACK_LOAD w/ profiling"""
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(
            0, measurement_edit_cmd, ['profile', '--system-load'])
        self.assertIn("Updated measurement 'profile'", stdout)
        self.assertFalse(stderr)
        stdout, stderr = self.assertCommandReturnValue(0, select_cmd,
                                                       ['profile'])
        self.assertIn("Selected experiment 'targ1-app1-profile'", stdout)
        self.assertFalse(stderr)
Esempio n. 7
0
class ListTest(tests.TestCase):
    """Tests for :any:`trial.list`."""
    def test_notrials(self):
        self.reset_project_storage()
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, [])
        self.assertIn("No trials.", stdout)
        self.assertFalse(stderr)

    def test_notrials_one(self):
        self.reset_project_storage()
        stdout, stderr = self.assertNotCommandReturnValue(
            0, LIST_COMMAND, ['100'])
        self.assertIn("No trial with number='100'", stderr)
        self.assertFalse(stdout)

    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_list(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, [])
        self.assertIn('./a.out', stdout)
        self.assertIn('  0  ', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)

    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_list_one(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND, ['0'])
        self.assertIn('./a.out', stdout)
        self.assertIn('  0  ', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)

    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_list_multiple(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        for _ in xrange(3):
            self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND,
                                                       ['0', '1', '2'])
        self.assertIn('./a.out', stdout)
        self.assertIn('  0  ', stdout)
        self.assertIn('  1  ', stdout)
        self.assertIn('  2  ', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)

    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_list_multiple_subset(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        for _ in xrange(4):
            self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
        stdout, stderr = self.assertCommandReturnValue(0, LIST_COMMAND,
                                                       ['1', '3'])
        self.assertIn('./a.out', stdout)
        self.assertIn('  1  ', stdout)
        self.assertIn('  3  ', stdout)
        self.assertNotIn('  0  ', stdout)
        self.assertNotIn('  2  ', stdout)
        self.assertIn('Selected experiment:', stdout)
        self.assertFalse(stderr)

    @tests.skipIf(HOST_ARCH.is_bluegene(), "Test skipped on BlueGene")
    def test_list_one_invalid(self):
        self.reset_project_storage()
        self.assertManagedBuild(0, CC, [], 'hello.c')
        self.assertCommandReturnValue(0, CREATE_COMMAND, ['./a.out'])
        stdout, stderr = self.assertNotCommandReturnValue(
            0, LIST_COMMAND, ['100'])
        self.assertIn("No trial with number='100'", stderr)
        self.assertFalse(stdout)