Megatest

Hex Artifact Content
Login

Artifact a529a5a104460a3229cc380dfcc9a59604906ab4:


0000: 23 20 54 68 69 73 20 69 73 20 74 68 65 20 6c 69  # This is the li
0010: 62 72 61 72 79 20 6f 66 20 73 74 75 66 66 20 66  brary of stuff f
0020: 6f 72 20 6d 65 67 61 74 65 73 74 0a 0a 64 65 66  or megatest..def
0030: 20 72 75 6e 5f 61 6e 64 5f 72 65 63 6f 72 64 28   run_and_record(
0040: 73 74 65 70 6e 61 6d 65 2c 20 63 6d 64 2c 20 63  stepname, cmd, c
0050: 68 65 63 6b 73 29 0a 20 20 73 79 73 74 65 6d 20  hecks).  system 
0060: 22 6d 65 67 61 74 65 73 74 20 2d 73 74 65 70 20  "megatest -step 
0070: 23 7b 73 74 65 70 6e 61 6d 65 7d 20 3a 73 74 61  #{stepname} :sta
0080: 74 65 20 73 74 61 72 74 20 3a 73 74 61 74 75 73  te start :status
0090: 20 6e 2f 61 22 0a 20 20 73 79 73 74 65 6d 20 63   n/a".  system c
00a0: 6d 64 0a 20 20 65 78 69 74 63 6f 64 65 3d 24 3f  md.  exitcode=$?
00b0: 0a 20 20 69 66 20 65 78 69 74 63 6f 64 65 3d 3d  .  if exitcode==
00c0: 30 0a 20 20 20 20 65 78 69 74 63 6f 64 65 3d 27  0.    exitcode='
00d0: 70 61 73 73 27 0a 20 20 65 6c 73 65 0a 20 20 20  pass'.  else.   
00e0: 20 65 78 69 74 63 6f 64 65 3d 27 66 61 69 6c 27   exitcode='fail'
00f0: 0a 20 20 65 6e 64 0a 20 20 73 79 73 74 65 6d 20  .  end.  system 
0100: 22 6d 65 67 61 74 65 73 74 20 2d 73 74 65 70 20  "megatest -step 
0110: 23 7b 73 74 65 70 6e 61 6d 65 7d 20 3a 73 74 61  #{stepname} :sta
0120: 74 65 20 65 6e 64 20 3a 73 74 61 74 75 73 20 23  te end :status #
0130: 7b 65 78 69 74 63 6f 64 65 7d 22 0a 65 6e 64 0a  {exitcode}".end.
0140: 0a 64 65 66 20 72 65 63 6f 72 64 5f 73 74 65 70  .def record_step
0150: 28 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c  (stepname,state,
0160: 73 74 61 74 75 73 29 0a 20 20 73 79 73 74 65 6d  status).  system
0170: 20 22 6d 65 67 61 74 65 73 74 20 2d 73 74 65 70   "megatest -step
0180: 20 23 7b 73 74 65 70 6e 61 6d 65 7d 20 3a 73 74   #{stepname} :st
0190: 61 74 65 20 23 7b 73 74 61 74 65 7d 20 3a 73 74  ate #{state} :st
01a0: 61 74 75 73 20 23 7b 73 74 61 74 75 73 7d 22 0a  atus #{status}".
01b0: 65 6e 64 0a 0a 64 65 66 20 74 65 73 74 5f 73 74  end..def test_st
01c0: 61 74 75 73 28 73 74 61 74 65 2c 73 74 61 74 75  atus(state,statu
01d0: 73 29 0a 20 20 73 79 73 74 65 6d 20 22 6d 65 67  s).  system "meg
01e0: 61 74 65 73 74 20 2d 74 65 73 74 2d 73 74 61 74  atest -test-stat
01f0: 75 73 20 3a 73 74 61 74 65 20 23 7b 73 74 61 74  us :state #{stat
0200: 65 7d 20 3a 73 74 61 74 75 73 20 23 7b 73 74 61  e} :status #{sta
0210: 74 75 73 7d 22 0a 65 6e 64 0a 0a 0a 23 20 57 41  tus}".end...# WA
0220: 52 4e 49 4e 47 3a 20 54 68 69 73 20 65 78 61 6d  RNING: This exam
0230: 70 6c 65 20 69 73 20 64 65 70 72 65 63 61 74 65  ple is deprecate
0240: 64 2e 20 44 6f 6e 27 74 20 75 73 65 20 74 68 65  d. Don't use the
0250: 20 2d 74 65 73 74 2d 73 74 61 74 75 73 20 63 6f   -test-status co
0260: 6d 6d 61 6e 64 0a 23 20 20 20 20 20 20 20 20 20  mmand.#         
0270: 20 75 6e 6c 65 73 73 20 79 6f 75 20 6b 6e 6f 77   unless you know
0280: 20 66 6f 72 20 73 75 72 65 20 77 68 61 74 20 79   for sure what y
0290: 6f 75 20 61 72 65 20 64 6f 69 6e 67 2e 0a 64 65  ou are doing..de
02a0: 66 20 66 69 6c 65 5f 73 69 7a 65 5f 63 68 65 63  f file_size_chec
02b0: 6b 65 72 28 73 74 65 70 6e 61 6d 65 2c 66 69 6c  ker(stepname,fil
02c0: 65 6e 61 6d 65 2c 6d 69 6e 73 69 7a 65 2c 6d 61  ename,minsize,ma
02d0: 78 73 69 7a 65 29 0a 20 20 66 73 69 7a 65 3d 46  xsize).  fsize=F
02e0: 69 6c 65 2e 73 69 7a 65 28 66 69 6c 65 6e 61 6d  ile.size(filenam
02f0: 65 29 0a 20 20 69 66 20 66 73 69 7a 65 20 3e 20  e).  if fsize > 
0300: 6d 61 78 73 69 7a 65 20 6f 72 20 66 73 69 7a 65  maxsize or fsize
0310: 20 3c 20 6d 69 6e 73 69 7a 65 0a 20 20 20 20 73   < minsize.    s
0320: 79 73 74 65 6d 20 22 6d 65 67 61 74 65 73 74 20  ystem "megatest 
0330: 2d 74 65 73 74 2d 73 74 61 74 75 73 20 3a 73 74  -test-status :st
0340: 61 74 65 20 43 4f 4d 50 4c 45 54 45 44 20 3a 73  ate COMPLETED :s
0350: 74 61 74 75 73 20 66 61 69 6c 22 0a 20 20 65 6c  tatus fail".  el
0360: 73 65 0a 20 20 20 73 79 73 74 65 6d 20 22 6d 65  se.   system "me
0370: 67 61 74 65 73 74 20 2d 74 65 73 74 2d 73 74 61  gatest -test-sta
0380: 74 75 73 20 3a 73 74 61 74 65 20 43 4f 4d 50 4c  tus :state COMPL
0390: 45 54 45 44 20 3a 73 74 61 74 75 73 20 70 61 73  ETED :status pas
03a0: 73 22 0a 20 20 65 6e 64 0a 65 6e 64 0a 0a 0a 64  s".  end.end...d
03b0: 65 66 20 77 61 69 74 5f 66 6f 72 5f 73 74 65 70  ef wait_for_step
03c0: 28 74 65 73 74 6e 61 6d 65 2c 73 74 65 70 6e 61  (testname,stepna
03d0: 6d 65 29 0a 65 6e 64 0a                          me).end.