X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/856e3152cf4b3d48782848ce738ed58e447f3a52..86051ed1b66342bae0e21fd6643e66331ac2c07d:/tools/tesh/run_context.h diff --git a/tools/tesh/run_context.h b/tools/tesh/run_context.h new file mode 100644 index 0000000000..1f496d74a6 --- /dev/null +++ b/tools/tesh/run_context.h @@ -0,0 +1,72 @@ +/* $Id$ */ + +/* run_context -- stuff in which TESH runs a command */ + +/* Copyright (c) 2007 Martin Quinson. */ +/* All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#ifndef TESH_RUN_CONTEXT_H +#define TESH_RUN_CONTEXT_H + +#include "tesh.h" + +typedef struct { + /* kind of job */ + char *cmd; + int pid; + int is_background:1; + int is_empty:1; + int is_stoppable:1; + int check_output:1; + + int brokenpipe:1; + int timeout:1; + + int reader_done:1; /* reader set this to true when he's done because + the child is dead. The main thread use it to detect + that the child is not dead before the end of timeout */ + + /* expected results */ + int end_time; /* begin_time + timeout, as epoch */ + char* expected_signal; /* name of signal to raise (or NULL if none) */ + int expected_return; /* the exepeted return code of following command */ + + /* buffers */ + buff_t input; + buff_t output_wanted; + buff_t output_got; + + /* Threads */ + xbt_thread_t writer, reader; /* IO handlers */ + + /* Pipes from/to the child */ + int child_to, child_from; + +} s_rctx_t, *rctx_t; + +/* module mgmt */ +void rctx_init(void); +void rctx_exit(void); + +/* wait for all currently running background jobs */ +void rctx_wait_bg(void); + +/* create a new empty running context */ +rctx_t rctx_new(void); +void rctx_free(rctx_t rctx); +void rctx_empty(rctx_t rc); /*reset to empty*/ +void rctx_dump(rctx_t rctx,const char *str); + + +/* Launch the current command */ +void rctx_start(void); +/* Wait till the end of this command */ +void *rctx_wait(void* rctx); + +/* Parse a line comming from the suite file, and add this into the rctx */ +void rctx_pushline(const char* filepos, char kind ,char *line); + +#endif /* TESH_RUN_CONTEXT_H */