[Libsysio-commit] HEAD: libsysio/tests test_regions.c test_rw.pl Makefile.am help.c sysio_stubs.c te
Brought to you by:
lward
|
From: Lee W. <lw...@us...> - 2004-02-06 20:10:48
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29990/tests Modified Files: Makefile.am help.c sysio_stubs.c test_all.pl test_driver.c test_driver.h test_stats.pl Added Files: test_regions.c test_rw.pl Log Message: Merging strided-IO branch + Strided-IO infrastructure. Internals altered to move data base don multiple targeted regions in both the file address space and local memory. + Added [i]{read,write}x, calls to perform extent-based or strided-IO directly. + Many bug fixes + Many uocnfig fixes + --with-zero-sum-memory; A config option that causes the shutdown code to carefully release *all* memory acquired from the heap, by the library. Useful for debugging tasks such as leak detection. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- Makefile.am 21 Jan 2004 14:44:54 -0000 1.17 +++ Makefile.am 6 Feb 2004 20:07:30 -0000 1.18 @@ -1,5 +1,13 @@ + +if WITH_STDFD_DEV +STDFD_DEV_TEST = test_stdfd +else +STDFD_DEV_TEST = +endif + noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd test_link test_unlink test_rename test_driver + test_getcwd $(STDFD_DEV_TEST) test_link test_unlink test_rename \ + test_regions test_driver CLEANFILES=drv_data.c @@ -7,7 +15,7 @@ if WITH_NATIVE_DRIVER NATIVE_DRIVER_NAME=native NATIVE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/native else -NATIVE_DRIVER_NAME=native +NATIVE_DRIVER_NAME= NATIVE_DRIVER_CFLAGS= endif @@ -15,7 +23,7 @@ if WITH_INCORE_DRIVER INCORE_DRIVER_NAME=incore INCORE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/incore else -INCORE_DRIVER_NAME=incore +INCORE_DRIVER_NAME= INCORE_DRIVER_CFLAGS= endif @@ -23,7 +31,7 @@ if WITH_STDFD_DEV STDFD_DEV_NAME=stdfd STDFD_DEV_CFLAGS= -I$(top_srcdir)/dev/stdfd else -STDFD_DEV_NAME=stdfd +STDFD_DEV_NAME= STDFD_DEV_CFLAGS= endif @@ -113,6 +121,11 @@ test_rename_CFLAGS=$(CFL) test_rename_LDADD=$(LIBS) test_rename_DEPENDENCIES=$(LIBS) +test_regions_SOURCES=test_regions.c $(CMNSRC) +test_regions_CFLAGS=$(CFL) +test_regions_LDADD=$(LIBS) +test_regions_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) Index: help.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/help.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- help.c 14 Aug 2003 21:16:33 -0000 1.2 +++ help.c 6 Feb 2004 20:07:31 -0000 1.3 @@ -46,6 +46,12 @@ void usage_setdebug() fprintf(outfp, "setdebug [level]: Set debugging level to level\n"); } +void usage_setbuf() +{ + fprintf(outfp, "setbuf val size buf: fill size bytes of buf with byte val\n"); +} + + void usage_clear() { fprintf(outfp, "clear buf: zero out the buffer\n"); @@ -492,6 +498,53 @@ void usage_umount() fprintf(outfp, "umount [path] : Umount file at path. Returns 0 on success and -1 on failure\n"); } +void usage_init_iovec() +{ + fprintf(outfp, "init_iovec buf offset len num iov_buf: Init iovector. iov_uf points to an array of\n"); + fprintf(outfp, " iovecs, num is the number of the iovec, \n"); + fprintf(outfp, " buf is the buffer to be used, offset \n"); + fprintf(outfp, " specifies how far into the buffer the iovec\n"); + fprintf(outfp, " should point and len is the iov length\n"); +} + +void usage_init_xtvec() +{ + fprintf(outfp, "init_xtvec offset len num buf: Init xtvector. Buf points to an array of\n"); + fprintf(outfp, " xtvecs, num is the number of the xtvec, offset\n"); + fprintf(outfp, " is xtv_off and len is the iov lenghth\n"); + fprintf(outfp, " the iov length\n"); +} + +void usage_writex() +{ + fprintf(outfp, "writex fd iovs iov_cnt xtvs xtvcnt: Write iov_cnt iovecs out to file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + +void usage_iwritex() +{ + fprintf(outfp, "iwritex fd iovs iov_cnt xtvs xtvcnt: Write iov_cnt iovecs out to file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + +void usage_readx() +{ + fprintf(outfp, "readx fd iovs iov_cnt xtvs xtvcnt: Read iov_cnt iovecs out from file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + +void usage_ireadx() +{ + fprintf(outfp, "ireadx fd iovs iov_cnt xtvs xtvcnt: Read iov_cnt iovecs out from file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + + +void usage_checkbuf() +{ + fprintf(outfp, "checkbuf buf size val: Checks to see if val is in first size bytes of buf\n"); +} + void usage_exit() { } Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- sysio_stubs.c 21 Jan 2004 15:38:45 -0000 1.7 +++ sysio_stubs.c 6 Feb 2004 20:07:31 -0000 1.8 @@ -13,6 +13,7 @@ #include "test_driver.h" #include "sysio.h" +#include "xtio.h" /* * ################################################ @@ -423,6 +424,43 @@ int get_endian(int argc, char **argv) return SUCCESS; } +int do_setbuf(int argc, char **argv) +{ + int val, size, index; + void *buf; + + if (argc != 3) { + DBG(2, fprintf(outfp, "Need val, size, and buffer for setbuf\n")); + return INVALID_ARGS; + } + val = get_obj(argv[0]); + if (val < 0) { + DBG(2, fprintf(outfp, "Unable to understand val of %s\n", + argv[0])); + return INVALID_VAR; + } + + size = get_obj(argv[1]); + if( size <=0 ) { + DBG(2, fprintf(outfp, "Size of %s is invalid\n", argv[1])); + return INVALID_VAR; + } + + index = get_obj(argv[2]); + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", + argv[2])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + memset(buf, val, size); + + return SUCCESS; +} + + int get_sizeof(int argc, char **argv) { char *type; @@ -450,6 +488,8 @@ int get_sizeof(int argc, char **argv) size = sizeof(struct statvfs); else if (!strcmp(type, "iovec")) size = sizeof(struct iovec); + else if (!strcmp(type, "xtvec")) + size = sizeof(struct xtvec); else return INVALID_ARGS; @@ -2229,3 +2269,416 @@ int test_do_umount(int argc, char **argv return SUCCESS; } +int test_do_init_iovec(int argc, char **argv) +{ + int iov_index, buf_index; + int offset, len, pos; + struct iovec *iov_ptr; + char *base_ptr; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Need buffer, offset, len, array pos, and iov pointer\n")); + return INVALID_ARGS; + } + + if ((buf_index = get_obj(argv[0])) < 0) { + DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[0])); + return INVALID_VAR; + } + base_ptr = buflist[buf_index]->buf; + + if ((offset = get_obj(argv[1])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[1])); + return INVALID_VAR; + } + + if ((len = get_obj(argv[2])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[2])); + return INVALID_VAR; + } + + if ((pos = get_obj(argv[3])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[3])); + return INVALID_VAR; + } + + if ((iov_index = get_obj(argv[4])) < 0) { + DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[4])); + return INVALID_VAR; + } + iov_ptr = (struct iovec *)(buflist[iov_index]->buf); + + iov_ptr[pos].iov_len = len; + iov_ptr[pos].iov_base = (void *)(base_ptr + (char)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)); + + my_errno = errno; + last_type = PTR; + + return SUCCESS; +} + + +int test_do_init_xtvec(int argc, char **argv) +{ + int xtv_index; + int offset, len, pos; + struct xtvec *xtv_ptr; + + if (argc != 4) { + DBG(2, fprintf(outfp, "Need offset, len, array pos, and xtv pointer\n")); + return INVALID_ARGS; + } + + if ((offset = get_obj(argv[0])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[0])); + return INVALID_VAR; + } + + if ((len = get_obj(argv[1])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[1])); + return INVALID_VAR; + } + + if ((pos = get_obj(argv[2])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[2])); + return INVALID_VAR; + } + + if ((xtv_index = get_obj(argv[3])) < 0) { + DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[3])); + return INVALID_VAR; + } + xtv_ptr = (struct xtvec *)(buflist[xtv_index]->buf); + + xtv_ptr[pos].xtv_len = len; + 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)); + + my_errno = errno; + last_type = PTR; + + return SUCCESS; +} + +int test_do_writex(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to writex\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "writex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = writex(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("writex"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int test_do_iwritex(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwritex\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "iwritex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = (int) iwritex(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("iwritex"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int test_do_readx(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to readx\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "readx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = readx(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("readx"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int test_do_ireadx(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ireadx\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "ireadx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = (int) ireadx(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("ireadx"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int do_checkbuf(int argc, char **argv) +{ + int size, val, index, i; + int *ref_buf, *buf; + + if (argc != 3) { + DBG(2, fprintf(outfp, "Need buffer and val for checkbuf\n")); + return INVALID_ARGS; + } + + index = get_obj(argv[0]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buf described by %s\n", argv[0])); + return INVALID_VAR; + } + + buf = (int *)buflist[index]->buf; + + val = get_obj(argv[1]); + + if (val < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[1])); + return INVALID_ARGS; + } + + size = get_obj(argv[2]); + + if (size < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + ref_buf = (int *)malloc(size); + memset((void *)ref_buf, val, size); + + last_ret_val =0; + for (i=0; i < size/sizeof(int); i++) { + if (buf[i] != ref_buf[i]) { + DBG(2, fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x\n", + i, buf[i], ref_buf[i])); + fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x\n", + i, buf[i], ref_buf[i]); + last_ret_val = 1; + break; + } + } + + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_all.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- test_all.pl 21 Jan 2004 15:13:56 -0000 1.7 +++ test_all.pl 6 Feb 2004 20:07:31 -0000 1.8 @@ -161,6 +161,17 @@ if ($res ne "Symlink test successful") { print "test_symlink finished successfully\n"; } +# Test r/w calls +$res = `perl $testdir/test_rw.pl $alpha_arg $cwd/tmp_dir/tmp.foo`; +chop($res); +if ($res ne "rw test successful") { + print "rw test failed with message: $res\n"; + $failures++; +} else { + $success++; + print "rw test 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.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- test_driver.c 21 Jan 2004 15:38:45 -0000 1.5 +++ test_driver.c 6 Feb 2004 20:07:31 -0000 1.6 @@ -40,6 +40,7 @@ struct queue_t { struct cmd_t cmd_list[] = { {"alloc", get_buffer, usage_get_buffer}, {"chdir", test_do_chdir, usage_chdir}, + {"checkbuf", do_checkbuf, usage_checkbuf}, {"chmod", test_do_chmod, usage_chmod}, {"chown", test_do_chown, usage_chown}, {"clear", test_do_clear, usage_clear}, @@ -62,6 +63,8 @@ struct cmd_t cmd_list[] = { {"getcwd", test_do_getcwd, usage_getcwd}, {"getdirentries", test_do_getdirentries, usage_getdirentries}, {"init", test_do_init, usage_init}, + {"init_iovec", test_do_init_iovec, usage_init_iovec}, + {"init_xtvec", test_do_init_xtvec, usage_init_xtvec}, {"ioctl", test_do_ioctl, usage_ioctl}, {"iodone", test_do_iodone, usage_iodone}, {"iowait", test_do_iowait, usage_iowait}, @@ -71,8 +74,10 @@ struct cmd_t cmd_list[] = { {"ipwritev", test_do_ipwritev, usage_ipwritev}, {"iread", test_do_iread, usage_iread}, {"ireadv", test_do_ireadv, usage_ireadv}, + {"ireadx", test_do_ireadx, usage_ireadx}, {"iwrite", test_do_iwrite, usage_iwrite}, {"iwritev", test_do_iwritev, usage_iwritev}, + {"iwritex", test_do_iwritex, usage_iwritex}, {"list", test_do_list, usage_list}, {"lseek", test_do_lseek, usage_lseek}, {"lstat", test_do_lstat, usage_lstat}, @@ -89,7 +94,9 @@ struct cmd_t cmd_list[] = { {"quit", test_do_exit, usage_exit}, {"read", test_do_read, usage_read}, {"readv", test_do_readv, usage_readv}, + {"readx", test_do_readx, usage_readx}, {"rmdir", test_do_rmdir, usage_rmdir}, + {"setbuf", do_setbuf, usage_setbuf}, {"sizeof", get_sizeof, usage_sizeof}, /* {"setoutput", test_do_setoutput, usage_setoutput}, */ {"stat", test_do_stat, usage_stat}, @@ -101,6 +108,7 @@ struct cmd_t cmd_list[] = { {"unlink", test_do_unlink, usage_unlink}, {"write", test_do_write, usage_write}, {"writev", test_do_writev, usage_writev}, + {"writex", test_do_writex, usage_writex}, {NULL, NULL, NULL} }; @@ -310,7 +318,7 @@ void store_result(char *var_name, int re } else new_map = &map[index]; - new_map->map.name = malloc(sizeof(var_name) + 1); + new_map->map.name = malloc(strlen(var_name) + 1); strcpy(new_map->map.name, var_name); new_map->map.obj = result; new_map->map.type = last_type; @@ -415,7 +423,6 @@ int execute_cmd(char *cmd, char **args, if (!strcmp(cmd, "help")) { if (arg_count > 0) { - while(cmd_list[i].cmd != NULL) { if (!strcmp(cmd_list[i].cmd, args[0])) { (cmd_list[i].usage)(); @@ -430,8 +437,9 @@ int execute_cmd(char *cmd, char **args, return -1; } while(cmd_list[i].cmd != NULL) { - if (!strcmp(cmd_list[i].cmd, cmd)) + if (!strcmp(cmd_list[i].cmd, cmd)) { return (cmd_list[i].func)(arg_count, args); + } i++; } DBG(2, fprintf(outfp, "Command %s was invalid\n", cmd)); @@ -729,11 +737,6 @@ 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 +820,124 @@ void init_map() } } +int getquotedlen(char *str) +{ + int i; + + if (str[0] != '"' && str[0] != '\'') + return -1; + + for (i=1; str[i] != '\0' && str[i] != '"' && str[i] != '\''; i++); + + return i; +} + +int perform_op(int num1, int num2, char op) +{ + switch(op) { + + case '+': + return num1 + num2; + break; + + case '*': + return num1 * num2; + break; + + case '/': + return num1 / num2; + break; + + case '-': + return num1 - num2; + break; + + case '%': + return num1%num2; + break; + + default: + return num1; + } + return 0; +} + +int get_constant_val(char **str_ptr, int type) +{ + struct buf_t *buf; + char *buf_ptr; + char *str = *str_ptr; + char ch; + int i, j, num1, num2, size; + + printf("Getting constant val from %s\n", str); + switch(type) { + case 1: + size = getquotedlen(str); + buf = (struct buf_t *)malloc(sizeof(struct buf_t)); + buf->buf = alloc_buff32(size, 8); + buf->len = size; + buf_ptr = buf->buf; + buflist[next] = buf; + j=0; + for (i=1; i < size; i++) { + buf_ptr[j] = str[i]; + j++; + } + buf_ptr[j] = '\0'; + + DBG(3, fprintf(outfp, "Your buffer (%p) (%p) is at index %d\n", + buf, buf->buf, next)); + next++; + + last_type = PTR; + last_ret_val = next-1; + return last_ret_val; + break; + + case 2: + if (str[0] == '$') { + num1 = get_obj(str); + } else { + num1 = atoi(str); + } + str = str_ptr[1]; + ch = str_ptr[1][0]; + if ((ch == '+') || (ch == '/') || (ch == '*') || + (ch == '-') || (ch == '%')) { + if (str_ptr[2][0] == '$') + num2 = get_obj(str_ptr[2]); + else + num2 = atoi(str_ptr[2]); + num1 = perform_op(num1, num2, ch); + } + + last_type = UINT; + last_ret_val = num1; + + break; + + default: + DBG(2, fprintf(outfp, "Can't understand type of %d\n", type)); + return INVALID_ARGS; + } + + return last_ret_val; +} + +int is_constant(char *str) +{ + if ((str[0] == '"') || (str[0] == '\'')) + return 1; + + + if ( (str[0] == '$') || + ( ((int)str[0] > 47) && ((int)str[0] < 57) ) ) + return 2; + + return 0; +} + int main(int argc, char *argv[]) { int count, err, i, orig_count; @@ -902,11 +1023,18 @@ int main(int argc, char *argv[]) count--; } i++; + if ((err=is_constant(cmd[i])) != 0) { + store_result((char *)(&cmd[0][1]), get_constant_val(&cmd[i], err)); + tree = NULL; + err = 0; + } else { + 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); Index: test_driver.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_driver.h 10 Oct 2003 18:50:31 -0000 1.3 +++ test_driver.h 6 Feb 2004 20:07:31 -0000 1.4 @@ -145,10 +145,12 @@ extern int test_do_list(int argc, char * 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_setbuf(int argc, char **argv); 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 test_do_chdir(int argc, char **args); +extern int do_checkbuf(int argc, char **argv); extern int test_do_chmod(int argc, char **args); extern int test_do_chown(int argc, char **args); extern int test_do_open(int argc, char **args); @@ -161,6 +163,8 @@ extern int test_do_fstat(int argc, char extern int test_do_fsync(int argc, char **argv); extern int test_do_ftruncate(int argc, char **argv); extern int test_do_getcwd(int argc, char **argv); +extern int test_do_init_iovec(int argc, char **argv); +extern int test_do_init_xtvec(int argc, char **argv); extern int test_do_lseek(int argc, char **argv); extern int test_do_lstat(int argc, char **argv); extern int test_do_getdirentries(int argc, char **argv); @@ -183,8 +187,10 @@ extern int test_do_ipread(int argc, char extern int test_do_preadv(int argc, char **argv); extern int test_do_pread(int argc, char **argv); extern int test_do_ireadv(int argc, char **argv); +extern int test_do_ireadx(int argc, char **argv); extern int test_do_iread(int argc, char **argv); extern int test_do_readv(int argc, char **argv); +extern int test_do_readx(int argc, char **argv); extern int test_do_read(int argc, char **argv); extern int test_do_ipwritev(int argc, char **argv); extern int test_do_ipwrite(int argc, char **argv); @@ -192,7 +198,9 @@ extern int test_do_pwritev(int argc, cha extern int test_do_pwrite(int argc, char **argv); extern int test_do_iwritev(int argc, char **argv); extern int test_do_iwrite(int argc, char **argv); +extern int test_do_iwritex(int argc, char **argv); extern int test_do_writev(int argc, char **argv); +extern int test_do_writex(int argc, char **argv); extern int test_do_write(int argc, char **argv); extern int test_do_mknod(int argc, char **argv); extern int test_do_umount(int argc, char **argv); @@ -246,12 +254,16 @@ extern void usage_fstat(); extern void usage_fsync(); extern void usage_ftruncate(); extern void usage_getcwd(); +extern void usage_init_iovec(); +extern void usage_init_xtvec(); extern void usage_lseek(); extern void usage_lstat(); extern void usage_getdirentries(); extern void usage_mkdir(); +extern void usage_checkbuf(); extern void usage_cmpbufs(); extern void usage_creat(); +extern void usage_setbuf(); extern void usage_stat(); extern void usage_statvfs(); extern void usage_fstatvfs(); @@ -270,7 +282,9 @@ extern void usage_preadv(); extern void usage_pread(); extern void usage_ireadv(); extern void usage_iread(); +extern void usage_ireadx(); extern void usage_readv(); +extern void usage_readx(); extern void usage_read(); extern void usage_ipwritev(); extern void usage_ipwrite(); @@ -278,8 +292,10 @@ extern void usage_pwritev(); extern void usage_pwrite(); extern void usage_iwritev(); extern void usage_iwrite(); +extern void usage_iwritex(); extern void usage_writev(); extern void usage_write(); +extern void usage_writex(); extern void usage_mknod(); extern void usage_umount(); extern void usage_exit(); Index: test_stats.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- test_stats.pl 21 Jan 2004 15:13:56 -0000 1.6 +++ test_stats.pl 6 Feb 2004 20:07:31 -0000 1.7 @@ -172,6 +172,7 @@ sub process_cmd verify_stat($cmdfh, $outfh, "lstat", $is_alpha, @stats); } + if (0) { # Now do statvfs functions $cmdstr = '$buf2 = ALLOC ( $size2 = CALL sizeof statvfs )'."\n"; helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); @@ -223,6 +224,7 @@ sub process_cmd helper::print_and_exit($cmdfh, $outfh, 1, $str); } } + } helper::print_and_exit($cmdfh, $outfh, 0, "stat test successful\n"); } |