10
10
from lisa .executable import Tool
11
11
from lisa .messages import TestStatus , send_sub_test_result_message
12
12
from 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
+ )
14
24
from lisa .testsuite import TestResult
15
25
from lisa .tools import Cp , Git , Ls , Make , RemoteCopy , Tar
16
26
from lisa .tools .chmod import Chmod
17
27
from lisa .tools .mkdir import Mkdir
18
- from lisa .tools .whoami import Whoami
19
28
from lisa .util import LisaException , UnsupportedDistroException , find_groups_in_lines
20
29
21
30
_UBUNTU_OS_PACKAGES = [
@@ -98,31 +107,56 @@ def __init__(
98
107
99
108
# tar file path specified in yml
100
109
self ._tar_file_path = kselftest_file_path
110
+ kselftest_install_path = "/tmp/kselftest"
111
+ kselftest_packages = "kselftest-packages"
101
112
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
+ )
110
132
111
133
self ._command = self ._kself_installed_dir / "run_kselftest.sh"
112
134
113
135
# install common dependencies
114
136
def _install (self ) -> bool :
115
- if not (
137
+ if (
116
138
(
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 (
117
147
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"
119
149
)
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 )))
121
155
):
122
156
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"
124
159
)
125
-
126
160
if self ._tar_file_path :
127
161
mkdir = self .node .tools [Mkdir ]
128
162
mkdir .create_directory (self ._remote_tar_path .parent .as_posix ())
@@ -202,14 +236,12 @@ def run_all(
202
236
test_result : TestResult ,
203
237
log_path : str ,
204
238
timeout : int = 5000 ,
205
- run_test_as_root : bool = False ,
206
239
) -> List [KselftestResult ]:
207
240
# Executing kselftest as root may cause
208
241
# VM to hang
209
242
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/"
213
245
if os .path .exists (result_directory ) is False :
214
246
mkdir = self .node .tools [Mkdir ]
215
247
mkdir .create_directory (result_directory )
@@ -218,7 +250,7 @@ def run_all(
218
250
result_file = f"{ result_directory } /{ result_file_name } "
219
251
self .run (
220
252
f" 2>&1 | tee { result_file } " ,
221
- sudo = run_test_as_root ,
253
+ sudo = True ,
222
254
force_run = True ,
223
255
shell = True ,
224
256
timeout = timeout ,
0 commit comments