├── .gitignore ├── AUTHORS ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── Sample.md ├── docs ├── Makefile ├── conf.py ├── index.rst └── make.bat ├── plmn ├── __init__.py ├── at_cmds.py ├── list-usb-devices.sh ├── mmcli_parser.py ├── modem_cmds.py ├── network_checks.py ├── results.py ├── runner.py ├── simple_cmds.py └── utils.py ├── requirements.txt ├── setup.py └── tests ├── __init__.py ├── at_checks.py ├── compat.py ├── daemons_check.py ├── modem_checks.py ├── network_register_atnt.py ├── network_register_verizon.py ├── network_register_worldsim.py ├── python_checks.py ├── sim_checks.py ├── simple_cmd_checks.py └── test_regression.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | 103 | 104 | # PyCharm 105 | .idea/ 106 | 107 | # Test Results JSON 108 | tests/test-results.json 109 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | plmn-regression package was originally created in November, 2017. 2 | 3 | The PRIMARY AUTHORS are: 4 | Harsh Murari 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Rhoynar Software Consulting 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include LICENSE 3 | include requirements*.txt 4 | recursive-include docs *.bat 5 | recursive-include docs *.py 6 | recursive-include docs *.rst 7 | recursive-include docs Makefile 8 | recursive-include tests *.py 9 | 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | init: 2 | pip install -r requirements.txt 3 | 4 | test: 5 | nosetests tests 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Modem Test Framework 2 | 3 | This project implements a number of test cases that provide a regression framework for checking modem status, registration and connectivity. 4 | 5 | ## Test Plan 6 | 7 | This project implements the following test plan is implemented. 8 | * Basic System Checks: 9 | * Check if sudo access is available for the user and application. 10 | * Check if Python is available and print its version (2.7+ should be supported) 11 | * Check if all python package requirements are satisfied (PySerial etc). 12 | * Check if modem manager is running. 13 | * Check if network manager is running. 14 | * Check if wwan interfaces are available and enumerated (part of ifconfig -a) 15 | * Check what is the interface to be used for AT commands. 16 | * Check if LAN interface is available and can be used to reach outside world. 17 | * Modem Existence Checks: 18 | * Check if modem is present 19 | * Check if modem is enabled 20 | * Print the name, model number of the modem. 21 | * Print Modem Capabilities 22 | * Check if SIM card is present in the modem 23 | * Check if SIM card is unlocked and can be used. 24 | * AT Command Pre-reqs: 25 | * Check if Modem Manager is running in debug mode or if socat application is present. Set AT runner to mmcli or socat 26 | * Check if extended AT commands set can be unlocked using the password 27 | * Check if basic AT commands like AT+GMM etc are running correctly. 28 | * Network Checks (mmcli and AT commands): 29 | * Check if modem is registered on a network. (simple-status) 30 | * Check if a 3GPP scan can be performed to list out all available networks. 31 | * Check to see if modem can be forced to register to other networks. 32 | * Force automatic registration at the end to bring modem to good state. 33 | * Data Call Checks 34 | * Bring up default data call in automatic registration mode. Use nmcli commands to bring up corresponding interfaces. Perform data transfer over this interface. 35 | * Bring up data call over a different registration. Use nmcli commands to bring up the interface. Perform data transfer over this interface. 36 | * Tear Down the data call. Verify interface is brought down. 37 | * Repeated data call bring-up. 38 | * Check and report Data Transfer speeds [uplink and downlink] 39 | 40 | 41 | ## How to Use 42 | The following steps show the various ways to use this project. 43 | 44 | * Options supported with all types of runs: 45 | 46 | We can specify ``--debug`` option with all the test cases and registration runs. 47 | 48 | * Running Individual Test Cases 49 | 50 | Run individual test cases by running them through the console directly. 51 | 52 | ```python modem_checks.py``` 53 | 54 | Or run with debug option: 55 | 56 | ```python modem_checks.py --debug``` 57 | 58 | * Running Regression Test Suite: 59 | 60 | We can run all the regression tests in one go by running the regression python module. 61 | 62 | ```python test_regression.py``` 63 | 64 | * Running Registration Scenarios: 65 | 66 | Registration scenarios are not included in regression as they are end-to-end scenario and do not belong with unit test cases. You can run registration commands by running the appropriate module: 67 | 68 | ```python network_register_atnt.py --debug``` 69 | 70 | 71 | ## Project Layout and Overview 72 | The project is divided into two main folders: ***plmn*** - which implement different features, functionalities and helper routines; and ***tests*** - which implement different test cases and scenarios. 73 | 74 | ### ***plmn*** 75 | The plmn folder consists of different modules for implementing features and functionalities required for this project. 76 | 77 | * **runner.py**: 78 | 79 | The runner.py file implements **Runner** class which allows to run a specific MMCLI command through subprocess call. It uses subprocess python call and pipes to capture the standard output or errors. This class exports a single class **Runner** which provides a static method: ``Runner.run_cmd(cmd)``. This is implemented as a static method to allow callers to call this without instantiating any object. 80 | 81 | * **results.py** 82 | 83 | The results.py file implements the **Results** class which maintains the state of execution. The main objective of **Results** class is to maintain a state of different operations performed, what were the errors observed, what is the modem state at the end of execution. The following variables in **Results** class indicate the overall state. Since there is a single state at the end of execution, this class is impelemented through static variables and methods. 84 | 85 | * State Variables in **Results** 86 | * **steps[]** : Maintains a list of steps or commands executed. 87 | * **errs[]**: Maintains a list of errors in Results. 88 | * **state{}**: Maintains different state variables of Results. This contains a dictionary of values and consists of parsed command outputs for ``mmcli -m 0`` and ``mmcli -m 0 --simple-status`` commands. 89 | 90 | * Methods available in **Results** 91 | * ``add_state(state, val)``: Add a state to the Results. state is a string attribute and val can be any value: string, integer, boolean or a dictionary object. 92 | * ``get_state(state)``: Return the value maintained by identifier ``state``. ``state`` is a string indicating which state to get. 93 | * ``add_step(step)``: Add a step that was recently executed to the state. 94 | * ``add_error(cmd, comment)``: If any command indicated error after execution, add the error message along with any additional comments on how to resolve this error through comments. 95 | * ``print_results()``: Prints the state of results in a human readable format. It will internally dump the results to a JSON file as well. 96 | 97 | * **mmcli_parser.py** 98 | 99 | The ``mmcli_parser.parse()`` method parses the output provided by any MMCLI command and translates it into a Python dictionary object. The mmcli command output, when successful, consists of tabulated, 3 column. We translate it into Python dictionary object. For example the following line is an output from MMCLI list command: 100 | 101 | ``"Hardware | manufacturer: 'Sierra Wireless, Incorporated'"`` 102 | 103 | This is translated into following Python object ``state``: 104 | 105 | ``` 106 | { 107 | Hardware : 108 | { 109 | manufacturer: "Sierra Wireless, Incorporated" 110 | } 111 | } 112 | ``` 113 | 114 | * **utils.py** 115 | 116 | This file provides various utility functionalities for rest of the modules. They include: 117 | * **Logging** : We use an internal logging formatter to allow us to format different types log messages. Info messages are usually used for printing state messages and don't have a time/date/filename pre-fix to them. Debug messages and error messages do include a time/date/filename prefix. 118 | 119 | * **Argument Parsing**: Most of the runners use unittest test cases, so we have to capture and parse known command line arguments before handing over rest of arguments to the unittest module. We do that through argparse module which is implemented in this file. 120 | 121 | * **Running with ``--debug`` Option**: We can run any of the test cases or entry points for this project using ``--debug`` argument. This allows us to observe the progress of the project in real time as all the logs are printed to screen console. 122 | 123 | * **Logging output**: All log messages (debug, info, errors and any exceptions observed) are logged directly to **test.log** file which would be generated in the tests directory. We also generate a **test-results.json** file which contains the status of ``Results`` state. 124 | 125 | * **modem_cmds.py**: 126 | 127 | This file contains all the functions related to various modem MMCLI commands. All methods are implemented as static methods and can be run by using ``ModemCmds.method_name()`` 128 | 129 | * ``mmcli_cmd_present()`` : Check if mmcli command is available. 130 | * ``list_modems()``: List different modems available using ``mmcli -L`` command. 131 | * ``list_modem_wait()``: This is a blocking function which waits till a modem becomes available. This is useful in cases of a modem restart - this waits till the modem becomes available and returns when it has been listed. 132 | * ``modem_enabled()``: This method checks if the modem is enabled (if it is in "enabled", "registered" or "connected" states) 133 | * ``modem_info()``: Get all modem info using ``mmcli -m 0`` command. Parse all results into a python object and store it in results. 134 | * ``sim_present()``: Checks if a SIM card is available. 135 | * ``sim_unlocked()``: Checks if a SIM card is unlocked. 136 | * ``is_sim_registered()``: Returns if a SIM card is "registered" or "connected" state. 137 | * ``sim_registered()``: This method asserts if a SIM card is registered. 138 | * ``modem_manager_is_running()``: This method checks to see if the modem manager daemon is running. 139 | * ``modem_manager_in_debug_mode()``: This function checks if the modem manager is running in debug mode (with ``--debug`` options.). Most AT commands need the modem manager to run in debug mode. 140 | * ``modem_manager_start_in_debug_mode()``: This function checks if the modem manager is running in debug mode, if not it starts the modem manager in debug mode. 141 | * ``modem_sanity()``: This performs few sanity checks on the modem. 142 | * ``modem_lpm_online()``: This performs a modem soft cycle: which means it puts modem in low-power mode and enables the modem again. Similar to putting modem in Air Plane mode and back online. 143 | 144 | * **network_checks.py** 145 | 146 | This file provides methods to perform network registration and connect to a APN. The idea is that this module will be used by carrier specific test cases (listed below) in order to initiate a registration/connection routine on a specific carrier. 147 | 148 | * ``network_register(network_name, apn)``: This method implements a network register routine from start to finish. Usually used after hot-swapping a SIM card, this would trigger all tricks in the book in order for the SIM card to quickly register on a particular network. There are differences in ways CDMA networks such as Verizon operate (support auto-connect on registration) vs other networks (like AT&T which require we explicitly connect). This method hides all those details internally and provides a simple, easy-to-use external interface that can be replicated in an app. 149 | 150 | * ``network_connect(network_name, apn)``: This method performs network connection after registration. Please note that network_register() should be called before this method. 151 | 152 | * **simple_cmds.py** 153 | 154 | This file contains wrapper methods for executing various ``simple`` commands that mmcli supports. Commands such as ``--simple-status`` and ``--simple-connect`` are supported. 155 | 156 | * ``modem_sanity()``: Checks for modem sanity before performing any commands. 157 | * ``simple_status_cmd()``: Wrapper around ``mmcli -m 0 --simple-status`` command. 158 | * ``simple_status_get_reg_status()``: Run simple-status command and check the registration status. 159 | * ``simple_status_is_registered()``: Run simple-status command and return True if registered or connected. 160 | * ``simple_status_is_connected()``: Run simple-status command and return True if connected. 161 | * ``simple_status_is_roaming()``: Run simple-status command to figure out if modem is roaming or on home network. 162 | * ``simple_connect()``: Connect to a network using mmcli simple commands. 163 | 164 | * **at_cmds.py** 165 | 166 | This file contains wrappers for executing various AT commands to the modem. We use mmcli as an interface to talk to the modem. In order for most of the AT commands to work, there are two pre-requisites. 167 | 168 | * Modem Manager must be running in debug mode. There is a method in this class ``AtCmds.restart_mm_debug_mode()`` which will restart the modem manager daemon in debug mode if it is not running in debug mode already. 169 | 170 | * Extended AT commands should be unlocked. Majority of the AT commands used herein fall under "Extended AT commands" category. In order to unlock these commands, we need to send **AT!ENTERCND="A710"** command to the modem. There is a wrapper method in this module ``AtCmds.unlock_at_cmds`` which performs unlocking for us. 171 | 172 | Following methods are exported through this module. 173 | 174 | * ``restart_mm_debug_mode()``: Restart modem manager in debug mode. 175 | * ``send_at_cmd()``: Send an AT command. Default timeout of 300 seconds is used. Timeout is worse case time for the command, in most cases, the command will complete well before the timeout. 176 | * ``unlock_at_cmds()``: This method performs an unlock of the Extended AT command set. This needs to be called only once prior to sending any extended AT commands. 177 | * ``set_apn_name_in_profile()``: This method sets the APN name specified in the modem profile. This is required, even for registration, on networks such as Verizon which support auto-connect on register. 178 | * ``perform_3gpp_scan()``: Uses ``AT+COPS=?`` to perform a network scan. This is simpilar in operation to ``mmcli -m 0 --3gpp-scan`` 179 | * ``perform_auto_register()``: Uses ``AT+COPS=0`` to trigger an automatic registration request to the modem. 180 | * ``perform_manual_register()``: Uses ``AT+COPS=1,0,"AT&T"`` to trigger a registration request on a specified network name. Network name is obtained from ``perform_3gpp_scan()`` method from above. 181 | * ``restart_modem()``: This command restarts the modem using the AT command: ``AT!GRESET`` command. After the modem is restarted, this performs a polling wait till the modem is listed again through MMCLI commands. 182 | 183 | 184 | ### ***tests*** 185 | 186 | This module lists all test cases supported for PLMN regression. 187 | 188 | * Regression Tests 189 | * **compat.py** : This file is a utility file that allows the test cases to be run from tests directory as well from main root directory. 190 | * **at_checks.py** : This file implements all the AT command regression test cases. 191 | * **daemons_checks.py** : This file implements checking if modem manager and network manager daemons are running, are they in debug modes etc. 192 | * **modem_checks.py**: This file checks different modem checks needed. Such as whether modem is listed, modem is enabled, getting modem info etc. 193 | * **python_checks.py**: This file checks whether python, pip and all its dependencies is available in the system. 194 | * **sim_checks.py**: This file checks for all SIM checks. Whether SIM card is present or not, whether sim card is enabled and unlocked and whether SIM card is registered on a network. 195 | * **simple_cmd_checks.py**: This file tests for different simple-commands such as simple-status and simple-connect. 196 | * **test_regression.py**: This is a single regression module that runs all the above test cases. It creates a test-suite, adds all modules to the test suite, creates a text test runner and runs all the test suites. 197 | 198 | * Network Registration Cycles: 199 | * **network_register_atnt.py**: This module perform complete registration on a AT&T SIM card. This creates the correct profile based on the network name and triggers a restart followed by registration process for AT&T. 200 | * **network_register_verizon.py**: This module perform complete registration on a Verizon SIM card. This creates the correct profile based on the network name and triggers a restart followed by registration process for Verizon. 201 | 202 | 203 | -------------------------------------------------------------------------------- /Sample.md: -------------------------------------------------------------------------------- 1 | # Project Title 2 | 3 | One Paragraph of project description goes here 4 | 5 | ## Getting Started 6 | 7 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. 8 | 9 | ### Prerequisites 10 | 11 | What things you need to install the software and how to install them 12 | 13 | ``` 14 | Give examples 15 | ``` 16 | 17 | ### Installing 18 | 19 | A step by step series of examples that tell you have to get a development env running 20 | 21 | Say what the step will be 22 | 23 | ``` 24 | Give the example 25 | ``` 26 | 27 | And repeat 28 | 29 | ``` 30 | until finished 31 | ``` 32 | 33 | End with an example of getting some data out of the system or using it for a little demo 34 | 35 | ## Running the tests 36 | 37 | Explain how to run the automated tests for this system 38 | 39 | ### Break down into end to end tests 40 | 41 | Explain what these tests test and why 42 | 43 | ``` 44 | Give an example 45 | ``` 46 | 47 | ### And coding style tests 48 | 49 | Explain what these tests test and why 50 | 51 | ``` 52 | Give an example 53 | ``` 54 | 55 | ## Deployment 56 | 57 | Add additional notes about how to deploy this on a live system 58 | 59 | ## Built With 60 | 61 | * [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used 62 | * [Maven](https://maven.apache.org/) - Dependency Management 63 | * [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds 64 | 65 | ## Contributing 66 | 67 | Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. 68 | 69 | ## Versioning 70 | 71 | We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). 72 | 73 | ## Authors 74 | 75 | * **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth) 76 | 77 | See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. 78 | 79 | ## License 80 | 81 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 82 | 83 | ## Acknowledgments 84 | 85 | * Hat tip to anyone who's code was used 86 | * Inspiration 87 | * etc 88 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sample.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sample.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/sample" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sample" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # sample documentation build configuration file, created by 4 | # sphinx-quickstart on Mon Apr 16 21:22:43 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = [] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'sample' 44 | copyright = u'2012, Kenneth Reitz' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = 'v0.0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = 'v0.0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = ['_build'] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'sampledoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | latex_elements = { 173 | # The paper size ('letterpaper' or 'a4paper'). 174 | #'papersize': 'letterpaper', 175 | 176 | # The font size ('10pt', '11pt' or '12pt'). 177 | #'pointsize': '10pt', 178 | 179 | # Additional stuff for the LaTeX preamble. 180 | #'preamble': '', 181 | } 182 | 183 | # Grouping the document tree into LaTeX files. List of tuples 184 | # (source start file, target name, title, author, documentclass [howto/manual]). 185 | latex_documents = [ 186 | ('index', 'sample.tex', u'sample Documentation', 187 | u'Kenneth Reitz', 'manual'), 188 | ] 189 | 190 | # The name of an image file (relative to this directory) to place at the top of 191 | # the title page. 192 | #latex_logo = None 193 | 194 | # For "manual" documents, if this is true, then toplevel headings are parts, 195 | # not chapters. 196 | #latex_use_parts = False 197 | 198 | # If true, show page references after internal links. 199 | #latex_show_pagerefs = False 200 | 201 | # If true, show URL addresses after external links. 202 | #latex_show_urls = False 203 | 204 | # Documents to append as an appendix to all manuals. 205 | #latex_appendices = [] 206 | 207 | # If false, no module index is generated. 208 | #latex_domain_indices = True 209 | 210 | 211 | # -- Options for manual page output -------------------------------------------- 212 | 213 | # One entry per manual page. List of tuples 214 | # (source start file, name, description, authors, manual section). 215 | man_pages = [ 216 | ('index', 'sample', u'sample Documentation', 217 | [u'Kenneth Reitz'], 1) 218 | ] 219 | 220 | # If true, show URL addresses after external links. 221 | #man_show_urls = False 222 | 223 | 224 | # -- Options for Texinfo output ------------------------------------------------ 225 | 226 | # Grouping the document tree into Texinfo files. List of tuples 227 | # (source start file, target name, title, author, 228 | # dir menu entry, description, category) 229 | texinfo_documents = [ 230 | ('index', 'sample', u'sample Documentation', 231 | u'Kenneth Reitz', 'sample', 'One line description of project.', 232 | 'Miscellaneous'), 233 | ] 234 | 235 | # Documents to append as an appendix to all manuals. 236 | #texinfo_appendices = [] 237 | 238 | # If false, no module index is generated. 239 | #texinfo_domain_indices = True 240 | 241 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 242 | #texinfo_show_urls = 'footnote' 243 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. sample documentation master file, created by 2 | sphinx-quickstart on Mon Apr 16 21:22:43 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to sample's documentation! 7 | ================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | 23 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\sample.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\sample.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /plmn/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /plmn/at_cmds.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import re 5 | from modem_cmds import * 6 | 7 | class AtCmds(): 8 | @classmethod 9 | def modem_sanity(cls): 10 | ModemCmds.modem_sanity() 11 | 12 | @classmethod 13 | def mm_debug_mode(cls): 14 | dbg_mode = ModemCmds.modem_manager_in_debug_mode() 15 | if dbg_mode is False: 16 | dbg_mode = ModemCmds.modem_manager_start_in_debug_mode() 17 | assert dbg_mode is True 18 | 19 | @classmethod 20 | def restart_mm_debug_mode(cls): 21 | cls.mm_debug_mode() 22 | 23 | @classmethod 24 | def _try_3gpp_scan(cls, timeout=300): 25 | 26 | for idx in range(0,3): 27 | modem_idx = Results.get_state('Modem Index') 28 | assert modem_idx is not None 29 | cmd = "mmcli -m {} --3gpp-scan --timeout {}".format(modem_idx, timeout + 100*idx) 30 | 31 | logging.debug("3GPP Scan command: " + str(cmd)) 32 | res = Runner.run_cmd(cmd).strip() 33 | logging.debug("Response: \n" + str(res)) 34 | 35 | if "couldn't scan networks in the modem" not in res: 36 | break 37 | 38 | 39 | @classmethod 40 | def _try_send_at_cmd(cls, at_cmd, timeout): 41 | AtCmds.mm_debug_mode() 42 | 43 | modem_idx = Results.get_state('Modem Index') 44 | assert modem_idx is not None 45 | cmd = "mmcli -m {} --command='{}' --timeout={}".format(modem_idx, at_cmd, timeout) 46 | 47 | logging.debug("AT command: " + str(cmd)) 48 | res = Runner.run_cmd(cmd).strip() 49 | logging.debug("Response: \n" + str(res)) 50 | 51 | res = res.replace('\r','|').replace('\n','|') 52 | match = re.search(r'response: \'(.*)\'', res) 53 | at_res = None 54 | if match is not None and match.group(1) is not None: 55 | at_res = match.group(1).strip() 56 | 57 | return at_res 58 | 59 | @classmethod 60 | def send_at_cmd(cls, at_cmd, timeout=300): 61 | at_res = cls._try_send_at_cmd(at_cmd, timeout) 62 | if at_res is None: 63 | for idx in range(0,2): 64 | time.sleep(1) 65 | # Some error occurred in AT command processing. Retry (upto 3 times) 66 | at_res = cls._try_send_at_cmd(at_cmd, timeout) 67 | if at_res is not None: 68 | break 69 | 70 | assert at_res is not None 71 | return at_res 72 | 73 | @classmethod 74 | def unlock_at_cmds(cls): 75 | if True != Results.get_state('AT Unlocked'): 76 | res = cls.send_at_cmd('AT!ENTERCND="A710"') 77 | logging.debug("AT Unlock Results: " + str(res)) 78 | assert res == '', 'AT unlock command not succesful' 79 | Results.add_state('AT Unlocked', True) 80 | 81 | @classmethod 82 | def set_apn_name_in_profile(cls, pid=1, apn='broadband'): 83 | cls.mm_debug_mode() 84 | cls.unlock_at_cmds() 85 | 86 | res = cls.send_at_cmd('AT+CGDCONT?') 87 | assert res is not None 88 | 89 | res = cls.send_at_cmd('AT+CGDCONT={},"IP","{}"'.format(pid, apn)) 90 | assert res is '' 91 | 92 | # Query again to check profile has been updated with new APN. 93 | res = cls.send_at_cmd('AT+CGDCONT?') 94 | assert res is not None 95 | assert apn in res 96 | 97 | @classmethod 98 | def perform_3gpp_scan(cls): 99 | AtCmds.mm_debug_mode() 100 | cls.unlock_at_cmds() 101 | 102 | # Check if network scan possible 103 | res = cls.send_at_cmd('AT+COPS?') 104 | assert res is not None 105 | 106 | # Perform Network Scan (default timeout of 300 sounds good) 107 | res = cls._try_3gpp_scan() 108 | assert res is not None 109 | 110 | @classmethod 111 | def perform_auto_register(cls): 112 | res = cls.send_at_cmd('AT+COPS=0') 113 | assert res is not None 114 | 115 | @classmethod 116 | def perform_manual_register(cls, network_name='AT&T'): 117 | cls.perform_3gpp_scan() 118 | 119 | # For manually registering networks, make sure correct profile is present for them. 120 | if network_name == 'AT&T': 121 | cls.set_apn_name_in_profile(apn='broadband') 122 | elif network_name == 'Verizon': 123 | cls.set_apn_name_in_profile(apn='vzwinternet') 124 | elif network_name == 'T-Mobile': 125 | cls.set_apn_name_in_profile(apn='fast.t-mobile.com') 126 | else: 127 | # Add other network names and their APNs as needed. 128 | assert 0, 'Unknown network name to register on.' 129 | 130 | # Register manually on the given network. 131 | res = cls.send_at_cmd('AT+COPS=1,0,"{}"'.format(network_name)) 132 | assert res is not None 133 | 134 | @classmethod 135 | def restart_modem(cls): 136 | ModemCmds.list_modem_wait() 137 | modem_idx = Results.get_state('Modem Index') 138 | assert modem_idx is not None 139 | 140 | cls.unlock_at_cmds() 141 | res = cls.send_at_cmd('AT!GRESET') 142 | time.sleep(5) 143 | 144 | Results.reset() 145 | ModemCmds.list_modem_wait() 146 | -------------------------------------------------------------------------------- /plmn/list-usb-devices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do 4 | ( 5 | syspath="${sysdevpath%/dev}" 6 | devname="$(udevadm info -q name -p $syspath)" 7 | [[ "$devname" == "bus/"* ]] && continue 8 | eval "$(udevadm info -q property --export -p $syspath)" 9 | [[ -z "$ID_SERIAL" ]] && continue 10 | echo "/dev/$devname - $ID_SERIAL" 11 | ) 12 | done 13 | 14 | -------------------------------------------------------------------------------- /plmn/mmcli_parser.py: -------------------------------------------------------------------------------- 1 | import re 2 | import json 3 | 4 | class MMCLIParser(): 5 | @classmethod 6 | def save_json(cls, obj, fname): 7 | with open(fname, 'w') as json_file: 8 | json.dump(obj, json_file, indent=4) 9 | 10 | @classmethod 11 | def parse(cls, text): 12 | # type (str) -> Object 13 | res = {} 14 | cur_sys = None 15 | cur_subsys = None 16 | lines = text.split('\n') 17 | 18 | for idx in range(0, len(lines)): 19 | line = lines[idx] 20 | if '-------------------------' in line: 21 | cur_sys = None 22 | cur_subsys = None 23 | continue 24 | 25 | if '|' not in line: 26 | continue 27 | 28 | if len(line.strip()) is 0: 29 | continue 30 | 31 | first_idx = line.find('|') 32 | if first_idx > 0: 33 | sys = re.search('([\w\d\s]+)', line[:first_idx]).group(1) 34 | sys = sys.strip() 35 | if sys is not '': 36 | cur_sys = sys 37 | res[cur_sys] = {} 38 | 39 | second_idx = line.find(':') 40 | if second_idx >= first_idx: 41 | subsys = re.search('([\w\d\s]+)', line[first_idx:second_idx]).group(1) 42 | subsys = subsys.strip() 43 | if subsys is not '': 44 | cur_subsys = subsys 45 | res[cur_sys][cur_subsys] = '' 46 | 47 | val = line[second_idx:].strip().strip(':').strip().strip('\'').strip() 48 | res[cur_sys][cur_subsys] = val 49 | 50 | elif second_idx == -1: 51 | val = line.strip().strip('\'').strip('|').strip() 52 | if val is not '': 53 | res[cur_sys][cur_subsys] = res[cur_sys][cur_subsys] + ', ' + val 54 | 55 | return res 56 | 57 | if __name__ == '__main__': 58 | text = ''' 59 | 60 | ------------------------- 61 | Hardware | manufacturer: 'Sierra Wireless, Incorporated' 62 | | model: 'MC7354' 63 | | revision: 'SWI9X15C_05.05.58.00 r27038 carmd-fwbuild1 2015/03/04 21:30:23' 64 | | supported: 'gsm-umts 65 | | cdma-evdo 66 | | lte 67 | | cdma-evdo, gsm-umts 68 | | gsm-umts, lte 69 | | cdma-evdo, lte 70 | | cdma-evdo, gsm-umts, lte' 71 | | current: 'gsm-umts, lte' 72 | | equipment id: '359225050108901' 73 | ------------------------- 74 | System | device: '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3' 75 | | drivers: 'option1, qmi_wwan' 76 | | plugin: 'Sierra' 77 | | primary port: 'cdc-wdm0' 78 | | ports: 'ttyUSB2 (at), cdc-wdm0 (qmi), cdc-wdm1 (qmi), wwan1 (net), wwan0 (net)' 79 | ------------------------- 80 | Numbers | own : '13035708302' 81 | ------------------------- 82 | Status | lock: 'sim-pin2' 83 | | unlock retries: 'sim-pin (3), sim-pin2 (3), sim-puk (10), sim-puk2 (10)' 84 | | state: 'registered' 85 | | power state: 'on' 86 | | access tech: 'lte' 87 | | signal quality: '59' (recent) 88 | ------------------------- 89 | Modes | supported: 'allowed: 2g, 3g, 4g; preferred: none' 90 | | current: 'allowed: 2g, 3g, 4g; preferred: none' 91 | ------------------------- 92 | Bands | supported: 'cdma-bc0-cellular-800, cdma-bc1-pcs-1900, cdma-bc10-secondary-800, cdma-bc15-aws, dcs, egsm, pcs, g850, u2100, u1900, u17iv, u850, u900, eutran-ii, eutran-iv, eutran-v, eutran-xiii, eutran-xvii, eutran-xxv' 93 | | current: 'cdma-bc15-aws, dcs, egsm, pcs, g850, u2100, u1900, u850, u900, eutran-ii, eutran-iv, eutran-v, eutran-xvii' 94 | ------------------------- 95 | IP | supported: 'ipv4, ipv6, ipv4v6' 96 | ------------------------- 97 | 3GPP | imei: '359225050108901' 98 | | enabled locks: 'none' 99 | | operator id: '310410' 100 | | operator name: 'AT&T' 101 | 102 | ''' 103 | 104 | # Parse text and save as out.json 105 | res = MMCLIParser.parse(text) 106 | MMCLIParser.save_json(res, 'out.json') 107 | 108 | -------------------------------------------------------------------------------- /plmn/modem_cmds.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import re 4 | from utils import * 5 | from results import * 6 | from runner import Runner 7 | from mmcli_parser import MMCLIParser 8 | 9 | import time 10 | 11 | class ModemCmds: 12 | @classmethod 13 | def mmcli_cmd_present(cls): 14 | mmcli_exec = Results.get_state('MMCLI Exec') 15 | if mmcli_exec is None: 16 | mmcli_exec = Runner.run_cmd('which mmcli') 17 | if mmcli_exec is not None and len(mmcli_exec.strip()) is 0: 18 | Results.add_state('MMCLI Exec', mmcli_exec.strip()) 19 | 20 | assert mmcli_exec is not None 21 | 22 | @classmethod 23 | def list_modems(cls): 24 | logging.debug('Listing modems.') 25 | cls.mmcli_cmd_present() 26 | 27 | modem_loc = Results.get_state('Modem Location') 28 | if modem_loc is None: 29 | mmcli = Runner.run_cmd('mmcli -L') 30 | if '/org/freedesktop/ModemManager' not in mmcli: 31 | Results.add_error('mmcli -L', 'Modem not found. Please enable the modem through instrument UI.') 32 | else: 33 | modem_loc = re.search(r'(/org/freedesktop/ModemManager\d/Modem/\d)', mmcli.strip()).group(1) 34 | Results.add_state('Modem Location', modem_loc) 35 | Results.add_state('Modem Index', re.search(r'/org/freedesktop/ModemManager\d/Modem/(\d)', modem_loc).group(1)) 36 | 37 | logging.debug('Modem Location: ' + str(modem_loc)) 38 | logging.debug('Modem Index: ' + str(Results.get_state('Modem Index'))) 39 | assert modem_loc is not None 40 | 41 | @classmethod 42 | def list_modem_wait(cls): 43 | cls.mmcli_cmd_present() 44 | 45 | modem_loc = Results.get_state('Modem Location') 46 | if modem_loc is None: 47 | for idx in range(0,60): 48 | mmcli = Runner.run_cmd('mmcli -L') 49 | if '/org/freedesktop/ModemManager1/Modem/' not in mmcli: 50 | logging.debug('Modem not listed yet. Waiting..') 51 | time.sleep(1) 52 | else: 53 | modem_loc = re.search(r'(/org/freedesktop/ModemManager\d/Modem/\d)', mmcli.strip()).group(1) 54 | Results.add_state('Modem Location', modem_loc) 55 | Results.add_state('Modem Index', 56 | re.search(r'/org/freedesktop/ModemManager\d/Modem/(\d)', modem_loc).group(1)) 57 | break 58 | 59 | 60 | @classmethod 61 | def modem_enabled(cls): 62 | cls.list_modems() 63 | 64 | modem_en = Results.get_state('Modem Enabled') 65 | if modem_en is None: 66 | modem_idx = Results.get_state('Modem Index') 67 | 68 | mmcli = Runner.run_cmd('mmcli -m {} --simple-status'.format(modem_idx)) 69 | res = MMCLIParser.parse(mmcli) 70 | 71 | logging.debug('mmcli -m {} --simple-status output'.format(modem_idx)) 72 | logging.debug(res) 73 | 74 | if res is not None and 'Status' in res.keys() and 'state' in res['Status'].keys(): 75 | if res['Status']['state'] == 'disabled': 76 | Results.add_error('mmcli -m {} --simple-status'.format(modem_idx), 'Modem not enabled. Please enable using mmcli -m {} --enable'.format(modem_idx)) 77 | 78 | elif res['Status']['state'] != 'registered' and res['Status']['state'] != 'connected' and res['Status']['state'] != 'searching' and res['Status']['state'] != 'enabled': 79 | Results.add_error('mmcli -m {} --simple-status'.format(modem_idx), 80 | 'Modem not enabled/registered. Contact support with log files') 81 | else: 82 | modem_en = True 83 | Results.add_state('Modem Enabled', modem_en) 84 | 85 | assert modem_en is True 86 | 87 | @classmethod 88 | def modem_info(cls): 89 | # This is a re-entrant method, so anytime this function is called: 90 | # - We re-run all commands and get complete modem info. 91 | Results.reset() 92 | 93 | cls.mmcli_cmd_present() 94 | cls.list_modems() 95 | cls.modem_enabled() 96 | cls.sim_present() 97 | cls.sim_unlocked() 98 | cls.sim_registered() 99 | 100 | modem_info = Results.get_state('Modem Info') 101 | if modem_info is None: 102 | modem_idx = Results.get_state('Modem Index') 103 | assert modem_idx is not None 104 | 105 | mmcli = Runner.run_cmd('mmcli -m {}'.format(modem_idx)).strip() 106 | modem_info = MMCLIParser.parse(mmcli) 107 | if len(modem_info.keys()) > 0: 108 | Results.add_state('Modem Info', modem_info) 109 | else: 110 | Results.add_error('mmcli -m {}'.format(modem_idx), 111 | 'Error getting/parsing modem info. Contact support with test output.') 112 | 113 | assert modem_info is not None 114 | 115 | @classmethod 116 | def sim_present(cls): 117 | cls.list_modems() 118 | 119 | sim_present = Results.get_state('SIM Present') 120 | if sim_present is None: 121 | modem_idx = Results.get_state('Modem Index') 122 | mmcli = Runner.run_cmd('mmcli -m {}'.format(modem_idx)) 123 | res = MMCLIParser.parse(mmcli) 124 | if 'SIM' in res.keys() and 'Status' in res.keys() and 'state' in res['Status'].keys(): 125 | if res['Status']['state'] == 'failed': 126 | Results.add_error('mmcli -m {}'.format(modem_idx) + ' | gerp state', 127 | 'SIM card not found. Insert SIM card and restart modem') 128 | else: 129 | sim_present = True 130 | Results.add_state('SIM Present', sim_present) 131 | 132 | assert sim_present is True 133 | 134 | @classmethod 135 | def sim_unlocked(cls): 136 | cls.sim_present() 137 | 138 | sim_unlocked = Results.get_state('SIM Unlocked') 139 | if sim_unlocked is None: 140 | modem_idx = Results.get_state('Modem Index') 141 | assert modem_idx is not None 142 | 143 | mmcli = Runner.run_cmd('mmcli -m {}'.format(modem_idx)) 144 | res = MMCLIParser.parse(mmcli) 145 | if '3GPP' in res.keys() and 'enabled locks' in res['3GPP'].keys(): 146 | if res['3GPP']['enabled locks'] == 'none': 147 | sim_unlocked = True 148 | Results.add_state('SIM Unlocked', sim_unlocked) 149 | else: 150 | Results.add_state('SIM Unlocked', False) 151 | Results.add_error('mmcli -m {}'.format(modem_idx) + ' | grep \'enabled lock\'', 'SIM card is locked with a PIN.') 152 | assert sim_unlocked is True 153 | 154 | @classmethod 155 | def is_sim_registered(cls): 156 | cls.sim_present() 157 | cls.sim_unlocked() 158 | 159 | sim_registered = Results.get_state('SIM Registered') 160 | logging.debug('SIM Registered: ' + str(sim_registered)) 161 | 162 | if sim_registered is not True: 163 | modem_idx = Results.get_state('Modem Index') 164 | assert modem_idx is not None 165 | 166 | mmcli = Runner.run_cmd('mmcli -m {}'.format(modem_idx)) 167 | res = MMCLIParser.parse(mmcli) 168 | if 'SIM' in res.keys() and 'Status' in res.keys() and 'state' in res['Status'].keys(): 169 | if res['Status']['state'] == 'registered' or res['Status']['state'] == 'connected': 170 | sim_registered = True 171 | Results.add_state('SIM Registered', sim_registered) 172 | else: 173 | Results.add_state('SIM Registered', False) 174 | 175 | if sim_registered is True: 176 | return True 177 | else: 178 | return False 179 | 180 | @classmethod 181 | def sim_registered(cls): 182 | sim_reg = cls.is_sim_registered() 183 | if sim_reg is False: 184 | Results.add_error('mmcli -m 0 | grep state', 185 | 'SIM card not registered. Please restart modem manager using: sudo stop modemmanager && sudo start modemmanager') 186 | 187 | assert sim_reg is True, 'SIM is not yet Registered' 188 | 189 | @classmethod 190 | def modem_manager_is_running(cls): 191 | ps_ef = Runner.run_cmd('ps -ef') 192 | if 'ModemManager' in ps_ef: 193 | return True 194 | else: 195 | return False 196 | 197 | @classmethod 198 | def modem_manager_in_debug_mode(cls): 199 | ps_ef = Runner.run_cmd('ps -ef') 200 | if 'ModemManager --debug' in ps_ef: 201 | Results.add_state('Modem Manager Debug', True) 202 | return True 203 | else: 204 | Results.add_state('Modem Manager Debug', False) 205 | return False 206 | 207 | 208 | @classmethod 209 | def modem_manager_start_in_debug_mode(cls): 210 | dbg_mode = cls.modem_manager_in_debug_mode() 211 | if not dbg_mode: 212 | Runner.run_cmd('sudo stop modemmanager') 213 | time.sleep(2) 214 | Runner.run_cmd('/usr/sbin/ModemManager --debug') 215 | time.sleep(5) 216 | 217 | # Get all modem info again. 218 | cls.modem_info() 219 | 220 | # Ensure debug omde is True 221 | dbg_mode = cls.modem_manager_in_debug_mode() 222 | if not dbg_mode: 223 | Results.add_error('/usr/sbin/ModemManager --debug', 'Modem manager cannot be started in debug mode.') 224 | 225 | assert dbg_mode is True 226 | return dbg_mode 227 | 228 | @classmethod 229 | def modem_sanity(cls): 230 | cls.mmcli_cmd_present() 231 | cls.modem_enabled() 232 | cls.sim_present() 233 | cls.sim_unlocked() 234 | 235 | 236 | # Uses MMCLI commands to put modem into Low power mode (LPM) and back online. 237 | @classmethod 238 | def mode_lpm_online(cls): 239 | cls.list_modems() 240 | 241 | modem_idx = Results.get_state('Modem Index') 242 | assert modem_idx is not None 243 | 244 | res = Runner.run_cmd('mmcli -m {} --disable'.format(modem_idx)) 245 | assert res is not None 246 | time.sleep(3) 247 | 248 | res = Runner.run_cmd('mmcli -m {} --enable'.format(modem_idx)) 249 | assert res is not None 250 | time.sleep(10) 251 | 252 | @classmethod 253 | def restart_modem_sometimes_does_not_work(cls): 254 | # works in most scenarios. 255 | # But sometimes this does not work if /dev/ttyACM device is busy. 256 | # Use the other method using AT commands (AT!GRESET) it works always. 257 | 258 | # Find the highest index /dev/ttyACM* device. 259 | res = Runner.run_cmd('ls /dev/ttyACM*').strip() 260 | devs = re.findall(r'/dev/ttyACM\d', res) 261 | largest_dev_idx = 0 262 | for dev in devs: 263 | dev_idx = re.search('/dev/ttyACM(\d)', dev).group(1) 264 | if int(dev_idx) > largest_dev_idx: 265 | largest_dev_idx = int(dev_idx) 266 | 267 | # Command to reset device: 268 | modem_off_cmd = "echo gprs 0 > /dev/ttyACM{}".format(largest_dev_idx) 269 | logging.debug("Turning OFF Modem using ACM Device command: " + modem_off_cmd) 270 | 271 | res = Runner.run_cmd(modem_off_cmd) 272 | time.sleep(5) 273 | 274 | # Command to turn-on Modem. 275 | modem_on_cmd = "echo gprs 1 > /dev/ttyACM{}".format(largest_dev_idx) 276 | logging.debug("Turning ON Modem using ACM Device command: " + modem_on_cmd) 277 | time.sleep(10) 278 | 279 | # Perform basics initialization. 280 | Results.reset() 281 | cls.mmcli_cmd_present() 282 | cls.list_modem_wait() 283 | 284 | if __name__ == '__main__': 285 | process_args() 286 | ModemCmds.modem_enabled() 287 | -------------------------------------------------------------------------------- /plmn/network_checks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import time 5 | import tests.compat 6 | from plmn.utils import * 7 | from plmn.results import * 8 | from plmn.modem_cmds import ModemCmds 9 | from plmn.runner import * 10 | from plmn.at_cmds import * 11 | from plmn.simple_cmds import * 12 | 13 | class NetworkChecks(): 14 | 15 | @classmethod 16 | def _network_register_using_at(cls, network_name, apn_name): 17 | # Modem sanity 18 | ModemCmds.modem_sanity() 19 | 20 | # Restart modem-manager in debug mode if needed. 21 | AtCmds.mm_debug_mode() 22 | 23 | # Unlock all at-commands. 24 | AtCmds.unlock_at_cmds() 25 | 26 | # Update default profile with correct APN name. 27 | AtCmds.set_apn_name_in_profile(1, apn_name) 28 | 29 | # Restart Modem. (put in Low Power mode and back online) 30 | AtCmds.restart_modem() 31 | 32 | for idx in range(0, 5): 33 | # Perform LPM/Online if still not registered. 34 | sim_reg = ModemCmds.is_sim_registered() 35 | if sim_reg is False: 36 | ModemCmds.mode_lpm_online() 37 | 38 | # Perform 3GPP scan if still not registered. 39 | sim_reg = ModemCmds.is_sim_registered() 40 | if sim_reg is False: 41 | AtCmds.perform_3gpp_scan() 42 | 43 | # Perform auto-register. 44 | sim_reg = ModemCmds.is_sim_registered() 45 | if sim_reg is False: 46 | AtCmds.perform_auto_register() 47 | 48 | if sim_reg is True: 49 | break 50 | 51 | # Perform manual register 52 | # AtCmds.perform_manual_register(network_name) 53 | 54 | 55 | # Ensure modem is registered now. 56 | ModemCmds.modem_enabled() 57 | ModemCmds.sim_registered() 58 | 59 | @classmethod 60 | def network_register(cls, network_name, apn_name): 61 | cls._network_register_using_at(network_name, apn_name) 62 | 63 | @classmethod 64 | def network_connect(cls, network_name, apn_name): 65 | SimpleCmds.simple_connect(apn_name) 66 | 67 | if __name__ == '__main__': 68 | process_args() 69 | NetworkChecks.network_register('AT&T', 'broadband') 70 | -------------------------------------------------------------------------------- /plmn/results.py: -------------------------------------------------------------------------------- 1 | from utils import * 2 | import json 3 | import pprint 4 | 5 | class Results: 6 | steps = [] 7 | errs = [] 8 | state = {} 9 | 10 | @classmethod 11 | def add_step(cls, cmd): 12 | step_already_added = False 13 | for step in Results.steps: 14 | if step == cmd: 15 | step_already_added = True 16 | break 17 | if not step_already_added: 18 | Results.steps.append(cmd) 19 | 20 | @classmethod 21 | def add_error(cls, cmd, comment): 22 | err_already_added = False 23 | for err in Results.errs: 24 | if err['cmd'] == cmd and err['comment'] == comment: 25 | err_already_added = True 26 | 27 | if err_already_added == False: 28 | Results.errs.append({'cmd' : cmd, 'comment': comment}) 29 | logging.error('Error in ' + cmd + ', Details: ' + comment) 30 | assert 0, comment 31 | 32 | @classmethod 33 | def add_state(cls, state, val): 34 | Results.state[state] = val 35 | 36 | @classmethod 37 | def get_state(cls, key): 38 | if key in Results.state.keys(): 39 | return Results.state[key] 40 | else: 41 | return None 42 | 43 | @classmethod 44 | def dump_results(cls, filename): 45 | res = { 'state' : Results.state, 'steps' : Results.steps, 'errors' : Results.errs } 46 | with open(filename, 'w') as json_file: 47 | json.dump(res, json_file, indent=4) 48 | 49 | @classmethod 50 | def reset(cls): 51 | logging.debug('Reset results state.') 52 | cls.state.clear() 53 | 54 | @classmethod 55 | def print_results(cls): 56 | logging.info('\n\n-------------------------------------------------------------------------------\n') 57 | logging.info(' RESULTS\n') 58 | logging.info('-------------------------------------------------------------------------------') 59 | if len(Results.state.keys()) > 0: 60 | logging.info('-------------------------------------------------------------------------------') 61 | logging.info(' STATE') 62 | logging.info(pprint.pformat(Results.state)) 63 | logging.info('-------------------------------------------------------------------------------') 64 | 65 | if len(Results.steps) > 0: 66 | logging.info('-------------------------------------------------------------------------------') 67 | logging.info(' STEPS') 68 | for step in Results.steps: 69 | logging.info(step) 70 | logging.info('-------------------------------------------------------------------------------') 71 | 72 | if len(Results.errs) > 0: 73 | logging.info('-------------------------------------------------------------------------------') 74 | logging.info(' ERRORS') 75 | logging.info(' %30s | %s' % ('Command', 'Error Details')) 76 | for err in Results.errs: 77 | logging.info(' %30s | %s' % (err['cmd'], err['comment'])) 78 | logging.info('-------------------------------------------------------------------------------') 79 | else: 80 | logging.info('-------------------------------------------------------------------------------') 81 | logging.info(' NO ERRORS!') 82 | logging.info('-------------------------------------------------------------------------------') 83 | 84 | logging.info('\n') 85 | cls.dump_results('test-results.json') 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /plmn/runner.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import inspect 4 | from utils import * 5 | from results import Results 6 | 7 | class Runner: 8 | @classmethod 9 | def run_cmd(cls, cmd): 10 | logging.debug('Executing: ' + str(cmd)) 11 | 12 | cmd_obj = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 13 | stack = inspect.stack() 14 | fname = os.path.basename(stack[1][1]) 15 | line = str(stack[1][2]) 16 | caller = stack[1][3] 17 | Results.add_step(fname + '(' + line + '): ' + caller + '(): ' + cmd) 18 | res = '\n'.join(cmd_obj.communicate()) 19 | return (res.strip()) -------------------------------------------------------------------------------- /plmn/simple_cmds.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import re 5 | from modem_cmds import * 6 | 7 | class SimpleCmds(): 8 | @classmethod 9 | def modem_sanity(cls): 10 | ModemCmds.modem_sanity() 11 | 12 | 13 | @classmethod 14 | def simple_status_cmd(cls): 15 | cls.modem_sanity() 16 | 17 | modem_idx = Results.get_state('Modem Index') 18 | assert modem_idx is not None 19 | 20 | cmd = "mmcli -m {} --simple-status".format(modem_idx) 21 | res = Runner.run_cmd(cmd).strip() 22 | 23 | logging.debug("Response: " + str(res)) 24 | 25 | simple_status = MMCLIParser.parse(res) 26 | assert simple_status is not {} 27 | 28 | Results.add_state('Simple Status', simple_status) 29 | 30 | 31 | @classmethod 32 | def simple_status_get_reg_status(cls): 33 | cls.simple_status_cmd() 34 | simple_status = Results.get_state('Simple Status') 35 | return simple_status['Status']['state'] 36 | 37 | @classmethod 38 | def simple_status_is_registered(cls): 39 | return cls.simple_status_get_reg_status() == 'registered' or cls.simple_status_get_reg_status() == 'connected' 40 | 41 | @classmethod 42 | def simple_status_is_connected(cls): 43 | return cls.simple_status_get_reg_status() == 'connected' 44 | 45 | @classmethod 46 | def simple_status_is_home(cls): 47 | if cls.simple_status_is_registered(): 48 | simple_status = Results.get_state('Simple Status') 49 | if simple_status['3GPP']['registration'] == 'home': 50 | return True 51 | return False 52 | 53 | @classmethod 54 | def simple_status_is_roaming(cls): 55 | if cls.simple_status_is_registered(): 56 | simple_status = Results.get_state('Simple Status') 57 | if simple_status['3GPP']['registration'] == 'roaming': 58 | return True 59 | return False 60 | 61 | @classmethod 62 | def _simple_connect(cls, apn): 63 | modem_idx = Results.get_state('Modem Index') 64 | assert modem_idx is not None 65 | 66 | cmd = 'mmcli -m {} --simple-connect="apn={}"'.format(modem_idx, apn) 67 | res = Runner.run_cmd(cmd).strip() 68 | 69 | time.sleep(2) 70 | 71 | cls.simple_status_cmd() 72 | 73 | @classmethod 74 | def simple_connect(cls, apn): 75 | if cls.simple_status_is_connected(): 76 | logging.debug('Modem is already connected!') 77 | elif cls.simple_status_is_registered(): 78 | logging.debug('Modem is registered on network. Connecting using APN: ' + apn) 79 | cls._simple_connect(apn) 80 | assert cls.simple_status_is_connected() 81 | else: 82 | assert 0, 'Modem not registered, cannot perform simple-connect' 83 | -------------------------------------------------------------------------------- /plmn/utils.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | # Setup debug variables. 4 | _log_lvl = 'DEBUG' 5 | 6 | # For minimal logging, use this setting: 7 | # _log_lvl = 'DEBUG' 8 | 9 | 10 | class MyFormatter(logging.Formatter): 11 | import datetime as dt 12 | 13 | converter = dt.datetime.fromtimestamp 14 | err_fmt = "%(asctime)s | ERR | %(filename)s:%(lineno)s - %(funcName)20s(): %(message)s" 15 | dbg_fmt = "%(asctime)s | DBG | %(filename)s:%(lineno)s - %(funcName)20s(): %(message)s" 16 | info_fmt = "%(message)s" 17 | 18 | def __init__(self, fmt="%(levelno)s: %(msg)s"): 19 | logging.Formatter.__init__(self, fmt) 20 | 21 | def formatTime(self, record, datefmt=None): 22 | ct = self.converter(record.created) 23 | if datefmt: 24 | s = ct.strftime(datefmt) 25 | else: 26 | t = ct.strftime("%H:%M:%S") 27 | s = "%s.%03d" % (t, record.msecs) 28 | return s 29 | 30 | def format(self, record): 31 | format_orig = self._fmt 32 | 33 | if record.levelno == logging.DEBUG: 34 | self._fmt = MyFormatter.dbg_fmt 35 | 36 | elif record.levelno == logging.INFO: 37 | self._fmt = MyFormatter.info_fmt 38 | 39 | elif record.levelno == logging.ERROR: 40 | self._fmt = MyFormatter.err_fmt 41 | 42 | result = logging.Formatter.format(self, record) 43 | self._fmt = format_orig 44 | return result 45 | 46 | 47 | # Decorator for running these functions only once. 48 | def run_once(f): 49 | def wrapper(*args, **kwargs): 50 | if not wrapper.has_run: 51 | wrapper.has_run = True 52 | return f(*args, **kwargs) 53 | wrapper.has_run = False 54 | return wrapper 55 | 56 | @run_once 57 | def setup_log_config(): 58 | logFormatter = MyFormatter() 59 | rootLogger = logging.getLogger() 60 | rootLogger.setLevel(_log_lvl) 61 | 62 | # Open new file everytime 63 | fileHandler = logging.FileHandler("test.log", mode='w') 64 | fileHandler.setFormatter(logFormatter) 65 | rootLogger.addHandler(fileHandler) 66 | 67 | def process_args(): 68 | import argparse 69 | 70 | parser = argparse.ArgumentParser('PLMN Regression Test Cases') 71 | parser.add_argument('-d', '--debug', action='store_true', help='Print debug message to screen.') 72 | args, unknown = parser.parse_known_args() 73 | 74 | if args.debug: 75 | logFormatter = MyFormatter() 76 | rootLogger = logging.getLogger() 77 | consoleHandler = logging.StreamHandler() 78 | consoleHandler.setFormatter(logFormatter) 79 | rootLogger.addHandler(consoleHandler) 80 | logging.info(' ---------------------- RUNNING TESTS IN DEBUG MODE ------------------------ ') 81 | 82 | # Return the number of arguments processed. 83 | return 1 84 | 85 | else: 86 | # Return indicating that no arguments were processed. 87 | return 0 88 | 89 | 90 | # Setup logging subsystem. 91 | setup_log_config() 92 | 93 | if __name__ == '__main__': 94 | 95 | process_args() 96 | 97 | logging.info('Info message') 98 | logging.error('Error message') 99 | logging.debug('Debug Message') 100 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | nose 2 | sphinx 3 | pyserial 4 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Learn more: https://github.com/kennethreitz/setup.py 4 | 5 | from setuptools import setup, find_packages 6 | 7 | 8 | with open('README.rst') as f: 9 | readme = f.read() 10 | 11 | with open('LICENSE') as f: 12 | license = f.read() 13 | 14 | setup( 15 | name='plmn', 16 | version='1.0.0', 17 | description='Perform Regression tests of 3G/4G Registration and Connections.', 18 | long_description=readme, 19 | author='Harsh Murari', 20 | author_email='harsh@rhoynar.com', 21 | url='https://github.com/Rhoynar/plmn-regression', 22 | license=license, 23 | packages=['plmn'], 24 | test_suite='tests' 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/at_checks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import compat 4 | import unittest 5 | import re 6 | import sys 7 | 8 | from plmn.utils import * 9 | from plmn.results import * 10 | from plmn.modem_cmds import ModemCmds 11 | from plmn.runner import * 12 | from plmn.at_cmds import * 13 | 14 | class AtCmdChecks(unittest.TestCase): 15 | 16 | def setUp(self): 17 | AtCmds.modem_sanity() 18 | # Check if modemmanager is in debug mode or socat application is installed. 19 | 20 | def test_modem_mgr_debug_mode(self): 21 | AtCmds.mm_debug_mode() 22 | 23 | def test_at_unlock(self): 24 | AtCmds.unlock_at_cmds() 25 | 26 | def test_at_basic_cmds(self): 27 | AtCmds.mm_debug_mode() 28 | AtCmds.unlock_at_cmds() 29 | 30 | # Check AT command version 31 | res = AtCmds.send_at_cmd('AT&V') 32 | assert res is not None 33 | 34 | # Check for model number 35 | res = AtCmds.send_at_cmd('AT+GMM') 36 | assert res is not None 37 | 38 | # Check for manufacturer 39 | res = AtCmds.send_at_cmd('AT+GMI') 40 | assert res is not None 41 | 42 | # Check modem capabilities. 43 | res = AtCmds.send_at_cmd('AT+GCAP') 44 | assert res is not None 45 | 46 | # Check current registration (manual or automatic) 47 | res = AtCmds.send_at_cmd('AT+COPS?') 48 | assert res is not None 49 | 50 | # Check modem firmware version. 51 | res = AtCmds.send_at_cmd('AT+CGMR') 52 | assert res is not None 53 | 54 | # Check supported registrations 55 | res = AtCmds.send_at_cmd('AT!SELRAT=?') 56 | assert res is not None 57 | 58 | # Check different PLMN profiles on modem. 59 | res = AtCmds.send_at_cmd('AT!SCACT?') 60 | assert res is not None 61 | 62 | # Check LTE Info 63 | res = AtCmds.send_at_cmd('AT!LTEINFO=?') 64 | assert res is not None 65 | 66 | # Check LTE NAS Info 67 | res = AtCmds.send_at_cmd('AT!LTENAS?') 68 | assert res is not None 69 | 70 | # Query Antenna settings configuration 71 | res = AtCmds.send_at_cmd('AT!ANTSEL=?') 72 | assert res is not None 73 | 74 | # Query Supported Bands. 75 | res = AtCmds.send_at_cmd('AT!BAND=?') 76 | assert res is not None 77 | 78 | # Query current band 79 | res = AtCmds.send_at_cmd('AT!GETBAND?') 80 | assert res is not None 81 | assert 'No Service' not in res, 'AT Command GETBAND reporting no service' 82 | 83 | # Query operational status 84 | res = AtCmds.send_at_cmd('AT!GSTATUS?') 85 | assert res is not None 86 | 87 | # Query Modem system indication mode. 88 | res = AtCmds.send_at_cmd('AT^MODE?') 89 | assert res is not None 90 | 91 | # Query Provisioned Network List. 92 | res = AtCmds.send_at_cmd('AT!NVPLMN?') 93 | assert res is not None 94 | 95 | # Query if PS (Packet Data Service) mode is enabled. 96 | res = AtCmds.send_at_cmd('AT!SELMODE?') 97 | assert res is not None 98 | assert 'PS' in res 99 | 100 | # Query currently configured profile details. 101 | res = AtCmds.send_at_cmd('AT+CGDCONT?') 102 | assert res is not None 103 | 104 | 105 | @unittest.skip('Skip 3GPP scanning. Enable this for manual run.') 106 | def test_at_3gpp_scan(self): 107 | AtCmds.perform_3gpp_scan() 108 | 109 | @unittest.skip('Skip Auto Register. Enable this for manual run.') 110 | def test_at_auto_register(self): 111 | AtCmds.perform_auto_register() 112 | 113 | @unittest.skip('Skip Manual Register Test on a given Network for regression. Enable this for manual run.') 114 | def test_at_manual_register(self): 115 | AtCmds.perform_manual_register('AT&T') 116 | 117 | if __name__ == '__main__': 118 | nargs = process_args() 119 | unittest.main(argv=sys.argv[nargs:], exit=False) 120 | Results.print_results() 121 | -------------------------------------------------------------------------------- /tests/compat.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 4 | -------------------------------------------------------------------------------- /tests/daemons_check.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import compat 4 | import unittest 5 | import sys 6 | 7 | from plmn.results import * 8 | from plmn.runner import * 9 | 10 | 11 | 12 | class DaemonChecks(unittest.TestCase): 13 | def required_services(self): 14 | ps_ef = Runner.run_cmd('ps -ef') 15 | if 'ModemManager' not in ps_ef: 16 | Results.add_error('ps -ef', 'Modem Manager is not running. Start using: sudo start modemmanager') 17 | 18 | if 'NetworkManager' not in ps_ef: 19 | Results.add_error('ps -ef', 'Network Manager is not running. Start using: sudo start network-manager') 20 | 21 | def wwan_interfaces(self): 22 | ifcfg = Runner.run_cmd('ifconfig -a') 23 | if 'wwan' not in ifcfg: 24 | Results.add_error('ifconfig -a', 'wwan interface is not enumerated. Please restart network-manager using: sudo stop network-manager && sudo start network-manager') 25 | 26 | def test_daemons(self): 27 | self.required_services() 28 | self.wwan_interfaces() 29 | 30 | if __name__ == '__main__': 31 | nargs = process_args() 32 | unittest.main(argv=sys.argv[nargs:], exit=False) 33 | Results.print_results() 34 | -------------------------------------------------------------------------------- /tests/modem_checks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import compat 4 | import unittest 5 | import sys 6 | 7 | from plmn.results import * 8 | 9 | from plmn.modem_cmds import ModemCmds 10 | 11 | 12 | class ModemChecks(unittest.TestCase): 13 | def test_mmcli_cmd_present(self): 14 | ModemCmds.mmcli_cmd_present() 15 | 16 | def test_list_modems(self): 17 | ModemCmds.list_modems() 18 | 19 | def test_modem_enabled(self): 20 | ModemCmds.modem_enabled() 21 | 22 | def test_modem_info(self): 23 | ModemCmds.modem_info() 24 | 25 | if __name__ == '__main__': 26 | nargs = process_args() 27 | unittest.main(argv=sys.argv[nargs:], exit=False) 28 | Results.print_results() 29 | -------------------------------------------------------------------------------- /tests/network_register_atnt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import compat 5 | import sys 6 | 7 | from plmn.network_checks import * 8 | 9 | class NetworkRegisterAtnt(unittest.TestCase): 10 | def test_register_and_connect_on_atnt(self): 11 | NetworkChecks.network_register('AT&T', 'broadband') 12 | NetworkChecks.network_connect('AT&T', 'broadband') 13 | 14 | if __name__ == '__main__': 15 | nargs = process_args() 16 | unittest.main(argv=sys.argv[nargs:], exit=False) 17 | Results.print_results() 18 | -------------------------------------------------------------------------------- /tests/network_register_verizon.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import compat 5 | import sys 6 | from plmn.network_checks import * 7 | 8 | class NetworkRegisterVerizon(unittest.TestCase): 9 | def test_register_on_verizon(self): 10 | NetworkChecks.network_register('Verizon', 'vzwinternet') 11 | NetworkChecks.network_connect('Verizon', 'vzwinternet') 12 | 13 | if __name__ == '__main__': 14 | nargs = process_args() 15 | unittest.main(argv=sys.argv[nargs:], exit=False) 16 | Results.print_results() 17 | -------------------------------------------------------------------------------- /tests/network_register_worldsim.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import compat 5 | import sys 6 | 7 | from plmn.network_checks import * 8 | 9 | class NetworkRegisterAtnt(unittest.TestCase): 10 | def test_register_and_connect_on_atnt(self): 11 | NetworkChecks.network_register('WorldSim', 'mobiledata') 12 | NetworkChecks.network_connect('WorldSim', 'mobiledata') 13 | 14 | if __name__ == '__main__': 15 | nargs = process_args() 16 | unittest.main(argv=sys.argv[nargs:], exit=False) 17 | Results.print_results() 18 | -------------------------------------------------------------------------------- /tests/python_checks.py: -------------------------------------------------------------------------------- 1 | import re 2 | import unittest 3 | import sys 4 | 5 | import compat 6 | from plmn.results import * 7 | from plmn.runner import * 8 | 9 | class PythonChecks(unittest.TestCase): 10 | def test_python_location(self): 11 | python_exec = Runner.run_cmd('which python').strip() 12 | 13 | if len(python_exec) is 0: 14 | Results.add_error('which python', 'Python not installed. Please install python using: sudo apt-get install python2.7') 15 | else: 16 | Results.add_state('Python Exec', python_exec) 17 | 18 | def test_python_version(self): 19 | python_ver = Runner.run_cmd('python --version') 20 | python_ver_major = re.findall(r'[0-9]+', python_ver)[0] 21 | python_ver_minor = re.findall(r'[0-9]+', python_ver)[1] 22 | # Suite is developed with Python 2.7+ in mind. 23 | if int(python_ver_major) != 2 or int(python_ver_minor) < 7: 24 | Results.add_error('Python 2.7+ version not present. Please install latest python 2.7 using: sudo apt-get install python2.7') 25 | else: 26 | Results.add_state('Python Version', python_ver.strip()) 27 | Results.add_state('Python Major Version', python_ver_major.strip()) 28 | Results.add_state('Python Minor Version', python_ver_minor.strip()) 29 | 30 | @unittest.skip('Not required for regression (Sudo is not required)') 31 | def test_check_sudo_permissions(self): 32 | username = os.getenv('SUDO_USER') 33 | if username is None: 34 | Results.add_error('env | grep SUDO_USER', 'Program needs to be run with sudo permissions.') 35 | else: 36 | Results.add_state('SUDO_USER', username.strip()) 37 | 38 | @unittest.skip('Not required for regression (PIP is not required for now)') 39 | def test_check_pip(self): 40 | pip = Runner.run_cmd('which pip').strip() 41 | 42 | if len(pip) == 0: 43 | Results.add_error('which pip', 'Python Package Manager (PIP) not present. Please install using: sudo apt-get install python-pip') 44 | else: 45 | Results.add_state('pip', pip) 46 | 47 | @unittest.skip('Not required for regression (Pyserial is not required)') 48 | def test_pip_pacakages(self): 49 | # Check if required pip packages exist 50 | pip_pkgs = Runner.run_cmd('pip freeze') 51 | 52 | # For now pyserial is the only required package, 53 | # others may be required in future. 54 | if ('pyserial' not in pip_pkgs.lower()): 55 | Results.add_error('pip freeze | grep pyserial', 'PySerial package not found. Please install using: pip install pyserial') 56 | else: 57 | Results.add_state('PySerial', True) 58 | 59 | if __name__ == '__main__': 60 | nargs = process_args() 61 | unittest.main(argv=sys.argv[nargs:], exit=False) 62 | Results.print_results() 63 | 64 | -------------------------------------------------------------------------------- /tests/sim_checks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | import compat 5 | import sys 6 | 7 | from plmn.results import * 8 | from plmn.modem_cmds import ModemCmds 9 | 10 | 11 | class SimChecks(unittest.TestCase): 12 | def test_sim_present(self): 13 | ModemCmds.sim_present() 14 | 15 | def test_sim_unlocked(self): 16 | ModemCmds.sim_unlocked() 17 | 18 | def test_sim_registered(self): 19 | ModemCmds.sim_registered() 20 | 21 | if __name__ == '__main__': 22 | nargs = process_args() 23 | unittest.main(argv=sys.argv[nargs:], exit=False) 24 | Results.print_results() 25 | -------------------------------------------------------------------------------- /tests/simple_cmd_checks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import compat 4 | import unittest 5 | import sys 6 | 7 | from plmn.utils import * 8 | from plmn.results import * 9 | from plmn.modem_cmds import * 10 | from plmn.simple_cmds import * 11 | 12 | class SimpleCmdChecks(unittest.TestCase): 13 | def test_simple_status_cmd(self): 14 | SimpleCmds.simple_status_cmd() 15 | assert Results.get_state('Simple Status') is not None 16 | 17 | def test_simple_status_get_reg_status(self): 18 | SimpleCmds.simple_status_get_reg_status() 19 | 20 | def test_simple_status_is_registered(self): 21 | assert SimpleCmds.simple_status_is_registered() is True 22 | 23 | def test_simple_status_is_home(self): 24 | assert SimpleCmds.simple_status_is_home() is True 25 | assert SimpleCmds.simple_status_is_roaming() is False 26 | 27 | @unittest.skip('Skipping this test since this is only applicable in connected state') 28 | def test_simple_status_is_connected(self): 29 | assert SimpleCmds.simple_status_is_connected() is True 30 | 31 | @unittest.skip('Skipping this as this is only applicable for Roaming scenario') 32 | def test_simple_status_is_roaming(self): 33 | assert SimpleCmds.simple_status_is_roaming() is True 34 | 35 | 36 | if __name__ == '__main__': 37 | nargs = process_args() 38 | unittest.main(argv=sys.argv[nargs:], exit=False) 39 | Results.print_results() 40 | -------------------------------------------------------------------------------- /tests/test_regression.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import at_checks 4 | import daemons_check 5 | import modem_checks 6 | import python_checks 7 | import sim_checks 8 | import simple_cmd_checks 9 | 10 | from plmn.utils import * 11 | from plmn.results import * 12 | 13 | if __name__ == '__main__': 14 | nargs = process_args() 15 | 16 | suite = unittest.TestSuite() 17 | 18 | # Add all regression test-cases to this test-suite. 19 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(python_checks.PythonChecks)) 20 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(daemons_check.DaemonChecks)) 21 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(modem_checks.ModemChecks)) 22 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(at_checks.AtCmdChecks)) 23 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(sim_checks.SimChecks)) 24 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(simple_cmd_checks.SimpleCmdChecks)) 25 | 26 | # Run the regression suite. 27 | unittest.TextTestRunner().run(suite) 28 | 29 | # Print final system state. 30 | Results.print_results() 31 | --------------------------------------------------------------------------------