Skip to contentSkip to conversation

avocado: Fix BUILD_DIR if it's equal to SOURCE_DIR

PATCH In review Peter Delevoryas 2 participants 4 messages Jul 2, 2022 – Jul 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avocado: Fix BUILD_DIR if it's equal to SOURCE_DIR

I like to build QEMU from the root source directory, rather than cd'ing into the build directory. This code may as well include a search path for that, so that you can run avocado tests individually without specifying "-p qemu_bin=build/qemu-system-arm" manually.

---
 tests/avocado/avocado_qemu/__init__.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
tests/avocado/avocado_qemu/__init__.py +9 -8
index b656a70c55..ed4853c805 100644
@@ -120,14 +120,15 @@ def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
     # qemu binary path does not match arch for powerpc, handle it
     if 'ppc64le' in arch:
         arch = 'ppc64'
-    qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
-    if is_readable_executable_file(qemu_bin_relative_path):
-        return qemu_bin_relative_path
-
-    qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR,
-                                              qemu_bin_relative_path)
-    if is_readable_executable_file(qemu_bin_from_bld_dir_path):
-        return qemu_bin_from_bld_dir_path
+    qemu_bin_name = bin_prefix + arch
+    qemu_bin_paths = [
+        os.path.join(".", qemu_bin_name),
+        os.path.join(BUILD_DIR, qemu_bin_name),
+        os.path.join(BUILD_DIR, "build", qemu_bin_name),
+    ]
+    for path in qemu_bin_paths:
+        if is_readable_executable_file(path):
+            return path
     return None
 
 
Signature · 1 line
2.37.0
#1 lore raw
Quoted 4 lines · Peter Delevoryas

I like to build QEMU from the root source directory, rather than cd'ing into the build directory. This code may as well include a search path for that, so that you can run avocado tests individually without specifying "-p qemu_bin=build/qemu-system-arm" manually.

Pinging this thread since I didn't get a response.

Quoted 17 lines
---
 tests/avocado/avocado_qemu/__init__.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
tests/avocado/avocado_qemu/__init__.py +0 -3
index b656a70c55..ed4853c805 100644
@@ -120,14 +120,15 @@ def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
     # qemu binary path does not match arch for powerpc, handle it
     if 'ppc64le' in arch:
         arch = 'ppc64'
-    qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
-    if is_readable_executable_file(qemu_bin_relative_path):
-        return qemu_bin_relative_path

tests/avocado/avocado_qemu/__init__.py def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None): · line 127

Quoted 10 lines
tests/avocado/avocado_qemu/__init__.py +5 -5
-
-    qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR,
-                                              qemu_bin_relative_path)
-    if is_readable_executable_file(qemu_bin_from_bld_dir_path):
-        return qemu_bin_from_bld_dir_path
+    qemu_bin_name = bin_prefix + arch
+    qemu_bin_paths = [
+        os.path.join(".", qemu_bin_name),
+        os.path.join(BUILD_DIR, qemu_bin_name),
+        os.path.join(BUILD_DIR, "build", qemu_bin_name),

Thinking about how to write this last line again, maybe it should actually be "os.path.join(SOURCE_DIR, "build", qemu_bin_name)"?

Quoted 11 lines
tests/avocado/avocado_qemu/__init__.py +4 -0
+    ]
+    for path in qemu_bin_paths:
+        if is_readable_executable_file(path):
+            return path
     return None
 
 
Signature · 1 line
2.37.0
Reviewed-by Philippe Mathieu-Daudé on v1 1/1
#2 lore raw
In reply to Peter Delevoryas
Quoted 21 lines · Peter Delevoryas

I like to build QEMU from the root source directory, rather than cd'ing into the build directory. This code may as well include a search path for that, so that you can run avocado tests individually without specifying "-p qemu_bin=build/qemu-system-arm" manually.

---
  tests/avocado/avocado_qemu/__init__.py | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
tests/avocado/avocado_qemu/__init__.py +0 -3
index b656a70c55..ed4853c805 100644
@@ -120,14 +120,15 @@ def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
      # qemu binary path does not match arch for powerpc, handle it
      if 'ppc64le' in arch:
          arch = 'ppc64'
-    qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
-    if is_readable_executable_file(qemu_bin_relative_path):
-        return qemu_bin_relative_path

tests/avocado/avocado_qemu/__init__.py def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None): · line 127

Quoted 10 lines
tests/avocado/avocado_qemu/__init__.py +5 -5
-
-    qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR,
-                                              qemu_bin_relative_path)
-    if is_readable_executable_file(qemu_bin_from_bld_dir_path):
-        return qemu_bin_from_bld_dir_path
+    qemu_bin_name = bin_prefix + arch
+    qemu_bin_paths = [
+        os.path.join(".", qemu_bin_name),
+        os.path.join(BUILD_DIR, qemu_bin_name),
+        os.path.join(BUILD_DIR, "build", qemu_bin_name),

I suppose you are building as pseudo-in-tree (see commit dedad02720: "configure: add support for pseudo-"in source tree" builds"). OK.

tests/avocado/avocado_qemu/__init__.py def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None): · line 134

Quoted 7 lines
tests/avocado/avocado_qemu/__init__.py +4 -0
+    ]
+    for path in qemu_bin_paths:
+        if is_readable_executable_file(path):
+            return path
      return None
 
 

And queued.

#3 lore raw
Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Peter Delevoryas

I like to build QEMU from the root source directory, rather than cd'ing into the build directory. This code may as well include a search path for that, so that you can run avocado tests individually without specifying "-p qemu_bin=build/qemu-system-arm" manually.

---
  tests/avocado/avocado_qemu/__init__.py | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
tests/avocado/avocado_qemu/__init__.py +0 -8
index b656a70c55..ed4853c805 100644
@@ -120,14 +120,15 @@ def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
      # qemu binary path does not match arch for powerpc, handle it
      if 'ppc64le' in arch:
          arch = 'ppc64'
-    qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
-    if is_readable_executable_file(qemu_bin_relative_path):
-        return qemu_bin_relative_path
-
-    qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR,
-                                              qemu_bin_relative_path)
-    if is_readable_executable_file(qemu_bin_from_bld_dir_path):
-        return qemu_bin_from_bld_dir_path
Quoted 8 lines

tests/avocado/avocado_qemu/__init__.py def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None): · line 127

Quoted 5 lines
tests/avocado/avocado_qemu/__init__.py +5 -0
+    qemu_bin_name = bin_prefix + arch
+    qemu_bin_paths = [
+        os.path.join(".", qemu_bin_name),
+        os.path.join(BUILD_DIR, qemu_bin_name),
+        os.path.join(BUILD_DIR, "build", qemu_bin_name),

I suppose you are building as pseudo-in-tree (see commit dedad02720:
"configure: add support for pseudo-"in source tree" builds"). OK.

That's right, thanks for adding the reference in the commit message.

Quoted 8 lines

tests/avocado/avocado_qemu/__init__.py def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None): · line 132

Quoted 6 lines
tests/avocado/avocado_qemu/__init__.py +4 -0
+    ]
+    for path in qemu_bin_paths:
+        if is_readable_executable_file(path):
+            return path
      return None

Thanks!!
Peter

Quoted 2 lines

And queued.