Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: tc-testing: Update README and TODO

Signed-off-by: Brenda J. Butler <bjb@mojatatu.com>
Acked-by: Lucas Bates <lucasb@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Brenda J. Butler and committed by
David S. Miller
95ce14c3 c25e4736

+179 -19
+156 -17
tools/testing/selftests/tc-testing/README
··· 14 14 15 15 * The kernel must have network namespace support 16 16 17 - * The kernel must have veth support available, as a veth pair is created 17 + * The kernel must have veth support available, as a veth pair is created 18 18 prior to running the tests. 19 19 20 - * All tc-related features must be built in or available as modules. 21 - To check what is required in current setup run: 20 + * All tc-related features being tested must be built in or available as 21 + modules. To check what is required in current setup run: 22 22 ./tdc.py -c 23 23 24 24 Note: ··· 44 44 RUNNING TDC 45 45 ----------- 46 46 47 - To use tdc, root privileges are required. tdc will not run otherwise. 47 + To use tdc, root privileges are required. This is because the 48 + commands being tested must be run as root. The code that enforces 49 + execution by root uid has been moved into a plugin (see PLUGIN 50 + ARCHITECTURE, below). 48 51 49 - All tests are executed inside a network namespace to prevent conflicts 50 - within the host. 52 + If nsPlugin is linked, all tests are executed inside a network 53 + namespace to prevent conflicts within the host. 51 54 52 55 Running tdc without any arguments will run all tests. Refer to the section 53 56 on command line arguments for more information, or run: ··· 60 57 TAP (Test Anything Protocol) format when they are done. If tests fail, 61 58 output captured from the failing test will be printed immediately following 62 59 the failed test in the TAP output. 60 + 61 + 62 + OVERVIEW OF TDC EXECUTION 63 + ------------------------- 64 + 65 + One run of tests is considered a "test suite" (this will be refined in the 66 + future). A test suite has one or more test cases in it. 67 + 68 + A test case has four stages: 69 + 70 + - setup 71 + - execute 72 + - verify 73 + - teardown 74 + 75 + The setup and teardown stages can run zero or more commands. The setup 76 + stage does some setup if the test needs it. The teardown stage undoes 77 + the setup and returns the system to a "neutral" state so any other test 78 + can be run next. These two stages require any commands run to return 79 + success, but do not otherwise verify the results. 80 + 81 + The execute and verify stages each run one command. The execute stage 82 + tests the return code against one or more acceptable values. The 83 + verify stage checks the return code for success, and also compares 84 + the stdout with a regular expression. 85 + 86 + Each of the commands in any stage will run in a shell instance. 63 87 64 88 65 89 USER-DEFINED CONSTANTS ··· 100 70 Example: 101 71 $TC qdisc add dev $DEV1 ingress 102 72 73 + The NAMES values are used to substitute into the commands in the test cases. 74 + 103 75 104 76 COMMAND LINE ARGUMENTS 105 77 ---------------------- 106 78 107 79 Run tdc.py -h to see the full list of available arguments. 108 80 109 - -p PATH Specify the tc executable located at PATH to be used on this 110 - test run 111 - -c Show the available test case categories in this test file 112 - -c CATEGORY Run only tests that belong to CATEGORY 113 - -f FILE Read test cases from the JSON file named FILE 114 - -l [CATEGORY] List all test cases in the JSON file. If CATEGORY is 115 - specified, list test cases matching that category. 116 - -s ID Show the test case matching ID 117 - -e ID Execute the test case identified by ID 118 - -i Generate unique ID numbers for test cases with no existing 119 - ID number 81 + usage: tdc.py [-h] [-p PATH] [-D DIR [DIR ...]] [-f FILE [FILE ...]] 82 + [-c [CATG [CATG ...]]] [-e ID [ID ...]] [-l] [-s] [-i] [-v] 83 + [-d DEVICE] [-n NS] [-V] 84 + 85 + Linux TC unit tests 86 + 87 + optional arguments: 88 + -h, --help show this help message and exit 89 + -p PATH, --path PATH The full path to the tc executable to use 90 + -v, --verbose Show the commands that are being run 91 + -d DEVICE, --device DEVICE 92 + Execute the test case in flower category 93 + 94 + selection: 95 + select which test cases: files plus directories; filtered by categories 96 + plus testids 97 + 98 + -D DIR [DIR ...], --directory DIR [DIR ...] 99 + Collect tests from the specified directory(ies) 100 + (default [tc-tests]) 101 + -f FILE [FILE ...], --file FILE [FILE ...] 102 + Run tests from the specified file(s) 103 + -c [CATG [CATG ...]], --category [CATG [CATG ...]] 104 + Run tests only from the specified category/ies, or if 105 + no category/ies is/are specified, list known 106 + categories. 107 + -e ID [ID ...], --execute ID [ID ...] 108 + Execute the specified test cases with specified IDs 109 + 110 + action: 111 + select action to perform on selected test cases 112 + 113 + -l, --list List all test cases, or those only within the 114 + specified category 115 + -s, --show Display the selected test cases 116 + -i, --id Generate ID numbers for new test cases 117 + 118 + netns: 119 + options for nsPlugin(run commands in net namespace) 120 + 121 + -n NS, --namespace NS 122 + Run commands in namespace NS 123 + 124 + valgrind: 125 + options for valgrindPlugin (run command under test under Valgrind) 126 + 127 + -V, --valgrind Run commands under valgrind 128 + 129 + 130 + PLUGIN ARCHITECTURE 131 + ------------------- 132 + 133 + There is now a plugin architecture, and some of the functionality that 134 + was in the tdc.py script has been moved into the plugins. 135 + 136 + The plugins are in the directory plugin-lib. The are executed from 137 + directory plugins. Put symbolic links from plugins to plugin-lib, 138 + and name them according to the order you want them to run. 139 + 140 + Example: 141 + 142 + bjb@bee:~/work/tc-testing$ ls -l plugins 143 + total 4 144 + lrwxrwxrwx 1 bjb bjb 27 Oct 4 16:12 10-rootPlugin.py -> ../plugin-lib/rootPlugin.py 145 + lrwxrwxrwx 1 bjb bjb 25 Oct 12 17:55 20-nsPlugin.py -> ../plugin-lib/nsPlugin.py 146 + -rwxr-xr-x 1 bjb bjb 0 Sep 29 15:56 __init__.py 147 + 148 + The plugins are a subclass of TdcPlugin, defined in TdcPlugin.py and 149 + must be called "SubPlugin" so tdc can find them. They are 150 + distinguished from each other in the python program by their module 151 + name. 152 + 153 + This base class supplies "hooks" to run extra functions. These hooks are as follows: 154 + 155 + pre- and post-suite 156 + pre- and post-case 157 + pre- and post-execute stage 158 + adjust-command (runs in all stages and receives the stage name) 159 + 160 + The pre-suite hook receives the number of tests and an array of test ids. 161 + This allows you to dump out the list of skipped tests in the event of a 162 + failure during setup or teardown stage. 163 + 164 + The pre-case hook receives the ordinal number and test id of the current test. 165 + 166 + The adjust-command hook receives the stage id (see list below) and the 167 + full command to be executed. This allows for last-minute adjustment 168 + of the command. 169 + 170 + The stages are identified by the following strings: 171 + 172 + - pre (pre-suite) 173 + - setup 174 + - command 175 + - verify 176 + - teardown 177 + - post (post-suite) 178 + 179 + 180 + To write a plugin, you need to inherit from TdcPlugin in 181 + TdcPlugin.py. To use the plugin, you have to put the 182 + implementation file in plugin-lib, and add a symbolic link to it from 183 + plugins. It will be detected at run time and invoked at the 184 + appropriate times. There are a few examples in the plugin-lib 185 + directory: 186 + 187 + - rootPlugin.py: 188 + implements the enforcement of running as root 189 + - nsPlugin.py: 190 + sets up a network namespace and runs all commands in that namespace 191 + - valgrindPlugin.py 192 + runs each command in the execute stage under valgrind, 193 + and checks for leaks. 194 + This plugin will output an extra test for each test in the test file, 195 + one is the existing output as to whether the test passed or failed, 196 + and the other is a test whether the command leaked memory or not. 197 + (This one is a preliminary version, it may not work quite right yet, 198 + but the overall template is there and it should only need tweaks.) 120 199 121 200 122 201 ACKNOWLEDGEMENTS
+23 -2
tools/testing/selftests/tc-testing/TODO.txt
··· 5 5 6 6 - Add support for multiple versions of tc to run successively 7 7 8 - - Improve error messages when tdc aborts its run 8 + - Improve error messages when tdc aborts its run. Partially done - still 9 + need to better handle problems in pre- and post-suite. 9 10 10 - - Allow tdc to write its results to file 11 + - Use python logger module for debug/verbose output 12 + 13 + - Allow tdc to write its results to file. 14 + Maybe use python logger module for this too. 15 + 16 + - A better implementation of the "hooks". Currently, every plugin 17 + will attempt to run a function at every hook point. Could be 18 + changed so that plugin __init__ methods will register functions to 19 + be run in the various predefined times. Then if a plugin does not 20 + require action at a specific point, no penalty will be paid for 21 + trying to run a function that will do nothing. 22 + 23 + - Proper exception handling - make an exception class and use it 24 + 25 + - a TestCase class, for easier testcase handling, searching, comparison 26 + 27 + - a TestSuite class 28 + and a way to configure a test suite, 29 + to automate running multiple "test suites" with different requirements 30 + 31 + - super simple test case example using ls, touch, etc