-
- /* Wait for child, and check why it terminated */
- wait(&status);
-
- if (WIFSIGNALED(status) &&
- strcmp(signal_name(WTERMSIG(status),expected_signal),
- expected_signal)) {
- fprintf(stderr,"Child got signal %s instead of signal %s\n",
- signal_name(WTERMSIG(status),expected_signal),
- expected_signal);
- exit(WTERMSIG(status)+4);
- }
-
- if (!WIFSIGNALED(status) && expected_signal) {
- fprintf(stderr,"Child didn't got expected signal %s\n",
- expected_signal);
- exit(5);
- }
-
- if (WIFEXITED(status) && WEXITSTATUS(status) != expected_return ) {
- if (expected_return)
- fprintf(stderr,"Child returned code %d instead of %d\n",
- WEXITSTATUS(status), expected_return);
- else
- fprintf(stderr,"Child returned code %d\n", WEXITSTATUS(status));
- exit(40+WEXITSTATUS(status));
- }
- expected_return = 0;
-
- if(expected_signal){
- free(expected_signal);
- expected_signal = NULL;
- }
-
- } else { /* child */
-
- close(child_stdin[1]);
- close(child_stdout[0]);
- dup2(child_stdin[0],0);
- close(child_stdin[0]);
- dup2(child_stdout[1],1);
- dup2(child_stdout[1],2);
- close(child_stdout[1]);
-
- execlp ("/bin/sh", "sh", "-c", cmd, NULL);
- }
-}
-
-static void run_cmd(char *cmd) {
- if (cmd[0] == 'c' && cmd[1] == 'd' && cmd[2] == ' ') {
- int pos = 2;
- /* Search end */
- pos = strlen(cmd)-1;
- while (cmd[pos] == '\n' || cmd[pos] == ' ' || cmd[pos] == '\t')
- cmd[pos--] = '\0';
- /* search begining */
- pos = 2;
- while (cmd[pos++] == ' ');
- pos--;
- // fprintf(stderr,"Saw cd '%s'\n",cmd+pos);
- if (chdir(cmd+pos)) {
- perror("Chdir failed");
- exit(4);
- }
-
- } else {
- exec_cmd(cmd);
- }
-}
-
-static void handle_line(int nl, char *line) {
-
- // printf("%d: %s",nl,line); fflush(stdout);
- switch (line[0]) {
- case '#': break;
- case '$':
- check_output(); /* Check that last command ran well */
-
- printf("[%d] %s",nl,line);
- fflush(stdout);
- run_cmd(line+2);
- break;
-
+ /* search begining */
+ while (*(dir++) == ' ');
+ dir--;
+ VERB1("Saw cd '%s'",dir);
+ if (chdir(dir)) {
+ ERROR2("Chdir to %s failed: %s",dir,strerror(errno));
+ ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
+ rctx_armageddon(rctx,4);
+ }
+ break;
+ } /* else, pushline */
+ case '&':