mbox series

[00/50] Use python3 compatible codes for hwsim tests

Message ID 20190124074630.4192-1-masashi.honma@gmail.com
Headers show
Series Use python3 compatible codes for hwsim tests | expand

Message

Masashi Honma Jan. 24, 2019, 7:45 a.m. UTC
[summary]
This patch set modifies hwsim test to support python3 because python2 is
deprecated from 2020. After applying this patch set, user can run hwsim
test both python2 and python3. We can run with python3 by modifying
run-tests.py.

#!/usr/bin/env python2
|
v
#!/usr/bin/env python3

[testing environment]
I have tested all the test cases with vm-run.sh. The vm-run.sh test is using
this wireless-testing kernel.
commit 24e1d9cd149ef4daed8d1fb457704cd03172d777 'Add localversion to
identify builds from this tree'.

hostap
	commit 3cd0adea2607c540c0603ef7c907d210da007ca1 'tests:
	wpa_supplicant config parsing and storing for new variables'

host OS
	Ubuntu 18.04 x64

python version
	Python 2.7.15rc1
	Python 3.6.7

[failing tests]
Some test cases fails. This is not because of python3, it fails with python2
also. This is the list of the test cases.

ap_acs(5)
ap_acs_5ghz ap_acs_5ghz_40mhz ap_acs_vht ap_acs_vht40 ap_acs_vht160

ap_params(2)
ap_country ap_spectrum_management_required

ap_vht(11)
ap_vht160 ap_vht160b ap_vht160_no_dfs ap_vht160_no_dfs_108_plus
ap_vht160_no_dfs_100_plus ap_vht160_no_dfs_112_minus ap_vht160_no_dfs_116_plus
ap_vht160_no_dfs_120_minus ap_vht160_no_dfs_124_plus ap_vht160_no_dfs_128_minus
ap_vht80_pwr_constraint

dbus(1)
dbus_mesh

rrm(2)
rrm_beacon_req_passive_scan_vht rrm_beacon_req_passive_scan_vht160

wmediumd(1)
wmediumd_path_ttl

wnm(9)
wnm_bss_tm wnm_bss_tm_scan_not_needed wnm_bss_tm_nei_vht wnm_bss_tm_nei_11a
wnm_bss_tm_nei_11b wnm_bss_tm_scan_needed wnm_bss_tm_scan_needed_e4
wnm_bss_tm_reject wnm_bss_tm_rsn

wpas_mesh(2)
wpas_mesh_peer_disconnected wpas_mesh_max_peering

