Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | import os |
| 3 | import _prep |
Pau Espin Pedrol | 0ffb414 | 2017-05-15 18:24:35 +0200 | [diff] [blame] | 4 | from osmo_gsm_tester import log, suite, config, report |
Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 5 | |
Neels Hofmeyr | 17c139e | 2017-04-12 02:42:02 +0200 | [diff] [blame] | 6 | config.ENV_CONF = './suite_test' |
Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 7 | |
| 8 | #log.style_change(trace=True) |
| 9 | |
| 10 | print('- non-existing suite dir') |
| 11 | assert(log.run_logging_exceptions(suite.load, 'does_not_exist') == None) |
| 12 | |
| 13 | print('- no suite.conf') |
| 14 | assert(log.run_logging_exceptions(suite.load, 'empty_dir') == None) |
| 15 | |
| 16 | print('- valid suite dir') |
| 17 | example_suite_dir = os.path.join('test_suite') |
| 18 | s_def = suite.load(example_suite_dir) |
| 19 | assert(isinstance(s_def, suite.SuiteDefinition)) |
| 20 | print(config.tostr(s_def.conf)) |
| 21 | |
| 22 | print('- run hello world test') |
Neels Hofmeyr | 1a7a3f0 | 2017-06-10 01:18:27 +0200 | [diff] [blame] | 23 | trial = log.Origin(log.C_TST, 'trial') |
Neels Hofmeyr | 6ccda11 | 2017-06-06 19:41:17 +0200 | [diff] [blame] | 24 | s = suite.SuiteRun(trial, 'test_suite', s_def) |
Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 25 | results = s.run_tests('hello_world.py') |
Pau Espin Pedrol | 0ffb414 | 2017-05-15 18:24:35 +0200 | [diff] [blame] | 26 | print(report.suite_to_text(s)) |
Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 27 | |
| 28 | log.style_change(src=True) |
| 29 | #log.style_change(trace=True) |
| 30 | print('\n- a test with an error') |
| 31 | results = s.run_tests('test_error.py') |
Pau Espin Pedrol | 0ffb414 | 2017-05-15 18:24:35 +0200 | [diff] [blame] | 32 | output = report.suite_to_text(s) |
Neels Hofmeyr | 6ccda11 | 2017-06-06 19:41:17 +0200 | [diff] [blame] | 33 | print(output) |
Pau Espin Pedrol | 0ffb414 | 2017-05-15 18:24:35 +0200 | [diff] [blame] | 34 | |
| 35 | print('\n- a test with a failure') |
| 36 | results = s.run_tests('test_fail.py') |
| 37 | output = report.suite_to_text(s) |
Neels Hofmeyr | 6ccda11 | 2017-06-06 19:41:17 +0200 | [diff] [blame] | 38 | print(output) |
Pau Espin Pedrol | 0ffb414 | 2017-05-15 18:24:35 +0200 | [diff] [blame] | 39 | |
| 40 | print('\n- a test with a raised failure') |
| 41 | results = s.run_tests('test_fail_raise.py') |
| 42 | output = report.suite_to_text(s) |
Neels Hofmeyr | 6ccda11 | 2017-06-06 19:41:17 +0200 | [diff] [blame] | 43 | print(output) |
Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 44 | |
Pau Espin Pedrol | 0b30279 | 2017-09-10 16:33:10 +0200 | [diff] [blame] | 45 | print('- test with half empty scenario') |
| 46 | trial = log.Origin(log.C_TST, 'trial') |
| 47 | scenario = config.Scenario('foo', 'bar') |
Pau Espin Pedrol | cbc7242 | 2017-09-14 15:55:49 +0200 | [diff] [blame] | 48 | scenario['resources'] = { 'bts': [{'type': 'osmo-bts-trx'}] } |
Pau Espin Pedrol | 0b30279 | 2017-09-10 16:33:10 +0200 | [diff] [blame] | 49 | s = suite.SuiteRun(trial, 'test_suite', s_def, [scenario]) |
| 50 | results = s.run_tests('hello_world.py') |
| 51 | print(report.suite_to_text(s)) |
| 52 | |
| 53 | print('- test with scenario') |
| 54 | trial = log.Origin(log.C_TST, 'trial') |
| 55 | scenario = config.Scenario('foo', 'bar') |
| 56 | scenario['resources'] = { 'bts': [{ 'times': '2', 'type': 'osmo-bts-trx', 'trx_list': [{'nominal_power': '10'}, {'nominal_power': '12'}]}, {'type': 'sysmo'}] } |
| 57 | s = suite.SuiteRun(trial, 'test_suite', s_def, [scenario]) |
| 58 | results = s.run_tests('hello_world.py') |
| 59 | print(report.suite_to_text(s)) |
| 60 | |
Neels Hofmeyr | 3531a19 | 2017-03-28 14:30:28 +0200 | [diff] [blame] | 61 | print('\n- graceful exit.') |
| 62 | # vim: expandtab tabstop=4 shiftwidth=4 |