merged pda stuff

This commit is contained in:
Jack Halford 2017-03-03 18:52:20 +01:00
commit eac301aa16
13 changed files with 112 additions and 9 deletions

View file

@ -0,0 +1 @@
echo 'je suis un test'

View file

@ -0,0 +1 @@
ls

View file

@ -0,0 +1 @@
pwd

View file

View file

14
42sh/TESTSHELL/stdin_ref Normal file
View file

@ -0,0 +1,14 @@
42sh
Makefile
TESTSHELL
donovan_segaults_06-02
file1
file2
includes
libft
objs
pdf
sample
src
test_framework.sh
update_makefile.sh

43
42sh/TESTSHELL/stdin_test Normal file
View file

@ -0,0 +1,43 @@
 main.c 107start of shell JOBC is ON
 token_print.c 21 token print
 token_print.c 25 token : TK_WORD data [ls]

 insert_newline.c 19 insert newline
 ft_parse.c 45 

 build_tree.c 83 func TK : 'TK_WORD' TK : 'TK_WORD'
 add_cmd.c 55 add data
 ft_parse.c 45 

 build_tree.c 83 func TK : 'TK_NEWLINE' TK : 'TK_NEWLINE'
 add_sep.c 21 add sep
 ft_parse.c 45 

 ft_parse.c 58 sucessful parsing
 main.c 64 Before execution:
NEW
+----+
CMD
 ft_exec.c 39 
 ft_exec.c 48 match : TK_NEWLINE and TK_NEWLINE
 exec_semi.c 20 
 exec_semi.c 22 
 ft_exec.c 39 
 ft_exec.c 48 match : NON-DEFINED and NON-DEFINED
 exec_command.c 52 op=2118139328
42sh
Makefile
TESTSHELL
donovan_segaults_06-02
file1
file2
includes
libft
objs
pdf
sample
src
test_framework.sh
update_makefile.sh
 exec_semi.c 24 
 ft_exec.c 39 

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:49:57 by jhalford ### ########.fr */ /* Updated: 2017/03/03 18:50:48 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/02 20:44:21 by jhalford #+# #+# */ /* Created: 2017/03/02 20:44:21 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:49:39 by jhalford ### ########.fr */ /* Updated: 2017/03/03 18:51:22 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:38:14 by jhalford ### ########.fr */ /* Updated: 2017/03/03 18:52:03 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,16 +19,13 @@ int put_job_in_foreground(t_job *j, int cont)
jobc = &data_singleton()->jobc; jobc = &data_singleton()->jobc;
tcsetpgrp(STDIN, j->pgid); tcsetpgrp(STDIN, j->pgid);
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes); tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
if (cont) if (cont)
{ {
tcsetattr(STDIN, TCSADRAIN, &j->tmodes); tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
if (kill(-j->pgid, SIGCONT) < 0) if (kill(-j->pgid, SIGCONT) < 0)
DG("kill(SIGCONT) failed"); DG("kill(SIGCONT) failed");
} }
DG("before wait");
job_wait(j->id); job_wait(j->id);
DG("after wait");
job_remove(j->id); job_remove(j->id);
tcsetpgrp(STDIN, jobc->shell_pgid); tcsetpgrp(STDIN, jobc->shell_pgid);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/02 12:36:35 by jhalford ### ########.fr */ /* Updated: 2017/03/03 18:29:03 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/03 18:05:41 by jhalford ### ########.fr */ /* Updated: 2017/03/03 18:33:40 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -63,10 +63,14 @@ int handle_instruction(int fd)
} }
DG("Before execution:"); DG("Before execution:");
btree_print(STDBUG, ast, &ft_putast); btree_print(STDBUG, ast, &ft_putast);
DG();
if (ft_exec(&ast)) if (ft_exec(&ast))
return (1); return (1);
DG();
btree_del(&ast, &ast_free); btree_del(&ast, &ast_free);
DG();
ft_add_str_in_history(lexer.str); ft_add_str_in_history(lexer.str);
DG();
return (0); return (0);
} }
@ -83,6 +87,7 @@ int get_input_fd()
return (fd); return (fd);
else if (data->opts & SH_OPTS_LC) else if (data->opts & SH_OPTS_LC)
{ {
DG();
pipe(fds); pipe(fds);
fd = fds[PIPE_READ]; fd = fds[PIPE_READ];
file = shell_get_avdata(); file = shell_get_avdata();
@ -105,7 +110,7 @@ int main(int ac, char **av)
shell_init(ac, av); shell_init(ac, av);
DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s", DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s",
SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF"); SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF");
if ((fd = get_input_fd() < 0)) if ((fd = get_input_fd()) < 0)
{ {
ft_printf("{red}%s: No such file or directory\n{eoc}", SHELL_NAME); ft_printf("{red}%s: No such file or directory\n{eoc}", SHELL_NAME);
return (1); return (1);

41
42sh/test_framework.sh Executable file
View file

@ -0,0 +1,41 @@
SHELL=$1
TOTAL_TEST=0
NBR_TEST_SUCCESS=0
unset LIST_TEST
LIST_TEST='./TESTSHELL/*'/'*'.test
DIR_TEST=./TESTSHELL
do_test() {
for TEST in $LIST_TEST
do
($SHELL < $TEST 1> ${DIR_TEST}/stdin_test 2> ${DIR_TEST}/stderr_test)
(bash < $TEST 1> ${DIR_TEST}/stdin_ref 2> ${DIR_TEST}/stderr_ref)
if ! diff ${DIR_TEST}/stdin_test ${DIR_TEST}/stdin_ref > /dev/null ||
! diff ${DIR_TEST}/stderr_test ${DIR_TEST}/stderr_test > /dev/null
then
echo "\033[0;31mFAILURE $TEST" >> ${DIR_TEST}/resultat
else
((NBR_TEST_SUCCESS++))
fi
((TOTAL_TEST++))
done
}
do_test
if [ -e ${DIR_TEST}/resultat ]
then
cat ${DIR_TEST}/resultat
fi
echo "\033[0;32mYou succeed $NBR_TEST_SUCCESS tests on $TOTAL_TEST"
rm -f $DIR_TEST/resultat
#add random input sed -n $RANDOM "p" /usr/share/dict/words
#add timeout
#charging phase of test
#real verification of references
#to add extranous comportement