(command.CommandList
  children: [
    (command.FuncDef
      name: usage
      body: 
        (command.BraceGroup
          children: [
            (command.SimpleCommand
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 36
                  stdin_parts: [
                    ('\n')
                    (
'Run Mesos tests within a duration and attach gdb if the tests time out. This\n'
                    )
                    (
'script will run the test command under the current work directory. To put the\n'
                    )
                    (
'time limit only on tests, compile the project before running the script. This\n'
                    )
                    ('script works only on Linux.\n')
                    ('\n')
                    ('Usage: ')
                    ($ VSub_Number '$0')
                    (' [-h] <test_cmd> <duration>\n')
                    ('\n')
                    ('  test_cmd   Command that runs the tests.\n')
                    ('             e.g., MESOS_VERBOSE=1 make check GTEST_SHUFFLE=1\n')
                    ('  duration   Duration (in seconds) before the tests time out.\n')
                    ('             e.g., 3600, ')
                    (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\$'>)
                    ('((160 * 60))\n')
                    ('  -h         Print this help message and exit\n')
                  ]
                )
              ]
            )
          ]
          spids: [11]
        )
      spids: [7 10]
    )
    (command.FuncDef
      name: die
      body: 
        (command.BraceGroup
          children: [
            (command.SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At '$@'))}]
              redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
            )
            (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
          ]
          spids: [45]
        )
      spids: [40 44]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: (C {(test)} {(${ VSub_Pound '#')} {(-ne)} {(2)})
              terminator: <Op_Semi ';'>
            )
          ]
          action: [(C {(usage)}) (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})]
          spids: [16777215 78]
        )
      ]
      spids: [16777215 88]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_cmd spids:[91])
          op: Equal
          rhs: {($ VSub_Number '$1')}
          spids: [91]
        )
      ]
      spids: [91]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:duration spids:[94])
          op: Equal
          rhs: {($ VSub_Number '$2')}
          spids: [94]
        )
      ]
      spids: [94]
    )
    (C {(echo)} 
      {
        (DQ ('This script runs with session id ') ($ VSub_Dollar '$$') 
          (' and can be terminated by: pkill -s ') ($ VSub_Dollar '$$')
        )
      }
    )
    (command.CommandList
      children: [
        (command.Sentence
          child: 
            (C {(printf)} 
              {
                (DQ 
                  (word_part.CommandSubPart
                    command_list: (command.CommandList children:[(C {(date)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [111 113]
                  )
                )
              }
            )
          terminator: <Op_Semi ';'>
        )
        (C {(echo)} {(DQ (': start running ') ($ VSub_DollarName '$test_cmd'))})
      ]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:start spids:[125])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [(C {(date)} {(Lit_Other '+') (DQ ('%s'))})]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [126 133]
              )
            }
          spids: [125]
        )
      ]
      spids: [125]
    )
    (command.Sentence
      child: (C {(eval)} {($ VSub_DollarName '$test_cmd')})
      terminator: <Op_Amp '&'>
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_cmd_pid spids:[142])
          op: Equal
          rhs: {($ VSub_Bang '$!')}
          spids: [142]
        )
      ]
      spids: [142]
    )
    (command.WhileUntil
      keyword: <KW_While while>
      cond: [
        (command.Sentence
          child: 
            (C {(Lit_Other '[')} 
              {
                (word_part.ArithSubPart
                  anode: 
                    (arith_expr.ArithBinary
                      op_id: Arith_Minus
                      left: 
                        (arith_expr.ArithWord
                          w: 
                            {
                              (word_part.CommandSubPart
                                command_list: 
                                  (command.CommandList
                                    children: [(C {(date)} {(Lit_Other '+') (DQ ('%s'))})]
                                  )
                                left_token: <Left_CommandSub '$('>
                                spids: [151 158]
                              )
                            }
                        )
                      right: (arith_expr.ArithWord w:{($ VSub_DollarName '$start')})
                    )
                  spids: [150 164]
                )
              } {(-lt)} {($ VSub_DollarName '$duration')} {(Lit_Other ']')}
            )
          terminator: <Op_Semi ';'>
        )
      ]
      body: 
        (command.DoGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:running spids:[176])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(ps)} {(p)} {($ VSub_DollarName '$test_cmd_pid')} {(h)})
                                  (C {(wc)} {(-l)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [177 191]
                      )
                    }
                  spids: [176]
                )
              ]
              spids: [176]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_Other '[')} {($ VSub_DollarName '$running')} {(-eq)} {(0)} 
                          {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ('Test finished'))})
                    (C {(wait)} {($ VSub_DollarName '$test_cmd_pid')})
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:exit_status spids:[226])
                          op: Equal
                          rhs: {($ VSub_QMark '$?')}
                          spids: [226]
                        )
                      ]
                      spids: [226]
                    )
                    (C {(echo)} {(DQ ('Exit status: ') ($ VSub_DollarName '$exit_status'))})
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {($ VSub_DollarName '$exit_status')}
                    )
                  ]
                  spids: [16777215 207]
                )
              ]
              spids: [16777215 243]
            )
            (C {(sleep)} {(5)})
          ]
          spids: [173 251]
        )
    )
    (command.CommandList
      children: [
        (command.Sentence
          child: 
            (C {(printf)} 
              {
                (DQ 
                  (word_part.CommandSubPart
                    command_list: (command.CommandList children:[(C {(date)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [257 259]
                  )
                )
              }
            )
          terminator: <Op_Semi ';'>
        )
        (C {(echo)} 
          {(DQ (': process still running after ') ($ VSub_DollarName '$duration') (' seconds'))}
        )
      ]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:tmp spids:[272])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: (command.CommandList children:[(C {(mktemp)} {(XXXXX)})])
                left_token: <Left_Backtick '`'>
                spids: [273 277]
              )
            }
          spids: [272]
        )
      ]
      spids: [272]
    )
    (command.SimpleCommand
      words: [{(echo)} {(DQ ('thread apply all bt'))}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{($ VSub_DollarName '$tmp')})]
    )
    (command.ForEach
      iter_name: test_pid
      iter_words: [
        {
          (word_part.CommandSubPart
            command_list: (command.CommandList children:[(C {(pgrep)} {(-s)} {(0)})])
            left_token: <Left_CommandSub '$('>
            spids: [296 304]
          )
        }
      ]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.SimpleCommand
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 337
                  stdin_parts: [
                    ('==========\n')
                    ('\n')
                    ('Attaching gdb to ')
                    (word_part.CommandSubPart
                      command_list: 
                        (command.CommandList
                          children: [
                            (C {(ps)} {(o)} {(pid) (Lit_Comma ',') (cmd)} {(p)} 
                              {($ VSub_DollarName '$test_pid')} {(h)}
                            )
                          ]
                        )
                      left_token: <Left_Backtick '`'>
                      spids: [318 332]
                    )
                    ('\n')
                    ('\n')
                    ('==========\n')
                  ]
                )
              ]
            )
            (command.SimpleCommand
              words: [{(gdb)} {(attach)} {($ VSub_DollarName '$test_pid')}]
              redirects: [
                (redir.Redir
                  op: <Redir_Less '<'>
                  fd: 16777215
                  arg_word: {($ VSub_DollarName '$tmp')}
                )
              ]
            )
          ]
          spids: [307 350]
        )
      spids: [295 305]
    )
    (C {(rm)} {($ VSub_DollarName '$tmp')})
    (C {(echo)} {(DQ ('Test failed and killing the stuck test process'))})
    (C {(pkill)} {(-s)} {(0)})
    (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
  ]
)