Skip to content

Commit 09ed84a

Browse files
authored
Merge pull request #11 from sdgtt/kuiper_apps_test
Kuiper applications tests
2 parents 71f49c7 + ba08768 commit 09ed84a

File tree

8 files changed

+239
-0
lines changed

8 files changed

+239
-0
lines changed

test/gnuradio/conftest.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import pytest
2+
3+
def pytest_addoption(parser):
4+
parser.addoption(
5+
"--remote",
6+
action="store_true",
7+
help="Run test on network mode",
8+
)
9+
10+
parser.addoption(
11+
"--local",
12+
action="store_true",
13+
help="Run test on local mode",
14+
)
15+
16+
parser.addoption(
17+
"--ip",
18+
action="store",
19+
default="localhost",
20+
help="IP of DUT",
21+
)
22+
23+
parser.addoption(
24+
"--delay",
25+
action="store",
26+
type=int,
27+
default=10,
28+
help="adding delay",
29+
)
30+
31+
32+
def pytest_configure(config):
33+
# register marker
34+
config.addinivalue_line("markers", "remote: mark remote tests")
35+
config.addinivalue_line("markers", "local: mark local tests")
36+
37+
38+
def pytest_runtest_setup(item):
39+
remote = item.config.getoption("--remote")
40+
marks = [mark.name for mark in item.iter_markers()]
41+
if not remote and "remote" in marks:
42+
pytest.skip(
43+
"Testing requires network flag: --remote"
44+
)
45+
46+
local = item.config.getoption("--local")
47+
marks = [mark.name for mark in item.iter_markers()]
48+
if not local and "local" in marks:
49+
pytest.skip(
50+
"Testing requires local flag: --local"
51+
)
52+
53+
@pytest.fixture(scope="session")
54+
def ip(pytestconfig):
55+
return pytestconfig.getoption("ip")
56+
57+
58+
@pytest.fixture(scope="session")
59+
def delay(pytestconfig):
60+
return pytestconfig.getoption("delay")
52.8 KB
Loading
52.8 KB
Loading

test/gnuradio/test_adi_gnuradio.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import pytest
2+
import pyguit
3+
import time
4+
import os
5+
import shutil
6+
7+
8+
9+
class TestADIGnuradio:
10+
11+
@classmethod
12+
def setup_class(self):
13+
'''Setup the pyguit object. Will be called once before the start of test'''
14+
self.gui = pyguit.gui()
15+
self.gui.attach_openbox()
16+
# self.gui.run_ssh_agent()
17+
time.sleep(10)
18+
try:
19+
os.makedirs("results")
20+
except FileExistsError:
21+
# directory already exists
22+
shutil.rmtree('results')
23+
os.makedirs("results")
24+
25+
@classmethod
26+
def teardown_class(self):
27+
'''Garbage collector. Will be called once after running of tests'''
28+
time.sleep(10)
29+
self.gui.dettach_openbox()
30+
del self.gui
31+
32+
@pytest.mark.remote
33+
def test_open_app_on_remote(self, ip, delay):
34+
print("Test build: Started")
35+
'''Test if app opens, and checks main window'''
36+
print("Test build: Opening application")
37+
self.gui.open_app(
38+
host= ip,
39+
user="analog",
40+
app_name="gnuradio",
41+
path="/usr/bin/gnuradio-companion",
42+
)
43+
time.sleep(delay)
44+
print("Test build: Check application title")
45+
# Find main screen
46+
found_window = None
47+
for w in self.gui.get_open_windows():
48+
if w:
49+
print(self.gui.get_window_title(w))
50+
51+
# Attempt to find the window titles
52+
for w in self.gui.get_open_windows():
53+
if self.gui.get_window_title(w) == "untitled - GNU Radio Companion":
54+
found_window = self.gui.find_window("untitled - GNU Radio Companion")
55+
break
56+
elif self.gui.get_window_title(w) == "*untitled - GNU Radio Companion":
57+
found_window = self.gui.find_window("*untitled - GNU Radio Companion")
58+
break
59+
# Perform actions based on the found window
60+
if found_window:
61+
print(found_window)
62+
assert self.gui.controller.locateOnScreen("ref_test_open_app.png", grayscale=True, confidence=0.9)
63+
time.sleep(delay)
64+
# Take a screenshot of the main screen
65+
print("Test build: Taking screenshot for reference")
66+
self.gui.controller.screenshot("results/test_open_app.png")
67+
print("Screenshot matches the reference image.")
68+
print("Testing done.")
69+
else:
70+
print("Application is not found")
71+
72+
73+

