[Libsysio-commit] libsysio_tests: libsysio/tests helper.pm sysio_stubs.c sysio_tests.c test_all.pl t
Brought to you by:
lward
From: Sonja T. <so...@us...> - 2003-07-08 16:41:22
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv9376/tests Modified Files: Tag: libsysio_tests helper.pm sysio_stubs.c sysio_tests.c test_all.pl test_driver.c Log Message: Completed stdfd test and added it to test_all.pl Index: helper.pm =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/helper.pm,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- helper.pm 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ helper.pm 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -7,6 +7,7 @@ package helper; use strict; +use Fcntl ':mode'; BEGIN{} Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/sysio_stubs.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- sysio_stubs.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ sysio_stubs.c 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -367,7 +367,7 @@ int do_init(int argc, char **argv) } rdriver = get_str(argv[0]); - rsize = sizeof(rdriver)+1; + rsize = strlen(rdriver)+1; if (rsize > 75) { DBG(2, fprintf(outfp, "%s too long for root driver\n", rdriver)); return INVALID_ARGS; @@ -376,7 +376,7 @@ int do_init(int argc, char **argv) memcpy(root_driver, rdriver, rsize); mpath = get_str(argv[1]); - msize = sizeof(mpath)+1; + msize = strlen(mpath)+1; if (msize > 250) { DBG(2, fprintf(outfp, "%s too long for mount path\n", mpath)); return INVALID_ARGS; @@ -393,6 +393,8 @@ int do_init(int argc, char **argv) DBG(5, fprintf(outfp, "In do_init\n")); last_type = SINT; + DBG(3, fprintf(outfp, "Using driver %s, path %s, flags %x\n", + root_driver, mntpath, mntflgs)); return initilize_sysio(root_driver, mntpath, mntflgs); } @@ -1745,10 +1747,10 @@ int do_readv(int argc, char **argv) int do_read(int argc, char **argv) { - int fd, count, index, numbytes; + int fd, count, index, numbytes=0; char *buf; - if (argc != 3) { + if (argc < 3) { DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to read\n", argc)); return INVALID_ARGS; } @@ -1775,7 +1777,18 @@ int do_read(int argc, char **argv) count = get_obj(argv[2]); + if ( (argc == 4) && (!strcmp(argv[3], "delay")) ){ + int i; + /* Wait a little while for input */ + for (i=0; i < count; i++) { + sleep(0.005); + numbytes += (int) read(fd, buf, 1); + last_ret_val = numbytes; + + } + } else { last_ret_val = numbytes = (int) read(fd, buf, count); + } my_errno = errno; DBG(3, fprintf(outfp, "Read %d bytes out of %d\n", numbytes, count)); Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/sysio_tests.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- sysio_tests.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ sysio_tests.c 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -52,9 +52,10 @@ int initilize_sysio(char *root_driver, c } err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); if (err) { - my_errno = err; + my_errno = errno; my_perror("_sysio_mount_root"); - last_ret_val = errno; + perror("_sysio_mount_root"); + last_ret_val = err; return SUCCESS; } @@ -891,6 +892,7 @@ int sysio_mknod(char *path, char *mode_a if (mode < 0) { DBG(2,sprintf(output, "Cant get mode from %s\n", mode_arg)); + fprintf(stderr, "Cant get mode from %s\n", mode_arg); return INVALID_VAR; } Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_all.pl,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -w -b -B -p -r1.1.2.1 -r1.1.2.2 --- test_all.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_all.pl 8 Jul 2003 16:41:18 -0000 1.1.2.2 @@ -2,10 +2,17 @@ # # VERY basic functionality test for sysio. To run, just type ./test_all.pl +# Absolutely no guarantees for running on alpha/cplant # use strict; +my $alpha_arg = ""; +if ((@ARGV > 0) && ($ARGV[0] eq "-alpha")) { + $alpha_arg = "-alpha"; +} + + # Will use this directory... system("mkdir tmp_dir"); @@ -20,7 +27,7 @@ $sysdir =~ s/\/\w+$//; # Test getdirentries -my $res = `./test_list.pl ../`; +my $res = `./test_list.pl $alpha_arg ../`; chop($res); if ($res ne "list test successful") { print "Basic getdirentries test failed with message: $res\n"; @@ -30,7 +37,7 @@ if ($res ne "list test successful") { } # Test mount -$res = `./test_list.pl -m native:$sysdir $cwd/tmp_dir`; +$res = `./test_list.pl $alpha_arg -m native:$sysdir $cwd/tmp_dir`; chop($res); if ($res ne "list test successful") { print "Mount test failed with message: $res\n"; @@ -40,7 +47,7 @@ if ($res ne "list test successful") { } # Test getcwd -$res = `./test_getcwd.pl $sysdir`; +$res = `./test_getcwd.pl $alpha_arg $sysdir`; chop($res); if ($res ne "getcwd test successful") { print "getcwd test failed with message: $res\n"; @@ -50,7 +57,7 @@ if ($res ne "getcwd test successful") { } # Test copy -$res = `./test_copy.pl ../README tmp_dir/README`; +$res = `./test_copy.pl $alpha_arg ../README tmp_dir/README`; chop($res); if ($res ne "copy test successful") { print "copy test failed with message: $res\n"; @@ -60,10 +67,20 @@ if ($res ne "copy test successful") { } # Test stats -$res = `./test_stats.pl tmp_dir/README`; +$res = `./test_stats.pl $alpha_arg tmp_dir/README`; chop($res); if ($res ne "stat test successful") { print "stat test failed with message: $res\n"; + $failures++; +} else { + $success++; +} + +# Test stdfd +$res = `./test_stdfd.pl $alpha_arg foo_dir`; +chop($res); +if ($res ne "test_stdfd successful") { + print "stdfd test failed with message: $res\n"; $failures++; } else { $success++; Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_driver.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_driver.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ test_driver.c 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -189,7 +189,7 @@ struct var_mapping *get_map(char *var_na index = dx_hack_hash(var_name, strlen(var_name)); index %= MAX_VARS -1; - DBG(5, fprintf(outfp, "Got index of %d\n", index)); + DBG(5, fprintf(outfp, "Got index of %d for %s\n", index, var_name)); curr = &map[index]; while ((curr) && (curr->map.obj != -1) ) { @@ -220,6 +220,8 @@ int get_obj(char *var_name) struct var_mapping *var_map; int i; + DBG(5, fprintf(outfp, "Getting object for %s\n", var_name)); + /* If var_name is a digit, we assume it is a literal */ if (isdigit(var_name[0])) return atoi(var_name); @@ -236,6 +238,7 @@ int get_obj(char *var_name) struct var_mapping *tmp_map; memcpy(str1, var_name, i); + str1[i] = '\0'; memcpy(str2, (char *)&var_name[i+1], strlen(var_name)-i); if (isdigit(str1[0])) { |