Skip to contentSkip to conversation

doc: add tests catalog page

PATCH Superseded Andrea Cervesato 3 participants 3 messages Feb 5, 2025 – Feb 6, 2025

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 doc: add tests catalog page

From: Andrea Cervesato <[email protected]>

Add a new section in the LTP documentation website, where we list all tests which are available in LTP and supporting new API.

---
This patch-set is meant to introduce a new page in the LTP
documentation, showing tests which are currently available with their description and information.
---
Changes in v4:
- show maximum runtime with timeout text
- correct timeout text
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- fix table widths alignment
- add warning at the beginning of the test catalog
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- add setup
- cleanup code
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 doc/.gitignore             |   1 +
 doc/conf.py                | 276 ++++++++++++++++++++++++++++++++++++++++++++-
 doc/index.rst              |   4 +
 doc/users/test_catalog.rst |   7 ++
 4 files changed, 284 insertions(+), 4 deletions(-)
doc/.gitignore +1 -0
index 173179852070f25acb6a729975df9d52d171b422..2b05a1ec368573778cfe7ee6a1cb5d6c5ecb0b5a 100644
@@ -1,4 +1,5 @@
 html/
 build/
 _static/syscalls.rst
+_static/tests.rst
 syscalls.tbl
doc/conf.py +272 -4

321 lines not on this page · raw message

doc/index.rst +4 -0
index b907ac36f0c9328c576d25dee5777d808c2e5119..c00a59d31345142e78deb74eacc9da2941291d76 100644
@@ -11,6 +11,7 @@
    users/setup_tests
    users/supported_systems
    users/stats
+   users/test_catalog
 
 .. toctree::
    :maxdepth: 3
@@ -54,6 +55,9 @@ For users
 :doc:`users/stats`
    Some LTP statistics
 
+:doc:`users/test_catalog`
+   The LTP test catalog
+
 For developers
 --------------
 
doc/users/test_catalog.rst new file +7 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b1674f9dc614ea04a89cf084e92b72c6862a5f48
@@ -0,0 +1,7 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Test catalog
+============
+
+.. include:: ../_static/tests.rst
+

---
base-commit: 07d79673a65f0f5f06c19507df4a15ceab22f2f9
change-id: 20250131-doc_tests_list-1b82f51e43fd

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Andrea,

generally LGTM, thanks for working on it.

1) clickable (referenced) keys

I asked keys (e.g. needs_root) to be referenced to be clickable to the relevant API. This allows reader to click and read relevant info about the key.

2) git commit description of referenced tags

Perl code was able to take git description. E.g. instead of plain "d2f007dbe7e4" it got:
d2f007dbe7e4 ("userns: also map extents in the reverse map to kernel IDs")

I understand you don't want to bother with it, but it was more descriptive. I guess using github API or simple fetching web page on git.kernel.org and take content of "commit-subject" would work, but it'd be slow and we could hit some access limits from the provider. I can have look into this afterwards (I don't want to block this issue).

3) CSS fix of some tables

Code on tables with keys and values (e.g. needs_kconfigs) looks ugly, when there are more items. E.g. needs_kconfigs at icmp_rate_limit01, which has:
CONFIG_VETH
CONFIG_USER_NS=y
CONFIG_NET_NS=y

The ugly part is margin-bottom: 24px; from class="line-block". Single item line uses <p></p>.

