selftest: Move tests into own subdirectories

Change-Id: Id21cda19df131e24402e1a593036e1e33a914920
This commit is contained in:
Pau Espin 2020-05-06 18:35:26 +02:00
parent 636f560dc2
commit ab1904a307
53 changed files with 37 additions and 18 deletions

1
.gitignore vendored
View File

@ -8,7 +8,6 @@ set_pythonpath
test_work
state
*.pyc
selftest/trial_test/
sysmocom/resources.conf
sysmocom/ttcn3/resources.conf

View File

@ -1,7 +1,7 @@
import sys, os
script_dir = sys.path[0]
top_dir = os.path.join(script_dir, '..')
top_dir = os.path.join(script_dir, '..', '..')
src_dir = os.path.join(top_dir, 'src')
# to find the osmo_gsm_tester py module

View File

@ -72,14 +72,20 @@ def verify_output(got, expect_file, update=False):
script_dir = sys.path[0]
tests = []
for f in os.listdir(script_dir):
file_path = os.path.join(script_dir, f)
if not os.path.isfile(file_path):
for d in os.listdir(script_dir):
dir_path = os.path.join(script_dir, d)
if not os.path.isdir(dir_path):
continue
if not dir_path.endswith('_test'):
continue
for f in os.listdir(dir_path):
file_path = os.path.join(script_dir, d, f)
if not os.path.isfile(file_path):
continue
if not (file_path.endswith('_test.py') or file_path.endswith('_test.sh')):
continue
tests.append(file_path)
if not (file_path.endswith('_test.py') or file_path.endswith('_test.sh')):
continue
tests.append(file_path)
ran = []
errors = []

1
selftest/cdf_test/_prep.py Symbolic link
View File

@ -0,0 +1 @@
../_prep.py

View File

@ -0,0 +1 @@
../_prep.py

View File

@ -11,7 +11,7 @@ import copy
from osmo_gsm_tester.core import config, log, schema
example_config_file = 'test.cfg'
example_config = os.path.join(_prep.script_dir, 'config_test', example_config_file)
example_config = os.path.join(_prep.script_dir, example_config_file)
cfg = config.read(example_config)
pprint.pprint(cfg, width=81)

1
selftest/lock_test/_prep.py Symbolic link
View File

@ -0,0 +1 @@
../_prep.py

View File

@ -1,5 +1,7 @@
#!/bin/sh
owndir="$(dirname -- "$0")"
echo 'creating files'
dir="$(mktemp -d)"
n1="long name"
@ -11,7 +13,7 @@ touch "$f2"
sync
echo 'launch a program that locks a given file, it will create $dir/lock_test'
python3 ./lock_test_help.py "$dir" "$n1" &
python3 $owndir/lock_test_help.py "$dir" "$n1" &
echo 'wait until this lock_test lock file was created by program'
while [ ! -f "$dir/lock_test" ]; do
@ -23,7 +25,7 @@ echo 'expecting the lock file to reflect "long name"'
echo "launched first, locked by: '$(cat "$dir/lock_test")'"
echo 'launching second program, should find the lock intact and wait'
python3 ./lock_test_help.py "$dir" "$n2" &
python3 $owndir/lock_test_help.py "$dir" "$n2" &
while [ ! -f "$f2.ready" ]; do
sleep .1
done

1
selftest/log_test/_prep.py Symbolic link
View File

@ -0,0 +1 @@
../_prep.py

View File

@ -0,0 +1 @@
../_prep.py

View File

@ -0,0 +1 @@
../_prep.py

View File

@ -9,12 +9,12 @@ The requested resource requirements are not solvable [[0, 2], [2], [0, 2]]
ok, caused exception RuntimeError: Refusing to drop a list of resources from itself. This is probably a bug where a list of Resources() should have been copied but is passed as-is. use Resources.clear() instead.
- test removing a Resources list from one with the same list in it
- test resources config and state dir:
cnf -: DBG: Found config file paths.conf as [PATH]/selftest/conf/paths.conf in ./conf which is [PATH]/selftest/conf
cnf -: DBG: [PATH]/selftest/conf/paths.conf: relative path ./test_work/state_dir is [PATH]/selftest/conf/test_work/state_dir
cnf -: DBG: [PATH]/selftest/conf/paths.conf: relative path ./suite_test is [PATH]/selftest/conf/suite_test
cnf -: DBG: Found path state_dir as [PATH]/selftest/conf/test_work/state_dir
cnf ResourcesPool: DBG: Found config file resources.conf as [PATH]/selftest/conf/resources.conf in ./conf which is [PATH]/selftest/conf
cnf ResourcesPool: DBG: Found path state_dir as [PATH]/selftest/conf/test_work/state_dir
cnf -: DBG: Found config file paths.conf as [PATH]/selftest/resource_test/conf/paths.conf in [PATH]/selftest/resource_test/conf which is [PATH]/selftest/resource_test/conf
cnf -: DBG: [PATH]/selftest/resource_test/conf/paths.conf: relative path ./test_work/state_dir is [PATH]/selftest/resource_test/conf/test_work/state_dir
cnf -: DBG: [PATH]/selftest/resource_test/conf/paths.conf: relative path ./suite_test is [PATH]/selftest/resource_test/conf/suite_test
cnf -: DBG: Found path state_dir as [PATH]/selftest/resource_test/conf/test_work/state_dir
cnf ResourcesPool: DBG: Found config file resources.conf as [PATH]/selftest/resource_test/conf/resources.conf in [PATH]/selftest/resource_test/conf which is [PATH]/selftest/resource_test/conf
cnf ResourcesPool: DBG: Found path state_dir as [PATH]/selftest/resource_test/conf/test_work/state_dir
*** all resources:
{'arfcn': [{'_hash': 'e620569450f8259b3f0212ec19c285dd07df063c',
'arfcn': '512',

View File

@ -2,6 +2,7 @@
import tempfile
import os
import sys
import pprint
import shutil
import atexit
@ -12,7 +13,7 @@ from osmo_gsm_tester.core.schema import generate_schemas
workdir = util.get_tempdir()
# override config locations to make sure we use only the test conf
config.ENV_CONF = './conf'
config.ENV_CONF = os.path.join(os.path.dirname(sys.argv[0]), 'conf')
log.get_process_id = lambda: '123-1490837279'

1
selftest/sms_test/_prep.py Symbolic link
View File

@ -0,0 +1 @@
../_prep.py

View File

@ -0,0 +1 @@
../_prep.py

View File

@ -0,0 +1 @@
../_prep.py

View File

@ -0,0 +1 @@
../_prep.py

1
selftest/util_test/_prep.py Symbolic link
View File

@ -0,0 +1 @@
../_prep.py