@@ -37,7 +37,7 @@ class LTP(Test):
3737
3838 """
3939 LTP (Linux Test Project) testsuite
40- :param args: Extra arguments ("runltp " can use with
40+ :param args: Extra arguments ("kirk " can use with
4141 "-f $test")
4242 LTP Network test can run on Single host or Two host
4343 :param two_host_configuration: must be set to True
@@ -84,6 +84,8 @@ def setUp(self):
8484 smg = SoftwareManager ()
8585 dist = distro .detect ()
8686 self .args = self .params .get ('args' , default = '' )
87+ self .use_kirk = self .params .get ('use_kirk' , default = True )
88+ # Available only with runltp
8789 self .mem_leak = self .params .get ('mem_leak' , default = 0 )
8890 self .peer_public_ip = self .params .get ("peer_public_ip" , default = "" )
8991 self .peer_user = self .params .get ("peer_user" , default = "root" )
@@ -140,6 +142,23 @@ def setUp(self):
140142 archive .extract (tarball , self .ltpdir )
141143 ltp_dir = os .path .join (self .ltpdir , "ltp-master" )
142144 os .chdir (ltp_dir )
145+
146+ # Initialize and update kirk submodule only if use_kirk is True
147+ if self .use_kirk :
148+ kirk_dir = f"{ ltp_dir } /tools/kirk/kirk-src/"
149+ if os .path .exists (kirk_dir ):
150+ shutil .rmtree (kirk_dir )
151+
152+ # Initialize and update kirk submodule
153+ process .run ('git init' , shell = True , ignore_status = True )
154+ process .run ('git submodule add \
155+ https://github.com/linux-test-project/kirk.git \
156+ tools/kirk/kirk-src' ,
157+ shell = True , ignore_status = True )
158+ process .run ('git submodule update --init \
159+ --recursive tools/kirk/kirk-src' ,
160+ shell = True , ignore_status = True )
161+
143162 build .make (ltp_dir , extra_args = 'autotools' )
144163 if not self .ltpbin_dir :
145164 self .ltpbin_dir = os .path .join (self .teststmpdir , 'bin' )
@@ -202,6 +221,16 @@ def setUp(self):
202221 build .make (ltp_dir )
203222 build .make (ltp_dir , extra_args = 'install' )
204223
224+ # Verify the appropriate runner is installed
225+ if self .use_kirk :
226+ kirk_path = os .path .join (self .ltpbin_dir , 'kirk' )
227+ if not os .path .exists (kirk_path ):
228+ self .cancel ("kirk was not installed properly" )
229+ else :
230+ runltp_path = os .path .join (self .ltpbin_dir , 'runltp' )
231+ if not os .path .exists (runltp_path ):
232+ self .cancel ("runltp was not installed properly" )
233+
205234 def test (self ):
206235 logfile = os .path .join (self .logdir , 'ltp.log' )
207236 failcmdfile = os .path .join (self .logdir , 'failcmdfile' )
@@ -213,30 +242,60 @@ def test(self):
213242 else :
214243 skipfilepath = self .get_data ('skipfile' )
215244 os .chmod (self .teststmpdir , 0o755 )
216- self .args += (" -q -p -l %s -C %s -d %s -S %s"
217- % (logfile , failcmdfile , self .teststmpdir ,
218- skipfilepath ))
219- if self .mem_leak :
220- self .args += " -M %s" % self .mem_leak
221- self .ltpbin_path = os .path .join (self .ltpbin_dir , 'runltp' )
222- with open (self .ltpbin_path , 'r' ) as lfile :
223- data = lfile .read ()
224- data = data .replace (" ${LTPROOT}/IDcheck.sh || \\ " , " echo -e \" y\" | ${LTPROOT}/IDcheck.sh || \\ " )
225- with open (self .ltpbin_path , 'w' ) as ofile :
226- ofile .write (data )
227- cmd = '%s %s' % (self .ltpbin_path , self .args )
228- process .run (cmd , ignore_status = True )
229- # Walk the ltp.log and try detect failed tests from lines like these:
230- # msgctl04 FAIL 2
231- with open (logfile , 'r' ) as file_p :
232- lines = file_p .readlines ()
233- for line in lines :
234- if 'FAIL' in line :
235- value = re .split (r'\s+' , line )
236- self .failed_tests .append (value [0 ])
237-
238- if self .failed_tests :
239- self .fail ("LTP tests failed: %s" % self .failed_tests )
245+ failed_tests = []
246+
247+ if self .use_kirk :
248+ # Kirk runner execution path
249+ self .args += (" -v -d %s -S %s"
250+ % (self .teststmpdir , skipfilepath ))
251+ self .kirkbin_path = os .path .join (self .ltpbin_dir , 'kirk' )
252+ # Set LTPROOT environment variable to tell kirk where LTP
253+ # is installed
254+ env_vars = os .environ .copy ()
255+ env_vars ['LTPROOT' ] = self .ltpbin_dir
256+ cmd = '%s %s' % (self .kirkbin_path , self .args )
257+ result = process .run (cmd , ignore_status = True , env = env_vars )
258+ # Walk the stdout and try detect failed tests from lines
259+ # like these:
260+ # aio01 5 TPASS : Test 5: 10 reads and
261+ # writes in 0.000022 sec
262+ # vhangup02 1 TFAIL : vhangup02.c:88:
263+ # vhangup() failed, errno:1
264+ # and check for fail_status The first part contain test name
265+ fail_status = ['TFAIL' , 'TBROK' , 'TWARN' ]
266+ split_lines = (line .split (None , 3 )
267+ for line in result .stdout .splitlines ())
268+ failed_tests = [items [0 ] for items in split_lines
269+ if len (items ) == 4 and items [2 ] in fail_status ]
270+ else :
271+ # Legacy runltp execution path
272+ self .args += (" -q -p -l %s -C %s -d %s -S %s"
273+ % (logfile , failcmdfile , self .teststmpdir ,
274+ skipfilepath ))
275+ if self .mem_leak :
276+ self .args += " -M %s" % self .mem_leak
277+ self .ltpbin_path = os .path .join (self .ltpbin_dir , 'runltp' )
278+ # Apply IDcheck.sh workaround for runltp
279+ with open (self .ltpbin_path , 'r' ) as lfile :
280+ data = lfile .read ()
281+ data = data .replace (" ${LTPROOT}/IDcheck.sh || \\ " ,
282+ " echo -e \" y\" | ${LTPROOT}/IDcheck.sh || \\ " )
283+ with open (self .ltpbin_path , 'w' ) as ofile :
284+ ofile .write (data )
285+ cmd = '%s %s' % (self .ltpbin_path , self .args )
286+ process .run (cmd , ignore_status = True )
287+ # Walk the ltp.log and try detect failed tests from lines like these:
288+ # msgctl04 FAIL 2
289+ with open (logfile , 'r' ) as file_p :
290+ lines = file_p .readlines ()
291+ failed_tests = []
292+ for line in lines :
293+ if 'FAIL' in line :
294+ value = re .split (r'\s+' , line )
295+ failed_tests .append (value [0 ])
296+
297+ if failed_tests :
298+ self .fail ("LTP tests failed: %s" % ", " .join (failed_tests ))
240299
241300 error = dmesg .collect_errors_dmesg (['WARNING: CPU:' , 'Oops' , 'Segfault' ,
242301 'soft lockup' , 'Unable to handle' ])
0 commit comments