[PATCH 1/6] auto-t: fix testAgent use of Process
by James Prestwood
This test was accessing the subprocess object and calling terminate
which ends up causing issues with test-runners own process cleanup.
Instead kill() should be used.
---
autotests/testAgent/agent_test.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/autotests/testAgent/agent_test.py b/autotests/testAgent/agent_test.py
index 7d3b6119..e2d6e49e 100644
--- a/autotests/testAgent/agent_test.py
+++ b/autotests/testAgent/agent_test.py
@@ -58,14 +58,13 @@ class Test(unittest.TestCase):
def test_connection_with_other_agent(self):
wd = IWD()
- iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']).pid
+ iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2'])
# Let iwctl to start and register its agent.
wd.wait(2)
self.check_connection(wd, 'ssid2')
- iwctl.terminate()
- iwctl.communicate()
+ iwctl.kill()
IWD.clear_storage()
@@ -73,7 +72,7 @@ class Test(unittest.TestCase):
wd = IWD()
- iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']).pid
+ iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2'])
# Let iwctl to start and register its agent.
wd.wait(2)
@@ -84,8 +83,7 @@ class Test(unittest.TestCase):
wd.unregister_psk_agent(psk_agent)
- iwctl.terminate()
- iwctl.communicate()
+ iwctl.kill()
IWD.clear_storage()
--
2.31.1
9 months
[PATCH 1/2] auto-t: iwd.py: allow renaming in copy_to_storage
by James Prestwood
By providing a 'name' keyword argument the file copied will be
renamed to that.
---
autotests/util/iwd.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 36b8f6f9..737b2beb 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -1152,11 +1152,14 @@ class IWD(AsyncOpAbstract):
fo.close()
@staticmethod
- def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR):
+ def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR, name=None):
import shutil
assert not os.path.isabs(source)
+ if name:
+ storage_dir += '/%s' % name
+
shutil.copy(source, storage_dir)
@staticmethod
--
2.31.1
9 months
[PATCH v2 1/3] station: Add generic Event signal
by James Prestwood
This is meant to be used as a generic notification to autotests. For
now 'no-roam-candidates' is the only event being sent. The idea
is to extend these events to signal conditions that are otherwise
undiscoverable in autotesting.
---
src/station.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/station.c b/src/station.c
index 408ae887..d3482e2c 100644
--- a/src/station.c
+++ b/src/station.c
@@ -153,6 +153,24 @@ static bool station_is_autoconnecting(struct station *station)
station->state == STATION_STATE_AUTOCONNECT_QUICK;
}
+static bool station_debug_event(struct station *station, const char *name)
+{
+ struct l_dbus_message *signal;
+
+ if (!iwd_is_developer_mode())
+ return true;
+
+ l_debug("StationDebug.Event(%s)", name);
+
+ signal = l_dbus_message_new_signal(dbus_get_bus(),
+ netdev_get_path(station->netdev),
+ IWD_STATION_DEBUG_INTERFACE, "Event");
+
+ l_dbus_message_set_arguments(signal, "sav", name, 0);
+
+ return l_dbus_send(dbus_get_bus(), signal) != 0;
+}
+
static void station_property_set_scanning(struct station *station,
bool scanning)
{
@@ -1938,8 +1956,10 @@ next:
goto fail_free_bss;
/* See if we have anywhere to roam to */
- if (!best_bss || scan_bss_addr_eq(best_bss, station->connected_bss))
+ if (!best_bss || scan_bss_addr_eq(best_bss, station->connected_bss)) {
+ station_debug_event(station, "no-roam-candidates");
goto fail_free_bss;
+ }
bss = network_bss_find_by_addr(network, best_bss->addr);
if (bss) {
@@ -3991,6 +4011,8 @@ static void station_setup_debug_interface(
station_debug_scan, "", "aq",
"frequencies");
+ l_dbus_interface_signal(interface, "Event", 0, "sav", "name", "data");
+
l_dbus_interface_property(interface, "AutoConnect", 0, "b",
station_property_get_autoconnect,
station_property_set_autoconnect);
--
2.31.1
9 months
[PATCH 1/6] test-runner: implement non_block_wait
by James Prestwood
There was a common bit of code all over test-runner and utilities
which would wait for 'something' in a loop. At best these loops
would do the right thing and use the GLib.iteration call as to not
block the main loop, and at worst would not use it and just busy
wait.
Namespace.non_block_wait unifies all these into a single API to
a) do the wait correctly and b) prevent duplicate code.
---
tools/test-runner | 80 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 65 insertions(+), 15 deletions(-)
diff --git a/tools/test-runner b/tools/test-runner
index 87f6ec6d..22e9066f 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -233,7 +233,7 @@ class Process:
if not wait and not check:
return
- self.pid.wait(timeout=5)
+ Namespace.non_block_wait(self.wait_for_process, 10, 1)
self.killed = True
self.ret = self.pid.returncode
@@ -245,6 +245,13 @@ class Process:
if check and self.ret != 0:
raise subprocess.CalledProcessError(returncode=self.ret, cmd=self.args)
+ def wait_for_process(self, timeout):
+ try:
+ self.pid.wait(timeout)
+ return True
+ except:
+ return False
+
def process_io(self, source):
data = source.read()
@@ -312,12 +319,7 @@ class Process:
self.killed = True
def wait_for_socket(self, socket, wait):
- waited = 0
- while not os.path.exists(socket):
- sleep(0.5)
- waited += 0.5
- if waited > wait:
- raise Exception("Timed out waiting for socket")
+ Namespace.non_block_wait(os.path.exists, wait, socket)
def __str__(self):
return str(self.args) + '\n'
@@ -641,7 +643,7 @@ class Namespace:
p = self.start_process(['dbus-daemon', '--config-file=%s' % self.dbus_cfg],
wait=False, cleanup=self._cleanup_dbus)
- p.wait_for_socket(self.dbus_address.split('=')[1], wait=5)
+ p.wait_for_socket(self.dbus_address.split('=')[1], 5)
self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
@@ -699,15 +701,62 @@ class Namespace:
return False
- def wait_for_dbus_service(self, service):
- tries = 0
+ @staticmethod
+ def non_block_wait(func, timeout, *args, exception=True):
+ '''
+ Convenience function for waiting in a non blocking
+ manor using GLibs context iteration i.e. does not block
+ the main loop while waiting.
+
+ 'func' will be called at least once and repeatedly until
+ either it returns success, throws an exception, or the
+ 'timeout' expires.
+
+ 'timeout' is the ultimate timeout in seconds
+
+ '*args' will be passed to 'func'
+
+ If 'exception' is an Exception type it will be raised.
+ If 'exception' is True a generic TimeoutError will be raised.
+ Any other value will not result in an exception.
+ '''
+ # Simple class for signaling the wait timeout
+ class Bool:
+ def __init__(self, value):
+ self.value = value
+
+ def wait_timeout_cb(done):
+ done.value = True
+ return False
+
+ mainloop = GLib.MainLoop()
+ done = Bool(False)
+
+ timeout = GLib.timeout_add_seconds(timeout, wait_timeout_cb, done)
+ context = mainloop.get_context()
+
+ while True:
+ context.iteration(may_block=False)
+
+ try:
+ ret = func(*args)
+ if ret:
+ GLib.source_remove(timeout)
+ return ret
+ except Exception as e:
+ GLib.source_remove(timeout)
+ raise e
- while not self._bus.name_has_owner(service):
- if tries > 200:
- raise TimeoutError('DBus service %s did not appear', service)
- tries += 1
sleep(0.1)
+ if done.value == True:
+ if isinstance(exception, Exception):
+ raise exception
+ elif type(exception) == bool and exception:
+ raise TimeoutError("Timeout on non_block_wait")
+ else:
+ return
+
def __str__(self):
ret = 'Namespace: %s\n' % self.name
ret += 'Processes:\n'
@@ -765,7 +814,8 @@ class TestContext(Namespace):
args.extend(['--no-register'])
self.start_process(args)
- self.wait_for_dbus_service('net.connman.hwsim')
+ self.non_block_wait(self._bus.name_has_owner, 20, 'net.connman.hwsim',
+ exception=TimeoutError('net.connman.hwsim did not appear'))
for i in range(nradios):
name = 'rad%u' % i
--
2.31.1
9 months
[PATCH 1/3] station: Add RoamScanning property to debug interface
by James Prestwood
This lets the test environment know if IWD is attempting a roam
prior to the roaming state being set.
---
src/station.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/station.c b/src/station.c
index 408ae887..a1885cfa 100644
--- a/src/station.c
+++ b/src/station.c
@@ -114,6 +114,7 @@ struct station {
bool ap_directed_roaming : 1;
bool scanning : 1;
bool autoconnect : 1;
+ bool roam_scanning : 1;
};
struct anqp_entry {
@@ -1842,8 +1843,15 @@ static void station_roam_scan_triggered(int err, void *user_data)
/*
* Do not update the Scanning property as we won't be updating the
- * list of networks.
+ * list of networks. But if in developer mode update the RoamScanning
+ * property for autotesting.
*/
+ station->roam_scanning = true;
+
+ if (iwd_is_developer_mode())
+ l_dbus_property_changed(dbus_get_bus(),
+ netdev_get_path(station->netdev),
+ IWD_STATION_DEBUG_INTERFACE, "RoamScanning");
}
static bool station_roam_scan_notify(int err, struct l_queue *bss_list,
@@ -1968,6 +1976,12 @@ static void station_roam_scan_destroy(void *userdata)
struct station *station = userdata;
station->roam_scan_id = 0;
+ station->roam_scanning = false;
+
+ if (iwd_is_developer_mode())
+ l_dbus_property_changed(dbus_get_bus(),
+ netdev_get_path(station->netdev),
+ IWD_STATION_DEBUG_INTERFACE, "RoamScanning");
}
static int station_roam_scan(struct station *station,
@@ -3978,6 +3992,22 @@ static struct l_dbus_message *station_property_set_autoconnect(
return l_dbus_message_new_method_return(message);
}
+static bool station_property_get_roam_scanning(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ struct l_dbus_message_builder *builder,
+ void *user_data)
+{
+ struct station *station = user_data;
+ bool scanning;
+
+ scanning = station->roam_scanning;
+
+ l_dbus_message_builder_append_basic(builder, 'b', &scanning);
+
+ return true;
+}
+
+
static void station_setup_debug_interface(
struct l_dbus_interface *interface)
{
@@ -3994,6 +4024,9 @@ static void station_setup_debug_interface(
l_dbus_interface_property(interface, "AutoConnect", 0, "b",
station_property_get_autoconnect,
station_property_set_autoconnect);
+ l_dbus_interface_property(interface, "RoamScanning", 0, "b",
+ station_property_get_roam_scanning,
+ NULL);
}
static void ap_roam_frame_event(const struct mmpdu_header *hdr,
--
2.31.1
9 months
[PATCH 1/6] station: implement Scan on debug interface
by James Prestwood
This is to support the autotesting framework by allowing a smaller
scan subset. This will cut down on the amount of time spent scanning
via normal DBus scans (where the entire spectrum is scanned).
---
src/station.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
diff --git a/src/station.c b/src/station.c
index 2155aa3c..5d447356 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3839,6 +3839,109 @@ invalid_args:
return dbus_error_invalid_args(message);
}
+static void station_debug_scan_triggered(int err, void *user_data)
+{
+ struct station *station = user_data;
+ struct l_dbus_message *reply;
+
+ if (err < 0) {
+ if (station->scan_pending) {
+ reply = dbus_error_from_errno(err,
+ station->scan_pending);
+ dbus_pending_reply(&station->scan_pending, reply);
+ }
+
+ station_dbus_scan_done(station);
+ return;
+ }
+
+ l_debug("debug scan triggered for %s",
+ netdev_get_name(station->netdev));
+
+ if (station->scan_pending) {
+ reply = l_dbus_message_new_method_return(station->scan_pending);
+ l_dbus_message_set_arguments(reply, "");
+ dbus_pending_reply(&station->scan_pending, reply);
+ }
+
+ station_property_set_scanning(station, true);
+}
+
+static bool station_debug_scan_results(int err, struct l_queue *bss_list,
+ const struct scan_freq_set *freqs,
+ void *userdata)
+{
+ struct station *station = userdata;
+ bool autoconnect;
+
+ if (err) {
+ station_dbus_scan_done(station);
+ return false;
+ }
+
+ autoconnect = station_is_autoconnecting(station);
+ station_set_scan_results(station, bss_list, freqs, autoconnect);
+
+ station_dbus_scan_done(station);
+
+ return true;
+}
+
+static struct l_dbus_message *station_debug_scan(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ void *user_data)
+{
+ struct station *station = user_data;
+ struct l_dbus_message_iter iter;
+ uint16_t *freqs;
+ uint32_t freqs_len;
+ struct scan_freq_set *freq_set;
+ unsigned int i;
+
+ if (station->dbus_scan_id)
+ return dbus_error_busy(message);
+
+ if (station->state == STATION_STATE_CONNECTING ||
+ station->state == STATION_STATE_CONNECTING_AUTO)
+ return dbus_error_busy(message);
+
+ if (!l_dbus_message_get_arguments(message, "aq", &iter))
+ goto invalid_args;
+
+ if (!l_dbus_message_iter_get_fixed_array(&iter, &freqs, &freqs_len))
+ goto invalid_args;
+
+ freq_set = scan_freq_set_new();
+
+ for (i = 0; i < freqs_len; i++) {
+ if (!scan_freq_set_add(freq_set, (uint32_t)freqs[i])) {
+ scan_freq_set_free(freq_set);
+ goto invalid_args;
+ }
+
+ l_debug("added frequency %u", freqs[i]);
+ }
+
+ station->dbus_scan_id = station_scan_trigger(station, freq_set,
+ station_debug_scan_triggered,
+ station_debug_scan_results,
+ NULL);
+
+ scan_freq_set_free(freq_set);
+
+ if (!station->dbus_scan_id)
+ goto failed;
+
+ station->scan_pending = l_dbus_message_ref(message);
+
+ return NULL;
+
+failed:
+ return dbus_error_failed(message);
+invalid_args:
+ return dbus_error_invalid_args(message);
+}
+
static bool station_property_get_autoconnect(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message_builder *builder,
@@ -3883,6 +3986,10 @@ static void station_setup_debug_interface(
l_dbus_interface_method(interface, "Roam", 0,
station_force_roam, "", "ay", "mac");
+ l_dbus_interface_method(interface, "Scan", 0,
+ station_debug_scan, "", "aq",
+ "frequencies");
+
l_dbus_interface_property(interface, "AutoConnect", 0, "b",
station_property_get_autoconnect,
station_property_set_autoconnect);
--
2.31.1
9 months
[PATCH 1/3] test-runner: print uncaught test exceptions always
by James Prestwood
---
tools/test-runner | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/test-runner b/tools/test-runner
index 1d148b13..f18ae538 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -1259,8 +1259,8 @@ def run_auto_tests(ctx, args):
ctx.results[os.path.basename(test)] = rqueue.get()
except Exception as ex:
- print(ex)
- print("Uncaught exception thrown for %s" % test)
+ dbg(ex)
+ dbg("Uncaught exception thrown for %s" % test)
ctx.results[os.path.basename(test)] = SimpleResult(run=0, failures=0,
errors=0, skipped=0, time=0)
finally:
--
2.31.1
9 months
[PATCH] station: set autoconnect via setter
by James Prestwood
This updates the autoconnect property for the debug interface
---
src/station.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/station.c b/src/station.c
index b2e12e9a..a1885cfa 100644
--- a/src/station.c
+++ b/src/station.c
@@ -2695,7 +2695,8 @@ void station_connect_network(struct station *station, struct network *network,
station_enter_state(station, STATION_STATE_CONNECTING);
station->connect_pending = l_dbus_message_ref(message);
- station->autoconnect = true;
+
+ station_set_autoconnect(station, true);
return;
--
2.31.1
9 months
Build your dream house and find a job Avakin Life MOD APK
by Avakin Life Mod Apk
https://techtodown.com/avakin-life-mod-apk/ - Of course in any world you need to work if you want money. However, unlike the real world, Avakin Life allows you to choose any job you love with no experience, college degree or any other requirements. A waiter at a cafe? A restaurant manager or a taxi driver? Choose a job you love, work hard and earn the most money possible.
Not only character decoration, you can design and build a house of your dreams. Arbitrarily move furniture and decorations to create space inside the house. This also helps you get a lot of experience points to help with the leveling process.
9 months
[PATCH 1/7] station: make autoconnect settable via debug interface
by James Prestwood
This adds the property "AutoConnect" to the station debug interface
which can be read/written to disable or enable autoconnect globally.
As one would expect this property is only going to be used for testing
hence why it was put on the debug interface. Mosts tests disable
autoconnect (or they should) because it leads to unexpected connections.
---
src/station.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/src/station.c b/src/station.c
index f77fd663..f9b2b16d 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1211,6 +1211,11 @@ bool station_set_autoconnect(struct station *station, bool autoconnect)
if (station_is_autoconnecting(station) && !autoconnect)
station_enter_state(station, STATION_STATE_DISCONNECTED);
+ if (iwd_is_developer_mode())
+ l_dbus_property_changed(dbus_get_bus(),
+ netdev_get_path(station->netdev),
+ IWD_STATION_DEBUG_INTERFACE, "AutoConnect");
+
return true;
}
@@ -3831,6 +3836,41 @@ invalid_args:
return dbus_error_invalid_args(message);
}
+static bool station_property_get_autoconnect(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ struct l_dbus_message_builder *builder,
+ void *user_data)
+{
+ struct station *station = user_data;
+ bool autoconnect;
+
+ autoconnect = station->autoconnect;
+
+ l_dbus_message_builder_append_basic(builder, 'b', &autoconnect);
+
+ return true;
+}
+
+static struct l_dbus_message *station_property_set_autoconnect(
+ struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ struct l_dbus_message_iter *new_value,
+ l_dbus_property_complete_cb_t complete,
+ void *user_data)
+{
+ struct station *station = user_data;
+ bool autoconnect;
+
+ if (!l_dbus_message_iter_get_variant(new_value, "b", &autoconnect))
+ return dbus_error_invalid_args(message);
+
+ l_debug("Setting autoconnect %s", autoconnect ? "true" : "false");
+
+ station_set_autoconnect(station, autoconnect);
+
+ return l_dbus_message_new_method_return(message);
+}
+
static void station_setup_debug_interface(
struct l_dbus_interface *interface)
{
@@ -3839,6 +3879,10 @@ static void station_setup_debug_interface(
"mac");
l_dbus_interface_method(interface, "Roam", 0,
station_force_roam, "", "ay", "mac");
+
+ l_dbus_interface_property(interface, "AutoConnect", 0, "b",
+ station_property_get_autoconnect,
+ station_property_set_autoconnect);
}
static void ap_roam_frame_event(const struct mmpdu_header *hdr,
--
2.31.1
9 months, 1 week