@@ -272,96 +272,51 @@ def gfullafter():
272272 os .system ('gufi_query -n1 -x -d\' |\' -E "select path(),name,type,inode,nlink,size,mode,uid,gid,blksize,blocks,mtime,ctime,linkname,xattr_names from vrpentries;" -S "select path(),name,type,inode,nlink,size,mode,uid,gid,blksize,blocks,mtime,ctime,linkname,xattr_names from vsummarydir;" -a 1 -o %s/fullbfqoutafter d0' % (top ))
273273 os .chdir (top )
274274
275- def test_prep (testn ):
276- # this cleans up and makes a fresh gufi
277- # you have to not be in the top temp directory as this deletes that and rebuilds it
275+ def test_prep (name ):
278276 os .chdir (mtmp )
279277 ginit ()
280- # set the dir back to top temp directory
281278 os .chdir (top )
282-
283- # wait a bit and make a change
284279 time .sleep (1 )
280+ print ("---------- test %s start" % (name ))
285281
286- print ("---------- test %s start" % (testn ))
287-
288- def test_finish (testn ):
282+ def test_finish (name ):
289283 print ("++++++++++ comparing bfq from fullafter and bfq from incrafter" )
290- cmd = os .system ('cmp %s/fullbfqoutafter.0 %s/incrbfqoutafter.0' % (top ,top ))
284+ cmd = os .system ('cmp %s/fullbfqoutafter.0 %s/incrbfqoutafter.0' % (top , top ))
291285 exit_code = os .WEXITSTATUS (cmd )
292- print ("---------- test %s done result %d" % (testn , exit_code ))
286+ print ("---------- test %s done result %d" % (name , exit_code ))
293287
294- def test_1 ():
295- testn = "change contents of one file"
296- test_prep (testn )
288+ # Runs a test with the given name, and calls the function operation()
289+ # to do the test-specific changes.
290+ def do_test (name , operation ):
291+ test_prep (name )
297292
298- os . system ( 'echo cheese >> d0/d00/d000/f0000' )
293+ operation ( )
299294
300295 # do a full gufi tree and a bfq on it to compare with the gufi we did an incremental on
301296 gfullafter ()
302297 # wait until incremental time
303298 time .sleep (1 )
304-
305299 # do incremental update of gufi tree
306300 gincr ("-A 3" )
307301
308- test_finish (testn )
302+ test_finish (name )
303+
304+ def test_1 ():
305+ os .system ('echo cheese >> d0/d00/d000/f0000' )
309306
310307def test_2 ():
311- testn = "delete directory segment"
312- test_prep (testn )
313308 os .system ('rm -rf d0/d00/d000' )
314309
315- # do a full gufi tree and a bfq on it to compare with the gufi we did an incremental on
316- gfullafter ()
317- # wait until incremental time
318- time .sleep (1 )
319- # do incremental update of gufi tree
320- gincr ("-A 3" )
321-
322- test_finish (testn )
323-
324-
325310def test_3 ():
326- testn = "move a directory segment"
327- test_prep (testn )
328-
329311 os .system ('mv d0/d00/d000 d0' )
330- #############################
331-
332- # do a full gufi tree and a bfq on it to compare with the gufi we did an incremental on
333- gfullafter ()
334- # wait until incremental time
335- time .sleep (1 )
336- # do incremental update of gufi tree
337- gincr ("-A 3" )
338-
339- test_finish (testn )
340312
341313def test_4 ():
342- testn = "add a directory segment"
343- test_prep (testn )
344-
345314 os .system ('mkdir d0/d00/nd000' )
346315 os .system ('touch d0/d00/nd000/fnd000' )
347316 os .system ('mkdir d0/d00/nd000/nd0000' )
348317 os .system ('touch d0/d00/nd000/nd0000/fnd0000' )
349318
350- #############################
351-
352- # do a full gufi tree and a bfq on it to compare with the gufi we did an incremental on
353- gfullafter ()
354- # wait until incremental time
355- time .sleep (1 )
356- # do incremental update of gufi tree
357- gincr ("-A 3" )
358-
359- test_finish (testn )
360-
361319def test_5 ():
362- testn = "add, delete, move multiple segments and touch an existing file"
363- test_prep (testn )
364-
365320 os .system ('mkdir d0/d00/nd000' )
366321 os .system ('touch d0/d00/nd000/fnd000' )
367322 os .system ('mkdir d0/d00/nd000/nd0000' )
@@ -372,15 +327,6 @@ def test_5():
372327 os .system ('rm -rf d0/d01/d000' )
373328 os .system ('echo cheese >> d0/d02/d020/f0200' )
374329
375- # do a full gufi tree and a bfq on it to compare with the gufi we did an incremental on
376- gfullafter ()
377- # wait until incremental time
378- time .sleep (1 )
379- # do incremental update of gufi tree
380- gincr ("-A 3" )
381-
382- test_finish (testn )
383-
384330def test_6 ():
385331 testn = "change an existing file using suspect file for file suspects"
386332 test_prep (testn )
@@ -405,9 +351,11 @@ def test_6():
405351 test_finish (testn )
406352
407353if __name__ == "__main__" :
408- test_1 ()
409- test_2 ()
410- test_3 ()
411- test_4 ()
412- test_5 ()
354+ do_test ("change contents of one file" , test_1 )
355+ do_test ("delete directory segment" , test_2 )
356+ do_test ("move a directory segment" , test_3 )
357+ do_test ("add a directory segment" , test_4 )
358+ do_test ("add, delete, move multiple segments and touch an existing file" , test_5 )
359+
360+ # test 6 has a different structure than the other 5 so it doesn't use do_test()
413361 test_6 ()
0 commit comments