| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Test that the fuzzer works the way ClusterFuzz invokes it.""" | 5 """Test that the fuzzer works the way ClusterFuzz invokes it.""" |
| 6 | 6 |
| 7 import glob | 7 import glob |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import sys | 10 import sys |
| 11 import tempfile | 11 import tempfile |
| 12 import unittest | 12 import unittest |
| 13 | 13 |
| 14 import fuzz_main_run | |
| 15 import setup | 14 import setup |
| 16 | 15 |
| 17 | 16 |
| 18 class WebBluetoothFuzzerTest(unittest.TestCase): | 17 class WebBluetoothFuzzerTest(unittest.TestCase): |
| 19 | 18 |
| 20 def setUp(self): | 19 def setUp(self): |
| 21 self._output_dir = tempfile.mkdtemp() | 20 self._output_dir = tempfile.mkdtemp() |
| 22 self._resources_path = setup.RetrieveResources() | 21 self._resources_path = setup.RetrieveResources() |
| 23 | 22 |
| 24 def tearDown(self): | 23 def tearDown(self): |
| 25 shutil.rmtree(self._output_dir) | 24 shutil.rmtree(self._output_dir) |
| 26 shutil.rmtree(self._resources_path) | 25 shutil.rmtree(self._resources_path) |
| 27 | 26 |
| 28 def testCanGenerate100Files(self): | 27 def testCanGenerate100Files(self): |
| 29 sys.argv = ['fuzz_main_run.py', '--no_of_files=100', | 28 sys.argv = ['fuzz_main_run.py', '--no_of_files=100', |
| 30 '--input_dir={}'.format(self._output_dir), | 29 '--input_dir={}'.format(self._output_dir), |
| 31 '--output_dir={}'.format(self._output_dir)] | 30 '--output_dir={}'.format(self._output_dir)] |
| 32 | 31 |
| 32 import fuzz_main_run |
| 33 fuzz_main_run.main() | 33 fuzz_main_run.main() |
| 34 | 34 |
| 35 written_files = glob.glob(os.path.join(self._output_dir, '*.html')) | 35 written_files = glob.glob(os.path.join(self._output_dir, '*.html')) |
| 36 | 36 |
| 37 self.assertEquals(100, len(written_files), 'Should have written 100 ' | 37 self.assertEquals(100, len(written_files), 'Should have written 100 ' |
| 38 'test files.') | 38 'test files.') |
| 39 | 39 |
| 40 if __name__ == '__main__': | 40 if __name__ == '__main__': |
| 41 unittest.main() | 41 unittest.main() |
| OLD | NEW |