Hi Tao,
On Mon, Feb 28, 2022 at 06:44:06PM +0800, Tao Liu wrote:
Hi Coiby,
The test suite is great!
Thanks for reviewing the patches!
On Mon, Feb 21, 2022 at 08:57:38PM +0800, Coiby Xu wrote:
> Potential benefits brought by unit tests
> =======================================
>
> - catch as many bugs as possible and catch them as early as possible
> - improve the code quality and make the code robust
> - Keep API stable
> - prevent regressions from change during the development and in the future
> (it's quite annoying to solve one problem only to find another cropping up)
> - make it easy for code review because of concrete test cases
>
> Why ShellSpec
> =============
>
> ShellSpec [1] is chosen for the following benefits,
> - rich features: to name a few
> - mocking
> - Parameterized tests
> - code coverage
> - good documentation and examples
>
> For the full comparison between shellspec and other frameworks, please
> refer to [2].
>
> How to run the tests
> ====================
>
> After installing shellspec and optionally kcov
> $ curl -fsSL
https://git.io/shellspec | sh
> $ sudo dnf install kcov
>
> 1. go to the root of this repo
> 2. create a file with _spec as suffix in the spec folder, e.g. spec/kdumpctl_spec.sh
> 3. run shellspec
> shellspec --kcov --kcov-options
"--include-pattern=kdumpctl,kdump-lib.sh,kdump-lib-initramfs.sh,kdump-logger.sh"
>
> Running: /bin/sh [bash 5.1.0(1)-release]
> ................................................................
>
> Finished in 11.15 seconds (user 6.97 seconds, sys 9.54 seconds)
> 64 examples, 0 failures
>
> Code covered: 16.08%, Executed lines: 224, Instrumented lines: 1393
>
However, by trying the test on my local machine, I noticed there are a few
failing cases, maybe due to our env differences. So I'm thinking about
running the test in a docker container, which will prevent the
shellspec installing, file modification and temporary files creating
on the local drive.
Sorry for these issues! v1 should be run smoothly after installing
shellspec.
Do you have any plan/preferences for shellspec integration with kexec-tools?
For example:
1) docker container
2) virtual machine disk image
3) physical host, with careful mock and temp-file cleanup.
4) rpm dependency
5) ???
I have an idea to change our workflow from email-based workflow to
gitlab/github-based workflow. So the unit-tests and CI tests (i.e. tests in
the tests folder) can be triggered automatically when an pull/merge
request is created or updated. To achieve this goal, we have to be able
to run tests inside a docker container (at least this required by
github. Gitlab may also requires this).
Thanks,
Tao Liu
> [1]
https://github.com/shellspec/shellspec
> [2]
https://github.com/dodie/testing-in-bash#detailed-comparision
>
> Coiby Xu (8):
> unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested
> unit tests: add tests for get_grub_kernel_boot_parameter
> unit tests: add tests for get_dump_mode_by_fadump_val
> unit tests: add tests for kdumpctl read_proc_environ_var and
> _is_osbuild
> unit tests: add tests for
> _{add,remove,read}_kernel_arg_in_grub_etc_default in kdumpctl
> unit tests: add tests for "kdumpctl reset-crashkernel"
> unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh
> unit tests: add check_config with with the default kdump.conf
>
> .shellspec | 0
> kdump-lib.sh | 7 +-
> kdumpctl | 24 +-
> spec/kdump-lib-initramfs_spec.sh | 41 ++++
> spec/kdumpctl_general_spec.sh | 175 ++++++++++++++
> spec/kdumpctl_reset_crashkernel_spec.sh | 216 ++++++++++++++++++
> spec/support/bin/@grubby | 3 +
> ...846f63134c7295458cf36300ba5b-0-rescue.conf | 8 +
> ...58cf36300ba5b-5.14.14-200.fc34.x86_64.conf | 8 +
> ...458cf36300ba5b-5.15.6-100.fc34.x86_64.conf | 8 +
> spec/support/grub_env | 3 +
> 11 files changed, 484 insertions(+), 9 deletions(-)
> create mode 100644 .shellspec
> create mode 100644 spec/kdump-lib-initramfs_spec.sh
> create mode 100644 spec/kdumpctl_general_spec.sh
> create mode 100644 spec/kdumpctl_reset_crashkernel_spec.sh
> create mode 100755 spec/support/bin/@grubby
> create mode 100644
spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf
> create mode 100644
spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf
> create mode 100644
spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf
> create mode 100644 spec/support/grub_env
>
> --
> 2.34.1
> _______________________________________________
> kexec mailing list -- kexec(a)lists.fedoraproject.org
> To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
> Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure
--
Best regards,
Coiby