]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add a test framework for various wpa_supplicant failure cases
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 19 Jan 2015 17:34:00 +0000 (19:34 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 19 Jan 2015 17:34:00 +0000 (19:34 +0200)
For CONFIG_TESTING_OPTIONS=y builds, add a new test parameter than can
be used to trigger various error cases within wpa_supplicant operations
to make it easier to test error path processing. "SET test_failure
<val>" is used to set which operation fails. For now, 0 = no failures
and 1 = scan trigger fails with EBUSY. More operations can be added in
the future to extend coverage.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/driver_i.h
wpa_supplicant/wpa_supplicant_i.h

index 70680a1c0edd94d7b39210196ccf06a150debc3f..c55e646ec60af4c936d5c5fa9658a04f4359eb8d 100644 (file)
@@ -437,6 +437,8 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_AP */
        } else if (os_strcasecmp(cmd, "extra_roc_dur") == 0) {
                wpa_s->extra_roc_dur = atoi(value);
+       } else if (os_strcasecmp(cmd, "test_failure") == 0) {
+               wpa_s->test_failure = atoi(value);
 #endif /* CONFIG_TESTING_OPTIONS */
 #ifndef CONFIG_NO_CONFIG_BLOBS
        } else if (os_strcmp(cmd, "blob") == 0) {
@@ -6195,6 +6197,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        wpa_s->ext_eapol_frame_io = 0;
 #ifdef CONFIG_TESTING_OPTIONS
        wpa_s->extra_roc_dur = 0;
+       wpa_s->test_failure = WPAS_TEST_FAILURE_NONE;
 #endif /* CONFIG_TESTING_OPTIONS */
 
        wpa_s->disconnected = 0;
index 8dc48d389ec9472ddc956fb066f33b32bf410add..9debcf84936354f1c8e9c48a1b727873a1abc352 100644 (file)
@@ -90,6 +90,10 @@ static inline int wpa_drv_leave_mesh(struct wpa_supplicant *wpa_s)
 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s,
                               struct wpa_driver_scan_params *params)
 {
+#ifdef CONFIG_TESTING_OPTIONS
+       if (wpa_s->test_failure == WPAS_TEST_FAILURE_SCAN_TRIGGER)
+               return -EBUSY;
+#endif /* CONFIG_TESTING_OPTIONS */
        if (wpa_s->driver->scan2)
                return wpa_s->driver->scan2(wpa_s->drv_priv, params);
        return -1;
index 2cb55ccb54cb32519287f6feb43858ae1f2394e9..e363967c189aa004a7a44e8c0f9bdcae973b1d35 100644 (file)
@@ -403,6 +403,11 @@ struct rrm_data {
        u8 next_neighbor_rep_token;
 };
 
+enum wpa_supplicant_test_failure {
+       WPAS_TEST_FAILURE_NONE,
+       WPAS_TEST_FAILURE_SCAN_TRIGGER,
+};
+
 /**
  * struct wpa_supplicant - Internal data for wpa_supplicant interface
  *
@@ -940,6 +945,7 @@ struct wpa_supplicant {
 #ifdef CONFIG_TESTING_OPTIONS
        struct l2_packet_data *l2_test;
        unsigned int extra_roc_dur;
+       enum wpa_supplicant_test_failure test_failure;
 #endif /* CONFIG_TESTING_OPTIONS */
 
        struct wmm_ac_assoc_data *wmm_ac_assoc_info;