tests: Add support for file families
And fix a problem in a test where an ident where wrongly identified by ctags. It is fixed in the new ctags version. Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
This commit is contained in:
parent
b7882b1282
commit
fbe9fa0e72
4 changed files with 22 additions and 23 deletions
|
|
@ -80,12 +80,12 @@ ok( (-r File::Spec->catfile($db_dir, $_)), "$_ exists" )
|
|||
# Spot-check some identifiers
|
||||
|
||||
run_produces_ok('ident query (nonexistent)',
|
||||
[$query_py, qw(v5.4 ident SOME_NONEXISTENT_IDENTIFIER_XYZZY_PLUGH)],
|
||||
[$query_py, qw(v5.4 ident SOME_NONEXISTENT_IDENTIFIER_XYZZY_PLUGH C)],
|
||||
[qr{^Symbol Definitions:}, qr{^Symbol References:}, qr{^\s*$}],
|
||||
MUST_SUCCEED);
|
||||
|
||||
run_produces_ok('ident query (existent)',
|
||||
[$query_py, qw(v5.4 ident i2c_acpi_notify)],
|
||||
[$query_py, qw(v5.4 ident i2c_acpi_notify C)],
|
||||
[qr{^Symbol Definitions:}, qr{^Symbol References:},
|
||||
qr{drivers/i2c/i2c-core-acpi\.c.+\b402\b.+\bfunction\b}, # def
|
||||
qr{drivers/i2c/i2c-core-acpi\.c.+\b402,439} # refs
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ ok_or_die( -d $tenv->lxr_data_dir, 'database dir exists',
|
|||
# Spot-check some identifiers
|
||||
|
||||
run_produces_ok('doc-comment query (nonexistent)',
|
||||
[$tenv->query_py, qw(v5.4 ident SOME_NONEXISTENT_IDENTIFIER_XYZZY_PLUGH)],
|
||||
[$tenv->query_py, qw(v5.4 ident SOME_NONEXISTENT_IDENTIFIER_XYZZY_PLUGH C)],
|
||||
[
|
||||
qr{^Documented in:},
|
||||
{doc => { not => qr{/} }}, # No file paths in the doc section
|
||||
|
|
@ -53,7 +53,7 @@ run_produces_ok('doc-comment query (nonexistent)',
|
|||
MUST_SUCCEED);
|
||||
|
||||
run_produces_ok('doc-comment query (existent but not documented)',
|
||||
[$tenv->query_py, qw(v5.4 ident gsb_buffer)], # in drivers/i2c/i2c-core-acpi.c
|
||||
[$tenv->query_py, qw(v5.4 ident gsb_buffer C)], # in drivers/i2c/i2c-core-acpi.c
|
||||
[
|
||||
qr{^Documented in:},
|
||||
{doc => { not => qr{/} }}
|
||||
|
|
@ -61,7 +61,7 @@ run_produces_ok('doc-comment query (existent but not documented)',
|
|||
MUST_SUCCEED);
|
||||
|
||||
run_produces_ok('ident query (existent, function, documented in C file)',
|
||||
[$tenv->query_py, qw(v5.4 ident i2c_acpi_get_i2c_resource)],
|
||||
[$tenv->query_py, qw(v5.4 ident i2c_acpi_get_i2c_resource C)],
|
||||
[
|
||||
qr{^Documented in:},
|
||||
{doc => qr{drivers/i2c/i2c-core-acpi\.c.+\b45\b}},
|
||||
|
|
@ -69,7 +69,7 @@ run_produces_ok('ident query (existent, function, documented in C file)',
|
|||
MUST_SUCCEED);
|
||||
|
||||
run_produces_ok('ident query (existent, function, documented in C file, #102)',
|
||||
[$tenv->query_py, qw(v5.4 ident documented_function_XYZZY)],
|
||||
[$tenv->query_py, qw(v5.4 ident documented_function_XYZZY C)],
|
||||
[
|
||||
qr{^Documented in:},
|
||||
{doc => qr{issue102\.c.+\b6\b}},
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class APITest(testing.TestCase):
|
|||
self.app = create_ident_getter()
|
||||
|
||||
def test_identifier_not_found(self):
|
||||
result = self.simulate_get('/ident/tree/SOME_NONEXISTENT_IDENTIFIER', query_string="version=latest")
|
||||
result = self.simulate_get('/ident/tree/SOME_NONEXISTENT_IDENTIFIER', query_string="version=latest&family=C")
|
||||
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.json, {'definitions': [], 'references':[]})
|
||||
|
|
@ -33,14 +33,13 @@ class APITest(testing.TestCase):
|
|||
self.assertEqual(result.json["description"], required_response.description)
|
||||
|
||||
def test_existing_identifier(self):
|
||||
result_for_specific_version = self.simulate_get('/ident/tree/of_i2c_get_board_info', query_string="version=v5.4")
|
||||
result_for_latest_version = self.simulate_get('/ident/tree/of_i2c_get_board_info', query_string="version=latest")
|
||||
result_for_specific_version = self.simulate_get('/ident/tree/of_i2c_get_board_info', query_string="version=v5.4&family=C")
|
||||
result_for_latest_version = self.simulate_get('/ident/tree/of_i2c_get_board_info', query_string="version=latest&family=C")
|
||||
|
||||
expected_json = {
|
||||
'definitions':
|
||||
[
|
||||
{'path': 'drivers/i2c/i2c-core-of.c', 'line': 22, 'type': 'function'},
|
||||
{'path': 'drivers/i2c/i2c-core-of.c', 'line': 62, 'type': 'variable'},
|
||||
{'path': 'include/linux/i2c.h', 'line': 968, 'type': 'function'},
|
||||
{'path': 'include/linux/i2c.h', 'line': 941, 'type': 'prototype'}
|
||||
],
|
||||
|
|
@ -55,4 +54,4 @@ class APITest(testing.TestCase):
|
|||
self.assertEqual(result_for_latest_version.status_code, 200)
|
||||
|
||||
self.assertEqual(result_for_specific_version.json, expected_json)
|
||||
self.assertEqual(result_for_latest_version.json, expected_json)
|
||||
self.assertEqual(result_for_latest_version.json, expected_json)
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ verbose = False
|
|||
#List of test elements
|
||||
project = 'linux'
|
||||
versions = ['latest', 'v5.6.2']
|
||||
idents = [ 'loopback',
|
||||
'devm_register_reboot_notifier',
|
||||
'notrace',
|
||||
'arch_local_irq_restore',
|
||||
'blk_queue_dma_alignment',
|
||||
'spinlock_t',
|
||||
'max',
|
||||
'task_struct',
|
||||
'eth_header',
|
||||
'sk_buff' ]
|
||||
idents = [ ('loopback', 'C'),
|
||||
('devm_register_reboot_notifier', 'C'),
|
||||
('notrace', 'C'),
|
||||
('arch_local_irq_restore', 'C'),
|
||||
('blk_queue_dma_alignment', 'C'),
|
||||
('spinlock_t', 'C'),
|
||||
('max', 'C'),
|
||||
('task_struct', 'C'),
|
||||
('eth_header', 'C'),
|
||||
('sk_buff', 'C') ]
|
||||
|
||||
files = [ '/block/partitions/osf.c',
|
||||
'/mm/kasan/quarantine.c',
|
||||
|
|
@ -68,7 +68,7 @@ def get_ident(ident, version):
|
|||
if version == 'latest':
|
||||
version = query('latest')
|
||||
|
||||
return query('ident', version, ident)
|
||||
return query('ident', version, ident[0], ident[1])
|
||||
|
||||
def get_file(path, version):
|
||||
if version == 'latest':
|
||||
|
|
@ -146,4 +146,4 @@ for version in versions:
|
|||
print((BOLD + "Min:" + NORMAL + " {0:.6f} ms\n"
|
||||
+ BOLD + "Max:" + NORMAL + " {1:.6f} ms\n"
|
||||
+ BOLD + "Average:" + NORMAL + " {2:.6f} ms\n"
|
||||
).format(files_min, files_max, files_average))
|
||||
).format(files_min, files_max, files_average))
|
||||
|
|
|
|||
Loading…
Reference in a new issue