(command.CommandList children: [ (command.ShFunction name: usage body: (BraceGroup children: [ (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc 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: '> ($ Id.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.EscapedLiteral token: <Id.Lit_EscapedChar '\\$'> ) <'((160 * 60))\n'> <' -h Print this help message and exit\n'> ] ) ) ] do_fork: T ) ] ) ) (command.ShFunction name: die body: (BraceGroup children: [ (command.Simple words: [{<echo>} {(DQ ($ Id.VSub_At '$@'))}] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] ) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<test>} {(${ Id.VSub_Pound '#')} {<-ne>} {<2>}) terminator: <Id.Op_Semi _> ) ] ) action: [(C {<usage>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})] spids: [65 78] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_cmd) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [91] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:duration) op: assign_op.Equal rhs: {($ Id.VSub_Number '$2')} spids: [94] ) ] ) (C {<echo>} { (DQ <'This script runs with session id '> ($ Id.VSub_Dollar '$$') <' and can be terminated by: pkill -s '> ($ Id.VSub_Dollar '$$') ) } ) (command.CommandList children: [ (command.Sentence child: (C {<printf>} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<date>})))}) terminator: <Id.Op_Semi _> ) (C {<echo>} {(DQ <': start running '> ($ Id.VSub_DollarName '$test_cmd'))}) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:start) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<date>} {<Id.Lit_Other '+'> (DQ <'%s'>)}) ) } spids: [125] ) ] ) (command.Sentence child: (C {<eval>} {($ Id.VSub_DollarName '$test_cmd')}) terminator: <Id.Op_Amp _> ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_cmd_pid) op: assign_op.Equal rhs: {($ Id.VSub_Bang '$!')} spids: [142] ) ] ) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Minus left: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<date>} {<Id.Lit_Other '+'> (DQ <'%s'>)}) ) } right: {($ Id.VSub_DollarName '$start')} ) ) } {<-lt>} {($ Id.VSub_DollarName '$duration')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) body: (command.DoGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:running) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<ps>} {<p>} {($ Id.VSub_DollarName '$test_cmd_pid')} {<h>}) (C {<wc>} {<-l>}) ] negated: F ) ) } spids: [176] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$running')} {<-eq>} {<0>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<echo>} {(DQ <'Test finished'>)}) (C {<wait>} {($ Id.VSub_DollarName '$test_cmd_pid')}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:exit_status) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [228] ) ] ) (C {<echo>} {(DQ <'Exit status: '> ($ Id.VSub_DollarName '$exit_status'))}) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {($ Id.VSub_DollarName '$exit_status')} ) ] spids: [196 209] ) ] ) (C {<sleep>} {<5>}) ] ) ) (command.CommandList children: [ (command.Sentence child: (C {<printf>} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<date>})))}) terminator: <Id.Op_Semi _> ) (C {<echo>} {(DQ <': process still running after '> ($ Id.VSub_DollarName '$duration') <' seconds'>)} ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tmp) op: assign_op.Equal rhs: {(command_sub left_token:<Id.Left_Backtick '`'> child:(C {<mktemp>} {<XXXXX>}))} spids: [274] ) ] ) (command.Simple words: [{<echo>} {(DQ <'thread apply all bt'>)}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$tmp')} ) ] do_fork: T ) (command.ForEach iter_name: test_pid iter_words: [{(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pgrep>} {<-s>} {<0>}))}] do_arg_iter: F body: (command.DoGroup children: [ (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {<EOF>} here_end_span_id: 343 stdin_parts: [ <'==========\n'> <'\n'> <'Attaching gdb to '> (command_sub left_token: <Id.Left_Backtick '`'> child: (C {<ps>} {<o>} {<pid> <Id.Lit_Comma ','> <cmd>} {<p>} {($ Id.VSub_DollarName '$test_pid')} {<h>} ) ) <'\n'> <'\n'> <'==========\n'> ] ) ) ] do_fork: T ) (command.Simple words: [{<gdb>} {<attach>} {($ Id.VSub_DollarName '$test_pid')}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {($ Id.VSub_DollarName '$tmp')} ) ] do_fork: T ) ] ) ) (C {<rm>} {($ Id.VSub_DollarName '$tmp')}) (C {<echo>} {(DQ <'Test failed and killing the stuck test process'>)}) (C {<pkill>} {<-s>} {<0>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] )