test/iio-oscilloscope/conftest.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import pytest
2+
3+
def pytest_addoption(parser):
4+
parser.addoption(
5+
"--remote",
6+
action="store_true",
7+
help="Run test on network mode",
8+
)
9+
10+
parser.addoption(
11+
"--local",
12+
action="store_true",
13+
help="Run test on local mode",
14+
)
15+
16+
parser.addoption(
17+
"--ip",
18+
action="store",
19+
default="localhost",
20+
help="IP of DUT",
21+
)
22+
23+
parser.addoption(
24+
"--delay",
25+
action="store",
26+
type=int,
27+
default=10,
28+
help="adding delay",
29+
)
30+
31+
32+
def pytest_configure(config):
33+
# register marker
34+
config.addinivalue_line("markers", "remote: mark remote tests")
35+
config.addinivalue_line("markers", "local: mark local tests")
36+
37+
38+
def pytest_runtest_setup(item):
39+
remote = item.config.getoption("--remote")
40+
marks = [mark.name for mark in item.iter_markers()]
41+
if not remote and "remote" in marks:
42+
pytest.skip(
43+
"Testing requires network flag: --remote"
44+
)
45+
46+
local = item.config.getoption("--local")
47+
marks = [mark.name for mark in item.iter_markers()]
48+
if not local and "local" in marks:
49+
pytest.skip(
50+
"Testing requires local flag: --local"
51+
)
52+
53+
@pytest.fixture(scope="session")
54+
def ip(pytestconfig):
55+
return pytestconfig.getoption("ip")
56+
57+
58+
@pytest.fixture(scope="session")
59+
def delay(pytestconfig):
60+
return pytestconfig.getoption("delay")
44.5 KB
Loading
30.9 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import pytest
2+
import pyguit
3+
import time
4+
import os
5+
import shutil
6+
7+
class TestIIOOscilloscope:
8+
9+
@classmethod
10+
def setup_class(self):
11+
'''Setup the pyguit object. Will be called once before the start of test'''
12+
self.gui = pyguit.gui()
13+
self.gui.attach_openbox()
14+
# self.gui.run_ssh_agent()
15+
time.sleep(10)
16+
try:
17+
os.makedirs("results")
18+
except FileExistsError:
19+
# directory already exists
20+
shutil.rmtree('results')
21+
os.makedirs("results")
22+
23+
@classmethod
24+
def teardown_class(self):
25+
'''Garbage collector. Will be called once after running of tests'''
26+
time.sleep(10)
27+
self.gui.dettach_openbox()
28+
del self.gui
29+
30+
@pytest.mark.remote
31+
def test_open_app_on_remote(self, ip, delay):
32+
'''Test if app opens, and checks main window'''
33+
self.gui.open_app(
34+
host=ip,
35+
user="analog",
36+
app_name="osc",
37+
path="/usr/local/bin/osc",
38+
)
39+
time.sleep(delay)
40+
#find_active_screen
41+
for w in self.gui.get_open_windows():
42+
if w:
43+
print(self.gui.get_window_title(w))
44+
time.sleep(delay)
45+
self.gui.controller.screenshot("results/test_open_a_app.png")
46+

0 commit comments

Comments
 (0)