(CommandList
  children: [
    (FuncDef
      name: usage
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(cat)}]
              redirects: [
                (HereDoc
                  op_id: Redir_DLess
                  fd: -1
                  body: 
                    {
                      (DQ ("\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, ") 
                        (EscapedLiteralPart token:<Lit_EscapedChar "\\$">) ("((160 * 60))\n") ("  -h         Print this help message and exit\n")
                      )
                    }
                  do_expansion: True
                  here_end: EOF
                  was_filled: True
                  spids: [15]
                )
              ]
            )
          ]
          spids: [11]
        )
      spids: [7 10]
    )
    (FuncDef
      name: die
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At "$@"))}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[48])]
            )
            (C {(exit)} {(1)})
          ]
          spids: [43]
        )
      spids: [38 42]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (C {(test)} {(${ VSub_Pound "#")} {(-ne)} {(2)})
              terminator: <Op_Semi ";">
            )
          ]
          action: [(C {(usage)}) (C {(exit)} {(1)})]
          spids: [-1 76]
        )
      ]
      spids: [-1 86]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_cmd)
          op: Equal
          rhs: {($ VSub_Number "$1")}
          spids: [89]
        )
      ]
      spids: [89]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:duration)
          op: Equal
          rhs: {($ VSub_Number "$2")}
          spids: [92]
        )
      ]
      spids: [92]
    )
    (C {(echo)} 
      {
        (DQ ("This script runs with session id ") ($ VSub_Dollar "$$") 
          (" and can be terminated by: pkill -s ") ($ VSub_Dollar "$$")
        )
      }
    )
    (Sentence
      child: 
        (C {(printf)} 
          {
            (DQ 
              (CommandSubPart
                command_list: (CommandList children:[(C {(date)})])
                left_token: <Left_CommandSub "$(">
                spids: [109 111]
              )
            )
          }
        )
      terminator: <Op_Semi ";">
    )
    (C {(echo)} {(DQ (": start running ") ($ VSub_Name "$test_cmd"))})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:start)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(date)} {(Lit_Other "+") (DQ ("%s"))})])
                left_token: <Left_CommandSub "$(">
                spids: [124 131]
              )
            }
          spids: [123]
        )
      ]
      spids: [123]
    )
    (Sentence child:(C {(eval)} {($ VSub_Name "$test_cmd")}) terminator:<Op_Amp "&">)
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_cmd_pid)
          op: Equal
          rhs: {($ VSub_Bang "$!")}
          spids: [140]
        )
      ]
      spids: [140]
    )
    (While
      cond: [
        (Sentence
          child: 
            (C {(Lit_Other "[")} 
              {
                (ArithSubPart
                  anode: 
                    (ArithBinary
                      op_id: Arith_Minus
                      left: 
                        (ArithWord
                          w: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [(C {(date)} {(Lit_Other "+") (DQ ("%s"))})]
                                  )
                                left_token: <Left_CommandSub "$(">
                                spids: [149 156]
                              )
                            }
                        )
                      right: (ArithWord w:{($ VSub_Name "$start")})
                    )
                  spids: [148 162]
                )
              } {(-lt)} {($ VSub_Name "$duration")} {(Lit_Other "]")}
            )
          terminator: <Op_Semi ";">
        )
      ]
      body: 
        (DoGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:running)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (Pipeline
                                children: [
                                  (C {(ps)} {(p)} {($ VSub_Name "$test_cmd_pid")} {(h)})
                                  (C {(wc)} {(-l)})
                                ]
                                negated: False
                              )
                            ]
                          )
                        left_token: <Left_Backtick "`">
                        spids: [175 189]
                      )
                    }
                  spids: [174]
                )
              ]
              spids: [174]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {($ VSub_Name "$running")} {(-eq)} {(0)} {(Lit_Other "]")})
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ("Test finished"))})
                    (C {(wait)} {($ VSub_Name "$test_cmd_pid")})
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:exit_status)
                          op: Equal
                          rhs: {($ VSub_QMark "$?")}
                          spids: [224]
                        )
                      ]
                      spids: [224]
                    )
                    (C {(echo)} {(DQ ("Exit status: ") ($ VSub_Name "$exit_status"))})
                    (C {(exit)} {($ VSub_Name "$exit_status")})
                  ]
                  spids: [-1 205]
                )
              ]
              spids: [-1 241]
            )
            (C {(sleep)} {(5)})
          ]
          spids: [171 249]
        )
    )
    (Sentence
      child: 
        (C {(printf)} 
          {
            (DQ 
              (CommandSubPart
                command_list: (CommandList children:[(C {(date)})])
                left_token: <Left_CommandSub "$(">
                spids: [255 257]
              )
            )
          }
        )
      terminator: <Op_Semi ";">
    )
    (C {(echo)} {(DQ (": process still running after ") ($ VSub_Name "$duration") (" seconds"))})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:tmp)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(mktemp)} {(XXXXX)})])
                left_token: <Left_Backtick "`">
                spids: [271 275]
              )
            }
          spids: [270]
        )
      ]
      spids: [270]
    )
    (SimpleCommand
      words: [{(echo)} {(DQ ("thread apply all bt"))}]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{($ VSub_Name "$tmp")} spids:[283])]
    )
    (ForEach
      iter_name: test_pid
      iter_words: [
        {
          (CommandSubPart
            command_list: (CommandList children:[(C {(pgrep)} {(-s)} {(0)})])
            left_token: <Left_CommandSub "$(">
            spids: [294 302]
          )
        }
      ]
      do_arg_iter: False
      body: 
        (DoGroup
          children: [
            (SimpleCommand
              words: [{(cat)}]
              redirects: [
                (HereDoc
                  op_id: Redir_DLess
                  fd: -1
                  body: 
                    {
                      (DQ ("==========\n") ("\n") ("Attaching gdb to ") 
                        (CommandSubPart
                          command_list: 
                            (CommandList
                              children: [
                                (C {(ps)} {(o)} {(pid) (Lit_Comma ",") (cmd)} {(p)} 
                                  {($ VSub_Name "$test_pid")} {(h)}
                                )
                              ]
                            )
                          left_token: <Left_Backtick "`">
                          spids: [316 330]
                        ) ("\n") ("\n") ("==========\n")
                      )
                    }
                  do_expansion: True
                  here_end: EOF
                  was_filled: True
                  spids: [310]
                )
              ]
            )
            (SimpleCommand
              words: [{(gdb)} {(attach)} {($ VSub_Name "$test_pid")}]
              redirects: [(Redir op_id:Redir_Less fd:-1 arg_word:{($ VSub_Name "$tmp")} spids:[342])]
            )
          ]
          spids: [305 346]
        )
      spids: [293 303]
    )
    (C {(rm)} {($ VSub_Name "$tmp")})
    (C {(echo)} {(DQ ("Test failed and killing the stuck test process"))})
    (C {(pkill)} {(-s)} {(0)})
    (C {(exit)} {(1)})
  ]
)