Skip to contentSkip to conversation

rteval: enhancement to --kcompile-source option for kernel tarball

PATCH In review Manasi Godse 2 participants 2 messages Aug 5, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rteval: enhancement to --kcompile-source option for kernel tarball

The --kcompile-source option is enhanced such that it can find the kernel source tarballs using the values as 'linux-5.18.1' , '5.18.1', 'linux-5.18.1.tar.xz' This eliminates the need to type the entire source filename as a value to the option. The enhancement will look for the tarballs in the loadsource directory.

---
 rteval/modules/loads/kcompile.py | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
rteval/modules/loads/kcompile.py +21 -4
index 6dd8d940f8b3..7d78d0ff9cae 100644
@@ -166,16 +166,33 @@ class Kcompile(CommandLineLoad):
             raise rtevalRuntimeError(self, \
                 f"error removing builddir ({self.buildir}) (ret={ret})")
 
+    def _find_tarball(self):
+       # If the user specifies the full kernel name, check if available
+        tarfile = os.path.join(self.srcdir, self._cfg.source)
+        if os.path.exists(tarfile):
+            return tarfile
+
+        if 'rc' in self._cfg.source:
+            tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\-[a-z]*\d{1,2}", self._cfg.source).group(0)
+        else:
+            tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", self._cfg.source).group(0)
+
+        # either a tar.xz or tar.gz might exist. Check for both.
+        xz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.xz" )
+        gz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.gz" )
+        if os.path.exists(xz_file):
+            return xz_file
+        elif os.path.exists(gz_file):
+            return gz_file
+        raise rtevalRuntimeError(self, f"tarfile {tarfile} does not exist!")
+
     def _WorkloadSetup(self):
         if self._donotrun:
             return
 
         # find our source tarball
         if self._cfg.source:
-            tarfile = os.path.join(self.srcdir, self._cfg.source)
-            if not os.path.exists(tarfile):
-                raise rtevalRuntimeError(self, f" tarfile {tarfile} does not exist!")
-            self.source = tarfile
+            self.source = self._find_tarball()
             kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}", self.source).group(0)
         else:
             tarfiles = glob.glob(os.path.join(self.srcdir, f"{DEFAULT_KERNEL_PREFIX}*"))
Signature · 1 line
2.31.1
Reviewed-by Leah Leshchinsky on v1 1/1
#1 lore raw
Quoted 57 lines · Manasi Godse

The --kcompile-source option is enhanced such that it can find the kernel source tarballs using the values as 'linux-5.18.1' , '5.18.1', 'linux-5.18.1.tar.xz' This eliminates the need to type the entire source filename as a value to the option. The enhancement will look for the tarballs in the loadsource directory.

---
 rteval/modules/loads/kcompile.py | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
rteval/modules/loads/kcompile.py +21 -4
index 6dd8d940f8b3..7d78d0ff9cae 100644
@@ -166,16 +166,33 @@ class Kcompile(CommandLineLoad):
             raise rtevalRuntimeError(self, \
                 f"error removing builddir ({self.buildir}) (ret={ret})")
 
+    def _find_tarball(self):
+       # If the user specifies the full kernel name, check if available
+        tarfile = os.path.join(self.srcdir, self._cfg.source)
+        if os.path.exists(tarfile):
+            return tarfile
+
+        if 'rc' in self._cfg.source:
+            tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\-[a-z]*\d{1,2}", self._cfg.source).group(0)
+        else:
+            tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", self._cfg.source).group(0)
+
+        # either a tar.xz or tar.gz might exist. Check for both.
+        xz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.xz" )
+        gz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.gz" )
+        if os.path.exists(xz_file):
+            return xz_file
+        elif os.path.exists(gz_file):
+            return gz_file
+        raise rtevalRuntimeError(self, f"tarfile {tarfile} does not exist!")
+
     def _WorkloadSetup(self):
         if self._donotrun:
             return
 
         # find our source tarball
         if self._cfg.source:
-            tarfile = os.path.join(self.srcdir, self._cfg.source)
-            if not os.path.exists(tarfile):
-                raise rtevalRuntimeError(self, f" tarfile {tarfile} does not exist!")
-            self.source = tarfile
+            self.source = self._find_tarball()
             kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}", self.source).group(0)
         else:
             tarfiles = glob.glob(os.path.join(self.srcdir, f"{DEFAULT_KERNEL_PREFIX}*"))
Signature · 1 line
2.31.1