I looked into docs (https://tables-with-sphinx.readthedocs.io/en/latest/),
but than I realized it's a simple CSS issue. It can be fixed by adding into doc/_static/custom.css:

/* remove margin for multiline cells */

.rst-content table td div.line-block {
    margin-bottom: 0;
}

I can send it as a separate patch if you don't want to bother with it.

doc/conf.py def generate_syscalls_stats(_): · line 263

Quoted 4 lines
doc/conf.py +4 -0
+def _generate_tags_table(tags):
+    """
+    Generate the tags table from tags hash.
+    """

nit: conf.py is getting slightly big. I need to remember that public functions are these which generates stats.html and test_catalog.html. Maybe having functions or setup() which references them on the top would help reader to start with relevant code.
...

doc/conf.py def generate_syscalls_stats(_): · line 333

Quoted 5 lines
doc/conf.py +5 -0
+def _generate_setup_table(keys):
+    """
+    Generate the table with test setup configuration.
+    """
+    exclude = [

This list is slightly confusing for a reader. I would expect there will be no options in generated docs nor tags. Obviously they are processed separately.

doc/conf.py def generate_syscalls_stats(_): · line 336

Quoted 3 lines
doc/conf.py +3 -0
+        'child_needs_reinit',
+        'needs_checkpoints',
+        'resource_files',

Maybe add this? e.g. creat07 requires also creat07_child. That might be useful for somebody to see that test needs another LTP binary.

Quoted 1 line

+ 'save_restore',

This is useful, it shows which /proc/sys files are touched.

doc/conf.py def generate_syscalls_stats(_): · line 339

Quoted 2 lines
doc/conf.py +2 -0
+        'forks_child',
+        'hugepages',

I know that these are cryptic:
.hugepages = {1, TST_NEEDS},
.hugepages = {TST_NO_HUGEPAGES},
but trying to filter out info may cause people prefer using 'git grep' sources instead of searching in 'ctrl+F' in this nice documentation.

doc/conf.py def generate_syscalls_stats(_): · line 342

Quoted 3 lines
doc/conf.py +3 -0
+        'options',
+        'timeout',
+        'runtime',

Cyril already asked for runtime, IMHO important to have.

Quoted 1 line

+ 'ulimit',

Also ulimit is useful.

Quoted 4 lines
doc/conf.py +4 -0
+        'fname',
+        'tags',
+        'doc',
+    ]

...

doc/conf.py def generate_syscalls_stats(_): · line 430

Quoted 11 lines
doc/conf.py +11 -0
+def generate_test_catalog(_):
+    """
+    Generate the test catalog from ltp.json metadata file.
+    """
+    output = '_static/tests.rst'
+    metadata_file = '../metadata/ltp.json'
+    text = [
+        '.. warning::',
+        '    The following catalog has been generated using LTP metadata',
+        '    which is including only tests using the new :ref:`LTP C API`.',
+        '    For this reason, some old tests might be missing from the list.',

Besides the fact that *all* tests using legacy API are skipped I don't think user is interested why they aren't included. I would just note that only tests which use new :ref:LTP C API are here listed.

Quoted 21 lines
doc/conf.py +21 -0
+        ''
+    ]
+
+    metadata = None
+    with open(metadata_file, 'r', encoding='utf-8') as data:
+        metadata = json.load(data)
+
+    timeout_def = metadata['defaults']['timeout']
+
+    for test_name, conf in metadata['tests'].items():
+        text.extend([
+            f'{test_name}',
+            len(test_name) * '-'
+        ])
+
+        # source url location
+        test_fname = conf.get('fname', None)
+        if test_fname:
+            text.extend([
+                '',
+                f"`source <{ltp_repo_base_url}/{test_fname}>`__",

doc/conf.py def generate_syscalls_stats(_): · line 461

Quoted 10 lines
doc/conf.py +10 -0
+                ''
+            ])
+
+        # test description
+        desc = conf.get('doc', None)
+        if desc:
+            desc_text = []
+            for line in desc:
+                if line.startswith("[Description]"):
+                    desc_text.append("**Description**")

I suggested about deleting all [Description] from the code. I see no value in it, but it forces reader to scroll more (it prolongs the page).

doc/conf.py def generate_syscalls_stats(_): · line 465

Quoted 4 lines
doc/conf.py +4 -0
+                elif line.startswith("[Algorithm]"):
+                    desc_text.append("**Algorithm**")
+                else:
+                    desc_text.append(line)

NOTE: because there are more titles in "[..]" (there can be anything, why not just replace \[(.*)\] with **\1** ?

doc/conf.py def generate_syscalls_stats(_): · line 508

Quoted 7 lines
doc/conf.py +7 -0
+
+            text.extend([
+                '\n'.join(desc_text),
+            ])
+
+
+        # developer information

For me would be more obvious comment something like: "parse struct tst_test content".

Kind regards,
Petr

Quoted 15 lines
doc/conf.py +15 -0
+        text.append('')
+        text.extend(_generate_setup_table(conf))
+        text.append('')
+
+        # small separator between tests
+        text.extend([
+            '',
+            '.. raw:: html',
+            '',
+            '    <hr>',
+            '',
+        ])
+
+    with open(output, 'w+', encoding='utf-8') as new_tests:
+        new_tests.write('\n'.join(text))

...

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Petr,

Quoted 8 lines · Petr Vorel

Hi Andrea,

generally LGTM, thanks for working on it.

1) clickable (referenced) keys

I asked keys (e.g. needs_root) to be referenced to be clickable to the relevant API. This allows reader to click and read relevant info about the key.

We can't do it because tst_test struct parsing does not generate a reference for the attributes, but only for the entire struct. Maybe there's a sphinx configuration somewhere, but I have no idea, we should read documentation. This should be done by a followup patch.

Quoted 11 lines

2) git commit description of referenced tags

