[Libsysio-commit] HEAD: libsysio/tests sysio_stubs.c sysio_tests.c test_path.pl test_stats.pl
Brought to you by:
lward
From: Sonja T. <so...@us...> - 2004-03-12 21:10:23
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14676/tests Modified Files: sysio_stubs.c sysio_tests.c test_path.pl test_stats.pl Log Message: Make tests work on x86_64 platform. Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- sysio_stubs.c 1 Mar 2004 22:46:39 -0000 1.11 +++ sysio_stubs.c 12 Mar 2004 20:42:41 -0000 1.12 @@ -144,14 +144,14 @@ int test_do_fillbuff(int argc, char **ar size, buf, (char *)valptr)); memcpy(buf, valptr, size); } else if (!strcmp(typestr, "PTR")) { - unsigned int val; + unsigned long val; int index = get_obj(argv[0]); if (index < 0) { DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[0])); return INVALID_VAR; } - val = (unsigned int)buflist[index]->buf; + val = (unsigned long)buflist[index]->buf; valptr = &val; DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %p\n", size, buf, valptr)); @@ -220,7 +220,7 @@ int test_do_printbuf(int argc, char **ar if (argv[0][0] == '$') { if (argv[0][1] == '$') { - sprintf(output, "\n%#010x", last_ret_val); + sprintf(output, "\n%#010x", (unsigned int)last_ret_val); return SUCCESS; } else if (!strcmp("errno", &argv[0][1])) { sprintf(output, "\n%#010x", my_errno); @@ -847,7 +847,7 @@ int test_do_fcntl(int argc, char **argv) last_ret_val = sysio_fcntl(fd, cmd, argv[2]); else last_ret_val = sysio_fcntl(fd, cmd, NULL); - DBG(4, fprintf(outfp, "Got return value of %d\n", last_ret_val)); + DBG(4, fprintf(outfp, "Got return value of %d\n", (int)last_ret_val)); my_errno = errno; last_type = SINT; @@ -1019,7 +1019,9 @@ int test_do_getcwd(int argc, char **argv DBG(4, fprintf(outfp, "Getting cwd with buffer size of %d\n", size)); - if (!(last_ret_val = (int)getcwd(buf, size))) { + last_ret_val = 0; + if (!getcwd(buf, size)) { + last_ret_val = -1; if (errno == ERANGE) { DBG(2, fprintf(outfp, "Need a bigger buffer!\n")); } @@ -1027,6 +1029,7 @@ int test_do_getcwd(int argc, char **argv my_errno = errno; + DBG(3, fprintf(outfp, "cwd: %s\n", buf)); last_type = SINT; @@ -1400,7 +1403,7 @@ int test_do_umask(int argc, char **argv) int test_do_iowait(int argc, char **argv) { - int err; + long err; ioid_t ioid; if (argc != 1) { @@ -1428,7 +1431,7 @@ int test_do_iowait(int argc, char **argv int test_do_iodone(int argc, char **argv) { - int err; + long err; ioid_t ioid; if (argc != 1) { @@ -1490,7 +1493,7 @@ int test_do_ipread(int argc, char **argv return INVALID_ARGS; } - last_ret_val = (int) ipread(fd, buf, count, offset); + last_ret_val = (long)ipread(fd, buf, count, offset); if (last_ret_val < 0) { my_perror("ipread"); } @@ -1530,7 +1533,7 @@ int test_do_iread(int argc, char **argv) return INVALID_ARGS; } - last_ret_val = (int) iread(fd, buf, count); + last_ret_val = (long) iread(fd, buf, count); if (last_ret_val < 0) { my_perror("iread"); } @@ -1584,9 +1587,9 @@ int test_do_ipreadv(int argc, char **arg } DBG(3, fprintf(outfp, "ipreadv(fd: %d vector:{iov_base: %p iov_len %d} count: %d offset: %d\n", - fd, iov->iov_base, iov->iov_len, count, (int) offset)); + fd, iov->iov_base, (int)iov->iov_len, count, (int) offset)); - last_ret_val = (int) ipreadv(fd, iov, count, offset); + last_ret_val = (long) ipreadv(fd, iov, count, offset); if (last_ret_val < 0) my_perror("ipreadv"); my_errno = errno; @@ -1639,7 +1642,7 @@ int test_do_preadv(int argc, char **argv } DBG(3, fprintf(outfp, "preadv(fd: %d vector:{iov_base: %p iov_len %d} count: %d offset: %d\n", - fd, iov->iov_base, iov->iov_len, count, (int) offset)); + fd, iov->iov_base, (int) iov->iov_len, count, (int) offset)); last_ret_val = preadv(fd, iov, count, offset); my_errno = errno; @@ -1740,9 +1743,9 @@ int test_do_ireadv(int argc, char **argv } DBG(3, fprintf(outfp, "ireadv (fd: %d, vector:{ iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, iov->iov_len, count)); + fd, iov->iov_base, (int)iov->iov_len, count)); - last_ret_val = (int) ireadv(fd, iov, count); + last_ret_val = (long) ireadv(fd, iov, count); if (last_ret_val < 0) my_perror("ireadv"); my_errno = errno; @@ -1787,7 +1790,7 @@ int test_do_readv(int argc, char **argv) } DBG(3, fprintf(outfp, "ireadv (fd: %d, vector:{ iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, iov->iov_len, count)); + fd, iov->iov_base, (int)iov->iov_len, count)); last_ret_val = readv(fd, iov, count); if (last_ret_val < 0) @@ -1894,9 +1897,9 @@ int test_do_ipwritev(int argc, char **ar DBG(3, fprintf(outfp, "ipwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d, offset: %d\n", - fd, iov->iov_base, iov->iov_len, count, offset)); + fd, iov->iov_base, (int)iov->iov_len, count, offset)); - last_ret_val = (int) ipwritev(fd, iov, count, offset); + last_ret_val = (long) ipwritev(fd, iov, count, offset); my_errno = errno; if (last_ret_val < 0) my_perror("ipwritev"); @@ -1943,7 +1946,7 @@ int test_do_ipwrite(int argc, char **arg return INVALID_ARGS; } - last_ret_val = (int) ipwrite(fd, buf, count, offset); + last_ret_val = (long) ipwrite(fd, buf, count, offset); if (last_ret_val < 0) my_perror("ipwrite"); my_errno = errno; @@ -1996,9 +1999,9 @@ int test_do_pwritev(int argc, char **arg DBG(3, fprintf(outfp, "pwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d, offset: %d\n", - fd, iov->iov_base, iov->iov_len, count, offset)); + fd, iov->iov_base, (int)iov->iov_len, count, offset)); - last_ret_val = pwritev(fd, iov, count, offset); + last_ret_val = (long) pwritev(fd, iov, count, offset); if (last_ret_val < 0) my_perror("ipwritev"); my_errno = errno; @@ -2091,9 +2094,9 @@ int test_do_iwritev(int argc, char **arg } DBG(3, fprintf(outfp, "iwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, iov->iov_len, count)); + fd, iov->iov_base, (int)iov->iov_len, count)); - last_ret_val = (int) iwritev(fd, iov, count); + last_ret_val = (long) iwritev(fd, iov, count); my_errno = errno; if (last_ret_val < 0) my_perror("iwritev"); @@ -2134,7 +2137,7 @@ int test_do_iwrite(int argc, char **argv return INVALID_ARGS; } - last_ret_val = (int) iwrite(fd, buf, count); + last_ret_val = (long) iwrite(fd, buf, count); my_errno = errno; if (last_ret_val < 0) my_perror("iwrite"); @@ -2226,7 +2229,7 @@ int test_do_writev(int argc, char **argv } DBG(3, fprintf(outfp, "writev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d\n", - fd, iov->iov_base, iov->iov_len, count)); + fd, iov->iov_base, (int)iov->iov_len, count)); last_ret_val = writev(fd, iov, count); if (last_ret_val < 0) @@ -2320,7 +2323,7 @@ int test_do_init_iovec(int argc, char ** iov_ptr[pos].iov_base = (void *)(base_ptr + offset); DBG(3, fprintf(outfp, "iov_ptr.len is %d and base is %p\n", - iov_ptr[pos].iov_len, iov_ptr[pos].iov_base)); + (int)iov_ptr[pos].iov_len, iov_ptr[pos].iov_base)); my_errno = errno; last_type = PTR; @@ -2364,7 +2367,7 @@ int test_do_init_xtvec(int argc, char ** xtv_ptr[pos].xtv_off = offset; DBG(3, fprintf(outfp, "xtv_ptr.len is %d and offset is %d\n", - xtv_ptr[pos].xtv_len, (int)xtv_ptr[pos].xtv_off)); + (int)xtv_ptr[pos].xtv_len, (int)xtv_ptr[pos].xtv_off)); my_errno = errno; last_type = PTR; @@ -2494,7 +2497,7 @@ int test_do_iwritex(int argc, char **arg DBG(3, fprintf(outfp, "iwritex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", fd, (void *)iov, iov_count, (void *)xtv, xtv_count)); - last_ret_val = (int) iwritex(fd, iov, iov_count, xtv, xtv_count); + last_ret_val = (long) iwritex(fd, iov, iov_count, xtv, xtv_count); if (last_ret_val < 0) my_perror("iwritex"); my_errno = errno; @@ -2626,7 +2629,7 @@ int test_do_ireadx(int argc, char **argv DBG(3, fprintf(outfp, "ireadx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", fd, (void *)iov, iov_count, (void *)xtv, xtv_count)); - last_ret_val = (int) ireadx(fd, iov, iov_count, xtv, xtv_count); + last_ret_val = (long) ireadx(fd, iov, iov_count, xtv, xtv_count); if (last_ret_val < 0) my_perror("ireadx"); my_errno = errno; Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_tests.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- sysio_tests.c 24 Feb 2004 15:46:33 -0000 1.6 +++ sysio_tests.c 12 Mar 2004 20:42:41 -0000 1.7 @@ -543,7 +543,7 @@ int sysio_open(char *path, int flags) last_ret_val = open(path, flags); my_errno = errno; DBG(3, sprintf(output, "Returning with errno set to %s (ret val is %d)\n", - strerror(my_errno), last_ret_val)); + strerror(my_errno), (int)last_ret_val)); return SUCCESS; } @@ -650,7 +650,7 @@ void print_stat(struct stat *st) DBG(3, sprintf(output, "%s st_dev: %#16x\n", output, (unsigned int)st->st_dev)); DBG(3, sprintf(output, "%s st_ino: %#16x\n", output, (unsigned int) st->st_ino)); DBG(3, sprintf(output, "%s st_mode: %#16x\n", output, st->st_mode)); - DBG(3, sprintf(output, "%s st_nlink: %#16x\n", output, st->st_nlink)); + DBG(3, sprintf(output, "%s st_nlink: %#16x\n", output, (int)st->st_nlink)); DBG(3, sprintf(output, "%s st_uid: %#16x\n", output, st->st_uid)); DBG(3, sprintf(output, "%s st_gid: %#16x\n", output, st->st_gid)); DBG(3, sprintf(output, "%s st_rdev: %#16x\n", output, (int)st->st_rdev)); Index: test_path.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- test_path.pl 21 Jan 2004 15:13:56 -0000 1.4 +++ test_path.pl 12 Mar 2004 20:42:41 -0000 1.5 @@ -12,10 +12,11 @@ use FindBin; use lib "$FindBin::Bin"; use helper; use POSIX; +use Fcntl ':mode'; sub usage { - print "Usage ./test_path.pl path1 [path2] [path3...] : Print each path listed and its type\n"; + print "Usage ./test_path.pl [path1 path2...] : Print each path listed and its type\n"; print " : If no paths are given, stdin is read\n"; exit(-1); } @@ -54,7 +55,7 @@ sub print_path sub process_path { - my ($cmdfh, $outfh, $path) = @_; + my ($cmdfh, $outfh, $bits, $path) = @_; # Issue the stat command my $cmdstr = 'CALL stat "'; @@ -64,7 +65,11 @@ sub process_path helper::verify_cmd($cmdfh, $outfh, "stat"); # Print out the stat buffer + if ($bits == 32) { $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 52 8 INT 64 24 LONG'; + } else { + $cmdstr = 'PRINT $buf 0 24 LONG 24 16 INT 48 32 LONG 88 8 LONG 104 8 LONG'; + } $cmdstr .= "\n"; helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); @@ -73,7 +78,11 @@ sub process_path my ( $iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime ) = split(' ', $res); - + if ($bits == 64) { + ( $iodev, $ioino, $ionlink, $iomode, $iouid, $iogid, $iordev, + $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime ) + = split(' ', $res); + } $iomode = oct($iomode); # Print out the path @@ -118,6 +127,17 @@ sub process_cmd $cmdstr .= "\n"; helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); + # Attempt to determine type + $cmdstr = 'PRINT $size'."\n"; + helper::send_cmd($cmdfh, $outfh, "print", $cmdstr); + my $statsize = <$outfh>; + chop($statsize); + $statsize = oct($statsize); + my $bits = 32; + if ($statsize == 144) { + $bits = 64; + } + my $i=0; if ($usestdin) { $path = <STDIN>; @@ -132,7 +152,7 @@ sub process_cmd # phase of loop. while (defined($path)) { - process_path($cmdfh, $outfh, $path); + process_path($cmdfh, $outfh, $bits, $path); if ($usestdin) { $path = <STDIN>; Index: test_stats.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- test_stats.pl 6 Feb 2004 20:07:31 -0000 1.7 +++ test_stats.pl 12 Mar 2004 20:42:41 -0000 1.8 @@ -30,7 +30,7 @@ sub usage sub cmp_stats { - my ( $cmdfh, $outfh, $is_alpha, @stats) = @_; + my ( $cmdfh, $outfh, $is_alpha, $bits, @stats) = @_; my ($iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, @@ -42,6 +42,11 @@ sub cmp_stats $iosize, $ioatime, $iomtime, $ioctime, $ioblks, $ioblksize, @pstats) = @stats; } + if ($bits == 64) { + ($iodev, $ioino, $ionlink, $iomode, $iouid, $iogid, $iordev, + $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime,@pstats) = + @stats; + } my ($pdev, $pino, $pmode, $pnlink, $puid, $pgid, $prdev, $psize, $patime, $pmtime, $pctime, $pblksize, $pblks) = @pstats; @@ -65,16 +70,19 @@ sub cmp_stats # Perl's output sub verify_stat { - my ($cmdfh, $outfh, $cmd, $is_alpha, @stats) = @_; + my ($cmdfh, $outfh, $cmd, $is_alpha, $bits, @stats) = @_; my $i=0; my $cmdstr; # Print out the stat buffer - if ($is_alpha == 0) { + if ($is_alpha == 1) { + $cmdstr = 'PRINT $buf 0 16 LONG 16 16 INT 32 8 LONG 40 4 INT 48 40 LONG'."\n"; + } elsif ($bits == 32) { $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 48 8 INT 56 24 LONG'."\n"; } else { - $cmdstr = 'PRINT $buf 0 16 LONG 16 16 INT 32 8 LONG 40 4 INT 48 40 LONG'."\n"; + $cmdstr = 'PRINT $buf 0 24 LONG 24 16 INT 48 32 LONG 88 8 LONG 104 8 LONG'."\n"; } + helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $res = <$outfh>; @@ -86,7 +94,7 @@ sub verify_stat $i++; } - cmp_stats($cmdfh, $outfh, $is_alpha, @iostats, @stats); + cmp_stats($cmdfh, $outfh, $is_alpha, $bits, @iostats, @stats); } @@ -138,10 +146,21 @@ sub process_cmd helper::send_cmd($cmdfh, $outfh, "stat", $cmdstr); helper::verify_cmd($cmdfh, $outfh, "stat"); + # Attempt to determine type + $cmdstr = 'PRINT $size'."\n"; + helper::send_cmd($cmdfh, $outfh, "print", $cmdstr); + my $statsize = <$outfh>; + chop($statsize); + $statsize = oct($statsize); + my $bits = 32; + if ($statsize == 144) { + $bits = 64; + } + if ($use_system == 1) { # Now print the buffer out and verify that it matches # what Perl has - verify_stat($cmdfh, $outfh, "stat", $is_alpha, @stats); + verify_stat($cmdfh, $outfh, "stat", $is_alpha, $bits, @stats); } # Open the file @@ -156,7 +175,7 @@ sub process_cmd helper::verify_cmd($cmdfh, $outfh, "fstat"); if ($use_system == 1) { - verify_stat($cmdfh, $outfh, "fstat", $is_alpha, @stats); + verify_stat($cmdfh, $outfh, "fstat", $is_alpha, $bits, @stats); } # Test lstat @@ -169,7 +188,7 @@ sub process_cmd helper::verify_cmd($cmdfh, $outfh, "lstat"); if ($use_system == 1) { - verify_stat($cmdfh, $outfh, "lstat", $is_alpha, @stats); + verify_stat($cmdfh, $outfh, "lstat", $is_alpha, $bits, @stats); } if (0) { |