Ejemplo n.º 1
0
 def test_pre_execute_copy(self):
     with mkdtemp() as path:
         with pushd(path):
             benchmark = IOSSD()
             benchmark.pre_execute(None)
             self.assertTrue(osp.isfile(IOSSD.SCRIPT_NAME))
             self.assertTrue(os.access(IOSSD.SCRIPT_NAME, os.X_OK))
Ejemplo n.º 2
0
 def test_pushd(self):
     cwd = osp.realpath(os.getcwd())
     with mkdtemp() as path, pushd(path) as ppath:
         path = osp.realpath(path)
         ppath = osp.realpath(ppath)
         cwd_in_context = osp.realpath(os.getcwd())
         self.assertNotEqual(cwd, cwd_in_context)
         self.assertEqual(path, ppath)
         self.assertEqual(path, cwd_in_context)
     self.assertEqual(cwd, osp.realpath(os.getcwd()))
     self.assertFalse(osp.isdir(path))
Ejemplo n.º 3
0
 def _aggregate_tarball(self, path):
     with mkdtemp(prefix='hpcbench-campaign-result', remove=False) as tmpd:
         local_output_dir = os.getcwd()
         with pushd(tmpd):
             subprocess.check_call(['tar', 'jxf', path])
             dirs = [
                 _dir
                 for _dir in os.listdir(self.remote_output_dir)
                 if osp.isdir(osp.join(self.remote_output_dir, _dir))
             ]
             if len(dirs) != 1:
                 raise Exception('Expected one directory but got: %s' %
                                 dirs)
             shutil.move(
                 osp.join(self.remote_output_dir, dirs[0]),
                 osp.join(local_output_dir, self.node)
             )
Ejemplo n.º 4
0
 def check_category_metrics(self, category):
     self.logger.info('testing metrics of category %s', category)
     self.maxDiff = None
     with mkdtemp() as top_dir, pushd(top_dir):
         with open(YAML_REPORT_FILE, 'w') as ostr:
             yaml.dump(dict(children=['sample-run'], category=category),
                       ostr)
         with pushd('sample-run'):
             self.create_sample_run(category)
             clazz = self.get_benchmark_clazz()
             benchmark = clazz()
             with open(YAML_REPORT_FILE, 'w') as ostr:
                 yaml.dump(dict(category=category), ostr)
             md = MetricsDriver('test-category', benchmark)
             report = md()
             parsed_metrics = report.get('metrics', {})
             expected_metrics = self.get_expected_metrics(category)
             self.assertEqual(parsed_metrics, expected_metrics)
Ejemplo n.º 5
0
 def test_mkdtemp_keep_file(self):
     with mkdtemp(remove=False) as path:
         self.assertTrue(osp.isdir(path))
     self.assertTrue(osp.isdir(path))
Ejemplo n.º 6
0
 def test_mkdtemp(self):
     with mkdtemp() as path:
         self.assertTrue(osp.isdir(path))
     self.assertFalse(osp.isdir(path))
Ejemplo n.º 7
0
 def test_local(self):
     with mkdtemp() as temp_dir:
         with pushd(temp_dir):
             bennett.main(TestNet.get_campaign_file())