All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] tools/testing/kunit/kunit.py: remove redundant double check
@ 2023-01-18  7:42 Alexander Pantyukhin
  2023-01-20  6:35 ` David Gow
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Pantyukhin @ 2023-01-18  7:42 UTC (permalink / raw)
  To: davidgow
  Cc: dlatypov, brendan.higgins, linux-kselftest, kunit-dev,
	linux-kernel, akpm, Alexander Pantyukhin

The build_tests function contained double checking for not success
result. It is fixed in the current patch. Additional small
simplifications of code like using ternary if were applied (avoid using
the same operation by calculation times differ in two places).

Signed-off-by: Alexander Pantyukhin <apantykhin@gmail.com>
---
 tools/testing/kunit/kunit.py | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 43fbe96318fe..0e3e08cc0204 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -77,11 +77,8 @@ def config_tests(linux: kunit_kernel.LinuxSourceTree,
 	config_start = time.time()
 	success = linux.build_reconfig(request.build_dir, request.make_options)
 	config_end = time.time()
-	if not success:
-		return KunitResult(KunitStatus.CONFIG_FAILURE,
-				   config_end - config_start)
-	return KunitResult(KunitStatus.SUCCESS,
-			   config_end - config_start)
+	status = KunitStatus.SUCCESS if success else KunitStatus.CONFIG_FAILURE
+	return KunitResult(status, config_end - config_start)
 
 def build_tests(linux: kunit_kernel.LinuxSourceTree,
 		request: KunitBuildRequest) -> KunitResult:
@@ -92,14 +89,8 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree,
 				     request.build_dir,
 				     request.make_options)
 	build_end = time.time()
-	if not success:
-		return KunitResult(KunitStatus.BUILD_FAILURE,
-				   build_end - build_start)
-	if not success:
-		return KunitResult(KunitStatus.BUILD_FAILURE,
-				   build_end - build_start)
-	return KunitResult(KunitStatus.SUCCESS,
-			   build_end - build_start)
+	status = KunitStatus.SUCCESS if success else KunitStatus.BUILD_FAILURE
+	return KunitResult(status, build_end - build_start)
 
 def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree,
 			   request: KunitBuildRequest) -> KunitResult:
@@ -145,7 +136,7 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -
 		tests = _list_tests(linux, request)
 		if request.run_isolated == 'test':
 			filter_globs = tests
-		if request.run_isolated == 'suite':
+		elif request.run_isolated == 'suite':
 			filter_globs = _suites_from_test_list(tests)
 			# Apply the test-part of the user's glob, if present.
 			if '.' in request.filter_glob:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] tools/testing/kunit/kunit.py: remove redundant double check
  2023-01-18  7:42 [PATCH V2] tools/testing/kunit/kunit.py: remove redundant double check Alexander Pantyukhin
@ 2023-01-20  6:35 ` David Gow
  0 siblings, 0 replies; 2+ messages in thread
From: David Gow @ 2023-01-20  6:35 UTC (permalink / raw)
  To: Alexander Pantyukhin
  Cc: dlatypov, brendan.higgins, linux-kselftest, kunit-dev,
	linux-kernel, akpm

[-- Attachment #1: Type: text/plain, Size: 3076 bytes --]

On Wed, 18 Jan 2023 at 15:42, Alexander Pantyukhin <apantykhin@gmail.com> wrote:
>
> The build_tests function contained double checking for not success
> result. It is fixed in the current patch. Additional small
> simplifications of code like using ternary if were applied (avoid using
> the same operation by calculation times differ in two places).
>
> Signed-off-by: Alexander Pantyukhin <apantykhin@gmail.com>
> ---

Looks good, thanks!

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David

>  tools/testing/kunit/kunit.py | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
> index 43fbe96318fe..0e3e08cc0204 100755
> --- a/tools/testing/kunit/kunit.py
> +++ b/tools/testing/kunit/kunit.py
> @@ -77,11 +77,8 @@ def config_tests(linux: kunit_kernel.LinuxSourceTree,
>         config_start = time.time()
>         success = linux.build_reconfig(request.build_dir, request.make_options)
>         config_end = time.time()
> -       if not success:
> -               return KunitResult(KunitStatus.CONFIG_FAILURE,
> -                                  config_end - config_start)
> -       return KunitResult(KunitStatus.SUCCESS,
> -                          config_end - config_start)
> +       status = KunitStatus.SUCCESS if success else KunitStatus.CONFIG_FAILURE
> +       return KunitResult(status, config_end - config_start)
>
>  def build_tests(linux: kunit_kernel.LinuxSourceTree,
>                 request: KunitBuildRequest) -> KunitResult:
> @@ -92,14 +89,8 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree,
>                                      request.build_dir,
>                                      request.make_options)
>         build_end = time.time()
> -       if not success:
> -               return KunitResult(KunitStatus.BUILD_FAILURE,
> -                                  build_end - build_start)
> -       if not success:
> -               return KunitResult(KunitStatus.BUILD_FAILURE,
> -                                  build_end - build_start)
> -       return KunitResult(KunitStatus.SUCCESS,
> -                          build_end - build_start)
> +       status = KunitStatus.SUCCESS if success else KunitStatus.BUILD_FAILURE
> +       return KunitResult(status, build_end - build_start)
>
>  def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree,
>                            request: KunitBuildRequest) -> KunitResult:
> @@ -145,7 +136,7 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -
>                 tests = _list_tests(linux, request)
>                 if request.run_isolated == 'test':
>                         filter_globs = tests
> -               if request.run_isolated == 'suite':
> +               elif request.run_isolated == 'suite':
>                         filter_globs = _suites_from_test_list(tests)
>                         # Apply the test-part of the user's glob, if present.
>                         if '.' in request.filter_glob:
> --
> 2.25.1
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-20  6:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18  7:42 [PATCH V2] tools/testing/kunit/kunit.py: remove redundant double check Alexander Pantyukhin
2023-01-20  6:35 ` David Gow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.