A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
test-test.py
Go to the documentation of this file.
1#! /usr/bin/env python3
2#
3# Copyright (c) 2014 Siddharth Santurkar
4#
5# SPDX-License-Identifier: GPL-2.0-only
6#
7
8# NOTE: Run this script with the Python3 interpreter if the python3 compatibility
9# of the ns-3 unit test runner needs to be tested.
10
11# The following options of test.py are being tested for portability by this script.
12# To see the options supported by this script, run with the -h option on the command line
13#
14# -h, --help show this help message and exit
15# -b BUILDPATH, --buildpath=BUILDPATH
16# specify the path where ns-3 was built (defaults to the
17# build directory for the current variant)
18# -c KIND, --constrain=KIND
19# constrain the test-runner by kind of test
20# -d, --duration print the duration of each test suite and example
21# -e EXAMPLE, --example=EXAMPLE
22# specify a single example to run (no relative path is
23# needed)
24# -u, --update-data If examples use reference data files, get them to re-
25# generate them
26# -f FULLNESS, --fullness=FULLNESS
27# choose the duration of tests to run: QUICK, EXTENSIVE,
28# or TAKES_FOREVER, where EXTENSIVE includes QUICK and
29# TAKES_FOREVER includes QUICK and EXTENSIVE (only QUICK
30# tests are run by default)
31# -g, --grind run the test suites and examples using valgrind
32# -k, --kinds print the kinds of tests available
33# -l, --list print the list of known tests
34# -m, --multiple report multiple failures from test suites and test
35# cases
36# -n, --no-build do not run ns3 before starting testing
37# -p PYEXAMPLE, --pyexample=PYEXAMPLE
38# specify a single python example to run (with relative
39# path)
40# -r, --retain retain all temporary files (which are normally
41# deleted)
42# -s TEST-SUITE, --suite=TEST-SUITE
43# specify a single test suite to run
44# -t TEXT-FILE, --text=TEXT-FILE
45# write detailed test results into TEXT-FILE.txt
46# -v, --verbose print progress and informational messages
47# -w HTML-FILE, --web=HTML-FILE, --html=HTML-FILE
48# write detailed test results into HTML-FILE.html
49# -x XML-FILE, --xml=XML-FILE
50# write detailed test results into XML-FILE.xml
51
52
53from __future__ import print_function
54
55import sys
56
57from TestBase import TestBaseClass
58
59
60def main(argv):
61 """
62 Prepares test cases and executes
63 """
64 test_cases = [
65 "",
66 "-h",
67 "--help",
68 "-b build/",
69 "--buildpath=build/",
70 "-c performance",
71 "--constrain=performance",
72 "-d",
73 "--duration",
74 "-e socket-options-ipv6",
75 "--example=socket-options-ipv6",
76 "-u",
77 "--update-data",
78 "-f EXTENSIVE",
79 "--fullness=EXTENSIVE",
80 "-g",
81 "--grind",
82 "-l",
83 "--list",
84 "-m",
85 "--multiple",
86 "-n",
87 "--no-build",
88 "-p first",
89 "--pyexample=first",
90 "-r",
91 "--retain",
92 "-s ns3-tcp-state",
93 "--suite=ns3-tcp-state",
94 "-t t_opt.txt",
95 "--text=t_opt.txt && rm t_opt.txt",
96 "-v",
97 "--verbose",
98 "-w t_opt.html && rm t_opt.html",
99 "--web=t_opt.html && rm t_opt.html",
100 "--html=t_opt.html && rm t_opt.html",
101 "-x t_opt.xml && rm t_opt.xml",
102 "--xml=t_opt.xml && rm t_opt.xml",
103 ]
104
105 configure_string = sys.executable + " ns3 configure --enable-tests --enable-examples"
106 clean_string = sys.executable + " ns3 clean"
107 cmd_execute_list = [
108 "%s && %s test.py %s && %s" % (configure_string, sys.executable, option, clean_string)
109 for option in test_cases
110 ]
111 runner = TestBaseClass(argv[1:], "Test suite for the ns-3 unit test runner", "test-py")
112 return runner.runtests(cmd_execute_list)
113
114
115if __name__ == "__main__":
116 sys.exit(main(sys.argv))
TestBaseClass class.
Definition TestBase.py:50