1010from lisa .executable import Tool
1111from lisa .messages import TestStatus , send_sub_test_result_message
1212from lisa .node import Node
13- from lisa .operating_system import CBLMariner , Ubuntu
13+ from lisa .operating_system import (
14+ CBLMariner ,
15+ Debian ,
16+ Linux ,
17+ NixOS ,
18+ OtherLinux ,
19+ Posix ,
20+ RPMDistro ,
21+ Suse ,
22+ Ubuntu ,
23+ )
1424from lisa .testsuite import TestResult
1525from lisa .tools import Cp , Git , Ls , Make , RemoteCopy , Tar
1626from lisa .tools .chmod import Chmod
1727from lisa .tools .mkdir import Mkdir
18- from lisa .tools .whoami import Whoami
1928from lisa .util import LisaException , UnsupportedDistroException , find_groups_in_lines
2029
2130_UBUNTU_OS_PACKAGES = [
@@ -98,31 +107,56 @@ def __init__(
98107
99108 # tar file path specified in yml
100109 self ._tar_file_path = kselftest_file_path
110+ kselftest_install_path = "/tmp/kselftest"
111+ kselftest_packages = "kselftest-packages"
101112 if self ._tar_file_path :
102- self ._remote_tar_path = self .get_tool_path (
103- use_global = True
104- ) / os .path .basename (self ._tar_file_path )
105-
106- # command to run kselftests
107- self ._kself_installed_dir = (
108- self .get_tool_path (use_global = True ) / "kselftest-packages"
109- )
113+ self ._remote_tar_path = (
114+ self .node .get_pure_path (
115+ kselftest_install_path
116+ ) / os .path .basename (self ._tar_file_path )
117+ )
118+ self ._kself_installed_dir = (
119+ self .node .get_pure_path (
120+ kselftest_install_path
121+ ) / kselftest_packages
122+ )
123+ else :
124+ self ._remote_tar_path = (
125+ self .get_tool_path (
126+ use_global = True
127+ ) / os .path .basename (self ._tar_file_path )
128+ )
129+ self ._kself_installed_dir = (
130+ self .get_tool_path (use_global = True ) / kselftest_packages
131+ )
110132
111133 self ._command = self ._kself_installed_dir / "run_kselftest.sh"
112134
113135 # install common dependencies
114136 def _install (self ) -> bool :
115- if not (
137+ if (
116138 (
139+ isinstance (self .node .os , Posix )
140+ and not isinstance (self .node .os , Linux )
141+ )
142+ or (
143+ isinstance (self .node .os , Debian )
144+ and not isinstance (self .node .os , Ubuntu )
145+ )
146+ or (
117147 isinstance (self .node .os , Ubuntu )
118- and self .node .os .information .version >= "18.4.0"
148+ and self .node .os .information .version < "18.4.0"
119149 )
120- or isinstance (self .node .os , CBLMariner )
150+ or (
151+ isinstance (self .node .os , RPMDistro )
152+ and not isinstance (self .node .os , CBLMariner )
153+ )
154+ or (isinstance (self .node .os , (Suse , NixOS , OtherLinux )))
121155 ):
122156 raise UnsupportedDistroException (
123- self .node .os , "kselftests in LISA does not support this os"
157+ self .node .os ,
158+ "kselftests in LISA does not support this os"
124159 )
125-
126160 if self ._tar_file_path :
127161 mkdir = self .node .tools [Mkdir ]
128162 mkdir .create_directory (self ._remote_tar_path .parent .as_posix ())
@@ -202,14 +236,12 @@ def run_all(
202236 test_result : TestResult ,
203237 log_path : str ,
204238 timeout : int = 5000 ,
205- run_test_as_root : bool = False ,
206239 ) -> List [KselftestResult ]:
207240 # Executing kselftest as root may cause
208241 # VM to hang
209242
210- # get username
211- username = self .node .tools [Whoami ].get_username ()
212- result_directory = f"/home/{ username } "
243+ # get result directory
244+ result_directory = "/tmp/"
213245 if os .path .exists (result_directory ) is False :
214246 mkdir = self .node .tools [Mkdir ]
215247 mkdir .create_directory (result_directory )
@@ -218,7 +250,7 @@ def run_all(
218250 result_file = f"{ result_directory } /{ result_file_name } "
219251 self .run (
220252 f" 2>&1 | tee { result_file } " ,
221- sudo = run_test_as_root ,
253+ sudo = True ,
222254 force_run = True ,
223255 shell = True ,
224256 timeout = timeout ,
0 commit comments