aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/bash/function/docs.sh22
-rwxr-xr-xresources/tools/doc_gen/gen_rst.py50
-rw-r--r--resources/tools/doc_gen/src/index.rst1
-rw-r--r--resources/tools/doc_gen/src/tests.trex.perf.rst2
4 files changed, 54 insertions, 21 deletions
diff --git a/resources/libraries/bash/function/docs.sh b/resources/libraries/bash/function/docs.sh
index be3f9861ce..c589416a37 100644
--- a/resources/libraries/bash/function/docs.sh
+++ b/resources/libraries/bash/function/docs.sh
@@ -47,12 +47,13 @@ function generate_docs () {
pushd "${TOOLS_DIR}"/doc_gen || die "Pushd failed!"
- WORKING_DIR="tmp"
BUILD_DIR="_build"
# Remove the old build:
rm -rf ${BUILD_DIR} || true
- rm -rf ${WORKING_DIR} || true
+ rm -rf /tmp/tmp-csit* || true
+
+ export WORKING_DIR=$(mktemp -d /tmp/tmp-csitXXX) || die "export failed"
# Create working directories
mkdir -p "${BUILD_DIR}" || die "Mkdir failed!"
@@ -81,17 +82,12 @@ function generate_docs () {
die "Touch index.robot file failed!"
}
- # Due to hoststack tests having dots in the name of suite, tests will become
- # disabled as spihnxdoc cannot properly work with the path. gen_rst
- # is generating dots scheme. The solution is to rename suites as
- # having dots is misleading with robot framework naming conventions.
-
- #from_dir="${CSIT_DIR}/tests/"
- #to_dir="${WORKING_DIR}/tests/"
- #dirs="${from_dir} ${to_dir}"
- #rsync -ar --include='*/' --include '*.robot' --exclude '*' ${dirs} || {
- # die "rSync failed!"
- #}
+ from_dir="${CSIT_DIR}/tests/"
+ to_dir="${WORKING_DIR}/tests/"
+ dirs="${from_dir} ${to_dir}"
+ rsync -ar --include='*/' --include '*.robot' --exclude '*' ${dirs} || {
+ die "rSync failed!"
+ }
find ${WORKING_DIR}/ -type d -exec echo {} \; -exec touch {}/__init__.py \;
diff --git a/resources/tools/doc_gen/gen_rst.py b/resources/tools/doc_gen/gen_rst.py
index 1cb1005a50..d3f7d96c58 100755
--- a/resources/tools/doc_gen/gen_rst.py
+++ b/resources/tools/doc_gen/gen_rst.py
@@ -10,13 +10,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-
-from os import walk, listdir
+from os import walk, listdir, scandir, environ
from os.path import isfile, isdir, join, getsize
-# Temporary working directory. It is created and deleted by run_doc.sh
-WORKING_DIR = u"tmp"
+# Temporary working directory. It is created and deleted by docs.sh
+WORKING_DIR = environ.get("WORKING_DIR")
# Directory with resources to be documented.
RESOURCES_DIR = u"resources"
@@ -83,7 +81,7 @@ def get_files(path, extension):
for root, dirs, files in walk(path):
for filename in files:
if extension:
- if filename.endswith(extension):
+ if filename.endswith(extension) and u"__init__" not in filename:
file_list.append(join(root, filename))
else:
file_list.append(join(root, filename))
@@ -126,6 +124,34 @@ def create_rst_file_names_set(files, start):
return file_names
+def add_nested_folders_in_rst_set(file_names, path):
+ """Add RST files from folders where are only folders without tests.
+
+ :param file_names: List of all files to be documented with path beginning
+ in the working directory.
+ :param path: Path where it starts adding missing RST files.
+ :type file_names: list
+ :type path: str
+ """
+
+ # When we split directory tree by "/" we don't need to create RST file in
+ # folders in depth <= 5. It's because the WORKING_DIR folder structure i
+ # as following:
+ # /tmp/tmp-csitXXX/tests/<subject_of_test>/<type_of_test>/<what_is_tested>
+ # That splits to ie:
+ # ['', 'tmp', 'tmp-csitXXX', 'tests', 'vpp', 'device', 'container_memif']
+ # We need to generate RST files for folders after <subject_of_test> which
+ # is in depth > 5
+
+ for directory in fast_scandir(path):
+ dir_list = directory.split(u"/")
+ if len(dir_list) > 5:
+ # cut ['', 'tmp', 'tmp-csitXXX']
+ dir_rst = u".".join(dir_list[3:]) + u".rst"
+ if dir_rst not in file_names and u"__pycache__" not in dir_rst:
+ file_names.add(dir_rst)
+
+
def scan_dir(path):
"""Create a list of files and directories in the given directory.
@@ -157,8 +183,8 @@ def write_toc(fh, path, dirs):
:type dirs: list
"""
fh.write(rst_toc)
- for dir in dirs:
- fh.write(f" {u'.'.join(path)}.{dir}\n")
+ for directory in dirs:
+ fh.write(f" {u'.'.join(path)}.{directory}\n")
def write_module_title(fh, module_name):
@@ -274,12 +300,20 @@ def generate_tests_rst_files():
tests = get_files(PATH_TESTS, RF_EXT)
file_names = create_rst_file_names_set(tests, TESTS_DIR)
+ add_nested_folders_in_rst_set(file_names, PATH_TESTS)
generate_rf_rst_files(
file_names, incl_suite_setup=True, incl_variables=True
)
+def fast_scandir(dirname):
+ subfolders = [f.path for f in scandir(dirname) if f.is_dir()]
+ for dirname in list(subfolders):
+ subfolders.extend(fast_scandir(dirname))
+ return subfolders
+
+
if __name__ == u"__main__":
# Generate all rst files:
diff --git a/resources/tools/doc_gen/src/index.rst b/resources/tools/doc_gen/src/index.rst
index 39f1d38fca..82f01db0c8 100644
--- a/resources/tools/doc_gen/src/index.rst
+++ b/resources/tools/doc_gen/src/index.rst
@@ -10,6 +10,7 @@ Contents
resources.libraries.python
resources.libraries.robot
tests.dpdk.perf
+ tests.trex.perf
tests.vpp.device
tests.vpp.perf
indices
diff --git a/resources/tools/doc_gen/src/tests.trex.perf.rst b/resources/tools/doc_gen/src/tests.trex.perf.rst
new file mode 100644
index 0000000000..55ab087177
--- /dev/null
+++ b/resources/tools/doc_gen/src/tests.trex.perf.rst
@@ -0,0 +1,2 @@
+TREX Performance Tests
+======================