[other modifications]
Basically, this patch set is for hwsim test. Though, there are several python
scripts other than hwsim test. This patch set modifies such a python scripts
also. Just only modified "except", "print" statements. These are not
re-tested because of trivial modifications. This is the list.
	hostapd/wps-ap-nfc.py
	wpa_supplicant/eapol_test.py
	wpa_supplicant/examples/*.py
	wpa_supplicant/utils/log2pcap.py

Masashi Honma (50):
  tests: Use python3 compatible "except" statement
  tests: Use python3 compatible print statement
  tests: Use python3 compatible dict operation
  tests: Use python3 compatible range operation
  tests: Use python3 compatible function attribute
  tests: Use python3 compatible raise statement
  tests: Use int instead of long for python3 compatibility
  tests: Remove deprecated statement for python3 compatibility
  tests: Python3 does not allow mixed indentation
  tests: python3 require escaping
  tests: Use python3 compatible liblaries
  tests: Decode subprocess.check_output return value for python3
  tests: Modify core functions for python3
  tests: ap_eap test requires more memory
  tests: Modify ap_eap test sets for python3
  tests: Modify ap_ft test sets for python3
  tests: Modify ap_hs20 test sets for python3
  tests: Modify ap_psk test sets for python3
  tests: Modify ap_wps test sets for python3
  tests: Modify cfg80211 test sets for python3
  tests: Modify dbus test sets for python3
  tests: Modify dbus_old test sets for python3
  tests: Modify dpp test sets for python3
  tests: Modify eap_proto test sets for python3
  tests: Modify erp test sets for python3
  tests: Modify fils test sets for python3
  tests: Modify fst_config test sets for python3
  tests: Modify gas test sets for python3
  tests: Modify hs20_filter test sets for python3
  tests: Modify ieee8021x test sets for python3
  tests: Modify kernel test sets for python3
  tests: Modify macsec test sets for python3
  tests: Modify mbo test sets for python3
  tests: Modify nfc_wps test sets for python3
  tests: Modify ocv test sets for python3
  tests: Modify p2p_channel test sets for python3
  tests: Modify p2p_grpform test sets for python3
  tests: Modify p2p_messages test sets for python3
  tests: Modify pmksa_cache test sets for python3
  tests: Modify radius test sets for python3
  tests: Modify rrm test sets for python3
  tests: Modify sae test sets for python3
  tests: Add WPA-EAP-SUITE-B-192 support
  tests: Modify sigma_dut test sets for python3
  tests: Modify ssid test sets for python3
  tests: Modify wmediumd test sets for python3
  tests: Modify wnm test sets for python3
  tests: Modify wpas_ctrl test sets for python3
  tests: Modify wpas_mesh test sets for python3
  tests: Modify wpas_wmm_ac test sets for python3

 hostapd/wps-ap-nfc.py                         |  62 +-
 tests/hwsim/example-hostapd.config            |   1 +
 tests/hwsim/example-wpa_supplicant.config     |   1 +
 tests/hwsim/fst_module_aux.py                 |   4 +-
 tests/hwsim/fst_test_common.py                |   2 +-
 tests/hwsim/hostapd.py                        |  11 +-
 tests/hwsim/hwsim.py                          |  10 +-
 tests/hwsim/hwsim_utils.py                    |   8 +-
 tests/hwsim/netlink.py                        |  11 +-
 tests/hwsim/nl80211.py                        |   4 +-
 tests/hwsim/p2p_utils.py                      |  13 +-
 tests/hwsim/remotehost.py                     |   6 +-
 tests/hwsim/rfkill.py                         |  24 +-
 tests/hwsim/run-tests.py                      |  96 +--
 tests/hwsim/test_ap_ciphers.py                |   4 +-
 tests/hwsim/test_ap_dynamic.py                |   4 +-
 tests/hwsim/test_ap_eap.py                    |  77 +-
 tests/hwsim/test_ap_ft.py                     | 134 ++--
 tests/hwsim/test_ap_hs20.py                   | 197 +++---
 tests/hwsim/test_ap_open.py                   |   2 +-
 tests/hwsim/test_ap_params.py                 |   2 +-
 tests/hwsim/test_ap_pmf.py                    |   6 +-
 tests/hwsim/test_ap_psk.py                    |  46 +-
 tests/hwsim/test_ap_tdls.py                   |   6 +-
 tests/hwsim/test_ap_vht.py                    |  32 +-
 tests/hwsim/test_ap_vlan.py                   |   2 +-
 tests/hwsim/test_ap_wps.py                    | 658 ++++++++++--------
 tests/hwsim/test_cfg80211.py                  |   4 +-
 tests/hwsim/test_dbus.py                      | 611 ++++++++--------
 tests/hwsim/test_dbus_old.py                  |  75 +-
 tests/hwsim/test_dpp.py                       |  71 +-
 tests/hwsim/test_eap_proto.py                 |  20 +-
 tests/hwsim/test_erp.py                       |   6 +-
 tests/hwsim/test_fils.py                      | 140 ++--
 tests/hwsim/test_fst_config.py                |   4 +-
 tests/hwsim/test_fst_module.py                |  46 +-
 tests/hwsim/test_gas.py                       |  52 +-
 tests/hwsim/test_hostapd_oom.py               |   4 +-
 tests/hwsim/test_hs20_filter.py               |  10 +-
 tests/hwsim/test_hs20_pps_mo.py               |   2 +-
 tests/hwsim/test_ibss.py                      |   8 +-
 tests/hwsim/test_ieee8021x.py                 |   2 +-
 tests/hwsim/test_kernel.py                    |   4 +-
 tests/hwsim/test_macsec.py                    |  20 +-
 tests/hwsim/test_mbo.py                       |  16 +-
 tests/hwsim/test_nfc_wps.py                   |   5 +-
 tests/hwsim/test_ocv.py                       |  14 +-
 tests/hwsim/test_p2p_channel.py               |   2 +-
 tests/hwsim/test_p2p_grpform.py               |   5 +-
 tests/hwsim/test_p2p_messages.py              |  97 ++-
 tests/hwsim/test_p2p_wifi_display.py          |   5 +-
 tests/hwsim/test_pmksa_cache.py               |  14 +-
 tests/hwsim/test_radius.py                    |   4 +-
 tests/hwsim/test_rfkill.py                    |   2 +-
 tests/hwsim/test_rrm.py                       |  20 +-
 tests/hwsim/test_sae.py                       |  12 +-
 tests/hwsim/test_scan.py                      |  14 +-
 tests/hwsim/test_sigma_dut.py                 |   2 +-
 tests/hwsim/test_ssid.py                      |   4 +-
 tests/hwsim/test_wext.py                      |   2 +-
 tests/hwsim/test_wmediumd.py                  |  16 +-
 tests/hwsim/test_wnm.py                       |  20 +-
 tests/hwsim/test_wpas_ctrl.py                 |  25 +-
 tests/hwsim/test_wpas_mesh.py                 |  53 +-
 tests/hwsim/test_wpas_wmm_ac.py               |  22 +-
 tests/hwsim/tshark.py                         |  18 +-
 tests/hwsim/vm/parallel-vm.py                 |  38 +-
 tests/hwsim/vm/vm-run.sh                      |   2 +-
 tests/hwsim/wlantest.py                       |   4 +-
 tests/hwsim/wpasupplicant.py                  |  19 +-
 tests/remote/hwsim_wrapper.py                 |   4 +-
 tests/remote/run-tests.py                     |  38 +-
 tests/remote/test_devices.py                  |  30 +-
 wpa_supplicant/eapol_test.py                  |   2 +-
 wpa_supplicant/examples/dbus-listen-preq.py   |  16 +-
 wpa_supplicant/examples/dpp-qrcode.py         |  36 +-
 wpa_supplicant/examples/p2p-nfc.py            | 168 ++---
 wpa_supplicant/examples/p2p/p2p_connect.py    |  70 +-
 wpa_supplicant/examples/p2p/p2p_disconnect.py |  30 +-
 wpa_supplicant/examples/p2p/p2p_find.py       |  34 +-
 wpa_supplicant/examples/p2p/p2p_flush.py      |  30 +-
 wpa_supplicant/examples/p2p/p2p_group_add.py  |  50 +-
 wpa_supplicant/examples/p2p/p2p_invite.py     |  44 +-
 wpa_supplicant/examples/p2p/p2p_listen.py     |  32 +-
 wpa_supplicant/examples/p2p/p2p_stop_find.py  |  32 +-
 .../examples/wpas-dbus-new-getall.py          |  28 +-
 .../examples/wpas-dbus-new-signals.py         |  34 +-
 wpa_supplicant/examples/wpas-dbus-new-wps.py  |  16 +-
 wpa_supplicant/examples/wpas-dbus-new.py      |  20 +-
 wpa_supplicant/examples/wpas-test.py          |  10 +-
 wpa_supplicant/examples/wps-nfc.py            | 124 ++--
 wpa_supplicant/utils/log2pcap.py              |   2 +-
 wpaspy/test.py                                |  28 +-
 wpaspy/wpaspy.py                              |  15 +-
 94 files changed, 2010 insertions(+), 1820 deletions(-)

Comments

Masashi Honma Jan. 25, 2019, 1:11 p.m. UTC | #1
Thank you Johanness !

I will reply to each of your comments.

Now I recognize parallel-vm.py does not work both python2 and 3.
This is my missing of test. I only tested by using vm-run.sh.

I will drop the modification of parallel-vm.py.
There is no influence to other patches.

And now I am trying to fix the parallel-vm.py for python3.
Though there is a problem. parallel-vm.py could not get results from
VMs when python3. The results are like "START", "PASS", "SKIP".
vm_read_stdout() could not get these strings.
Fixing this may take a while.

Masashi Honma.
Johannes Berg Jan. 25, 2019, 1:14 p.m. UTC | #2
Hi,

> Now I recognize parallel-vm.py does not work both python2 and 3.

FWIW, I'm not sure I see a need to keep this python2 compatible. This is
a development thing, and there we should not have a problem to just
require python3.

I see that it's not *that* much more work to keep it working on python2,
however, if the default remains python2 then people are only going to
break python3 support in the future again.

And trying to keep it working on python2 will have exactly the same
problem - if python3 is the default then python2 will be broken quickly
... so I'd say we should just switch, but Jouni should decide I guess :)

> And now I am trying to fix the parallel-vm.py for python3.
> Though there is a problem. parallel-vm.py could not get results from
> VMs when python3. The results are like "START", "PASS", "SKIP".
> vm_read_stdout() could not get these strings.
> Fixing this may take a while.

That's odd. Good luck, and thank you very much for all this work!

johannes
Jouni Malinen Jan. 25, 2019, 5:54 p.m. UTC | #3
On Fri, Jan 25, 2019 at 02:14:52PM +0100, Johannes Berg wrote:
> > Now I recognize parallel-vm.py does not work both python2 and 3.
> 
> FWIW, I'm not sure I see a need to keep this python2 compatible. This is
> a development thing, and there we should not have a problem to just
> require python3.
> 
> I see that it's not *that* much more work to keep it working on python2,
> however, if the default remains python2 then people are only going to
> break python3 support in the future again.
> 
> And trying to keep it working on python2 will have exactly the same
> problem - if python3 is the default then python2 will be broken quickly
> ... so I'd say we should just switch, but Jouni should decide I guess :)

Agreed. If it makes this any easier to manage, I would have no problems
with moving all this from python2 to python3 (only) if everything
continues to work after these changes. While I do not really like the
way python language is updated without backwards compatibility, I
obviously have python3 installed and can learn the new language
requirements once needed ;-). The key requirement here really is that
the test setup should be easy to use for anyone and if distros start
strongly preferring python3 and potentially dropping python2 altogether,
it is clear that things need to change here.
Masashi Honma Jan. 26, 2019, 12:11 a.m. UTC | #4
On 2019/01/26 2:54, Jouni Malinen wrote:
> On Fri, Jan 25, 2019 at 02:14:52PM +0100, Johannes Berg wrote:
>>> Now I recognize parallel-vm.py does not work both python2 and 3.
>>
>> FWIW, I'm not sure I see a need to keep this python2 compatible. This is
>> a development thing, and there we should not have a problem to just
>> require python3.
>>
>> I see that it's not *that* much more work to keep it working on python2,
>> however, if the default remains python2 then people are only going to
>> break python3 support in the future again.
>>
>> And trying to keep it working on python2 will have exactly the same
>> problem - if python3 is the default then python2 will be broken quickly
>> ... so I'd say we should just switch, but Jouni should decide I guess :)
> 
> Agreed. If it makes this any easier to manage, I would have no problems
> with moving all this from python2 to python3 (only) if everything
> continues to work after these changes. While I do not really like the
> way python language is updated without backwards compatibility, I
> obviously have python3 installed and can learn the new language
> requirements once needed ;-). The key requirement here really is that
> the test setup should be easy to use for anyone and if distros start
> strongly preferring python3 and potentially dropping python2 altogether,
> it is clear that things need to change here.

Thank you Johannes and Jouni !

Ok, from now on I will only test with python3.

Masashi Honma.
Jouni Malinen Jan. 26, 2019, 11:26 a.m. UTC | #5
On Sat, Jan 26, 2019 at 09:11:43AM +0900, Masashi Honma wrote:
> On 2019/01/26 2:54, Jouni Malinen wrote:
> >Agreed. If it makes this any easier to manage, I would have no problems
> >with moving all this from python2 to python3 (only) if everything
> >continues to work after these changes.

> Ok, from now on I will only test with python3.

Just to be clear on what I meant there with "everything continues to
work": that applies after every single commit. In other words, each
separate change needs to be compatible with python2 and python3 until we
get to a point where one commit is ready to move everything remaining
into python3-only. As an example, I'm planning on applying a subset of
this patch series and things need to continue to work with such subset.
It is going to be easier to get updated versions in with same policy of
being able to pick a subset of the updated series and apply that instead
of everything if there are open questions on some of the changes.
Jouni Malinen Jan. 26, 2019, 2:34 p.m. UTC | #6
Thanks, patches 1-9, 14, 35, 39 applied. I dropped the other patches
of the series from my queue due to open comments on them.
Masashi Honma Jan. 26, 2019, 8:16 p.m. UTC | #7
On 2019/01/26 20:26, Jouni Malinen wrote:
> Just to be clear on what I meant there with "everything continues to
> work": that applies after every single commit. In other words, each
> separate change needs to be compatible with python2 and python3 until we
> get to a point where one commit is ready to move everything remaining
> into python3-only. As an example, I'm planning on applying a subset of
> this patch series and things need to continue to work with such subset.
> It is going to be easier to get updated versions in with same policy of
> being able to pick a subset of the updated series and apply that instead
> of everything if there are open questions on some of the changes.

OK. I will keep the code works on both python 2 and 3 until the point
and keep every single commit does not break all.

Masashi Honma.
Masashi Honma Jan. 26, 2019, 8:19 p.m. UTC | #8
On 2019/01/26 23:34, Jouni Malinen wrote:
> Thanks, patches 1-9, 14, 35, 39 applied. I dropped the other patches
> of the series from my queue due to open comments on them.

Thank you. Additionally please drop 02/50 also. Because of this patch
parallel-vm.py could not run even though with python2.

Masashi Honma.
Jouni Malinen Jan. 27, 2019, 10:13 a.m. UTC | #9
On Sun, Jan 27, 2019 at 05:19:51AM +0900, Masashi Honma wrote:
> On 2019/01/26 23:34, Jouni Malinen wrote:
> >Thanks, patches 1-9, 14, 35, 39 applied. I dropped the other patches
> >of the series from my queue due to open comments on them.
> 
> Thank you. Additionally please drop 02/50 also. Because of this patch
> parallel-vm.py could not run even though with python2.

I already applied those, so this would be a request to revert the commit
rather than drop the patch.. Anyway, parallel-vm.py works fine for me
with python2 and the changes I mentioned to that patch, so I'm not sure
why I'd revert that commit.
Masashi Honma Jan. 28, 2019, 8:04 a.m. UTC | #10
On 2019/01/27 19:13, Jouni Malinen wrote:
> I already applied those, so this would be a request to revert the commit
> rather than drop the patch.. Anyway, parallel-vm.py works fine for me
> with python2 and the changes I mentioned to that patch, so I'm not sure
> why I'd revert that commit.

Sorry, I missed your previous comment.
It works. Revert not required.

Masashi Honma.