Perl code was able to take git description. E.g. instead of plain "d2f007dbe7e4" it got:
d2f007dbe7e4 ("userns: also map extents in the reverse map to kernel IDs")

I understand you don't want to bother with it, but it was more descriptive. I guess using github API or simple fetching web page on git.kernel.org and take content of "commit-subject" would work, but it'd be slow and we could hit some access limits from the provider. I can have look into this afterwards (I don't want to block this issue).

I seen that, but it's really too slow and I'm not sure if it provides a big help honestly. It's a "nice to have" but slow feature that can be resolved with 1 click more on the git commit hash. Feel free to try adding it after this patch has been merged, but my impression was negative, due to the fact network was having issues (timeouts, slow website, etc).

Quoted 15 lines

3) CSS fix of some tables

Code on tables with keys and values (e.g. needs_kconfigs) looks ugly, when there are more items. E.g. needs_kconfigs at icmp_rate_limit01, which has:
CONFIG_VETH
CONFIG_USER_NS=y
CONFIG_NET_NS=y

The ugly part is margin-bottom: 24px; from class="line-block". Single item line uses <p></p>.

I looked into docs (https://tables-with-sphinx.readthedocs.io/en/latest/),
but than I realized it's a simple CSS issue. It can be fixed by adding into doc/_static/custom.css:

Quoted 6 lines

/* remove margin for multiline cells */

.rst-content table td div.line-block {
     margin-bottom: 0;
}

I can send it as a separate patch if you don't want to bother with it.

I can add that, thanks for checking.

Quoted 10 lines

doc/conf.py def generate_syscalls_stats(_): · line 263

Quoted 5 lines
doc/conf.py +4 -0
+def _generate_tags_table(tags):
+    """
+    Generate the tags table from tags hash.
+    """

nit: conf.py is getting slightly big. I need to remember that public functions are these which generates stats.html and test_catalog.html. Maybe having functions or setup() which references them on the top would help reader to start with relevant code.
...

If you mean to move small functions on top, that can be done easily. At the moment, I only see the syscall table generator function being a bit long. The test catalog generator function is already splitting it into multiple functions and it's pretty easy to read.

Quoted 7 lines

doc/conf.py def generate_syscalls_stats(_): · line 333

Quoted 5 lines
doc/conf.py +5 -0
+def _generate_setup_table(keys):
+    """
+    Generate the table with test setup configuration.
+    """
+    exclude = [

This list is slightly confusing for a reader. I would expect there will be no options in generated docs nor tags. Obviously they are processed separately.

We can add a comment.

Quoted 18 lines

doc/conf.py def generate_syscalls_stats(_): · line 336

Quoted 4 lines
doc/conf.py +3 -0
+        'child_needs_reinit',
+        'needs_checkpoints',
+        'resource_files',

Maybe add this? e.g. creat07 requires also creat07_child. That might be useful for somebody to see that test needs another LTP binary.

Quoted 1 line

+ 'save_restore',

This is useful, it shows which /proc/sys files are touched.

doc/conf.py def generate_syscalls_stats(_): · line 339

Quoted 2 lines
doc/conf.py +2 -0
+        'forks_child',
+        'hugepages',

I know that these are cryptic:
.hugepages = {1, TST_NEEDS},
.hugepages = {TST_NO_HUGEPAGES},
but trying to filter out info may cause people prefer using 'git grep' sources instead of searching in 'ctrl+F' in this nice documentation.

Quoted 4 lines

doc/conf.py def generate_syscalls_stats(_): · line 342

Quoted 3 lines
doc/conf.py +3 -0
+        'options',
+        'timeout',
+        'runtime',

Cyril already asked for runtime, IMHO important to have.

It has been moved in the timeout text. No need have it in the table as well.

Quoted 59 lines
Quoted 2 lines

+ 'ulimit',

Also ulimit is useful.

Quoted 4 lines
doc/conf.py +4 -0
+        'fname',
+        'tags',
+        'doc',
+    ]

...

doc/conf.py def generate_syscalls_stats(_): · line 430

Quoted 11 lines
doc/conf.py +11 -0
+def generate_test_catalog(_):
+    """
+    Generate the test catalog from ltp.json metadata file.
+    """
+    output = '_static/tests.rst'
+    metadata_file = '../metadata/ltp.json'
+    text = [
+        '.. warning::',
+        '    The following catalog has been generated using LTP metadata',
+        '    which is including only tests using the new :ref:`LTP C API`.',
+        '    For this reason, some old tests might be missing from the list.',

Besides the fact that *all* tests using legacy API are skipped I don't think user is interested why they aren't included. I would just note that only tests which use new :ref:LTP C API are here listed.

Quoted 21 lines
doc/conf.py +21 -0
+        ''
+    ]
+
+    metadata = None
+    with open(metadata_file, 'r', encoding='utf-8') as data:
+        metadata = json.load(data)
+
+    timeout_def = metadata['defaults']['timeout']
+
+    for test_name, conf in metadata['tests'].items():
+        text.extend([
+            f'{test_name}',
+            len(test_name) * '-'
+        ])
+
+        # source url location
+        test_fname = conf.get('fname', None)
+        if test_fname:
+            text.extend([
+                '',
+                f"`source <{ltp_repo_base_url}/{test_fname}>`__",

doc/conf.py def generate_syscalls_stats(_): · line 461

Quoted 10 lines
doc/conf.py +10 -0
+                ''
+            ])
+
+        # test description
+        desc = conf.get('doc', None)
+        if desc:
+            desc_text = []
+            for line in desc:
+                if line.startswith("[Description]"):
+                    desc_text.append("**Description**")

I suggested about deleting all [Description] from the code. I see no value in it, but it forces reader to scroll more (it prolongs the page).

Quoted 6 lines

doc/conf.py def generate_syscalls_stats(_): · line 465

Quoted 4 lines
doc/conf.py +4 -0
+                elif line.startswith("[Algorithm]"):
+                    desc_text.append("**Algorithm**")
+                else:
+                    desc_text.append(line)

NOTE: because there are more titles in "[..]" (there can be anything, why not just replace \[(.*)\] with **\1** ?

That's how it should be done yes. But at the moment we are still having [..], so that should be removed with a followup patch when titles will be adapted.

Quoted 28 lines

doc/conf.py def generate_syscalls_stats(_): · line 508

Quoted 7 lines
doc/conf.py +7 -0
+
+            text.extend([
+                '\n'.join(desc_text),
+            ])
+
+
+        # developer information

For me would be more obvious comment something like: "parse struct tst_test content".

Kind regards,
Petr

Quoted 15 lines
doc/conf.py +15 -0
+        text.append('')
+        text.extend(_generate_setup_table(conf))
+        text.append('')
+
+        # small separator between tests
+        text.extend([
+            '',
+            '.. raw:: html',
+            '',
+            '    <hr>',
+            '',
+        ])
+
+    with open(output, 'w+', encoding='utf-8') as new_tests:
+        new_tests.write('\n'.join(text))

...

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp