Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: test kernel_match_version? function #242

Open
rli9 opened this issue Mar 28, 2023 · 4 comments
Open

spec: test kernel_match_version? function #242

rli9 opened this issue Mar 28, 2023 · 4 comments

Comments

@rli9
Copy link

rli9 commented Mar 28, 2023

The function is defined in lib/kernel_tag.rb

Reference

https://github.com/intel/lkp-tests/wiki/Coding-Standard#rspec-test

@saiteja13427
Copy link

@rli9 Can you please explain me this issue? What exactly has to be done?

@rli9
Copy link
Author

rli9 commented Apr 19, 2023

The function is to check whether kernel_version is contained in expected_kernel_versions

def kernel_match_version?(kernel_version, expected_kernel_versions)

For example

  • kernel_match_version?('v5.9', ['v4.15-rc1', '< v5.10']) is true
  • kernel_match_version?('v5.10', ['v4.15-rc1', '< v5.10']) is false
  • kernel_match_version?('v4.15', ['>= v4.15-rc1', '< v5.10']) is false # the default operator is >= if there's no operator specified before the version

Consider the workaround in code

    operator = '<' if operator == '<='

It can be tested with

  • kernel_match_version?('v5.10', ['v4.15-rc1', '<= v5.10']) is false # this looks quite confusion, but is how code is implemented now

The possible input of expected_kernel_versions can be found at etc/kconfigs.yaml, such as

  • <= v5.10
  • v4.18-rc1

Or feel free to construct valid and invalid ones

@shekhar-chauhan
Copy link

shekhar-chauhan commented Apr 19, 2023

Hey @rli9, me and @saiteja13427 were looking at your comment. We got that
def kernel_match_version?(kernel_version, expected_kernel_versions)
is present in the lib/kernel_tag.rb
But, what exactly is our ask in this?
Do we have to modify this method and to make it cleaner, or do we have to add some documentation describing this method?

@rli9
Copy link
Author

rli9 commented Apr 19, 2023

Thanks, the initial goal is to add the rspec unit test (refer to spec dir for existing ones) to test this method with either positive or negative tests based on your understanding of this method. If any issue is found (like a unit test fails which is supposed to work), you can then file a new issue after confirmed. So for the new issue (the bug fix), you can modify the method to fix the bug.

There's no requirement for documentation initially, but it would be appreciated/helpful to enhance the documentation and readability of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants