[Libsysio-commit] b_lustre: libsysio/tests cleanup.pl setup.pl test_link.c test_rename.c test_symlin
Brought to you by:
lward
|
From: Mei <me...@us...> - 2003-11-01 03:08:28
|
Update of /cvsroot/libsysio/libsysio/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv28091/tests
Modified Files:
Tag: b_lustre
Makefile.am README drv_init_all.c helper.pm sysio_stubs.c
sysio_tests.c test_all.pl test_copy.c test_copy.pl
test_driver.c test_driver.h test_getcwd.c test_getcwd.pl
test_list.c test_list.pl test_mounts.c test_path.c
test_path.pl test_stats.c test_stats.pl test_stdfd.c
test_stdfd.pl
Added Files:
Tag: b_lustre
cleanup.pl setup.pl test_link.c test_rename.c test_symlink.pl
test_unlink.c
Log Message:
merge HEAD into b_lustre, some fixes
--- NEW FILE ---
#!/usr/bin/perl -w
use IPC::Open2;
use strict;
use FindBin;
use lib "$FindBin::Bin";
use helper;
sub usage
{
print "Usage: ./cleanup.pl <cwd> : Remove system directories used for test\n";
exit(-1);
}
sub do_remove
{
my ($cmdfh, $outfh, $type, $cwd, $lastdir) = @_;
my $cmd;
if ($type eq "dir") {
$cmd = "rmdir";
} else {
$cmd = "unlink";
}
my $cmdstr = "CALL $cmd $cwd/$lastdir\n";
# Now remove the file/dir
helper::send_cmd($cmdfh, $outfh, $cmd, $cmdstr);
# Verify the directory was made correctly
helper::verify_cmd($cmdfh, $outfh, $cmd);
}
my $currarg = 0;
my $is_alpha = 0;
my $alpha_arg = "";
if (@ARGV == 0) {
usage();
}
if ((@ARGV > 1) && ($ARGV[$currarg++] eq "-alpha")){
$is_alpha = 1;
$alpha_arg = $ARGV[$currarg-1];
}
my $cwd = $ARGV[$currarg];
# Get tests directory
my $testdir = $0;
$testdir =~ s/\/\w+.pl$//;
eval {
if ($is_alpha == 0) {
open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np");
} else {
open2(\*OUTFILE, \*CMDFILE,
"yod -batch -quiet -sz 1 $testdir/test_driver --np");
}
};
if ($@) {
if ($@ =~ /^open2/) {
warn "open2 failed: $!\n$@\n";
return;
}
die;
}
my $outfh = \*OUTFILE;
my $cmdfh = \*CMDFILE;
if ($is_alpha == 0) {
helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n");
}
# Remove the helper.pms
do_remove($cmdfh, $outfh, "file", $cwd, "tmp_dir/helper.pm");
do_remove($cmdfh, $outfh, "file", $cwd, "tmp_dir/test1/helper.pm");
# Remove directories
do_remove($cmdfh, $outfh, "dir", $cwd, "tmp_dir/test1");
do_remove($cmdfh, $outfh, "dir", $cwd, "tmp_dir/test2");
do_remove($cmdfh, $outfh, "dir", $cwd, "tmp_dir");
print $cmdfh "exit\n";
close $outfh;
# Give test_driver time to finish
sleep 0.000001;
print STDOUT "cleanup successful\n";
exit 0;
--- NEW FILE ---
#!/usr/bin/perl -w
use IPC::Open2;
use strict;
use FindBin;
use lib "$FindBin::Bin";
use helper;
sub usage
{
print "Usage: ./setup.pl <cwd> : Setup initial system directories for test\n";
exit(-1);
}
sub do_makedir
{
my ($cmdfh, $outfh, $cwd, $lastdir) = @_;
my $cmd = "CALL mkdir $cwd/$lastdir 0777\n";
# Now create newdir
helper::send_cmd($cmdfh, $outfh, "mkdir", $cmd);
# Verify the directory was made correctly
helper::verify_cmd($cmdfh, $outfh, "mkdir");
}
my $currarg = 0;
my $is_alpha = 0;
my $alpha_arg = "";
if (@ARGV == 0) {
usage();
}
if ((@ARGV > 1) && ($ARGV[$currarg++] eq "-alpha")){
$is_alpha = 1;
$alpha_arg = $ARGV[$currarg-1];
}
my $cwd = $ARGV[$currarg];
# Get tests directory
my $testdir = $0;
$testdir =~ s/\/\w+.pl$//;
eval {
if ($is_alpha == 0) {
open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np");
} else {
open2(\*OUTFILE, \*CMDFILE,
"yod -batch -quiet -sz 1 $testdir/test_driver --np");
}
};
if ($@) {
if ($@ =~ /^open2/) {
warn "open2 failed: $!\n$@\n";
return;
}
die;
}
my $outfh = \*OUTFILE;
my $cmdfh = \*CMDFILE;
if ($is_alpha == 0) {
helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n");
}
# Create tmp_dir
do_makedir($cmdfh, $outfh, $cwd, "tmp_dir");
do_makedir($cmdfh, $outfh, $cwd, "tmp_dir/test1");
do_makedir($cmdfh, $outfh, $cwd, "tmp_dir/test2");
# Copy helper.pm
print STDERR "Copying $testdir/helper.pm to $cwd/tmp_dir/test1/helper.pm\n";
my $res = `perl $testdir/test_copy.pl $alpha_arg $testdir/helper.pm $cwd/tmp_dir/test1/helper.pm`;
chop($res);
if ($res ne "copy test successful") {
print STDERR "setup (copy test) failed with message: $res\n";
print $cmdfh "exit\n";
close $outfh;
# Give test_driver time to finish
sleep 0.000001;
print STDOUT "Copying of helper.pm failed\n";
exit 1;
}
print $cmdfh "exit\n";
close $outfh;
# Give test_driver time to finish
sleep 0.000001;
print STDOUT "setup successful\n";
exit 0;
--- NEW FILE ---
/*
* This Cplant(TM) source code is the property of Sandia National
* Laboratories.
*
* This Cplant(TM) source code is copyrighted by Sandia National
* Laboratories.
*
* The redistribution of this Cplant(TM) source code is subject to the
* terms of the GNU Lesser General Public License
* (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
*
* Cplant(TM) Copyright 1998-2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the US Government.
* Export of this program may require a license from the United States
* Government.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Questions or comments about this library should be sent to:
*
* Lee Ward
* Sandia National Laboratories, New Mexico
* P.O. Box 5800
* Albuquerque, NM 87185-1110
*
* le...@sa...
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef REDSTORM
#include <getopt.h>
#else
#include <unistd.h>
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/queue.h>
#if 0
#include <dirent.h>
#endif
#include "sysio.h"
#include "mount.h"
#include "test.h"
/*
* Test hard link
*
* Usage: link [-a] [-m <fsname>] [-r <mntpath>] oldpath newpath
*
*/
static int linkit(const char *old, const char *new);
static void usage(void);
static const char *root_driver = DEFAULT_DRIVER;
static const char *mntpath = "/";
static unsigned mntflgs = 0;
#ifdef AUTOMOUNT_FILE_NAME
#define EXTRA_AUTOMOUNT_OPT "a"
#else
#define EXTRA_AUTOMOUNT_OPT
#endif
const char *opts = EXTRA_AUTOMOUNT_OPT "m:r:";
int
main(int argc, char *const argv[])
{
int i;
int err;
int n;
/*
* Parse command line arguments.
*/
while ((i = getopt(argc, argv, opts)) != -1)
switch (i) {
#ifdef AUTOMOUNT_FILE_NAME
case 'a':
mntflgs |= MOUNT_F_AUTO;
break;
#endif
case 'm':
root_driver = optarg;
break;
case 'r':
mntpath = optarg;
break;
default:
usage();
}
/*
* Init sysio lib.
*/
_sysio_init();
/*
* Init native file system driver and request mount of specified
* source directory.
*/
err = drv_init_all();
if (err) {
errno = -err;
perror("drv_init_all");
exit(1);
}
err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL);
if (err) {
errno = -err;
perror("_sysio_mount_root");
exit(1);
}
n = argc - optind;
if (n < 2) usage();
/*
* Try paths listed on command-line.
*/
while (optind < argc) {
const char *old, *new;
old = argv[optind++];
new = argv[optind++];
(void )linkit(old, new);
}
/*
* Clean up.
*/
_sysio_shutdown();
return 0;
}
static int
linkit(const char *old, const char *new)
{
unlink(new);
if (link(old, new) < 0) {
perror(old);
return -1;
}
return 0;
}
static void
usage()
{
(void )fprintf(stderr,
"Usage: unlink [-a] [-m <driver>] [-r <mntpath>]"
" oldpath newpath\n");
exit(1);
}
--- NEW FILE ---
/*
* This Cplant(TM) source code is the property of Sandia National
* Laboratories.
*
* This Cplant(TM) source code is copyrighted by Sandia National
* Laboratories.
*
* The redistribution of this Cplant(TM) source code is subject to the
* terms of the GNU Lesser General Public License
* (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
*
* Cplant(TM) Copyright 1998-2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the US Government.
* Export of this program may require a license from the United States
* Government.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Questions or comments about this library should be sent to:
*
* Lee Ward
* Sandia National Laboratories, New Mexico
* P.O. Box 5800
* Albuquerque, NM 87185-1110
*
* le...@sa...
*/
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef REDSTORM
#include <getopt.h>
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/queue.h>
#include "sysio.h"
#include "mount.h"
#include "fs_native.h"
#include "test.h"
/*
* Rename a file system object.
*
* Usage: test_rename [-a] [-r <source>] [-m <root-driver>] <src> <dest>
*/
char *root_driver = DEFAULT_DRIVER;
char *mntpath = "/";
unsigned mntflgs = 0;
void usage(void);
int rename_file(const char *spath, const char *dpath);
int
main(int argc, char * const argv[])
{
int i;
int err;
const char *spath, *dpath;
/*
* Parse command-line args.
*/
while ((i = getopt(argc,
argv,
#ifdef AUTOMOUNT_FILE_NAME
"a"
#endif
"r:m:")) != -1)
switch (i) {
#ifdef AUTOMOUNT_FILE_NAME
case 'a':
mntflgs |= MOUNT_F_AUTO;
break;
#endif
case 'r': /* set working dir */
mntpath = optarg;
break;
case 'm':
root_driver = optarg;
break;
default:
usage();
}
if (!(argc - optind))
usage();
#ifndef CPLANT_YOD
if (_sysio_init() != 0) {
perror("init sysio");
exit(1);
}
err = drv_init_all();
if (err) {
perror("init drivers");
exit(1);
}
err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL);
if (err) {
errno = -err;
perror(root_driver);
exit(1);
}
#endif
(void )umask(022);
/*
* Source
*/
spath = argv[optind++];
if (!(argc - optind))
usage();
/*
* Destination
*/
dpath = argv[optind++];
if (argc - optind)
usage();
err = rename(spath, dpath);
if (err)
perror("rename");
#ifndef CPLANT_YOD
_sysio_shutdown();
#endif
return err;
}
void
usage()
{
(void )fprintf(stderr,
"Usage: test_rename "
#ifdef AUTOMOUNT_FILE_NAME
"[-a] "
#endif
"[-r <source>] [-m <fsname>]"
" source destination\n");
exit(1);
}
--- NEW FILE ---
#!/usr/bin/perl -w
#
# symlink test: Verify that symbolic links work
#
use IPC::Open2;
use strict;
use FindBin;
use lib "$FindBin::Bin";
use helper;
sub usage
{
print "Usage: ./test_symlink.pl [-alpha] <src> <dest>: Create a symlink from src to dest\n";
exit(-1);
}
sub clean_exit
{
my ($cmdfh, $outfh, $exit_num, $exit_str) = @_;
print STDOUT "$exit_str";
# Free buffers
my $cmdstr = 'FREE $srcbuf'."\n";
print $cmdfh $cmdstr;
my $res = <$outfh>;
chop($res);
if ($res ne "0000 ") {
print STDOUT "ERROR! Failed to free srcbuf (code $res)\n";
}
$cmdstr = 'FREE $destbuf'."\n";
print $cmdfh $cmdstr;
$res = <$outfh>;
chop($res);
if ($res ne "0000 ") {
print STDOUT "ERROR! Failed to free destbuf (code $res)\n";
}
print $cmdfh "exit\n";
close $outfh;
# Give test_driver time to finish
sleep 0.000001;
exit $exit_num;
}
sub process_cmd
{
my ($src, $dest, $is_alpha) = @_;
# Get tests directory
my $testdir = $0;
$testdir =~ s/\/\w+.pl$//;
eval {
if ($is_alpha == 0) {
open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np");
} else {
open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 $testdir/test_driver --np");
}
};
if ($@) {
if ($@ =~ /^open2/) {
warn "open2 failed: $!\n$@\n";
return;
}
die;
}
my $outfh = \*OUTFILE;
my $cmdfh = \*CMDFILE;
if ($is_alpha == 0) {
helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n");
}
# Get the filesize of src
my $size = -s $src;
my $bufsize;
if ( $size > 1024) { # Arbitrary limit
$bufsize = 1024;
} else {
$bufsize = $size;
}
# Create the symbolic link from src to dest
my $cmdstr = "CALL symlink $src $dest\n";
helper::send_cmd($cmdfh, $outfh, "open", $cmdstr);
helper::verify_cmd($cmdfh, $outfh, "symlink");
# Open src
$cmdstr = '$src = CALL open '."$src O_RDONLY\n";
helper::send_cmd($cmdfh, $outfh, "open", $cmdstr);
# Open dest
$cmdstr = '$dest = CALL open '."$dest O_RDONLY\n";
helper::send_cmd($cmdfh, $outfh, "open", $cmdstr);
my $res = helper::verify_cmd($cmdfh, $outfh, "open $dest");
# Allocate buffer for src
$cmdstr = '$srcbuf = ALLOC '."$bufsize\n";
helper::send_cmd($cmdfh, $outfh, "ALLOC", $cmdstr);
# Allocate buffer for dest
$cmdstr = '$destbuf = ALLOC '."$bufsize\n";
helper::send_cmd($cmdfh, $outfh, "ALLOC", $cmdstr);
# Read size bytes from src and dest, then compare them and verify they
# are the same
$cmdstr = 'CALL read $src $srcbuf '."$bufsize\n";
helper::send_cmd($cmdfh, $outfh, "read $src", $cmdstr);
$res = helper::verify_cmd($cmdfh, $outfh, "read $src");
my $readb = oct($res);
# Now read $readb from dest
$cmdstr = 'CALL read $dest $destbuf '."$readb\n";
helper::send_cmd($cmdfh, $outfh, "read $dest", $cmdstr);
$res = helper::verify_cmd($cmdfh, $outfh, "read $dest");
my $errstr;
if ($readb != oct($res)) {
$errstr = "ERROR! Read $readb bytes from src but only $res bytes from dest\n";
clean_exit($cmdfh, $outfh, 1, $errstr);
}
# Compare the two buffers
$cmdstr = 'CALL cmpstr $srcbuf $destbuf'."\n";
helper::send_cmd($cmdfh, $outfh, "cmpstr", $cmdstr);
# Verify that it returned an error
$cmdstr = 'PRINT $$';
$cmdstr .= "\n";
helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
$res = <$outfh>;
chop($res);
$res = helper::verify_cmd($cmdfh, $outfh, "cmpstr");
$res = oct($res);
if ($res != 0) {
$errstr = "ERROR! Buffers from $src and $dest do not match\n";
clean_exit($cmdfh, $outfh, 1, $errstr);
}
# Clean up
$cmdstr = 'CALL close $src'."\n";
helper::send_cmd($cmdfh, $outfh, "close", $cmdstr);
$cmdstr = 'CALL close $dest'."\n";
helper::send_cmd($cmdfh, $outfh, "close", $cmdstr);
# Clear out destbuf
$cmdstr = 'CALL clear $destbuf'."\n";
helper::send_cmd($cmdfh, $outfh, "CLEAR", $cmdstr);
# Now remove the symbolic link and make sure everything stays the same
# Remove the link (this assumes the link is not in incore)
$cmdstr = "CALL unlink $dest\n";
helper::send_cmd($cmdfh, $outfh, "unlink", $cmdstr);
helper::verify_cmd($cmdfh, $outfh, "unlink");
# Attempt to open the symbolic link. This should return an error
$cmdstr = 'CALL open '."$dest O_RDONLY\n";
helper::send_cmd($cmdfh, $outfh, "open", $cmdstr);
# Verify that it returned an error
$cmdstr = 'PRINT $$';
$cmdstr .= "\n";
helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
$res = <$outfh>;
chop($res);
if ($res ne "0xffffffff") {
$errstr = "ERROR! Open on $dest succeeded (should have failed)\n";
clean_exit($cmdfh, $outfh, 1, $errstr);
}
# Now read from the src again and make sure it matches the original
# Open src
$cmdstr = '$src2 = CALL open '."$src O_RDONLY\n";
helper::send_cmd($cmdfh, $outfh, "open", $cmdstr);
helper::verify_cmd($cmdfh, $outfh, "open $src(2)");
$cmdstr = 'CALL read $src2 $destbuf '."$readb\n";
helper::send_cmd($cmdfh, $outfh, "read $src(2)", $cmdstr);
$res = helper::verify_cmd($cmdfh, $outfh, "read $src(2)");
if ($readb != oct($res)) {
$errstr = "ERROR! Read $readb bytes from src originally but now only $res bytes\n";
clean_exit($cmdfh, $outfh, 1, $errstr);
}
# Compare the two buffers
$cmdstr = 'CALL cmpstr $srcbuf $destbuf'."\n";
helper::send_cmd($cmdfh, $outfh, "cmpstr", $cmdstr);
$res = helper::verify_cmd($cmdfh, $outfh, "cmpstr");
$res = oct($res);
if ($res != 0) {
$errstr = "ERROR! Original buffers from $src and new buf do not match\n";
clean_exit($cmdfh, $outfh, 1, $errstr);
}
# Clean up
$cmdstr = 'CALL close $src2'."\n";
helper::send_cmd($cmdfh, $outfh, "close", $cmdstr);
clean_exit($cmdfh, $outfh, 0, "Symlink test successful\n");
exit 0;
}
my $currarg = 0;
my $is_alpha = 0;
if (@ARGV < 2) {
usage;
} elsif (@ARGV > 2 ) {
if ($ARGV[$currarg++] eq "-alpha") {
$is_alpha = 1;
}
}
my $src = $ARGV[$currarg++];
my $dest = $ARGV[$currarg];
process_cmd($src, $dest, $is_alpha);
exit 0;
--- NEW FILE ---
/*
* This Cplant(TM) source code is the property of Sandia National
* Laboratories.
*
* This Cplant(TM) source code is copyrighted by Sandia National
* Laboratories.
*
* The redistribution of this Cplant(TM) source code is subject to the
* terms of the GNU Lesser General Public License
* (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
*
* Cplant(TM) Copyright 1998-2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the US Government.
* Export of this program may require a license from the United States
* Government.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Questions or comments about this library should be sent to:
*
* Lee Ward
* Sandia National Laboratories, New Mexico
* P.O. Box 5800
* Albuquerque, NM 87185-1110
*
* le...@sa...
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef REDSTORM
#include <getopt.h>
#else
#include <unistd.h>
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/queue.h>
#if 0
#include <dirent.h>
#endif
#include "sysio.h"
#include "mount.h"
#include "test.h"
/*
* Unlink files.
*
* Usage: unlink [-a] [-m <fsname>] [-r <mntpath>] [path...]
*
* Without any path arguments, the program unlinks files named
* by the ocmmand line args.
*/
static int unlinkit(const char *path);
static void usage(void);
static const char *root_driver = DEFAULT_DRIVER;
static const char *mntpath = "/";
static unsigned mntflgs = 0;
#ifdef AUTOMOUNT_FILE_NAME
#define EXTRA_AUTOMOUNT_OPT "a"
#else
#define EXTRA_AUTOMOUNT_OPT
#endif
const char *opts = EXTRA_AUTOMOUNT_OPT "m:r:";
int
main(int argc, char *const argv[])
{
int i;
int err;
int n;
/*
* Parse command line arguments.
*/
while ((i = getopt(argc, argv, opts)) != -1)
switch (i) {
#ifdef AUTOMOUNT_FILE_NAME
case 'a':
mntflgs |= MOUNT_F_AUTO;
break;
#endif
case 'm':
root_driver = optarg;
break;
case 'r':
mntpath = optarg;
break;
default:
usage();
}
/*
* Init sysio lib.
*/
_sysio_init();
/*
* Init native file system driver and request mount of specified
* source directory.
*/
err = drv_init_all();
if (err) {
errno = -err;
perror("drv_init_all");
exit(1);
}
err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL);
if (err) {
errno = -err;
perror("_sysio_mount_root");
exit(1);
}
n = argc - optind;
/*
* Try path(s) listed on command-line.
*/
while (optind < argc) {
const char *path;
path = argv[optind++];
(void )unlinkit(path);
}
/*
* If no command-line arguments, read from stdin until EOF.
*/
if (!n) {
int doflush;
static char buf[4096];
size_t len;
char *cp;
char c;
doflush = 0;
while (fgets(buf, sizeof(buf), stdin) != NULL) {
len = strlen(buf);
cp = buf + len - 1;
c = *cp;
*cp = '\0';
if (!doflush)
unlinkit(buf);
doflush = c == '\n' ? 0 : 1;
}
}
/*
* Clean up.
*/
_sysio_shutdown();
return 0;
}
static int
unlinkit(const char *path)
{
if (unlink(path) != 0) {
perror(path);
return -1;
}
return 0;
}
static void
usage()
{
(void )fprintf(stderr,
"Usage: unlink [-a] [-m <driver>] [-r <mntpath>]"
" [<path> ...\n]");
exit(1);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v
retrieving revision 1.8.4.2
retrieving revision 1.8.4.3
diff -u -w -b -B -p -r1.8.4.2 -r1.8.4.3
--- Makefile.am 8 Sep 2003 03:52:28 -0000 1.8.4.2
+++ Makefile.am 1 Nov 2003 03:08:23 -0000 1.8.4.3
@@ -1,5 +1,5 @@
noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \
- test_getcwd test_stdfd test_driver
+ test_getcwd test_stdfd test_link test_unlink test_rename test_driver
CLEANFILES=drv_data.c
@@ -36,6 +36,7 @@ endif
if WITH_CPLANT_YOD
YOD_DRIVER_NAME=yod
YOD_DRIVER_CFLAGS= -DCPLANT_YOD
+YOD_DRIVER_LIB=$(top_builddir)/drivers/yod/libsysio_yod.a
else
YOD_DRIVER_NAME=
YOD_DRIVER_CFLAGS=
@@ -55,7 +56,13 @@ CMNSRC=drv_init_all.c drv_data.c
BUILT_SOURCES=drv_data.c
check_PROGRAMS=test_driver
+if TEST_ALPHA_ARG
+TESTS_ENVIRONMENT=IS_ALPHA=yes
+else
+TESTS_ENVIRONMENT=IS_ALPHA=no
+endif
TESTS=test_all.pl
+
CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \
$(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \
$(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS)
@@ -100,12 +107,27 @@ test_stdfd_CFLAGS=$(CFL)
test_stdfd_LDADD=$(LIBS)
test_stdfd_DEPENDENCIES=$(LIBS)
+test_link_SOURCES=test_link.c $(CMNSRC)
+test_link_CFLAGS=$(CFL)
+test_link_LDADD=$(LIBS)
+test_link_DEPENDENCIES=$(LIBS)
+
+test_unlink_SOURCES=test_unlink.c $(CMNSRC)
+test_unlink_CFLAGS=$(CFL)
+test_unlink_LDADD=$(LIBS)
+test_unlink_DEPENDENCIES=$(LIBS)
+
+test_rename_SOURCES=test_rename.c $(CMNSRC)
+test_rename_CFLAGS=$(CFL)
+test_rename_LDADD=$(LIBS)
+test_rename_DEPENDENCIES=$(LIBS)
+
test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC)
test_driver_CFLAGS=$(CFL)
test_driver_LDADD=$(LIBS)
test_driver_DEPENDENCIES=$(LIBS)
-EXTRA_DIST=gendrvdata.sh test.h test_driver.h
+EXTRA_DIST=$(shell ls *.pl *.pm) gendrvdata.sh test.h test_driver.h
drv_data.c: $(CONFIG_DEPENDENCIES) $(top_srcdir)/tests/gendrvdata.sh
test -z "drv_data.c" && rm -f drv_data.c; \
Index: README
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/README,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- README 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ README 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -1,8 +1,12 @@
-To run the tests, just do ./test_all.pl (at some point I will
-integrate that into the build environment). This will run the 6
-basic functionality tests (explained below) and report the total
-number of passes and failures. This is not currently working on
-alpha/cplant architectures, however.
+To run the tests, just do a "make check" in the tests subdirectory.
+On the CPlant alpha systems, 3 of the 7 tests in test_all.pl are excluded
+due to known problems (problems as of the date of writing this; they
+may have since been fixed). You can also manually run the individual
+tests or ./test_all.pl. If you are running on CPlant, you need to
+run test_all.pl with a -alpha argument. Either "make check" or
+test_all.pl will run the 7 basic functionality tests (explained
+below) and report the total number of passes and failures.
+number of passes and failures.
-----------------------SCRIPTS---------------------------------
Index: drv_init_all.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/drv_init_all.c,v
retrieving revision 1.1
retrieving revision 1.1.12.1
diff -u -w -b -B -p -r1.1 -r1.1.12.1
--- drv_init_all.c 22 Feb 2003 18:25:11 -0000 1.1
+++ drv_init_all.c 1 Nov 2003 03:08:23 -0000 1.1.12.1
@@ -1,3 +1,5 @@
+#include <stdio.h>
+
extern int (*drvinits[])(void);
/*
Index: helper.pm
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/helper.pm,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- helper.pm 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ helper.pm 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -7,7 +7,7 @@
package helper;
use strict;
-use Fcntl ':mode';
+use POSIX;
BEGIN{}
Index: sysio_stubs.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- sysio_stubs.c 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ sysio_stubs.c 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -7,7 +7,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/uio.h>
-#include <linux/fs.h>
+#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
@@ -22,7 +22,7 @@
* ################################################
*/
-int do_setdebug(int argc, char **argv)
+int test_do_setdebug(int argc, char **argv)
{
int level;
@@ -43,7 +43,7 @@ int do_setdebug(int argc, char **argv)
return SUCCESS;
}
-int do_printline(int argc, char **argv)
+int test_do_printline(int argc, char **argv)
{
int on;
@@ -64,7 +64,7 @@ int do_printline(int argc, char **argv)
}
/*
-int do_setoutput(int argc, char **argv)
+int test_do_setoutput(int argc, char **argv)
{
FILE *newfp;
@@ -88,7 +88,7 @@ int do_setoutput(int argc, char **argv)
*/
-int do_fillbuff(int argc, char **argv)
+int test_do_fillbuff(int argc, char **argv)
{
char *typestr, *buf;
void *valptr;
@@ -209,7 +209,7 @@ void print_partial(char *buf, int offset
}
}
-int do_printbuf(int argc, char **argv)
+int test_do_printbuf(int argc, char **argv)
{
int index, i, type, offset, len;
struct buf_t *buf_st;
@@ -288,10 +288,10 @@ int do_printbuf(int argc, char **argv)
return SUCCESS;
}
-int do_mount(int argc, char **argv)
+int test_do_mount(int argc, char **argv)
{
if (argc != 2) {
- DBG(2, fprintf(outfp, "Invalid number of args (%d) for do_mount\n",
+ DBG(2, fprintf(outfp, "Invalid number of args (%d) for test_do_mount\n",
argc));
return INVALID_ARGS;
}
@@ -304,7 +304,7 @@ int do_mount(int argc, char **argv)
return SUCCESS;
}
-int do_clear(int argc, char **argv)
+int test_do_clear(int argc, char **argv)
{
int index;
struct buf_t *buf;
@@ -326,7 +326,7 @@ int do_clear(int argc, char **argv)
return SUCCESS;
}
-int do_list(int argc, char **argv)
+int test_do_list(int argc, char **argv)
{
char *buf;
@@ -336,7 +336,7 @@ int do_list(int argc, char **argv)
return INVALID_ARGS;
}
- DBG(5,fprintf(outfp, "In do_list with args %p\n", argv));
+ DBG(5,fprintf(outfp, "In test_do_list with args %p\n", argv));
if (!argv) {
buf = getcwd(NULL, 0);
DBG(4, fprintf(outfp, "Calling list with dir of %s\n", buf));
@@ -354,7 +354,7 @@ int do_list(int argc, char **argv)
* Initlizes sysio library. Will use default initlization
* unless arguments are given
*/
-int do_init(int argc, char **argv)
+int test_do_init(int argc, char **argv)
{
if (argc > 0) {
char *rdriver;
@@ -391,7 +391,7 @@ int do_init(int argc, char **argv)
}
}
- DBG(5, fprintf(outfp, "In do_init\n"));
+ DBG(5, fprintf(outfp, "In test_do_init\n"));
last_type = SINT;
DBG(3, fprintf(outfp, "Using driver %s, path %s, flags %x\n",
root_driver, mntpath, mntflgs));
@@ -408,7 +408,7 @@ int get_endian(int argc, char **argv)
int x = 1;
if ((argc) || (argv)) {
- DBG(2, fprintf(outfp, "Expected no args for do_endian\n"));
+ DBG(2, fprintf(outfp, "Expected no args for test_do_endian\n"));
return INVALID_ARGS;
}
@@ -460,7 +460,7 @@ int get_sizeof(int argc, char **argv)
return SUCCESS;
}
-int do_exit(int argc, char **argv)
+int test_do_exit(int argc, char **argv)
{
int val = 0;
@@ -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,17 +572,17 @@ 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 do_chdir(int argc, char **argv)
+int test_do_chdir(int argc, char **argv)
{
if (argc != 1) {
DBG(2, fprintf(outfp, "Number of args (%d) invalid for chdir\n",
@@ -594,7 +594,7 @@ int do_chdir(int argc, char **argv)
}
-int do_chmod(int argc, char **argv)
+int test_do_chmod(int argc, char **argv)
{
if (argc != 2) {
DBG(2, fprintf(outfp, "Number of args (%d) invalid for chmod\n",
@@ -605,7 +605,7 @@ int do_chmod(int argc, char **argv)
return sysio_chmod(argv[0], argv[1]);
}
-int do_chown(int argc, char **argv)
+int test_do_chown(int argc, char **argv)
{
if (argc != 2) {
DBG(2, fprintf(outfp, "Number of args (%d) invalid for chown\n",
@@ -616,7 +616,7 @@ int do_chown(int argc, char **argv)
return sysio_chown(argv[0], argv[1]);
}
-int do_open(int argc, char **argv)
+int test_do_open(int argc, char **argv)
{
char *name = argv[0];
int flags = O_RDWR;
@@ -649,7 +649,7 @@ int do_open(int argc, char **argv)
return SUCCESS;
}
-int do_close(int argc, char **argv)
+int test_do_close(int argc, char **argv)
{
int fd;
char *name = argv[0];
@@ -675,7 +675,7 @@ int do_close(int argc, char **argv)
return SUCCESS;
}
-int do_dup(int argc, char **argv)
+int test_do_dup(int argc, char **argv)
{
int fd;
char *var_name = argv[0];
@@ -700,7 +700,7 @@ int do_dup(int argc, char **argv)
return SUCCESS;
}
-int do_dup2(int argc, char **argv)
+int test_do_dup2(int argc, char **argv)
{
int fd1, fd2;
char *var_name1 = argv[0];
@@ -770,7 +770,7 @@ struct cmd_map* get_cmd(char *cmd_name,
return NULL;
}
-int do_fcntl(int argc, char **argv)
+int test_do_fcntl(int argc, char **argv)
{
struct cmd_map *cmd;
@@ -806,7 +806,7 @@ int do_fcntl(int argc, char **argv)
return SUCCESS;
}
-int do_fstat(int argc, char **argv)
+int test_do_fstat(int argc, char **argv)
{
int fd, index;
void *buf;
@@ -841,7 +841,7 @@ int do_fstat(int argc, char **argv)
return SUCCESS;
}
-int do_lstat(int argc, char **argv)
+int test_do_lstat(int argc, char **argv)
{
char *name = argv[0];
int index;
@@ -866,7 +866,7 @@ int do_lstat(int argc, char **argv)
return sysio_lstat(name, buf);
}
-int do_fsync(int argc, char **argv)
+int test_do_fsync(int argc, char **argv)
{
int fd;
@@ -892,7 +892,7 @@ int do_fsync(int argc, char **argv)
}
-int do_fdatasync(int argc, char **argv)
+int test_do_fdatasync(int argc, char **argv)
{
int fd;
@@ -918,7 +918,7 @@ int do_fdatasync(int argc, char **argv)
}
-int do_ftruncate(int argc, char **argv)
+int test_do_ftruncate(int argc, char **argv)
{
int fd;
off_t length;
@@ -948,7 +948,7 @@ int do_ftruncate(int argc, char **argv)
return SUCCESS;
}
-int do_getcwd(int argc, char **argv)
+int test_do_getcwd(int argc, char **argv)
{
char *buf;
int size, index;
@@ -985,7 +985,7 @@ int do_getcwd(int argc, char **argv)
return SUCCESS;
}
-int do_lseek(int argc, char **argv)
+int test_do_lseek(int argc, char **argv)
{
int fd, whence;
off_t offset;
@@ -1021,7 +1021,7 @@ int do_lseek(int argc, char **argv)
return SUCCESS;
}
-int do_getdirentries(int argc, char **argv)
+int test_do_getdirentries(int argc, char **argv)
{
int fd, nbytes;
int bufindex;
@@ -1084,7 +1084,7 @@ int do_getdirentries(int argc, char **ar
return SUCCESS;
}
-int do_mkdir(int argc, char **argv)
+int test_do_mkdir(int argc, char **argv)
{
if (argc !=2) {
DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to mkdir\n", argc));
@@ -1095,7 +1095,7 @@ int do_mkdir(int argc, char **argv)
return sysio_mkdir(argv[0], argv[1]);
}
-int do_creat(int argc, char **argv)
+int test_do_creat(int argc, char **argv)
{
if (argc !=2) {
DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to creat\n", argc));
@@ -1106,7 +1106,7 @@ int do_creat(int argc, char **argv)
return sysio_creat(argv[0], argv[1]);
}
-int do_stat(int argc, char **argv)
+int test_do_stat(int argc, char **argv)
{
int index;
void *buf;
@@ -1132,7 +1132,7 @@ int do_stat(int argc, char **argv)
return sysio_stat(str, buf);
}
-int do_statvfs(int argc, char **argv)
+int test_do_statvfs(int argc, char **argv)
{
int index;
void *buf;
@@ -1156,7 +1156,7 @@ int do_statvfs(int argc, char **argv)
return sysio_statvfs(argv[0], buf);
}
-int do_fstatvfs(int argc, char **argv)
+int test_do_fstatvfs(int argc, char **argv)
{
int index, fd;
void *buf;
@@ -1188,7 +1188,7 @@ int do_fstatvfs(int argc, char **argv)
return sysio_fstatvfs(fd, buf);
}
-int do_truncate(int argc, char **argv)
+int test_do_truncate(int argc, char **argv)
{
off_t length;
@@ -1208,7 +1208,7 @@ int do_truncate(int argc, char **argv)
return SUCCESS;
}
-int do_rmdir(int argc, char **argv)
+int test_do_rmdir(int argc, char **argv)
{
if (argc != 1) {
@@ -1225,7 +1225,7 @@ int do_rmdir(int argc, char **argv)
return SUCCESS;
}
-int do_symlink(int argc, char **argv)
+int test_do_symlink(int argc, char **argv)
{
if (argc != 2) {
DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to symlink\n", argc));
@@ -1235,8 +1235,11 @@ int do_symlink(int argc, char **argv)
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;
@@ -1245,6 +1248,7 @@ int do_symlink(int argc, char **argv)
struct cmd_map ioctl_cmds[] = {
+#if 0
{ "BLKROSET", BLKROSET, 3 },
{ "BLKROGET", BLKROGET, 3 },
{ "BLKRRPART", BLKRRPART, 3 },
@@ -1260,6 +1264,7 @@ struct cmd_map ioctl_cmds[] = {
{ "BLKBSZSET", BLKBSZSET, 3 },
{ "FIBMAP", FIBMAP, 3 },
{ "FIGETBSZ", FIGETBSZ, 3},
+#endif
{ NULL, -1, 0 }
};
@@ -1277,7 +1282,7 @@ int get_ioctl_cmd(char *cmd)
return -1;
}
-int do_ioctl(int argc, char **argv)
+int test_do_ioctl(int argc, char **argv)
{
int fd, cmd;
@@ -1310,7 +1315,7 @@ int do_ioctl(int argc, char **argv)
return SUCCESS;
}
-int do_unlink(int argc, char **argv)
+int test_do_unlink(int argc, char **argv)
{
if (argc != 1) {
DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to unlink\n", argc));
@@ -1328,7 +1333,7 @@ int do_unlink(int argc, char **argv)
return SUCCESS;
}
-int do_umask(int argc, char **argv)
+int test_do_umask(int argc, char **argv)
{
mode_t old_mask;
@@ -1345,7 +1350,7 @@ int do_umask(int argc, char **argv)
return SUCCESS;
}
-int do_iowait(int argc, char **argv)
+int test_do_iowait(int argc, char **argv)
{
int err;
ioid_t ioid;
@@ -1373,7 +1378,7 @@ int do_iowait(int argc, char **argv)
return SUCCESS;
}
-int do_iodone(int argc, char **argv)
+int test_do_iodone(int argc, char **argv)
{
int err;
ioid_t ioid;
@@ -1401,7 +1406,7 @@ int do_iodone(int argc, char **argv)
}
-int do_ipread(int argc, char **argv)
+int test_do_ipread(int argc, char **argv)
{
int fd, index, count, offset;
char *buf;
@@ -1447,7 +1452,7 @@ int do_ipread(int argc, char **argv)
return SUCCESS;
}
-int do_iread(int argc, char **argv)
+int test_do_iread(int argc, char **argv)
{
int fd, index, count;
char *buf;
@@ -1488,7 +1493,7 @@ int do_iread(int argc, char **argv)
}
-int do_ipreadv(int argc, char **argv)
+int test_do_ipreadv(int argc, char **argv)
{
int fd, count, index;
off_t offset;
@@ -1543,7 +1548,7 @@ int do_ipreadv(int argc, char **argv)
}
-int do_preadv(int argc, char **argv)
+int test_do_preadv(int argc, char **argv)
{
int fd, count, index;
off_t offset;
@@ -1598,7 +1603,7 @@ int do_preadv(int argc, char **argv)
}
-int do_pread(int argc, char **argv)
+int test_do_pread(int argc, char **argv)
{
int fd, count, index, numbytes, offset;
char *buf;
@@ -1651,7 +1656,7 @@ int do_pread(int argc, char **argv)
}
-int do_ireadv(int argc, char **argv)
+int test_do_ireadv(int argc, char **argv)
{
int fd, count, index;
char *buf;
@@ -1698,7 +1703,7 @@ int do_ireadv(int argc, char **argv)
return SUCCESS;
}
-int do_readv(int argc, char **argv)
+int test_do_readv(int argc, char **argv)
{
int fd, count, index;
char *buf;
@@ -1745,7 +1750,7 @@ int do_readv(int argc, char **argv)
return SUCCESS;
}
-int do_read(int argc, char **argv)
+int test_do_read(int argc, char **argv)
{
int fd, count, index, numbytes=0;
char *buf;
@@ -1798,7 +1803,7 @@ int do_read(int argc, char **argv)
return SUCCESS;
}
-int do_ipwritev(int argc, char **argv)
+int test_do_ipwritev(int argc, char **argv)
{
int fd, count, index, offset;
char *buf;
@@ -1852,7 +1857,7 @@ int do_ipwritev(int argc, char **argv)
return SUCCESS;
}
-int do_ipwrite(int argc, char **argv)
+int test_do_ipwrite(int argc, char **argv)
{
int fd, count, index, offset;
char *buf;
@@ -1899,7 +1904,7 @@ int do_ipwrite(int argc, char **argv)
return SUCCESS;
}
-int do_pwritev(int argc, char **argv)
+int test_do_pwritev(int argc, char **argv)
{
int fd, count, index, offset;
char *buf;
@@ -1954,7 +1959,7 @@ int do_pwritev(int argc, char **argv)
return SUCCESS;
}
-int do_pwrite(int argc, char **argv)
+int test_do_pwrite(int argc, char **argv)
{
int fd, count, index, offset;
char *buf;
@@ -2002,7 +2007,7 @@ int do_pwrite(int argc, char **argv)
}
-int do_iwritev(int argc, char **argv)
+int test_do_iwritev(int argc, char **argv)
{
int fd, count, index;
char *buf;
@@ -2049,7 +2054,7 @@ int do_iwritev(int argc, char **argv)
return SUCCESS;
}
-int do_iwrite(int argc, char **argv)
+int test_do_iwrite(int argc, char **argv)
{
int fd, count, index;
char *buf;
@@ -2091,7 +2096,7 @@ int do_iwrite(int argc, char **argv)
}
-int do_write(int argc, char **argv)
+int test_do_write(int argc, char **argv)
{
int fd, count, index, err;
char *buf;
@@ -2137,7 +2142,7 @@ int do_write(int argc, char **argv)
}
-int do_writev(int argc, char **argv)
+int test_do_writev(int argc, char **argv)
{
int fd, count, index;
char *buf;
@@ -2184,7 +2189,7 @@ int do_writev(int argc, char **argv)
return SUCCESS;
}
-int do_mknod(int argc, char **argv)
+int test_do_mknod(int argc, char **argv)
{
int dev;
@@ -2204,7 +2209,7 @@ int do_mknod(int argc, char **argv)
return sysio_mknod(argv[0], argv[1], (dev_t) dev);
}
-int do_umount(int argc, char **argv)
+int test_do_umount(int argc, char **argv)
{
int err;
Index: sysio_tests.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/sysio_tests.c,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- sysio_tests.c 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ sysio_tests.c 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -44,6 +44,7 @@ int initilize_sysio(char *root_driver, c
* source directory.
*/
err = drv_init_all();
+ DBG(5, sprintf(output, "%sdrv_init_all: err %d\n", output, err));
if (err) {
my_errno = err;
my_perror("drv_init_all");
@@ -51,6 +52,7 @@ int initilize_sysio(char *root_driver, c
return SUCCESS;
}
err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL);
+ DBG(5, sprintf(output, "%ssysio_mount_root: err %d\n", output, err));
if (err) {
my_errno = errno;
my_perror("_sysio_mount_root");
@@ -70,6 +72,7 @@ int initilize_sysio(char *root_driver, c
strcpy(wd, "/");
}
if (chdir(wd) != 0) {
+ DBG(5, sprintf(output, "%schdir: errno %d\n", output, errno));
my_perror(wd);
my_errno = errno;
last_ret_val = errno;
@@ -551,10 +555,10 @@ int sysio_chown(char *new_id, char *file
int sysio_open(char *path, int flags)
{
- DBG(4, sprintf(output, "Opening file %s with flags %x\n",
- path, 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));
return SUCCESS;
}
@@ -574,6 +578,7 @@ int sysio_open3(char *path, int flags, c
last_ret_val = open(path, flags, mode);
my_errno = errno;
+
return SUCCESS;
}
@@ -824,7 +829,11 @@ void print_statvfs(struct statvfs *st)
DBG(3, sprintf(output, "%s f_ffree: %x\n", output, (unsigned int) st->f_ffree));
DBG(3, sprintf(output, "%s f_favail: %x\n", output, (unsigned int) st->f_favail));
DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files));
+#if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1)
+ DBG(3, sprintf(output, "%s f_fsid: %x\n", output, (unsigned int) st->f_fsid.__val[1]));
+#else
DBG(3, sprintf(output, "%s f_fsid: %x\n", output, (unsigned int) st->f_fsid));
+#endif
DBG(3, sprintf(output, "%s f_flag: %x\n", output, (unsigned int) st->f_flag));
DBG(3, sprintf(output, "%s f_fnamemax: %x\n", output, (unsigned int) st->f_namemax));
}
Index: test_all.pl
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_all.pl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- test_all.pl 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ test_all.pl 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -6,30 +6,58 @@
#
use strict;
+use Cwd 'abs_path';
my $alpha_arg = "";
+my $use_system = 1;
my $is_broke = 1; # Don't test certain areas known to not work on Cplant
-if ((@ARGV > 0) && ($ARGV[0] eq "-alpha")) {
+my $arg_count = @ARGV;
+foreach my $arg (@ARGV) {
+ if ($arg eq "-alpha") {
+ $alpha_arg = "-alpha";
+ } elsif ($arg eq "-nosystem") {
+ $use_system = 0;
+ }
+}
+my $alpha_env = $ENV{"IS_ALPHA"};
+# Check the environment vars
+if (defined($alpha_env) && ($alpha_env eq "yes")) {
$alpha_arg = "-alpha";
}
-
-
-# Will use this directory...
-system("mkdir ./tmp_dir");
my $failures = 0;
my $success = 0;
# Get cwd..
my $cwd = $ENV{PWD};
-# Get the sysio dir
-my $sysdir = $cwd;
-$sysdir =~ s/\/\w+$//;
+# Get tests directory
+my $testdir = $0;
+$testdir =~ s/\/\w+.pl$//;
+
my $res;
+if ($use_system == 1) {
+ # Will use this directory...
+ system("mkdir -p $cwd/tmp_dir");
+
+ # Create a couple of files and subdirectories for use in the tests
+ system("mkdir -p $cwd/tmp_dir/test1");
+ system("mkdir -p $cwd/tmp_dir/test2");
+
+ system("cp $testdir/helper.pm $cwd/tmp_dir/test1");
+} else {
+ $res = `perl $testdir/setup.pl $alpha_arg $cwd`;
+ chop($res);
+ if ($res ne "setup successful") {
+ print "Test setup failed with $res, bailing out\n";
+ exit 1;
+ }
+}
+
+
if (($alpha_arg eq "") || ($is_broke == 0)) {
# Test getdirentries
- $res = `./test_list.pl $alpha_arg $sysdir`;
+ $res = `perl $testdir/test_list.pl $alpha_arg $cwd/tmp_dir`;
chop($res);
if ($res ne "list test successful") {
print "Basic getdirentries test failed with message: $res\n";
@@ -41,8 +69,9 @@ if (($alpha_arg eq "") || ($is_broke ==
}
# Test path
-my @resarr = `./test_path.pl $alpha_arg $sysdir $cwd $cwd/tmp_dir`;
-$res = $sysdir.": d\n";
+my $path1 = abs_path($testdir);
+my @resarr = `perl $testdir/test_path.pl $alpha_arg $path1 $cwd $cwd/tmp_dir`;
+$res = $path1.": d\n";
if ($resarr[0] ne $res) {
print "path test returned $resarr[0] instead of $res\n";
$failures++;
@@ -65,7 +94,7 @@ if ($resarr[0] ne $res) {
if (($alpha_arg eq "") || ($is_broke == 0)) {
# Test mount
- $res = `./test_list.pl $alpha_arg -m native:$sysdir $cwd/tmp_dir`;
+ $res = `perl $testdir/test_list.pl $alpha_arg -m native:$testdir $cwd/tmp_dir/test2`;
chop($res);
if ($res ne "list test successful") {
print "Mount test failed with message: $res\n";
@@ -75,8 +104,9 @@ if (($alpha_arg eq "") || ($is_broke ==
print "test_mount finished successfully\n";
}
+}
# Test getcwd
- $res = `./test_getcwd.pl $alpha_arg $sysdir`;
+$res = `perl $testdir/test_getcwd.pl $alpha_arg $cwd/tmp_dir/test1`;
chop($res);
if ($res ne "getcwd test successful") {
print "getcwd test failed with message: $res\n";
@@ -85,10 +115,9 @@ if (($alpha_arg eq "") || ($is_broke ==
$success++;
print "test_getcwd finished successfully\n";
}
-}
# Test copy
-$res = `./test_copy.pl $alpha_arg $sysdir/README $cwd/tmp_dir/README`;
+$res = `perl $testdir/test_copy.pl $alpha_arg $cwd/tmp_dir/test1/helper.pm $cwd/tmp_dir/helper.pm`;
chop($res);
if ($res ne "copy test successful") {
print "copy test failed with message: $res\n";
@@ -99,7 +128,7 @@ if ($res ne "copy test successful") {
}
# Test stats
-$res = `./test_stats.pl $alpha_arg $cwd/tmp_dir/README`;
+$res = `perl $testdir/test_stats.pl $alpha_arg $use_system $cwd/tmp_dir/helper.pm`;
chop($res);
if ($res ne "stat test successful") {
print "stat test failed with message: $res\n";
@@ -110,7 +139,7 @@ if ($res ne "stat test successful") {
}
# Test stdfd
-$res = `./test_stdfd.pl $alpha_arg foo_dir`;
+$res = `perl $testdir/test_stdfd.pl $alpha_arg foo_dir`;
chop($res);
if ($res ne "test_stdfd successful") {
print "stdfd test failed with message: $res\n";
@@ -120,7 +149,29 @@ 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
-system(`rm -rf tmp_dir`);
+if ($use_system == 1) {
+ system(`rm -rf $cwd/tmp_dir`);
+} else {
+ $res = `perl $testdir/cleanup.pl $alpha_arg $cwd`;
+ chop($res);
+ if ($res ne "cleanup successful") {
+ print "Test cleanup failed with $res, bailing out\n";
+ exit 1;
+ }
+}
+
+exit $failures;
Index: test_copy.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.c,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -w -b -B -p -r1.5.4.1 -r1.5.4.2
--- test_copy.c 15 Aug 2003 07:43:15 -0000 1.5.4.1
+++ test_copy.c 1 Nov 2003 03:08:23 -0000 1.5.4.2
@@ -46,7 +46,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#ifndef REDSTORM
#include <getopt.h>
+#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -90,7 +92,7 @@ main(int argc, char * const argv[])
#ifdef AUTOMOUNT_FILE_NAME
"a"
#endif
- "i:m:")) != -1)
+ "r:m:")) != -1)
switch (i) {
#ifdef AUTOMOUNT_FILE_NAME
Index: test_copy.pl
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.pl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- test_copy.pl 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ test_copy.pl 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -8,6 +8,8 @@
use IPC::Open2;
use strict;
+use FindBin;
+use lib "$FindBin::Bin";
use helper;
sub usage
@@ -20,12 +22,15 @@ sub process_cmd
{
my ($src, $dest, $is_alpha) = @_;
+# Get tests directory
+my $testdir = $0;
+$testdir =~ s/\/\w+.pl$//;
eval {
if ($is_alpha == 0) {
- open2(\*OUTFILE, \*CMDFILE, "./test_driver --np");
+ open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np");
} else {
- open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 ./test_driver --np");
+ open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 $testdir/test_driver --np");
}
};
Index: test_driver.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- test_driver.c 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ test_driver.c 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -39,68 +39,68 @@ struct queue_t {
struct cmd_t cmd_list[] = {
{"alloc", get_buffer, usage_get_buffer},
- {"chdir", do_chdir, usage_chdir},
- {"chmod", do_chmod, usage_chmod},
- {"chown", do_chown, usage_chown},
- {"clear", do_clear, usage_clear},
- {"close", do_close, usage_close},
+ {"chdir", test_do_chdir, usage_chdir},
+ {"chmod", test_do_chmod, usage_chmod},
+ {"chown", test_do_chown, usage_chown},
+ {"clear", test_do_clear, usage_clear},
+ {"close", test_do_close, usage_close},
{"cmpstr", cmp_bufs, usage_cmpbufs},
- {"creat", do_creat, usage_creat},
- {"debug", do_setdebug, usage_setdebug},
- {"dup", do_dup, usage_dup},
- {"dup2", do_dup2, usage_dup2},
+ {"creat", test_do_creat, usage_creat},
+ {"debug", test_do_setdebug, usage_setdebug},
+ {"dup", test_do_dup, usage_dup},
+ {"dup2", test_do_dup2, usage_dup2},
{"endian", get_endian, usage_endian},
- {"exit", do_exit, usage_exit},
- {"fcntl", do_fcntl, usage_fcntl},
- {"fdatasync", do_fdatasync, usage_fdatasync},
- {"fill", do_fillbuff, usage_do_fillbuff},
+ {"exit", test_do_exit, usage_exit},
+ {"fcntl", test_do_fcntl, usage_fcntl},
+ {"fdatasync", test_do_fdatasync, usage_fdatasync},
+ {"fill", test_do_fillbuff, usage_do_fillbuff},
{"free", free_buffer, usage_free_buffer},
- {"fstat", do_fstat, usage_fstat},
- {"fstatvfs", do_fstatvfs, usage_fstatvfs},
- {"fsync", do_fsync, usage_fsync},
- {"ftruncate", do_ftruncate, usage_ftruncate},
- {"getcwd", do_getcwd, usage_getcwd},
- {"getdirentries", do_getdirentries, usage_getdirentries},
- {"init", do_init, usage_init},
- {"ioctl", do_ioctl, usage_ioctl},
- {"iodone", do_iodone, usage_iodone},
- {"iowait", do_iowait, usage_iowait},
- {"ipread", do_ipread, usage_ipread},
- {"ipreadv", do_ipreadv, usage_ipreadv},
- {"ipwrite", do_ipwrite, usage_ipwrite},
- {"ipwritev", do_ipwritev, usage_ipwritev},
- {"iread", do_iread, usage_iread},
- {"ireadv", do_ireadv, usage_ireadv},
- {"iwrite", do_iwrite, usage_iwrite},
- {"iwritev", do_iwritev, usage_iwritev},
- {"list", do_list, usage_list},
- {"lseek", do_lseek, usage_lseek},
- {"lstat", do_lstat, usage_lstat},
- {"mkdir", do_mkdir, usage_mkdir},
- {"mknod", do_mknod, usage_mknod},
- {"mount", do_mount, usage_mount},
- {"open", do_open, usage_open},
- {"printbuf", do_printbuf, usage_do_printbuf},
- {"printline", do_printline, usage_printline},
- {"pread", do_pread, usage_pread},
- {"preadv", do_preadv, usage_preadv},
- {"pwritev", do_pwritev, usage_pwritev},
- {"pwrite", do_pwrite, usage_pwrite},
- {"quit", do_exit, usage_exit},
- {"read", do_read, usage_read},
- {"readv", do_readv, usage_readv},
- {"rmdir", do_rmdir, usage_rmdir},
+ {"fstat", test_do_fstat, usage_fstat},
+ {"fstatvfs", test_do_fstatvfs, usage_fstatvfs},
+ {"fsync", test_do_fsync, usage_fsync},
+ {"ftruncate", test_do_ftruncate, usage_ftruncate},
+ {"getcwd", test_do_getcwd, usage_getcwd},
+ {"getdirentries", test_do_getdirentries, usage_getdirentries},
+ {"init", test_do_init, usage_init},
+ {"ioctl", test_do_ioctl, usage_ioctl},
+ {"iodone", test_do_iodone, usage_iodone},
+ {"iowait", test_do_iowait, usage_iowait},
+ {"ipread", test_do_ipread, usage_ipread},
+ {"ipreadv", test_do_ipreadv, usage_ipreadv},
+ {"ipwrite", test_do_ipwrite, usage_ipwrite},
+ {"ipwritev", test_do_ipwritev, usage_ipwritev},
+ {"iread", test_do_iread, usage_iread},
+ {"ireadv", test_do_ireadv, usage_ireadv},
+ {"iwrite", test_do_iwrite, usage_iwrite},
+ {"iwritev", test_do_iwritev, usage_iwritev},
+ {"list", test_do_list, usage_list},
+ {"lseek", test_do_lseek, usage_lseek},
+ {"lstat", test_do_lstat, usage_lstat},
+ {"mkdir", test_do_mkdir, usage_mkdir},
+ {"mknod", test_do_mknod, usage_mknod},
+ {"mount", test_do_mount, usage_mount},
+ {"open", test_do_open, usage_open},
+ {"printbuf", test_do_printbuf, usage_do_printbuf},
+ {"printline", test_do_printline, usage_printline},
+ {"pread", test_do_pread, usage_pread},
+ {"preadv", test_do_preadv, usage_preadv},
+ {"pwritev", test_do_pwritev, usage_pwritev},
+ {"pwrite", test_do_pwrite, usage_pwrite},
+ {"quit", test_do_exit, usage_exit},
+ {"read", test_do_read, usage_read},
+ {"readv", test_do_readv, usage_readv},
+ {"rmdir", test_do_rmdir, usage_rmdir},
{"sizeof", get_sizeof, usage_sizeof},
- /* {"setoutput", do_setoutput, usage_setoutput}, */
- {"stat", do_stat, usage_stat},
- {"statvfs", do_statvfs, usage_statvfs},
- {"symlink", do_symlink, usage_symlink},
- {"truncate", do_truncate, usage_truncate},
- {"umask", do_umask, usage_umask},
- {"umount", do_umount, usage_umount},
- {"unlink", do_unlink, usage_unlink},
- {"write", do_write, usage_write},
- {"writev", do_writev, usage_writev},
+ /* {"setoutput", test_do_setoutput, usage_setoutput}, */
+ {"stat", test_do_stat, usage_stat},
+ {"statvfs", test_do_statvfs, usage_statvfs},
+ {"symlink", test_do_symlink, usage_symlink},
+ {"truncate", test_do_truncate, usage_truncate},
+ {"umask", test_do_umask, usage_umask},
+ {"umount", test_do_umount, usage_umount},
+ {"unlink", test_do_unlink, usage_unlink},
+ {"write", test_do_write, usage_write},
+ {"writev", test_do_writev, usage_writev},
{NULL, NULL, NULL}
};
@@ -120,8 +120,8 @@ void * alloc_buff32(unsigned int size, i
long buf_ptr;
int err;
/*
- if ((err = posix_memalign(&buf, align, size)) != 0) {
- perror("posix_memalign");
+ if ((err = memalign(&buf, align, size)) != 0) {
+ perror("memalign");
return 0;
}
*/
@@ -145,7 +145,7 @@ long alloc_buff64(unsigned int size, int
char * buf;
long ret_value;
- if (posix_memalign((void **)&buf, align, size))
+ if (memalign((void **)&buf, align, size))
return 0;
ret_value = (long)buf;
@@ -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;
@@ -721,7 +725,11 @@ char *getline(char *prompt)
if ((do_prompt) && (infp == stdin))
printf(prompt);
+ /*
+ fprintf(stderr, "getline: errno %x\n", errno);
fseek(infp, 0, SEEK_CUR);
+ fprintf(stderr, "getline: errno %x\n", errno);
+ */
do {
/* If we get an end of file, just wait */
if (feof(infp)) {
@@ -817,6 +825,7 @@ int main(int argc, char *argv[])
do_prompt = 1;
+ errno = 0;
/* Get the input/output streams */
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--input")) {
@@ -889,10 +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 */
Index: test_driver.h
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.h,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- test_driver.h 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ test_driver.h 1 Nov 2003 03:08:23 -0000 1.2.2.2
@@ -135,67 +135,67 @@ extern void my_perror(char *msg);
extern char *get_str(char *var_name);
/* Stub functions defined in sysio_stubs.c */
-extern int do_setdebug(int argc, char **argv);
-extern int do_printline(int argc, char **argv);
+extern int test_do_setdebug(int argc, char **argv);
+extern int test_do_printline(int argc, char **argv);
extern int cmp_bufs(int argc, char **argv);
-extern int do_printbuf(int argc, char **argv);
-extern int do_fillbuff(int argc, char **argv);
-extern int do_mount(int argc, char **args);
-extern int do_list(int argc, char **args);
-extern int do_init(int argc, char **args);
+extern int test_do_printbuf(int argc, char **argv);
+extern int test_do_fillbuff(int argc, char **argv);
+extern int test_do_mount(int argc, char **args);
+extern int test_do_list(int argc, char **args);
+extern int test_do_init(int argc, char **args);
extern int get_endian(int argc, char **args);
extern int get_sizeof(int argc, char **args);
-extern int do_exit(int argc, char **args);
+extern int test_do_exit(int argc, char **args);
extern int get_buffer(int argc, char **args);
extern int free_buffer(int argc, char **args);
-extern int do_chdir(int argc, char **args);
-extern int do_chmod(int argc, char **args);
-extern int do_chown(int argc, char **args);
-extern int do_open(int argc, char **args);
-extern int do_close(int argc, char **args);
-extern int do_clear(int argc, char **argv);
-extern int do_dup(int argc, char **args);
-extern int do_dup2(int argc, char **args);
-extern int do_fcntl(int argc, char **args);
-extern int do_fstat(int argc, char **argv);
-extern int do_fsync(int argc, char **argv);
-extern int do_ftruncate(int argc, char **argv);
-extern int do_getcwd(int argc, char **argv);
-extern int do_lseek(int argc, char **argv);
-extern int do_lstat(int argc, char **argv);
-extern int do_getdirentries(int argc, char **argv);
-extern int do_mkdir(int argc, char **argv);
-extern int do_creat(int argc, char **argv);
-extern int do_stat(int argc, char **argv);
-extern int do_statvfs(int argc, char **argv);
-extern int do_fstatvfs(int argc, char **argv);
-extern int do_truncate(int argc, char **argv);
-extern int do_rmdir(int argc, char **argv);
-extern int do_symlink(int argc, char **argv);
-extern int do_unlink(int argc, char **argv);
-extern int do_fdatasync(int argc, char **argv);
-extern int do_ioctl(int argc, char **argv);
-extern int do_umask(int argc, char **argv);
-extern int do_iodone(int argc, char **argv);
-extern int do_iowait(int argc, char **argv);
-extern int do_ipreadv(int argc, char **argv);
-extern int do_ipread(int argc, char **argv);
-extern int do_preadv(int a...
[truncated message content] |