restore cfgfile library tests
cover restore cfgfile library tests
The cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
Stephen Hemminger (3):
buildtools: add helper to convert text file to header
test: restore cfgfile tests
test: remove unused resource API
app/meson.build | 3 +- app/test/meson.build | 8 +- app/test/resource.c | 276 ----------------------------- app/test/resource.h | 106 ----------- app/test/test_cfgfile.c | 160 +++++++++++------ app/test/test_cfgfiles/meson.build | 19 ++ app/test/test_resource.c | 104 ----------- buildtools/gen-header.py | 36 ++++ buildtools/meson.build | 2 +- 9 files changed, 164 insertions(+), 550 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h create mode 100644 app/test/test_cfgfiles/meson.build delete mode 100644 app/test/test_resource.c create mode 100644 buildtools/gen-header.py
Signature · 1 line
2.43.0
PATCH 1/3 buildtools: add helper to convert text file to header
Simple script to read a file and make it into a initialized C string in a header file.
--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
buildtools/gen-header.py new file +36 -0
@@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger <[email protected]> + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main()
buildtools/meson.build +1 -1
@@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([
@@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif -
Signature · 1 line
2.43.0
PATCH 2/3 test: restore cfgfile tests
In reply to Stephen HemmingerThese tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate before the test.
--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 160 ++++++++++++++++++----------- app/test/test_cfgfiles/meson.build | 19 ++++ 4 files changed, 127 insertions(+), 61 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
app/meson.build +2 -1
@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags
@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,
app/test/meson.build +5 -1
@@ -36,7 +36,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],
@@ -263,3 +263,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_h
app/test/test_cfgfile.c +101 -59
317 lines not on this page · raw message
app/test/test_cfgfiles/meson.build new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'etc/empty.ini', + 'etc/empty_key_value.ini', + 'etc/invalid_section.ini', + 'etc/line_too_long.ini', + 'etc/missing_section.ini', + 'etc/realloc_sections.ini', + 'etc/sample1.ini', + 'etc/sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])
Signature · 1 line
2.43.0
PATCH 3/3 test: remove unused resource API
In reply to Stephen HemmingerThis API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
--- app/test/meson.build | 2 - app/test/resource.c | 276 --------------------------------------- app/test/resource.h | 106 --------------- app/test/test_resource.c | 104 --------------- 4 files changed, 488 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h delete mode 100644 app/test/test_resource.c
app/test/meson.build +0 -2
@@ -20,7 +20,6 @@ test_cryptodev_deps = ['bus_vdev', 'net', 'cryptodev', 'security'] source_file_deps = { # The C files providing functionality to other test cases 'packet_burst_generator.c': packet_burst_generator_deps, -# 'resource.c': [], # unused currently. 'sample_packet_forward.c': sample_packet_forward_deps, 'virtual_pmd.c': virtual_pmd_deps,
@@ -154,7 +153,6 @@ source_file_deps = { 'test_reciprocal_division_perf.c': [], 'test_red.c': ['sched'], 'test_reorder.c': ['reorder'], -# 'test_resource.c': [], 'test_rib.c': ['net', 'rib'], 'test_rib6.c': ['net', 'rib'], 'test_ring.c': ['ptr_compress'],
app/test/resource.c deleted +0 -276
276 lines not on this page · raw message
app/test/resource.h deleted +0 -106
106 lines not on this page · raw message
app/test/test_resource.c deleted +0 -104
104 lines not on this page · raw message
Signature · 1 line
2.43.0
v2 cover restore cfgfile library tests
In reply to Stephen HemmingerThe cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
v2 - use mkstemp instead of mktemps since the later does
not exist on Windows (in mingw).
Stephen Hemminger (3):
buildtools: add helper to convert text file to header
test: restore cfgfile tests
test: remove unused resource API
app/meson.build | 3 +- app/test/meson.build | 8 +- app/test/resource.c | 276 ----------------------------- app/test/resource.h | 106 ----------- app/test/test_cfgfile.c | 164 ++++++++++------- app/test/test_cfgfiles/meson.build | 19 ++ app/test/test_resource.c | 104 ----------- buildtools/gen-header.py | 36 ++++ buildtools/meson.build | 2 +- 9 files changed, 166 insertions(+), 552 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h create mode 100644 app/test/test_cfgfiles/meson.build delete mode 100644 app/test/test_resource.c create mode 100644 buildtools/gen-header.py
Signature · 1 line
2.43.0
PATCH v2 1/3 buildtools: add helper to convert text file to header
Simple script to read a file and make it into a initialized C string in a header file.
--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
buildtools/gen-header.py new file +36 -0
@@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger <[email protected]> + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main()
buildtools/meson.build +1 -1
@@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([
@@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif -
Signature · 1 line
2.43.0
PATCH v2 2/3 test: restore cfgfile tests
In reply to Stephen HemmingerThese tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate before the test.
--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 160 ++++++++++++++++++----------- app/test/test_cfgfiles/meson.build | 19 ++++ 4 files changed, 127 insertions(+), 61 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
app/meson.build +2 -1
@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags
@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,
app/test/meson.build +5 -1
@@ -36,7 +36,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],
@@ -263,3 +263,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_h
app/test/test_cfgfile.c +101 -59
317 lines not on this page · raw message
app/test/test_cfgfiles/meson.build new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'etc/empty.ini', + 'etc/empty_key_value.ini', + 'etc/invalid_section.ini', + 'etc/line_too_long.ini', + 'etc/missing_section.ini', + 'etc/realloc_sections.ini', + 'etc/sample1.ini', + 'etc/sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])
Signature · 1 line
2.43.0
PATCH v2 3/3 test: remove unused resource API
In reply to Stephen HemmingerThis API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
--- app/test/meson.build | 2 - app/test/resource.c | 276 --------------------------------------- app/test/resource.h | 106 --------------- app/test/test_cfgfile.c | 46 +++---- app/test/test_resource.c | 104 --------------- 5 files changed, 23 insertions(+), 511 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h delete mode 100644 app/test/test_resource.c
app/test/meson.build +0 -2
@@ -20,7 +20,6 @@ test_cryptodev_deps = ['bus_vdev', 'net', 'cryptodev', 'security'] source_file_deps = { # The C files providing functionality to other test cases 'packet_burst_generator.c': packet_burst_generator_deps, -# 'resource.c': [], # unused currently. 'sample_packet_forward.c': sample_packet_forward_deps, 'virtual_pmd.c': virtual_pmd_deps,
@@ -154,7 +153,6 @@ source_file_deps = { 'test_reciprocal_division_perf.c': [], 'test_red.c': ['sched'], 'test_reorder.c': ['reorder'], -# 'test_resource.c': [], 'test_rib.c': ['net', 'rib'], 'test_rib6.c': ['net', 'rib'], 'test_ring.c': ['ptr_compress'],
app/test/resource.c deleted +0 -276
276 lines not on this page · raw message
app/test/resource.h deleted +0 -106
106 lines not on this page · raw message
app/test/test_cfgfile.c +23 -23
184 lines not on this page · raw message
app/test/test_resource.c deleted +0 -104
104 lines not on this page · raw message
Signature · 1 line
2.43.0
v3 cover restore lost tests for rte_cfgfile
In reply to Stephen HemmingerThe cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
v3 - change creation of temp file to support Windows
Stephen Hemminger (3):
buildtools: add helper to convert text file to header
test: remove unused resource API
test: restore cfgfile tests
app/meson.build | 3 +- app/test/meson.build | 8 +- app/test/resource.c | 276 ----------------------------- app/test/resource.h | 106 ----------- app/test/test_cfgfile.c | 153 ++++++++++------ app/test/test_cfgfiles/meson.build | 19 ++ app/test/test_resource.c | 104 ----------- buildtools/gen-header.py | 36 ++++ buildtools/meson.build | 2 +- 9 files changed, 166 insertions(+), 541 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h create mode 100644 app/test/test_cfgfiles/meson.build delete mode 100644 app/test/test_resource.c create mode 100644 buildtools/gen-header.py
Signature · 1 line
2.43.0
PATCH v3 1/3 buildtools: add helper to convert text file to header
Simple script to read a file and make it into a initialized C string in a header file.
--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
buildtools/gen-header.py new file +36 -0
@@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger <[email protected]> + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main()
buildtools/meson.build +1 -1
@@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([
@@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif -
Signature · 1 line
2.43.0
PATCH v3 2/3 test: remove unused resource API
In reply to Stephen HemmingerThis API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
--- app/test/meson.build | 2 - app/test/resource.c | 276 --------------------------------------- app/test/resource.h | 106 --------------- app/test/test_resource.c | 104 --------------- 4 files changed, 488 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h delete mode 100644 app/test/test_resource.c
app/test/meson.build +0 -2
@@ -20,7 +20,6 @@ test_cryptodev_deps = ['bus_vdev', 'net', 'cryptodev', 'security'] source_file_deps = { # The C files providing functionality to other test cases 'packet_burst_generator.c': packet_burst_generator_deps, -# 'resource.c': [], # unused currently. 'sample_packet_forward.c': sample_packet_forward_deps, 'virtual_pmd.c': virtual_pmd_deps,
@@ -154,7 +153,6 @@ source_file_deps = { 'test_reciprocal_division_perf.c': [], 'test_red.c': ['sched'], 'test_reorder.c': ['reorder'], -# 'test_resource.c': [], 'test_rib.c': ['net', 'rib'], 'test_rib6.c': ['net', 'rib'], 'test_ring.c': ['ptr_compress'],
app/test/resource.c deleted +0 -276
276 lines not on this page · raw message
app/test/resource.h deleted +0 -106
106 lines not on this page · raw message
app/test/test_resource.c deleted +0 -104
104 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 3/3 test: restore cfgfile tests
In reply to Stephen HemmingerThese tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate temporary file before the test.
--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 153 +++++++++++++++++++---------- app/test/test_cfgfiles/meson.build | 19 ++++ 4 files changed, 129 insertions(+), 52 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
app/meson.build +2 -1
@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags
@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,
app/test/meson.build +5 -1
@@ -35,7 +35,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],
@@ -261,3 +261,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_h
app/test/test_cfgfile.c +103 -50
322 lines not on this page · raw message
app/test/test_cfgfiles/meson.build new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'etc/empty.ini', + 'etc/empty_key_value.ini', + 'etc/invalid_section.ini', + 'etc/line_too_long.ini', + 'etc/missing_section.ini', + 'etc/realloc_sections.ini', + 'etc/sample1.ini', + 'etc/sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])
Signature · 1 line
2.43.0
v4 cover restore lost cfgfile tests
In reply to Stephen HemmingerThe cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
v4 - add special treatment for temp directory in Windows
the test obviously never ran before on Windows.
Stephen Hemminger (3):
buildtools: add helper to convert text file to header
test: remove unused resource API
test: restore cfgfile tests
app/meson.build | 3 +- app/test/meson.build | 8 +- app/test/resource.c | 276 ----------------------------- app/test/resource.h | 106 ----------- app/test/test_cfgfile.c | 153 ++++++++++------ app/test/test_cfgfiles/meson.build | 19 ++ app/test/test_resource.c | 104 ----------- buildtools/gen-header.py | 36 ++++ buildtools/meson.build | 2 +- 9 files changed, 166 insertions(+), 541 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h create mode 100644 app/test/test_cfgfiles/meson.build delete mode 100644 app/test/test_resource.c create mode 100644 buildtools/gen-header.py
Signature · 1 line
2.43.0
PATCH v4 1/3 buildtools: add helper to convert text file to header
Simple script to read a file and make it into a initialized C string in a header file.
--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
buildtools/gen-header.py new file +36 -0
@@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger <[email protected]> + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main()
buildtools/meson.build +1 -1
@@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([
@@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif -
Signature · 1 line
2.43.0
Re: [PATCH v4 1/3] buildtools: add helper to convert text file to header
Quoted 10 lines · Stephen Hemminger
Simple script to read a file and make it into a initialized C string in a header file.
Signed-off-by Stephen Hemminger <[email protected]>--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
Resulting header output LGTM
PATCH v4 2/3 test: remove unused resource API
In reply to Stephen HemmingerThis API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
--- app/test/meson.build | 2 - app/test/resource.c | 276 --------------------------------------- app/test/resource.h | 106 --------------- app/test/test_resource.c | 104 --------------- 4 files changed, 488 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h delete mode 100644 app/test/test_resource.c
app/test/meson.build +0 -2
@@ -20,7 +20,6 @@ test_cryptodev_deps = ['bus_vdev', 'net', 'cryptodev', 'security'] source_file_deps = { # The C files providing functionality to other test cases 'packet_burst_generator.c': packet_burst_generator_deps, -# 'resource.c': [], # unused currently. 'sample_packet_forward.c': sample_packet_forward_deps, 'virtual_pmd.c': virtual_pmd_deps,
@@ -154,7 +153,6 @@ source_file_deps = { 'test_reciprocal_division_perf.c': [], 'test_red.c': ['sched'], 'test_reorder.c': ['reorder'], -# 'test_resource.c': [], 'test_rib.c': ['net', 'rib'], 'test_rib6.c': ['net', 'rib'], 'test_ring.c': ['ptr_compress'],
app/test/resource.c deleted +0 -276
276 lines not on this page · raw message
app/test/resource.h deleted +0 -106
106 lines not on this page · raw message
app/test/test_resource.c deleted +0 -104
104 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v4 2/3] test: remove unused resource API
Quoted 6 lines · Stephen Hemminger
This API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
Signed-off-by Stephen Hemminger <[email protected]>---
It's always there in git history if we ever need it back again! :-)
PATCH v4 3/3 test: restore cfgfile tests
In reply to Stephen HemmingerThese tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate temporary file before the test.
--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 153 +++++++++++++++++++---------- app/test/test_cfgfiles/meson.build | 19 ++++ 4 files changed, 129 insertions(+), 52 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
app/meson.build +2 -1
@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags
@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,
app/test/meson.build +5 -1
@@ -35,7 +35,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],
@@ -261,3 +261,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_h
app/test/test_cfgfile.c +103 -50
322 lines not on this page · raw message
app/test/test_cfgfiles/meson.build new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'etc/empty.ini', + 'etc/empty_key_value.ini', + 'etc/invalid_section.ini', + 'etc/line_too_long.ini', + 'etc/missing_section.ini', + 'etc/realloc_sections.ini', + 'etc/sample1.ini', + 'etc/sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])
Signature · 1 line
2.43.0
Re: [PATCH v4 3/3] test: restore cfgfile tests
Quoted 4 lines · Stephen Hemminger
These tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate temporary file before the test.
Quoted 9 lines
Signed-off-by Stephen Hemminger <[email protected]>--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 153 +++++++++++++++++++---------- app/test/test_cfgfiles/meson.build | 19 ++++ 4 files changed, 129 insertions(+), 52 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
A further cleanup that could be done with the test files is to remove the unnecessary "etc" subdirectory.
Quoted 414 lines
app/meson.build +2
-1@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,app/test/meson.build +5
-1@@ -35,7 +35,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],@@ -261,3 +261,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_happ/test/test_cfgfile.c +103
-50@@ -5,48 +5,54 @@#include <stdio.h> #include <string.h> #include <stdint.h> -#include <sys/queue.h> +#include <unistd.h> + +#ifdef RTE_EXEC_ENV_WINDOWS +#include <io.h> +#endif #include <rte_cfgfile.h> #include "test.h" -#include "resource.h" - - -#define CFG_FILES_ETC "test_cfgfiles/etc" -REGISTER_LINKED_RESOURCE (test_cfgfiles); +#include "test_cfgfiles.h" static int -test_cfgfile_setup (void ) +make_tmp_file (char *filename,const char *prefix,const char *data) { -const struct resource *r; -int ret; +size_t len =strlen (data); +size_t count; +FILE *f; - r =resource_find ("test_cfgfiles" ); -TEST_ASSERT_NOT_NULL (r,"missing resource test_cfgfiles" ); +#ifdef RTE_EXEC_ENV_WINDOWS +char tempDirName[MAX_PATH -14 ]; - ret =resource_untar (r); -TEST_ASSERT_SUCCESS (ret,"failed to untar %s" , r->name); +if (GetTempPathA (sizeof (tempDirName), tempDirName) ==0 ) +return -1 ; -return 0 ; -} +if (GetTempFileNameA (tempDirName, prefix,0 , filename) ==0 ) +return -1 ; -static int -test_cfgfile_cleanup (void ) -{ -const struct resource *r; -int ret; + f =fopen (filename,"wt" ); +#else +snprintf (filename,PATH_MAX ,"/tmp/%s_XXXXXXX" , prefix); - r =resource_find ("test_cfgfiles" ); -TEST_ASSERT_NOT_NULL (r,"missing resource test_cfgfiles" ); +int fd =mkstemp (filename); +if (fd <0 ) +return -1 ; - ret =resource_rm_by_tar (r); -TEST_ASSERT_SUCCESS (ret,"Failed to delete resource %s" , r->name); + f =fdopen (fd,"w" ); +#endif +if (f ==NULL ) +return -1 ; -return 0 ; + count =fwrite (data,sizeof (char ), len, f); +fclose (f); + +return (count == len) ?0 :-1 ; } +static int _test_cfgfile_sample (struct rte_cfgfile *cfgfile) {@@ -87,9 +93,13 @@ static inttest_cfgfile_sample1 (void) {struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ];int ret; - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/sample1.ini" ,0 ); + ret =make_tmp_file (filename,"sample1" , sample1_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); + + cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NOT_NULL (cfgfile,"Failed to load config file" ); ret =_test_cfgfile_sample (cfgfile);@@ -98,6 +108,8 @@ test_cfgfile_sample1(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); +remove (filename); +return 0 ; }@@ -106,15 +118,18 @@ test_cfgfile_sample2(void) {struct rte_cfgfile_parameters params;struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ];int ret; + ret =make_tmp_file (filename,"sample2" , sample2_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); +/* override comment character */ memset (¶ms,0 ,sizeof (params)); params.comment_character ='#' ; - cfgfile =rte_cfgfile_load_with_params (CFG_FILES_ETC "/sample2.ini" ,0 , - ¶ms); -TEST_ASSERT_NOT_NULL (cfgfile,"Failed to parse sample2.ini" ); + cfgfile =rte_cfgfile_load_with_params (filename,0 , ¶ms); +TEST_ASSERT_NOT_NULL (cfgfile,"Failed to parse sample2" ); ret =_test_cfgfile_sample (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to validate sample file: %d" , ret);@@ -122,6 +137,8 @@ test_cfgfile_sample2(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); +remove (filename); +return 0 ; }@@ -129,10 +146,14 @@ static inttest_cfgfile_realloc_sections (void) {struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ];int ret;const char *value; - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/realloc_sections.ini" ,0 ); + ret =make_tmp_file (filename,"realloc" , realloc_sections_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); + + cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NOT_NULL (cfgfile,"Failed to load config file" ); ret =rte_cfgfile_num_sections (cfgfile,NULL ,0 );@@ -152,13 +173,15 @@ test_cfgfile_realloc_sections(void)TEST_ASSERT (strcmp ("value8_section9" , value) ==0 ,"key unexpected value: %s" , value); - ret =rte_cfgfile_save (cfgfile,"/tmp/cfgfile_save.ini" ); + ret =rte_cfgfile_save (cfgfile,"/tmp/cfg_save.ini" );TEST_ASSERT_SUCCESS (ret,"Failed to save *.ini file" ); -remove ("/tmp/cfgfile_save.ini" ); +remove ("/tmp/cfg_save.ini" ); ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); +remove (filename); +return 0 ; }@@ -166,10 +189,16 @@ static inttest_cfgfile_invalid_section_header (void) {struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ]; +int ret; + + ret =make_tmp_file (filename,"invalid" , invalid_section_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/invalid_section.ini" ,0 ); + cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); +remove (filename);return 0 ; }@@ -178,15 +207,20 @@ test_cfgfile_invalid_comment(void) {struct rte_cfgfile_parameters params;struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ]; +int ret;/* override comment character with an invalid one */ memset (¶ms,0 ,sizeof (params)); params.comment_character ='$' ; - cfgfile =rte_cfgfile_load_with_params (CFG_FILES_ETC "/sample2.ini" ,0 , - ¶ms); + ret =make_tmp_file (filename,"sample2" , sample2_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); + + cfgfile =rte_cfgfile_load_with_params (filename,0 , ¶ms);TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); +remove (filename);return 0 ; }@@ -194,10 +228,16 @@ static inttest_cfgfile_invalid_key_value_pair (void) {struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ]; +int ret; + + ret =make_tmp_file (filename,"empty_key" , empty_key_value_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/empty_key_value.ini" ,0 ); + cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); +remove (filename);return 0 ; }@@ -206,11 +246,14 @@ test_cfgfile_empty_key_value_pair(void) {struct rte_cfgfile *cfgfile;const char *value; +char filename[PATH_MAX ];int ret; - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/empty_key_value.ini" , -CFG_FLAG_EMPTY_VALUES ); -TEST_ASSERT_NOT_NULL (cfgfile,"Failed to parse empty_key_value.ini" ); + ret =make_tmp_file (filename,"empty_key_value" , empty_key_value_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); + + cfgfile =rte_cfgfile_load (filename,CFG_FLAG_EMPTY_VALUES ); +TEST_ASSERT_NOT_NULL (cfgfile,"Failed to parse empty_key_value" ); ret =rte_cfgfile_num_sections (cfgfile,NULL ,0 );TEST_ASSERT (ret ==1 ,"Unexpected number of sections: %d" , ret);@@ -227,6 +270,7 @@ test_cfgfile_empty_key_value_pair(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); +remove (filename);return 0 ; }@@ -234,10 +278,16 @@ static inttest_cfgfile_missing_section (void) {struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ]; +int ret; + + ret =make_tmp_file (filename,"missing_section" , missing_section_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/missing_section.ini" ,0 ); + cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); +remove (filename);return 0 ; }@@ -246,10 +296,13 @@ test_cfgfile_global_properties(void) {struct rte_cfgfile *cfgfile;const char *value; +char filename[PATH_MAX ];int ret; - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/missing_section.ini" , -CFG_FLAG_GLOBAL_SECTION ); + ret =make_tmp_file (filename,"missing_section" , missing_section_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); + + cfgfile =rte_cfgfile_load (filename,CFG_FLAG_GLOBAL_SECTION );TEST_ASSERT_NOT_NULL (cfgfile,"Failed to load config file" ); ret =rte_cfgfile_num_sections (cfgfile,NULL ,0 );@@ -268,6 +321,7 @@ test_cfgfile_global_properties(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); +remove (filename);return 0 ; }@@ -275,9 +329,13 @@ static inttest_cfgfile_empty_file (void) {struct rte_cfgfile *cfgfile; +char filename[PATH_MAX ];int ret; - cfgfile =rte_cfgfile_load (CFG_FILES_ETC "/empty.ini" ,0 ); + ret =make_tmp_file (filename,"empty" , empty_ini); +TEST_ASSERT_SUCCESS (ret,"Failed to setup temp file" ); + + cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NOT_NULL (cfgfile,"Failed to load config file" ); ret =rte_cfgfile_num_sections (cfgfile,NULL ,0 );@@ -286,15 +344,13 @@ test_cfgfile_empty_file(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); +remove (filename);return 0 ; }static int test_cfgfile (void ) { -if (test_cfgfile_setup ()) -return -1 ; -if (test_cfgfile_sample1 ())return -1 ;@@ -325,10 +381,7 @@ test_cfgfile(void)if (test_cfgfile_empty_file ())return -1 ; -if (test_cfgfile_cleanup ()) -return -1 ; -return 0 ; } -REGISTER_TEST_COMMAND (cfgfile_autotest, test_cfgfile); +REGISTER_FAST_TEST (cfgfile_autotest, true, true, test_cfgfile);app/test/test_cfgfiles/meson.build new file +19
-0@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'etc/empty.ini', + 'etc/empty_key_value.ini', + 'etc/invalid_section.ini', + 'etc/line_too_long.ini', + 'etc/missing_section.ini', + 'etc/realloc_sections.ini', + 'etc/sample1.ini', + 'etc/sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])Signature · 1 line
2.43.0
v5 cover restore unused cfgfile tests
In reply to Stephen HemmingerThe cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
v5 - rearrange tests input files
- use unit_suite_runner
- more Windows fixes
Stephen Hemminger (4):
buildtools: add helper to convert text file to header
test: remove unused resource API
test: restore cfgfile tests
test: rearrange test_cfgfiles cases
app/meson.build | 3 +-
app/test/meson.build | 8 +-
app/test/resource.c | 276 ------------------
app/test/resource.h | 106 -------
app/test/test_cfgfile.c | 213 ++++++++------
app/test/test_cfgfiles/{etc => }/empty.ini | 0
.../{etc => }/empty_key_value.ini | 0
.../{etc => }/invalid_section.ini | 0
.../test_cfgfiles/{etc => }/line_too_long.ini | 0
app/test/test_cfgfiles/meson.build | 19 ++
.../{etc => }/missing_section.ini | 0
.../{etc => }/realloc_sections.ini | 0
app/test/test_cfgfiles/{etc => }/sample1.ini | 0
app/test/test_cfgfiles/{etc => }/sample2.ini | 0
app/test/test_resource.c | 104 -------
buildtools/gen-header.py | 36 +++
buildtools/meson.build | 2 +-
17 files changed, 194 insertions(+), 573 deletions(-)
delete mode 100644 app/test/resource.c
delete mode 100644 app/test/resource.h
rename app/test/test_cfgfiles/{etc => }/empty.ini (100%)
rename app/test/test_cfgfiles/{etc => }/empty_key_value.ini (100%)
rename app/test/test_cfgfiles/{etc => }/invalid_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/line_too_long.ini (100%)
create mode 100644 app/test/test_cfgfiles/meson.build
rename app/test/test_cfgfiles/{etc => }/missing_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/realloc_sections.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample1.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample2.ini (100%)
delete mode 100644 app/test/test_resource.c
create mode 100644 buildtools/gen-header.pySignature · 1 line
2.43.0
PATCH v5 1/4 buildtools: add helper to convert text file to header
Simple script to read a file and make it into a initialized C string in a header file.
--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
buildtools/gen-header.py new file +36 -0
@@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger <[email protected]> + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main()
buildtools/meson.build +1 -1
@@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([
@@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif -
Signature · 1 line
2.43.0
PATCH v5 2/4 test: remove unused resource API
In reply to Stephen HemmingerThis API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
--- app/test/meson.build | 2 - app/test/resource.c | 276 --------------------------------------- app/test/resource.h | 106 --------------- app/test/test_resource.c | 104 --------------- 4 files changed, 488 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h delete mode 100644 app/test/test_resource.c
app/test/meson.build +0 -2
@@ -20,7 +20,6 @@ test_cryptodev_deps = ['bus_vdev', 'net', 'cryptodev', 'security'] source_file_deps = { # The C files providing functionality to other test cases 'packet_burst_generator.c': packet_burst_generator_deps, -# 'resource.c': [], # unused currently. 'sample_packet_forward.c': sample_packet_forward_deps, 'virtual_pmd.c': virtual_pmd_deps,
@@ -154,7 +153,6 @@ source_file_deps = { 'test_reciprocal_division_perf.c': [], 'test_red.c': ['sched'], 'test_reorder.c': ['reorder'], -# 'test_resource.c': [], 'test_rib.c': ['net', 'rib'], 'test_rib6.c': ['net', 'rib'], 'test_ring.c': ['ptr_compress'],
app/test/resource.c deleted +0 -276
276 lines not on this page · raw message
app/test/resource.h deleted +0 -106
106 lines not on this page · raw message
app/test/test_resource.c deleted +0 -104
104 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 3/4 test: restore cfgfile tests
In reply to Stephen HemmingerThese tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate temporary file before the test.
The changes to app/test/meson.build are to handle auto-generated files (resources) differently. Don't scan these files to look for test input.
Using common unit test macro allows for simpler management of more tests.
--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 213 ++++++++++++++++++----------- app/test/test_cfgfiles/meson.build | 19 +++ 4 files changed, 157 insertions(+), 84 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
app/meson.build +2 -1
@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags
@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,
app/test/meson.build +5 -1
@@ -35,7 +35,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],
@@ -261,3 +261,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_h
app/test/test_cfgfile.c +131 -82
370 lines not on this page · raw message
app/test/test_cfgfiles/meson.build new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'etc/empty.ini', + 'etc/empty_key_value.ini', + 'etc/invalid_section.ini', + 'etc/line_too_long.ini', + 'etc/missing_section.ini', + 'etc/realloc_sections.ini', + 'etc/sample1.ini', + 'etc/sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])
Signature · 1 line
2.43.0
Re: [PATCH v5 3/4] test: restore cfgfile tests
Quoted 4 lines · Stephen Hemminger
These tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate temporary file before the test.
Quoted 8 lines
The changes to app/test/meson.build are to handle auto-generated files (resources) differently. Don't scan these files to look for test input.
Using common unit test macro allows for simpler management of more tests.
Signed-off-by Stephen Hemminger <[email protected]>
PATCH v5 4/4 test: rearrange test_cfgfiles cases
In reply to Stephen HemmingerThe input files don't need to be in a separate subdirectory.
---
app/test/test_cfgfiles/{etc => }/empty.ini | 0
.../test_cfgfiles/{etc => }/empty_key_value.ini | 0
.../test_cfgfiles/{etc => }/invalid_section.ini | 0
.../test_cfgfiles/{etc => }/line_too_long.ini | 0
app/test/test_cfgfiles/meson.build | 16 ++++++++--------
.../test_cfgfiles/{etc => }/missing_section.ini | 0
.../test_cfgfiles/{etc => }/realloc_sections.ini | 0
app/test/test_cfgfiles/{etc => }/sample1.ini | 0
app/test/test_cfgfiles/{etc => }/sample2.ini | 0
9 files changed, 8 insertions(+), 8 deletions(-)
rename app/test/test_cfgfiles/{etc => }/empty.ini (100%)
rename app/test/test_cfgfiles/{etc => }/empty_key_value.ini (100%)
rename app/test/test_cfgfiles/{etc => }/invalid_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/line_too_long.ini (100%)
rename app/test/test_cfgfiles/{etc => }/missing_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/realloc_sections.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample1.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample2.ini (100%)app/test/test_cfgfiles/empty.ini renamed from app/test/test_cfgfiles/etc/empty.ini +0 -0
app/test/test_cfgfiles/empty_key_value.ini renamed from app/test/test_cfgfiles/etc/empty_key_value.ini +0 -0
app/test/test_cfgfiles/invalid_section.ini renamed from app/test/test_cfgfiles/etc/invalid_section.ini +0 -0
app/test/test_cfgfiles/line_too_long.ini renamed from app/test/test_cfgfiles/etc/line_too_long.ini +0 -0
app/test/test_cfgfiles/meson.build +8 -8
@@ -1,14 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause test_cfgfiles = files( - 'etc/empty.ini', - 'etc/empty_key_value.ini', - 'etc/invalid_section.ini', - 'etc/line_too_long.ini', - 'etc/missing_section.ini', - 'etc/realloc_sections.ini', - 'etc/sample1.ini', - 'etc/sample2.ini', + 'empty.ini', + 'empty_key_value.ini', + 'invalid_section.ini', + 'line_too_long.ini', + 'missing_section.ini', + 'realloc_sections.ini', + 'sample1.ini', + 'sample2.ini', ) # generate the header file used in cfgfile test
app/test/test_cfgfiles/missing_section.ini renamed from app/test/test_cfgfiles/etc/missing_section.ini +0 -0
app/test/test_cfgfiles/realloc_sections.ini renamed from app/test/test_cfgfiles/etc/realloc_sections.ini +0 -0
app/test/test_cfgfiles/sample1.ini renamed from app/test/test_cfgfiles/etc/sample1.ini +0 -0
app/test/test_cfgfiles/sample2.ini renamed from app/test/test_cfgfiles/etc/sample2.ini +0 -0
Signature · 1 line
2.43.0
Re: [PATCH v5 4/4] test: rearrange test_cfgfiles cases
Quoted 3 lines · Stephen Hemminger
The input files don't need to be in a separate subdirectory.
Signed-off-by Stephen Hemminger <[email protected]>
Small suggestion - I'd move this up to be patch 3, rather than patch 4, which would save editing the list in the meson.build file to remove the "etc/" prefix
Quoted 82 lines
--- app/test/test_cfgfiles/{etc => }/empty.ini | 0 .../test_cfgfiles/{etc => }/empty_key_value.ini | 0 .../test_cfgfiles/{etc => }/invalid_section.ini | 0 .../test_cfgfiles/{etc => }/line_too_long.ini | 0 app/test/test_cfgfiles/meson.build | 16 ++++++++-------- .../test_cfgfiles/{etc => }/missing_section.ini | 0 .../test_cfgfiles/{etc => }/realloc_sections.ini | 0 app/test/test_cfgfiles/{etc => }/sample1.ini | 0 app/test/test_cfgfiles/{etc => }/sample2.ini | 0 9 files changed, 8 insertions(+), 8 deletions(-) rename app/test/test_cfgfiles/{etc => }/empty.ini (100%) rename app/test/test_cfgfiles/{etc => }/empty_key_value.ini (100%) rename app/test/test_cfgfiles/{etc => }/invalid_section.ini (100%) rename app/test/test_cfgfiles/{etc => }/line_too_long.ini (100%) rename app/test/test_cfgfiles/{etc => }/missing_section.ini (100%) rename app/test/test_cfgfiles/{etc => }/realloc_sections.ini (100%) rename app/test/test_cfgfiles/{etc => }/sample1.ini (100%) rename app/test/test_cfgfiles/{etc => }/sample2.ini (100%)app/test/test_cfgfiles/empty.ini renamed from app/test/test_cfgfiles/etc/empty.ini +0
-0app/test/test_cfgfiles/empty_key_value.ini renamed from app/test/test_cfgfiles/etc/empty_key_value.ini +0
-0app/test/test_cfgfiles/invalid_section.ini renamed from app/test/test_cfgfiles/etc/invalid_section.ini +0
-0app/test/test_cfgfiles/line_too_long.ini renamed from app/test/test_cfgfiles/etc/line_too_long.ini +0
-0app/test/test_cfgfiles/meson.build +8
-8@@ -1,14 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause test_cfgfiles = files( - 'etc/empty.ini', - 'etc/empty_key_value.ini', - 'etc/invalid_section.ini', - 'etc/line_too_long.ini', - 'etc/missing_section.ini', - 'etc/realloc_sections.ini', - 'etc/sample1.ini', - 'etc/sample2.ini', + 'empty.ini', + 'empty_key_value.ini', + 'invalid_section.ini', + 'line_too_long.ini', + 'missing_section.ini', + 'realloc_sections.ini', + 'sample1.ini', + 'sample2.ini', ) # generate the header file used in cfgfile testapp/test/test_cfgfiles/missing_section.ini renamed from app/test/test_cfgfiles/etc/missing_section.ini +0
-0app/test/test_cfgfiles/realloc_sections.ini renamed from app/test/test_cfgfiles/etc/realloc_sections.ini +0
-0app/test/test_cfgfiles/sample1.ini renamed from app/test/test_cfgfiles/etc/sample1.ini +0
-0app/test/test_cfgfiles/sample2.ini renamed from app/test/test_cfgfiles/etc/sample2.ini +0
-0Signature · 1 line
2.43.0
Re: [PATCH v5 4/4] test: rearrange test_cfgfiles cases
Quoted 10 lines · On Fri, 2 Aug 2024 17:51:01 +0100 Bruce Richardson…
Quoted 3 lines · Stephen Hemminger
The input files don't need to be in a separate subdirectory.
Signed-off-by Stephen Hemminger <[email protected]>Small suggestion - I'd move this up to be patch 3, rather than patch 4, which would save editing the list in the meson.build file to remove the "etc/" prefix
Acked-by Bruce Richardson <[email protected]>
Sure it would be logical to merge the two, just wanted the patches to be smaller and easier to review
Re: [PATCH v5 4/4] test: rearrange test_cfgfiles cases
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 2 Aug 2024 17:51:01 +0100 Bruce Richardson…
Quoted 3 lines · Stephen Hemminger
The input files don't need to be in a separate subdirectory.
Signed-off-by Stephen Hemminger <[email protected]>
Quoted 9 lines
Quoted 5 lines
Small suggestion - I'd move this up to be patch 3, rather than patch 4, which would save editing the list in the meson.build file to remove the "etc/" prefix
Acked-by Bruce Richardson <[email protected]>Sure it would be logical to merge the two, just wanted the patches to be smaller and easier to review
I actually think they are better separate, just switch the order.
/Bruce
v6 cover test: restore cfgfile lib tests
In reply to Stephen HemmingerThe cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
v6 - rearrange patch order for easier review
Stephen Hemminger (4):
buildtools: add helper to convert text file to header
test: remove unused resource API
test: rearrange test_cfgfiles cases
test: restore cfgfile tests
app/meson.build | 3 +-
app/test/meson.build | 8 +-
app/test/resource.c | 276 ------------------
app/test/resource.h | 106 -------
app/test/test_cfgfile.c | 213 ++++++++------
app/test/test_cfgfiles/{etc => }/empty.ini | 0
.../{etc => }/empty_key_value.ini | 0
.../{etc => }/invalid_section.ini | 0
.../test_cfgfiles/{etc => }/line_too_long.ini | 0
app/test/test_cfgfiles/meson.build | 19 ++
.../{etc => }/missing_section.ini | 0
.../{etc => }/realloc_sections.ini | 0
app/test/test_cfgfiles/{etc => }/sample1.ini | 0
app/test/test_cfgfiles/{etc => }/sample2.ini | 0
app/test/test_resource.c | 104 -------
buildtools/gen-header.py | 36 +++
buildtools/meson.build | 2 +-
17 files changed, 194 insertions(+), 573 deletions(-)
delete mode 100644 app/test/resource.c
delete mode 100644 app/test/resource.h
rename app/test/test_cfgfiles/{etc => }/empty.ini (100%)
rename app/test/test_cfgfiles/{etc => }/empty_key_value.ini (100%)
rename app/test/test_cfgfiles/{etc => }/invalid_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/line_too_long.ini (100%)
create mode 100644 app/test/test_cfgfiles/meson.build
rename app/test/test_cfgfiles/{etc => }/missing_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/realloc_sections.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample1.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample2.ini (100%)
delete mode 100644 app/test/test_resource.c
create mode 100644 buildtools/gen-header.pySignature · 1 line
2.43.0
PATCH v6 1/4 buildtools: add helper to convert text file to header
Simple script to read a file and make it into a initialized C string in a header file.
--- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py
buildtools/gen-header.py new file +36 -0
@@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger <[email protected]> + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main()
buildtools/meson.build +1 -1
@@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([
@@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif -
Signature · 1 line
2.43.0
PATCH v6 2/4 test: remove unused resource API
In reply to Stephen HemmingerThis API was used only for cfgfile tests and was never built after the conversion to meson. Will be replaced by simpler method of doing cfgfile tests.
--- app/test/meson.build | 2 - app/test/resource.c | 276 --------------------------------------- app/test/resource.h | 106 --------------- app/test/test_resource.c | 104 --------------- 4 files changed, 488 deletions(-) delete mode 100644 app/test/resource.c delete mode 100644 app/test/resource.h delete mode 100644 app/test/test_resource.c
app/test/meson.build +0 -2
@@ -20,7 +20,6 @@ test_cryptodev_deps = ['bus_vdev', 'net', 'cryptodev', 'security'] source_file_deps = { # The C files providing functionality to other test cases 'packet_burst_generator.c': packet_burst_generator_deps, -# 'resource.c': [], # unused currently. 'sample_packet_forward.c': sample_packet_forward_deps, 'virtual_pmd.c': virtual_pmd_deps,
@@ -154,7 +153,6 @@ source_file_deps = { 'test_reciprocal_division_perf.c': [], 'test_red.c': ['sched'], 'test_reorder.c': ['reorder'], -# 'test_resource.c': [], 'test_rib.c': ['net', 'rib'], 'test_rib6.c': ['net', 'rib'], 'test_ring.c': ['ptr_compress'],
app/test/resource.c deleted +0 -276
276 lines not on this page · raw message
app/test/resource.h deleted +0 -106
106 lines not on this page · raw message
app/test/test_resource.c deleted +0 -104
104 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v6 3/4 test: rearrange test_cfgfiles cases
In reply to Stephen HemmingerThe input files don't need to be in a separate subdirectory.
---
app/test/test_cfgfiles/{etc => }/empty.ini | 0
app/test/test_cfgfiles/{etc => }/empty_key_value.ini | 0
app/test/test_cfgfiles/{etc => }/invalid_section.ini | 0
app/test/test_cfgfiles/{etc => }/line_too_long.ini | 0
app/test/test_cfgfiles/{etc => }/missing_section.ini | 0
app/test/test_cfgfiles/{etc => }/realloc_sections.ini | 0
app/test/test_cfgfiles/{etc => }/sample1.ini | 0
app/test/test_cfgfiles/{etc => }/sample2.ini | 0
8 files changed, 0 insertions(+), 0 deletions(-)
rename app/test/test_cfgfiles/{etc => }/empty.ini (100%)
rename app/test/test_cfgfiles/{etc => }/empty_key_value.ini (100%)
rename app/test/test_cfgfiles/{etc => }/invalid_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/line_too_long.ini (100%)
rename app/test/test_cfgfiles/{etc => }/missing_section.ini (100%)
rename app/test/test_cfgfiles/{etc => }/realloc_sections.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample1.ini (100%)
rename app/test/test_cfgfiles/{etc => }/sample2.ini (100%)app/test/test_cfgfiles/empty.ini renamed from app/test/test_cfgfiles/etc/empty.ini +0 -0
app/test/test_cfgfiles/empty_key_value.ini renamed from app/test/test_cfgfiles/etc/empty_key_value.ini +0 -0
app/test/test_cfgfiles/invalid_section.ini renamed from app/test/test_cfgfiles/etc/invalid_section.ini +0 -0
app/test/test_cfgfiles/line_too_long.ini renamed from app/test/test_cfgfiles/etc/line_too_long.ini +0 -0
app/test/test_cfgfiles/missing_section.ini renamed from app/test/test_cfgfiles/etc/missing_section.ini +0 -0
app/test/test_cfgfiles/realloc_sections.ini renamed from app/test/test_cfgfiles/etc/realloc_sections.ini +0 -0
app/test/test_cfgfiles/sample1.ini renamed from app/test/test_cfgfiles/etc/sample1.ini +0 -0
app/test/test_cfgfiles/sample2.ini renamed from app/test/test_cfgfiles/etc/sample2.ini +0 -0
Signature · 1 line
2.43.0
PATCH v6 4/4 test: restore cfgfile tests
In reply to Stephen HemmingerThese tests were not built since the conversion to meson. Instead of using embedded resource functions, put data in include file and generate temporary file before the test.
The changes to app/test/meson.build are to handle auto-generated files (resources) differently. Don't scan these files to look for test input.
Using common unit test macro allows for simpler management of more tests.
--- app/meson.build | 3 +- app/test/meson.build | 6 +- app/test/test_cfgfile.c | 213 ++++++++++++++++++----------- app/test/test_cfgfiles/meson.build | 19 +++ 4 files changed, 157 insertions(+), 84 deletions(-) create mode 100644 app/test/test_cfgfiles/meson.build
app/meson.build +2 -1
@@ -55,6 +55,7 @@ foreach app:apps build = true reason = '<unknown reason>' # set if build == false to explain sources = [] + resources = [] includes = [] cflags = default_cflags ldflags = default_ldflags
@@ -115,7 +116,7 @@ foreach app:apps endif exec = executable('dpdk-' + name, - sources, + [ sources, resources ], c_args: cflags, link_args: ldflags, link_whole: link_libs,
app/test/meson.build +5 -1
@@ -35,7 +35,7 @@ source_file_deps = { 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [], -# 'test_cfgfile.c': ['cfgfile'], + 'test_cfgfile.c': ['cfgfile'], 'test_cksum.c': ['net'], 'test_cksum_perf.c': ['net'], 'test_cmdline.c': [],
@@ -261,3 +261,7 @@ if not is_windows build_by_default: true, install: false) endif + +subdir('test_cfgfiles') + +resources += test_cfgfile_h
app/test/test_cfgfile.c +131 -82
370 lines not on this page · raw message
app/test/test_cfgfiles/meson.build new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause + +test_cfgfiles = files( + 'empty.ini', + 'empty_key_value.ini', + 'invalid_section.ini', + 'line_too_long.ini', + 'missing_section.ini', + 'realloc_sections.ini', + 'sample1.ini', + 'sample2.ini', +) + +# generate the header file used in cfgfile test +test_cfgfile_h = custom_target('test_cfgfile', + output: 'test_cfgfiles.h', + input: test_cfgfiles, + capture: true, + command: [ header_gen_cmd, '@INPUT@'])
Signature · 1 line
2.43.0
Re: [PATCH v6 0/4] test: restore cfgfile lib tests
In reply to Stephen Hemminger13/08/2024 17:57, Stephen Hemminger:
Quoted 7 lines
The cfgfile tests did not get built since conversion to meson and they used an awkward way to manage the test data.
This patchset converts the tests to use a helper to take text file and make it into a C header. Then use the C header to generate temporary files as needed.
Quoted 7 lines
v6 - rearrange patch order for easier review
Stephen Hemminger (4):
buildtools: add helper to convert text file to header
test: remove unused resource API
test: rearrangetest_cfgfilescases
test: restore cfgfile tests
Applied with some fixes in the file MAINTAINERS, thanks.