Skip to content

Instantly share code, notes, and snippets.

@apahim
Created March 10, 2017 15:13
Show Gist options
  • Save apahim/d1acda76d9700deccd5146037427ab62 to your computer and use it in GitHub Desktop.
Save apahim/d1acda76d9700deccd5146037427ab62 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from avocado import Test
from avocado import main
from avocado.utils.process import run
from avocado.utils.software_manager import SoftwareManager
class CancelTest(Test):
"""
Example tests that cancel the current test from inside the test.
"""
def setUp(self):
sm = SoftwareManager()
self.pkgs = sm.list_all(software_components=False)
def test_iperf(self):
if 'iperf-2.0.8-6.fc25.x86_64' not in self.pkgs:
self.cancel('iperf is not installed or wrong version')
self.assertIn('pthreads', run('iperf -v', ignore_status=True).stderr)
def test_gcc(self):
if 'gcc-6.3.1-1.fc25.x86_64' not in self.pkgs:
self.cancel('gcc is not installed or wrong version')
self.assertIn('enable-gnu-indirect-function', run('gcc -v').stderr)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment