[Libsysio-commit] HEAD: libsysio/tests sysio_stubs.c test_all.pl test_driver.c
Brought to you by:
lward
From: Sonja T. <so...@us...> - 2003-10-28 21:02:27
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv3617/tests Modified Files: sysio_stubs.c test_all.pl test_driver.c Log Message: Fixed bug in namei that assumed a non-zero return from readlink was an error Fixed bugs in test_driver.c Added test_symlink.pl into test_all.pl Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- sysio_stubs.c 10 Oct 2003 18:50:31 -0000 1.5 +++ sysio_stubs.c 28 Oct 2003 20:59:39 -0000 1.6 @@ -557,14 +557,14 @@ int cmp_bufs(int argc, char **argv) if (argc != 2) { fprintf(outfp, "Need two buffers to compare\n"); - return -1; + return INVALID_ARGS; } index1 = get_obj(argv[0]); if (index1 < 0) { fprintf(outfp, "Unable to locate buffer %s\n", argv[0]); - return -1; + return INVALID_VAR; } buf1 = buflist[index1]->buf; @@ -572,14 +572,14 @@ int cmp_bufs(int argc, char **argv) if (index2 < 0) { fprintf(outfp, "Unable to locate buffer %s\n", argv[1]); - return -1; + return INVALID_VAR; } buf2 = buflist[index2]->buf; - res = strcmp(buf1, buf2); + last_ret_val = strcmp(buf1, buf2); DBG(3, fprintf(outfp, "strcmp returned %d\n", res)); - return res; + return SUCCESS; } int test_do_chdir(int argc, char **argv) @@ -1235,8 +1235,11 @@ int test_do_symlink(int argc, char **arg DBG(3, fprintf(outfp, "Linking %s to %s\n", argv[0], argv[1])); last_ret_val = symlink(argv[0], argv[1]); - if (last_ret_val) + if (last_ret_val) { + if (errno < 0) + errno = errno*-1; my_perror("symlink"); + } my_errno = errno; last_type = SINT; Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_all.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- test_all.pl 10 Oct 2003 18:50:31 -0000 1.4 +++ test_all.pl 28 Oct 2003 20:59:39 -0000 1.5 @@ -135,6 +135,17 @@ if ($res ne "test_stdfd successful") { print "test_stdfd finished successfully\n"; } +# Test symlink +$res = `perl $testdir/test_symlink.pl $alpha_arg $cwd/tmp_dir/helper.pm $cwd/tmp_dir/helper.foo`; +chop($res); +if ($res ne "Symlink test successful") { + print "symlink test failed with message: $res\n"; + $failures++; +} else { + $success++; + print "test_symlink finished successfully\n"; +} + print "$failures tests failed and $success tests succeeded\n"; # cleanup Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_driver.c 10 Oct 2003 18:50:31 -0000 1.3 +++ test_driver.c 28 Oct 2003 20:59:39 -0000 1.4 @@ -621,6 +621,9 @@ int add_args(char **cmd, int length, int new->val = NULL; new->cmd = build_tree(&cmd[1], &new_len, total); + if (new->cmd == NULL) { /* Invalid command */ + return length; /* Pretend we used everything up */ + } total = (length - new_len); DBG(4, fprintf(outfp, "Used %d bytes\n", total)); } @@ -659,9 +662,10 @@ cmd_tree* build_tree(char **cmd, int *le { int index = 0, used_args = 0; cmd_tree *tree; - if ((*length < 0) || (!cmd)) + if ((*length < 0) || (!cmd) || (*cmd == NULL)) return NULL; + DBG(4, fprintf(outfp, "length is %d\n", *length)); tree = (cmd_tree *)malloc(sizeof(cmd_tree)); tree->res_name = NULL; @@ -895,11 +899,14 @@ int main(int argc, char *argv[]) } i++; tree = build_tree(&cmd[i], &count, 0); + if (tree != NULL) { err = run_cmd(tree); store_result((char *)(&cmd[0][1]), last_ret_val); + } } else { tree = build_tree(cmd, &count, 0); + if (tree != NULL) err = run_cmd(tree); } /* Print out return code and any string from command */ |