wfa_dut: Return success from sta_disconnect if no network connected
BUG=b:167983959
TEST:python simple_console.py sta_disconnect,interface,wlan0
Change-Id: Ib3f4c04567dd41a4e464b90efd7590ce17b076bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/Wi-FiTestSuite-Linux-DUT/+/2475215
Tested-by: Wojciech Jakobczyk <jakobczyk@google.com>
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
diff --git a/lib/wfa_cs.c b/lib/wfa_cs.c
index a329821..191fee9 100644
--- a/lib/wfa_cs.c
+++ b/lib/wfa_cs.c
@@ -2720,26 +2720,26 @@
}
fclose(tmpfd);
- if (networkId == -1) {
- RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR, "no network connected\n");
- }
+ if (networkId != -1) {
+ sprintf(gCmdStr, "wpa_cli.sh -i %s disable_network %d > %s", ifname,
+ networkId, tmpfile);
+ sret = systemWithLog(gCmdStr);
+ if (sret != 0) {
+ RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR,
+ "error disabling network: %d\n", sret);
+ }
- sprintf(gCmdStr, "wpa_cli.sh -i %s disable_network %d > %s", ifname,
- networkId, tmpfile);
- sret = systemWithLog(gCmdStr);
- if (sret != 0) {
- RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR,
- "error disabling network: %d\n", sret);
- }
+ if (!readLine(tmpfile, string, sizeof(string))) {
+ RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR,
+ "unable to read command output\n");
+ }
- if (!readLine(tmpfile, string, sizeof(string))) {
- RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR,
- "unable to read command output\n");
- }
-
- if (strcmp(string, "OK") != 0) {
- RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR,
- "disable network failed, error: %s\n", string);
+ if (strcmp(string, "OK") != 0) {
+ RETURN_STA_CMD_ERROR(staDiscResp, STATUS_ERROR,
+ "disable network failed, error: %s\n", string);
+ }
+ } else {
+ DPRINT_INFO(WFA_OUT, "No network connected\n");
}
staDiscResp->status = STATUS_COMPLETE;