From 4fe6fbde6c77e8a7a9714f8b8b481332b00288f8 Mon Sep 17 00:00:00 2001 From: mananth Date: Thu, 19 Feb 2004 09:10:53 +0000 Subject: Testsuite updates, conf/script file addition and errno set correctly --- ChangeLog | 6 ++ aclocal.m4 | 78 +++++++++++++++++++++++ configure | 18 ++++-- docs/libsysfs.txt | 11 +++- lib/sysfs_bus.c | 2 +- lib/sysfs_dir.c | 22 ++++++- test/Makefile.am | 9 ++- test/Makefile.in | 14 +++- test/create-test | 39 ++++++++++++ test/libsysfs.conf | 77 ++++++++++++++++++++++ test/test-defs.h | 153 ++++++++++++++++++++++++++++++++++++++++++++ test/test.c | 2 +- test/test.h | 183 ----------------------------------------------------- test/test_bus.c | 73 +++++++++++++-------- test/test_class.c | 104 ++++++++++++++++++++++-------- test/test_dir.c | 2 +- test/test_driver.c | 127 +++++++++++++++++++++++++++++-------- test/test_root.c | 79 +++++++++++++++++------ test/test_utils.c | 4 +- test/testout.c | 2 +- 20 files changed, 701 insertions(+), 304 deletions(-) create mode 100755 test/create-test create mode 100644 test/libsysfs.conf create mode 100644 test/test-defs.h delete mode 100644 test/test.h diff --git a/ChangeLog b/ChangeLog index a2401f9..47bd613 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ +02/19/2004 - Ananth Mavinakayanahalli + * Set errnos correctly in the library + * Provided libsysfs.conf - the config file for the testsuite + and a script to create a test.h on the fly + * Added numerous testsuite updates + 02/13/2004 - Ananth Mavinakayanahalli * Patched code to fill sysfs_device->driver_name correctly diff --git a/aclocal.m4 b/aclocal.m4 index b73a11f..bf9ed34 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -756,6 +756,84 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]) fi])]) +# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- + +# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +AC_PREREQ([2.52]) + +# serial 6 + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. We must strip everything past the first ":", +# and everything past the last "/". + +# _AM_DIRNAME(PATH) +# ----------------- +# Like AS_DIRNAME, only do it during macro expansion +AC_DEFUN([_AM_DIRNAME], + [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, + m4_if(regexp([$1], [^//\([^/]\|$\)]), -1, + m4_if(regexp([$1], [^/.*]), -1, + [.], + patsubst([$1], [^\(/\).*], [\1])), + patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), + patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl +])# _AM_DIRNAME + + +# The stamp files are numbered to have different names. +# We could number them on a directory basis, but that's additional +# complications, let's have a unique counter. +m4_define([_AM_STAMP_Count], [0]) + + +# _AM_STAMP(HEADER) +# ----------------- +# The name of the stamp file for HEADER. +AC_DEFUN([_AM_STAMP], +[m4_define([_AM_STAMP_Count], m4_incr(_AM_STAMP_Count))dnl +AS_ESCAPE(_AM_DIRNAME(patsubst([$1], + [:.*])))/stamp-h[]_AM_STAMP_Count]) + + +# _AM_CONFIG_HEADER(HEADER[:SOURCES], COMMANDS, INIT-COMMANDS) +# ------------------------------------------------------------ +# We used to try to get a real timestamp in stamp-h. But the fear is that +# that will cause unnecessary cvs conflicts. +AC_DEFUN([_AM_CONFIG_HEADER], +[# Add the stamp file to the list of files AC keeps track of, +# along with our hook. +AC_CONFIG_HEADERS([$1], + [# update the timestamp +echo 'timestamp for $1' >"_AM_STAMP([$1])" +$2], + [$3]) +])# _AM_CONFIG_HEADER + + +# AM_CONFIG_HEADER(HEADER[:SOURCES]..., COMMANDS, INIT-COMMANDS) +# -------------------------------------------------------------- +AC_DEFUN([AM_CONFIG_HEADER], +[AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])]) +])# AM_CONFIG_HEADER + # libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- # serial 46 AC_PROG_LIBTOOL diff --git a/configure b/configure index ea31a4f..6953005 100755 --- a/configure +++ b/configure @@ -1756,8 +1756,12 @@ INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +# Add the stamp file to the list of files AC keeps track of, +# along with our hook. ac_config_headers="$ac_config_headers config.h" + + # Check whether --enable-shared or --disable-shared was given. if test "${enable_shared+set}" = set; then enableval="$enable_shared" @@ -4167,7 +4171,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 4170 "configure"' > conftest.$ac_ext + echo '#line 4174 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4703,7 +4707,7 @@ chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no -if { (eval echo configure:4706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then +if { (eval echo configure:4710: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then @@ -6496,7 +6500,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <"./stamp-h1" + ;; + esac done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF diff --git a/docs/libsysfs.txt b/docs/libsysfs.txt index 5929a25..9d18c4a 100644 --- a/docs/libsysfs.txt +++ b/docs/libsysfs.txt @@ -1891,11 +1891,16 @@ c. Detailed output is provided for the correct case. d. Facility to redirect output of the tests to a normal file. e. Number of iterations of tests can be specified. +The testsuite comes with its own configuration file "libsysfs.conf" in the +"test" directory. This file is used to generate a header file at the time +the tests are built. + To use the testsuite: -a. Modify the #defines in test/test.h file to appropriate values. For example, - the tests could be run on a system with only ide drives, in which case, - the value of "val_block_class_dev_path" has to be appropriately modified. +a. Modify the variables libsysfs.conf file to appropriate values for your +system. (The libsysfs.conf file contains comments describing what each variable +stands for and, in some cases, how to determine an appropriate value for the +system under test). b. Build and install the testsuite. diff --git a/lib/sysfs_bus.c b/lib/sysfs_bus.c index 821938c..89105b9 100644 --- a/lib/sysfs_bus.c +++ b/lib/sysfs_bus.c @@ -121,7 +121,7 @@ struct dlist *sysfs_get_bus_devices(struct sysfs_bus *bus) return NULL; } - if (devdir->links != 0) { + if (devdir->links != NULL) { dlist_for_each_data(devdir->links, curl, struct sysfs_link) { bdev = sysfs_open_device_path(curl->target); if (bdev == NULL) { diff --git a/lib/sysfs_dir.c b/lib/sysfs_dir.c index 5fbd019..7d69012 100644 --- a/lib/sysfs_dir.c +++ b/lib/sysfs_dir.c @@ -184,6 +184,7 @@ int sysfs_write_attribute(struct sysfs_attribute *sysattr, if (!(sysattr->method & SYSFS_METHOD_STORE)) { dprintf ("Store method not supported for attribute %s\n", sysattr->path); + errno = EACCES; return -1; } if (sysattr->method & SYSFS_METHOD_SHOW) { @@ -271,6 +272,7 @@ int sysfs_read_attribute(struct sysfs_attribute *sysattr) if (!(sysattr->method & SYSFS_METHOD_SHOW)) { dprintf("Show method not supported for attribute %s\n", sysattr->path); + errno = EACCES; return -1; } pgsize = sysconf(_SC_PAGESIZE); @@ -431,6 +433,7 @@ static struct sysfs_link *alloc_link(void) int sysfs_read_all_subdirs(struct sysfs_directory *sysdir) { struct sysfs_directory *cursub = NULL; + int retval = 0; if (sysdir == NULL) { errno = EINVAL; @@ -442,12 +445,16 @@ int sysfs_read_all_subdirs(struct sysfs_directory *sysdir) if (sysdir->subdirs != NULL) { dlist_for_each_data(sysdir->subdirs, cursub, struct sysfs_directory) { - if ((sysfs_read_dir_subdirs(cursub)) != 0) + if ((sysfs_read_dir_subdirs(cursub)) != 0) { dprintf ("Error reading subdirectory %s\n", cursub->name); + retval = -1; + } } } - return 0; + if (!retval) + errno = 0; + return retval; } /** @@ -628,6 +635,8 @@ int sysfs_read_dir_attributes(struct sysfs_directory *sysdir) retval = add_attribute(sysdir, file_path); } closedir(dir); + if (!retval) + errno = 0; return(retval); } @@ -668,6 +677,8 @@ int sysfs_read_dir_links(struct sysfs_directory *sysdir) } } closedir(dir); + if (!retval) + errno = 0; return(retval); } @@ -705,6 +716,8 @@ int sysfs_read_dir_subdirs(struct sysfs_directory *sysdir) retval = add_subdirectory(sysdir, file_path); } closedir(dir); + if (!retval) + errno = 0; return(retval); } @@ -753,6 +766,8 @@ int sysfs_read_directory(struct sysfs_directory *sysdir) retval = add_attribute(sysdir, file_path); } closedir(dir); + if (!retval) + errno = 0; return(retval); } @@ -781,6 +796,7 @@ int sysfs_refresh_dir_attributes(struct sysfs_directory *sysdir) sysdir->path); return 1; } + errno = 0; return 0; } @@ -809,6 +825,7 @@ int sysfs_refresh_dir_links(struct sysfs_directory *sysdir) sysdir->path); return 1; } + errno = 0; return 0; } @@ -837,6 +854,7 @@ int sysfs_refresh_dir_subdirs(struct sysfs_directory *sysdir) sysdir->path); return 1; } + errno = 0; return 0; } diff --git a/test/Makefile.am b/test/Makefile.am index bf88667..e33528c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,9 @@ bin_PROGRAMS = dlist_test get_class_dev get_device get_driver write_attr \ get_bus_devices_list get_classdev_parent testlibsysfs +BUILT_SOURCES = test.h +CLEANFILES = test.h +test.h: + ./create-test dlist_test_SOURCES = dlist_test.c get_class_dev_SOURCES = get_class_dev.c get_device_SOURCES = get_device.c @@ -7,8 +11,9 @@ get_driver_SOURCES = get_driver.c get_bus_devices_list_SOURCES = get_bus_devices_list.c write_attr_SOURCES = write_attr.c get_classdev_parent_SOURCES = get_classdev_parent.c -testlibsysfs_SOURCES = test.c test_bus.c test_class.c test_dir.c \ - test_driver.c test_root.c test_utils.c testout.c test.h +testlibsysfs_SOURCES = test.c test_bus.c test_class.c test_dir.c test_driver.c \ + test_root.c test_utils.c testout.c test-defs.h \ + libsysfs.conf create-test INCLUDES = -I../include LDADD = ../lib/libsysfs.la CFLAGS = -Wall -Wshadow -W -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls diff --git a/test/Makefile.in b/test/Makefile.in index 11254c4..4ab200e 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -86,6 +86,8 @@ install_sh = @install_sh@ bin_PROGRAMS = dlist_test get_class_dev get_device get_driver write_attr \ get_bus_devices_list get_classdev_parent testlibsysfs +BUILT_SOURCES = test.h +CLEANFILES = test.h dlist_test_SOURCES = dlist_test.c get_class_dev_SOURCES = get_class_dev.c get_device_SOURCES = get_device.c @@ -93,8 +95,9 @@ get_driver_SOURCES = get_driver.c get_bus_devices_list_SOURCES = get_bus_devices_list.c write_attr_SOURCES = write_attr.c get_classdev_parent_SOURCES = get_classdev_parent.c -testlibsysfs_SOURCES = test.c test_bus.c test_class.c test_dir.c \ - test_driver.c test_root.c test_utils.c testout.c test.h +testlibsysfs_SOURCES = test.c test_bus.c test_class.c test_dir.c test_driver.c \ + test_root.c test_utils.c testout.c test-defs.h \ + libsysfs.conf create-test INCLUDES = -I../include LDADD = ../lib/libsysfs.la @@ -183,7 +186,8 @@ DIST_SOURCES = $(dlist_test_SOURCES) $(get_bus_devices_list_SOURCES) \ DIST_COMMON = Makefile.am Makefile.in SOURCES = $(dlist_test_SOURCES) $(get_bus_devices_list_SOURCES) $(get_class_dev_SOURCES) $(get_classdev_parent_SOURCES) $(get_device_SOURCES) $(get_driver_SOURCES) $(testlibsysfs_SOURCES) $(write_attr_SOURCES) -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -385,6 +389,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) @@ -392,6 +397,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am @@ -442,6 +448,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am mostlyclean-libtool tags uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-info-am +test.h: + ./create-test # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/test/create-test b/test/create-test new file mode 100755 index 0000000..0e40c63 --- /dev/null +++ b/test/create-test @@ -0,0 +1,39 @@ +#! /bin/sh + +rm -f test.h + +conf_file=./libsysfs.conf + +. $conf_file + +echo "#define val_dir_path \"$VALID_DIRECTORY_PATH\"" > test.h +echo "#define val_link_path \"$VALID_LINK_PATH\"" >> test.h +echo "#define val_file_path \"$VALID_FILE_PATH\"" >> test.h +echo "#define val_subdir_link_name \"$VALID_SUBDIR_LINK_NAME\"" >> test.h +echo "#define val_subdir_name \"$VALID_SUBDIR_NAME\"" >> test.h +echo "#define val_subsys \"$VALID_SUBSYSTEM\"" >> test.h +echo "#define val_bus_name \"$VALID_BUS_NAME\"" >> test.h +echo "#define val_bus_attr \"$VALID_BUS_ATTR\"" >> test.h +echo "#define val_root_name \"$VALID_ROOT_NAME\"" >> test.h +echo "#define val_root_dev_path \"$VALID_ROOT_PATH\"" >> test.h +echo "#define val_bus_id \"$VALID_BUS_ID\"" >> test.h +echo "#define val_dev_path \"$VALID_DEVICE_PATH\"" >> test.h +echo "#define val_dev_attr \"$VALID_DEVICE_ATTR\"" >> test.h +echo "#define val_class \"$VALID_CLASS\"" >> test.h +echo "#define val_class_dev \"$VALID_CLASS_DEVICE\"" >> test.h +echo "#define val_class_dev_path \"$VALID_CLASS_DEVICE_PATH\"" >> test.h +echo "#define val_class_dev_attr \"$VALID_CLASS_DEV_ATTR\"" >> test.h +echo "#define val_block_class_dev_path \"$VALID_BLOCK_DEV_PATH\"" >> test.h +echo "#define val_class_dev_attr \"$VALID_CLASS_DEV_ATTR\"" >> test.h +echo "#define val_drv_name \"$VALID_DRIVER\"" >> test.h +echo "#define val_drv_path \"$VALID_DRIVER_PATH\"" >> test.h +echo "#define val_drv_bus_name \"$VALID_DRIVER_BUS\"" >> test.h +echo "#define val_drv_dev_name \"$VALID_DRIVER_DEVICE\"" >> test.h +echo "#define val_drv_attr_name \"$VALID_DRIVER_ATTR\"" >> test.h +echo "#define val_drv1_name \"$VALID_DRIVER1\"" >> test.h +echo "#define val_drv1_path \"$VALID_DRIVER1_PATH\"" >> test.h +echo "#define val_drv1_bus_name \"$VALID_DRIVER1_BUS\"" >> test.h +echo "#define val_drv1_dev_name \"$VALID_DRIVER1_DEVICE\"" >> test.h +echo "#define val_drv1_attr_name \"$VALID_DRIVER1_ATTR\"" >> test.h +echo "#define val_write_attr_path \"$VALID_WRITE_ATTR_PATH\"" >> test.h + diff --git a/test/libsysfs.conf b/test/libsysfs.conf new file mode 100644 index 0000000..de1f977 --- /dev/null +++ b/test/libsysfs.conf @@ -0,0 +1,77 @@ +# The config file for libsysfs testsuite +# All values in this file are in relation to the sysfs filesystem only + +# A valid directory path +VALID_DIRECTORY_PATH=/sys/bus/pci + +# A valid link path under sysfs +VALID_LINK_PATH=/sys/block/sda/device + +# Path to a regular attribute (file) +VALID_FILE_PATH=/sys/block/sda/dev + +# A valid link name under a subdirectory of VALID_DIRECTORY_PATH - enter a +# pci device name here if you have defined VALID_DIRECTORY_PATH as /sys/bus/pci +VALID_SUBDIR_LINK_NAME=0000:00:00.0 + +# A valid subsystem name - an entry under /sys +VALID_SUBSYSTEM=bus + +# A valid bus name supported on this system +# A device belonging to the bus +# Absolute path to the device +# A valid attribute defined for this device +VALID_BUS_NAME=pci +VALID_BUS_ID=0000:00:00.0 +VALID_DEVICE_PATH=/sys/devices/pci0000:00/0000:00:00.0 +VALID_DEVICE_ATTR=vendor + +# A valid attribute exported under VALID_BUS_NAME +# NOTE: As of now, no buses export attributes, change this to a valid value +# when one becomes avaliable +VALID_BUS_ATTR=online + +# A valid directory under /sys/devices +# Its absolute path +# A valid subdirectory under VALID_ROOT_PATH +VALID_ROOT_NAME=pci0000:00 +VALID_ROOT_PATH=/sys/devices/pci0000:00 +VALID_SUBDIR_NAME=0000:00:00.0 + +# A valid class - directory under /sys/class +# A valid class_device belonging to the class - a dir under VALID_CLASS +# Abslolute path to the VALID_CLASS_DEVICE +# A valid attribute defined for the VALID_CLASS_DEVICE +VALID_CLASS=net +VALID_CLASS_DEVICE=eth0 +VALID_CLASS_DEVICE_PATH=/sys/class/net/eth0 +VALID_CLASS_DEV_ATTR=type + +# A valid directory path under /sys/block/xxx - preferably a partition +VALID_BLOCK_DEV_PATH=/sys/block/sda/sda1 + +# A valid driver (preferably a driver that exports readable attributes) +# the absolute path to the driver +# the bus the driver is registered on +# a device that is using it and +# a valid attribute corresponding to the driver +VALID_DRIVER=3c59x +VALID_DRIVER_PATH=/sys/bus/pci/drivers/3c59x +VALID_DRIVER_BUS=pci +VALID_DRIVER_DEVICE=0000:01:0a.0 +VALID_DRIVER_ATTR=new_id + +# Another valid driver - one without attributes/devices that use it +# its absolute path +# the bus the driver is registered +# a device that is using it (a dummy value basically) +# an attribute corresponding to the driver (another dummy value) +VALID_DRIVER1=usbfs +VALID_DRIVER1_PATH=/sys/bus/usb/drivers/usbfs +VALID_DRIVER1_BUS=usb +VALID_DRIVER1_DEVICE=dummy1 +VALID_DRIVER1_ATTR=dummy2 + +# Path to a writable attribute +VALID_WRITE_ATTR_PATH=/sys/class/net/eth0/tx_queue_len + diff --git a/test/test-defs.h b/test/test-defs.h new file mode 100644 index 0000000..f9fde7a --- /dev/null +++ b/test/test-defs.h @@ -0,0 +1,153 @@ +/* + * test.h + * + * Generic defines/declarations for the libsysfs testsuite + * + * Copyright (C) IBM Corp. 2004 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2 of the License. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _TESTER_H_ +#define _TESTER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libsysfs.h" +#include "dlist.h" +#include "test.h" + +#define inval_name "invalid_name" +#define inval_path "/sys/invalid/path" +#define FUNC_TABLE_SIZE 81 + +FILE *my_stdout; + +#define dbg_print(format, arg...) fprintf(my_stdout, format, ## arg) + +/** + * list of display functions + */ +extern void show_device(struct sysfs_device *device); +extern void show_driver(struct sysfs_driver *driver); +extern void show_device_list(struct dlist *devlist); +extern void show_driver_list(struct dlist *drvlist); +extern void show_root_device(struct sysfs_root_device *root); +extern void show_attribute(struct sysfs_attribute *attr); +extern void show_attribute_list(struct dlist *list); +extern void show_link(struct sysfs_link *ln); +extern void show_links_list(struct dlist *linklist); +extern void show_dir(struct sysfs_directory *dir); +extern void show_dir_list(struct dlist *dirlist); +extern void show_directory(struct sysfs_directory *dir); +extern void show_dir_tree(struct sysfs_directory *dir); +extern void show_class_device(struct sysfs_class_device *dev); +extern void show_class_device_list(struct dlist *devlist); +extern void show_list(struct dlist *list); + +/** + * list of test functions..... + */ +extern int test_sysfs_get_mnt_path(int flag); +extern int test_sysfs_remove_trailing_slash(int flag); +extern int test_sysfs_get_name_from_path(int flag); +extern int test_sysfs_path_is_dir(int flag); +extern int test_sysfs_path_is_link(int flag); +extern int test_sysfs_path_is_file(int flag); +extern int test_sysfs_get_link(int flag); +extern int test_sysfs_open_subsystem_list(int flag); +extern int test_sysfs_open_bus_devices_list(int flag); +extern int test_sysfs_close_list(int flag); +extern int test_sysfs_close_attribute(int flag); +extern int test_sysfs_open_attribute(int flag); +extern int test_sysfs_read_attribute(int flag); +extern int test_sysfs_read_attribute_value(int flag); +extern int test_sysfs_write_attribute(int flag); +extern int test_sysfs_get_value_from_attributes(int flag); +extern int test_sysfs_refresh_dir_attributes(int flag); +extern int test_sysfs_refresh_dir_links(int flag); +extern int test_sysfs_refresh_dir_subdirs(int flag); +extern int test_sysfs_close_directory(int flag); +extern int test_sysfs_open_directory(int flag); +extern int test_sysfs_read_dir_attributes(int flag); +extern int test_sysfs_read_dir_links(int flag); +extern int test_sysfs_read_dir_subdirs(int flag); +extern int test_sysfs_read_directory(int flag); +extern int test_sysfs_read_all_subdirs(int flag); +extern int test_sysfs_get_subdirectory(int flag); +extern int test_sysfs_close_link(int flag); +extern int test_sysfs_open_link(int flag); +extern int test_sysfs_get_directory_link(int flag); +extern int test_sysfs_get_subdirectory_link(int flag); +extern int test_sysfs_get_directory_attribute(int flag); +extern int test_sysfs_get_dir_attributes(int flag); +extern int test_sysfs_get_dir_links(int flag); +extern int test_sysfs_get_dir_subdirs(int flag); +extern int test_sysfs_close_driver(int flag); +extern int test_sysfs_open_driver(int flag); +extern int test_sysfs_open_driver_path(int flag); +extern int test_sysfs_get_driver_attr(int flag); +extern int test_sysfs_get_driver_attributes(int flag); +extern int test_sysfs_get_driver_devices(int flag); +extern int test_sysfs_refresh_driver_devices(int flag); +extern int test_sysfs_get_driver_links(int flag); +extern int test_sysfs_get_driver_device(int flag); +extern int test_sysfs_refresh_driver_attributes(int flag); +extern int test_sysfs_open_driver_attr(int flag); +extern int test_sysfs_close_root_device(int flag); +extern int test_sysfs_open_root_device(int flag); +extern int test_sysfs_get_root_devices(int flag); +extern int test_sysfs_close_device(int flag); +extern int test_sysfs_open_device(int flag); +extern int test_sysfs_get_device_parent(int flag); +extern int test_sysfs_open_device_path(int flag); +extern int test_sysfs_get_device_attr(int flag); +extern int test_sysfs_get_device_attributes(int flag); +extern int test_sysfs_refresh_device_attributes(int flag); +extern int test_sysfs_open_device_attr(int flag); +extern int test_sysfs_close_bus(int flag); +extern int test_sysfs_open_bus(int flag); +extern int test_sysfs_get_bus_device(int flag); +extern int test_sysfs_get_bus_driver(int flag); +extern int test_sysfs_get_bus_drivers(int flag); +extern int test_sysfs_get_bus_devices(int flag); +extern int test_sysfs_get_bus_attributes(int flag); +extern int test_sysfs_refresh_bus_attributes(int flag); +extern int test_sysfs_get_bus_attribute(int flag); +extern int test_sysfs_find_driver_bus(int flag); +extern int test_sysfs_close_class_device(int flag); +extern int test_sysfs_open_class_device_path(int flag); +extern int test_sysfs_open_class_device(int flag); +extern int test_sysfs_get_classdev_device(int flag); +extern int test_sysfs_get_classdev_driver(int flag); +extern int test_sysfs_get_classdev_parent(int flag); +extern int test_sysfs_close_class(int flag); +extern int test_sysfs_open_class(int flag); +extern int test_sysfs_get_class_devices(int flag); +extern int test_sysfs_get_class_device(int flag); +extern int test_sysfs_get_classdev_attributes(int flag); +extern int test_sysfs_refresh_classdev_attributes(int flag); +extern int test_sysfs_get_classdev_attr(int flag); +extern int test_sysfs_open_classdev_attr(int flag); + +#endif /* _TESTER_H_ */ diff --git a/test/test.c b/test/test.c index 8d85800..3ecdc37 100644 --- a/test/test.c +++ b/test/test.c @@ -24,7 +24,7 @@ * this doesn't do much, just loops throug to call each function. */ -#include "test.h" +#include "test-defs.h" #include /*************************************************/ diff --git a/test/test.h b/test/test.h deleted file mode 100644 index 6dfe277..0000000 --- a/test/test.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * test.h - * - * Generic defines/declarations for the libsysfs testsuite - * - * Copyright (C) IBM Corp. 2004 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2 of the License. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef _TESTER_H_ -#define _TESTER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libsysfs.h" -#include "dlist.h" - -/* - * FIXME: Change the following #defines appropriately for the system that you - * run the tests on. - */ -#define val_dir_path "/sys/bus/pci" -#define val_link_path "/sys/block/sda/device" -#define val_file_path "/sys/block/sda/dev" -#define val_link_name "device" -#define val_subdir_link_name "0000:00:00.0" -#define val_subdir_name "0000:00:00.0" -#define val_bus_id "0000:00:00.0" -#define val_bus "pci" -#define val_subsys "bus" -#define val_bus_name "pci" -#define val_class "net" -#define val_class_dev "eth0" -#define val_class_dev_path "/sys/class/net/eth0" -#define val_class_dev_attr "type" -#define val_block_class_dev_path "/sys/block/sda/sda1" -#define val_root_name "pci0000:00" -#define val_root_dev_path "/sys/devices/pci0000:00" -#define val_drv_name "scsi_debug" -#define val_drv_bus_name "pseudo" -#define val_drv_dev_name "adapter0" -#define val_drv_path "/sys/bus/pseudo/drivers/scsi_debug" -#define val_dev_path "/sys/devices/pci0000:00/0000:00:00.0" -#define val_dev_attr "vendor" -#define val_drv_attr_name "opts" -#define val_write_attr_path "/sys/class/net/eth0/tx_queue_len" -#define val_attr_name "online" -#define val_bus_attr "online" -#define inval_name "invalid_name" -#define inval_path "/sys/invalid/path" -#define FUNC_TABLE_SIZE 81 - -FILE *my_stdout; - -#define dbg_print(format, arg...) fprintf(my_stdout, format, ## arg) - -/** - * list of display functions - */ -extern void show_device(struct sysfs_device *device); -extern void show_driver(struct sysfs_driver *driver); -extern void show_device_list(struct dlist *devlist); -extern void show_driver_list(struct dlist *drvlist); -extern void show_root_device(struct sysfs_root_device *root); -extern void show_attribute(struct sysfs_attribute *attr); -extern void show_attribute_list(struct dlist *list); -extern void show_link(struct sysfs_link *ln); -extern void show_links_list(struct dlist *linklist); -extern void show_dir(struct sysfs_directory *dir); -extern void show_dir_list(struct dlist *dirlist); -extern void show_directory(struct sysfs_directory *dir); -extern void show_dir_tree(struct sysfs_directory *dir); -extern void show_class_device(struct sysfs_class_device *dev); -extern void show_class_device_list(struct dlist *devlist); -extern void show_list(struct dlist *list); - -/** - * list of test functions..... - */ -extern int test_sysfs_get_mnt_path(int flag); -extern int test_sysfs_remove_trailing_slash(int flag); -extern int test_sysfs_get_name_from_path(int flag); -extern int test_sysfs_path_is_dir(int flag); -extern int test_sysfs_path_is_link(int flag); -extern int test_sysfs_path_is_file(int flag); -extern int test_sysfs_get_link(int flag); -extern int test_sysfs_open_subsystem_list(int flag); -extern int test_sysfs_open_bus_devices_list(int flag); -extern int test_sysfs_close_list(int flag); -extern int test_sysfs_close_attribute(int flag); -extern int test_sysfs_open_attribute(int flag); -extern int test_sysfs_read_attribute(int flag); -extern int test_sysfs_read_attribute_value(int flag); -extern int test_sysfs_write_attribute(int flag); -extern int test_sysfs_get_value_from_attributes(int flag); -extern int test_sysfs_refresh_dir_attributes(int flag); -extern int test_sysfs_refresh_dir_links(int flag); -extern int test_sysfs_refresh_dir_subdirs(int flag); -extern int test_sysfs_close_directory(int flag); -extern int test_sysfs_open_directory(int flag); -extern int test_sysfs_read_dir_attributes(int flag); -extern int test_sysfs_read_dir_links(int flag); -extern int test_sysfs_read_dir_subdirs(int flag); -extern int test_sysfs_read_directory(int flag); -extern int test_sysfs_read_all_subdirs(int flag); -extern int test_sysfs_get_subdirectory(int flag); -extern int test_sysfs_close_link(int flag); -extern int test_sysfs_open_link(int flag); -extern int test_sysfs_get_directory_link(int flag); -extern int test_sysfs_get_subdirectory_link(int flag); -extern int test_sysfs_get_directory_attribute(int flag); -extern int test_sysfs_get_dir_attributes(int flag); -extern int test_sysfs_get_dir_links(int flag); -extern int test_sysfs_get_dir_subdirs(int flag); -extern int test_sysfs_close_driver(int flag); -extern int test_sysfs_open_driver(int flag); -extern int test_sysfs_open_driver_path(int flag); -extern int test_sysfs_get_driver_attr(int flag); -extern int test_sysfs_get_driver_attributes(int flag); -extern int test_sysfs_get_driver_devices(int flag); -extern int test_sysfs_refresh_driver_devices(int flag); -extern int test_sysfs_get_driver_links(int flag); -extern int test_sysfs_get_driver_device(int flag); -extern int test_sysfs_refresh_driver_attributes(int flag); -extern int test_sysfs_open_driver_attr(int flag); -extern int test_sysfs_close_root_device(int flag); -extern int test_sysfs_open_root_device(int flag); -extern int test_sysfs_get_root_devices(int flag); -extern int test_sysfs_close_device(int flag); -extern int test_sysfs_open_device(int flag); -extern int test_sysfs_get_device_parent(int flag); -extern int test_sysfs_open_device_path(int flag); -extern int test_sysfs_get_device_attr(int flag); -extern int test_sysfs_get_device_attributes(int flag); -extern int test_sysfs_refresh_device_attributes(int flag); -extern int test_sysfs_open_device_attr(int flag); -extern int test_sysfs_close_bus(int flag); -extern int test_sysfs_open_bus(int flag); -extern int test_sysfs_get_bus_device(int flag); -extern int test_sysfs_get_bus_driver(int flag); -extern int test_sysfs_get_bus_drivers(int flag); -extern int test_sysfs_get_bus_devices(int flag); -extern int test_sysfs_get_bus_attributes(int flag); -extern int test_sysfs_refresh_bus_attributes(int flag); -extern int test_sysfs_get_bus_attribute(int flag); -extern int test_sysfs_find_driver_bus(int flag); -extern int test_sysfs_close_class_device(int flag); -extern int test_sysfs_open_class_device_path(int flag); -extern int test_sysfs_open_class_device(int flag); -extern int test_sysfs_get_classdev_device(int flag); -extern int test_sysfs_get_classdev_driver(int flag); -extern int test_sysfs_get_classdev_parent(int flag); -extern int test_sysfs_close_class(int flag); -extern int test_sysfs_open_class(int flag); -extern int test_sysfs_get_class_devices(int flag); -extern int test_sysfs_get_class_device(int flag); -extern int test_sysfs_get_classdev_attributes(int flag); -extern int test_sysfs_refresh_classdev_attributes(int flag); -extern int test_sysfs_get_classdev_attr(int flag); -extern int test_sysfs_open_classdev_attr(int flag); - -#endif /* _TESTER_H_ */ diff --git a/test/test_bus.c b/test/test_bus.c index 6392dd3..8bd04af 100644 --- a/test/test_bus.c +++ b/test/test_bus.c @@ -42,7 +42,7 @@ ****************************************************************************** */ -#include "test.h" +#include "test-defs.h" #include /** @@ -202,10 +202,14 @@ int test_sysfs_get_bus_device(int flag) switch (flag) { case 0: - if (dev == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (dev == NULL) { + if (errno == 0) + dbg_print("%s: Device %s not on bus %s\n", + __FUNCTION__, id, bus_name); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device(dev); @@ -300,10 +304,14 @@ int test_sysfs_get_bus_driver(int flag) switch (flag) { case 0: - if (drv == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (drv == NULL) { + if (errno == 0) + dbg_print("%s: Driver %s not on bus %s\n", + __FUNCTION__, drvname, bus_name); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_driver(drv); @@ -364,10 +372,14 @@ int test_sysfs_get_bus_drivers(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: No drivers registered with bus %s\n", + __FUNCTION__, bus_name); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_driver_list(list); @@ -423,10 +435,14 @@ int test_sysfs_get_bus_devices(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: No devices registered with bus %s\n", + __FUNCTION__, bus_name); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device_list(list); @@ -483,11 +499,13 @@ int test_sysfs_get_bus_attributes(int flag) switch (flag) { case 0: if (list == NULL) { -/* dbg_print("%s: FAILED with flag = %d errno = %d\n", - __FUNCTION__, flag, errno);*/ - dbg_print("%s: SUCCEEDED with flag = %d\n", + if (errno == 0) { + dbg_print("%s: SUCCEEDED with flag = %d\n", __FUNCTION__, flag); - dbg_print("since no buses have attribs as of now\n"); + dbg_print("since no buses have attribs as of now\n"); + } else + dbg_print("%s: FAILED with flag = %d errno = %d\n", + __FUNCTION__, flag, errno); } else { dbg_print("%s: SUCCEEDED with flag = %d\n", __FUNCTION__, flag); @@ -544,11 +562,13 @@ int test_sysfs_refresh_bus_attributes(int flag) switch (flag) { case 0: if (list == NULL) { - /*dbg_print("%s: FAILED with flag = %d errno = %d\n", - __FUNCTION__, flag, errno);*/ - dbg_print("%s: SUCCEEDED with flag = %d\n", + if (errno == 0) { + dbg_print("%s: SUCCEEDED with flag = %d\n", __FUNCTION__, flag); - dbg_print("since no buses have attribs as of now\n"); + dbg_print("since no buses have attribs as of now\n"); + } else + dbg_print("%s: FAILED with flag = %d errno = %d\n", + __FUNCTION__, flag, errno); } else { dbg_print("%s: SUCCEEDED with flag %d\n", __FUNCTION__, flag); @@ -640,11 +660,14 @@ int test_sysfs_get_bus_attribute(int flag) switch (flag) { case 0: if (attr == NULL) { -/* dbg_print("%s: FAILED with flag = %d errno = %d\n", - __FUNCTION__, flag, errno); */ - dbg_print("%s: SUCCEEDED with flag = %d\n", + if (errno == 0) { + dbg_print("%s: SUCCEEDED with flag = %d\n", __FUNCTION__, flag); - dbg_print("since no buses have attribs as of now\n"); + + dbg_print("since no buses have attribs as of now\n"); + } else + dbg_print("%s: FAILED with flag = %d errno = %d\n", + __FUNCTION__, flag, errno); } else { dbg_print("%s: SUCCEEDED with flag = %d\n", __FUNCTION__, flag); diff --git a/test/test_class.c b/test/test_class.c index 4b29c44..85cb3a1 100644 --- a/test/test_class.c +++ b/test/test_class.c @@ -53,7 +53,7 @@ ***************************************************************************** */ -#include "test.h" +#include "test-defs.h" #include /** @@ -283,10 +283,14 @@ int test_sysfs_get_classdev_device(int flag) switch (flag) { case 0: - if (dev == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (dev == NULL) { + if (errno == 0) + dbg_print("%s: Class device at %s does not have a device symlink\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device(dev); @@ -345,10 +349,14 @@ int test_sysfs_get_classdev_driver(int flag) switch (flag) { case 0: - if (drv == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (drv == NULL) { + if (errno == 0) + dbg_print("%s: Class device at %s does not have a driver symlink\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_driver(drv); @@ -405,10 +413,14 @@ int test_sysfs_get_classdev_parent(int flag) switch (flag) { case 0: - if (parent == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (parent == NULL) { + if (errno == 0) + dbg_print("%s: Class device at %s does not have a parent\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_class_device(parent); @@ -558,10 +570,14 @@ int test_sysfs_get_class_devices(int flag) switch(flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: Class %s does not have devices\n", + __FUNCTION__, val_class); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_class_device_list(list); @@ -650,10 +666,14 @@ int test_sysfs_get_class_device(int flag) switch(flag) { case 0: - if (clsdev == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (clsdev == NULL) { + if (errno == 0) + dbg_print("%s: Class device %s does not belong to the %s class\n", + __FUNCTION__, val_class_dev, val_class); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_class_device(clsdev); @@ -713,10 +733,14 @@ int test_sysfs_get_classdev_attributes(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: Class device at %s does not export attributes\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute_list(list); @@ -773,10 +797,14 @@ int test_sysfs_refresh_classdev_attributes(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: Class device at %s does not export attributes\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute_list(list); @@ -869,10 +897,20 @@ int test_sysfs_get_classdev_attr(int flag) switch (flag) { case 0: - if (attr == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (attr == NULL) { + if (errno == EACCES) + dbg_print("%s: attribute %s does not support READ\n", + __FUNCTION__, name); + else if (errno == ENOENT) + dbg_print("%s: attribute %s not defined for class device at %s\n", + __FUNCTION__, name, path); + else if (errno == 0) + dbg_print("%s: class device at %s does not export attributes\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute(attr); @@ -1084,10 +1122,20 @@ int test_sysfs_open_classdev_attr(int flag) switch (flag) { case 0: - if (attr == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (attr == NULL) { + if (errno == EACCES) + dbg_print("%s: attribute %s does not support READ\n", + __FUNCTION__, attrib); + else if (errno == ENOENT) + dbg_print("%s: attribute %s not defined for class device %s\n", + __FUNCTION__, attrib, dev); + else if (errno == 0) + dbg_print("%s: class device %s does not export attributes\n", + __FUNCTION__, dev); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute(attr); diff --git a/test/test_dir.c b/test/test_dir.c index 99a5d5f..1e0b79b 100644 --- a/test/test_dir.c +++ b/test/test_dir.c @@ -61,7 +61,7 @@ **************************************************************************** */ -#include "test.h" +#include "test-defs.h" #include /** diff --git a/test/test_driver.c b/test/test_driver.c index 576befb..c0287be 100644 --- a/test/test_driver.c +++ b/test/test_driver.c @@ -48,7 +48,7 @@ ****************************************************************************** */ -#include "test.h" +#include "test-defs.h" #include /** @@ -302,10 +302,20 @@ int test_sysfs_get_driver_attr(int flag) attr = sysfs_get_driver_attr(drv, attrname); switch (flag) { case 0: - if (attr == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (attr == NULL) { + if (errno == EACCES) + dbg_print("%s: attribute %s does not support READ\n", + __FUNCTION__, attrname); + else if (errno == ENOENT) + dbg_print("%s: attribute %s not defined for driver at %s\n", + __FUNCTION__, attrname, name); + else if (errno == 0) + dbg_print("%s: driver at %s does not export attributes\n", + __FUNCTION__, val_drv_path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute(attr); @@ -344,10 +354,12 @@ int test_sysfs_get_driver_attributes(int flag) { struct sysfs_driver *driver = NULL; struct dlist *list = NULL; + unsigned char *drv = NULL; switch (flag) { case 0: - driver = sysfs_open_driver_path(val_drv_path); + drv = val_drv_path; + driver = sysfs_open_driver_path(drv); if (driver == NULL) { dbg_print("%s: failed opening driver at %s\n", __FUNCTION__, val_drv_path); @@ -357,6 +369,15 @@ int test_sysfs_get_driver_attributes(int flag) case 1: driver = NULL; break; + case 2: + drv = val_drv1_path; + driver = sysfs_open_driver_path(drv); + if (driver == NULL) { + dbg_print("%s: failed opening driver at %s\n", + __FUNCTION__, val_drv1_path); + return 0; + } + break; default: return -1; } @@ -364,10 +385,15 @@ int test_sysfs_get_driver_attributes(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + case 2: + if (list == NULL) { + if (errno == 0) + dbg_print("%s: No attributes are defined for the driver at %s\n", + __FUNCTION__, drv); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute_list(list); @@ -401,10 +427,12 @@ int test_sysfs_get_driver_devices(int flag) { struct sysfs_driver *driver = NULL; struct dlist *list = NULL; + unsigned char *drv = NULL; switch (flag) { case 0: - driver = sysfs_open_driver_path(val_drv_path); + drv = val_drv_path; + driver = sysfs_open_driver_path(drv); if (driver == NULL) { dbg_print("%s: failed opening driver at %s\n", __FUNCTION__, val_drv_path); @@ -414,6 +442,15 @@ int test_sysfs_get_driver_devices(int flag) case 1: driver = NULL; break; + case 2: + drv = val_drv1_path; + driver = sysfs_open_driver_path(drv); + if (driver == NULL) { + dbg_print("%s: failed opening driver at %s\n", + __FUNCTION__, val_drv1_path); + return 0; + } + break; default: return -1; } @@ -421,10 +458,15 @@ int test_sysfs_get_driver_devices(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + case 2: + if (list == NULL) { + if (errno == 0) + dbg_print("%s: No devices are using the driver at %s\n", + __FUNCTION__, drv); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device_list(list); @@ -487,10 +529,14 @@ int test_sysfs_refresh_driver_devices(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: No devices are using the driver at %s\n", + __FUNCTION__, val_drv_path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device_list(list); @@ -545,10 +591,14 @@ int test_sysfs_get_driver_links(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: Driver at %s does not have any links\n", + __FUNCTION__, val_drv_path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_links_list(list); @@ -637,10 +687,14 @@ int test_sysfs_get_driver_device(int flag) switch (flag) { case 0: - if (dev == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (dev == NULL) { + if (errno == 0) + dbg_print("%s: Device with name %s does not use the driver at %s\n", + __FUNCTION__, name, val_drv_path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device(dev); @@ -699,10 +753,14 @@ int test_sysfs_refresh_driver_attributes(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: driver at %s does not export attributes\n", + __FUNCTION__, val_drv_path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute_list(list); @@ -787,7 +845,7 @@ int test_sysfs_open_driver_attr(int flag) case 3: bus = val_drv_bus_name; drv = inval_name; - attrib = val_attr_name; + attrib = val_drv_attr_name; break; case 4: bus = val_drv_bus_name; @@ -904,6 +962,11 @@ int test_sysfs_open_driver_attr(int flag) drv = NULL; attrib = NULL; break; + case 27: + bus = val_drv1_bus_name; + drv = val_drv1_name; + attrib = val_drv1_attr_name; + break; default: return -1; } @@ -911,10 +974,18 @@ int test_sysfs_open_driver_attr(int flag) switch (flag) { case 0: - if (attr == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + case 27: + if (attr == NULL) { + if (errno == EACCES) + dbg_print("%s: attribute %s does not support READ\n", + __FUNCTION__, attrib); + else if (errno == ENOENT) + dbg_print("%s: attribute %s not defined for driver %s\n", + __FUNCTION__, attrib, drv); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute(attr); diff --git a/test/test_root.c b/test/test_root.c index 2e0c0b1..d532970 100644 --- a/test/test_root.c +++ b/test/test_root.c @@ -49,7 +49,7 @@ ****************************************************************************** */ -#include "test.h" +#include "test-defs.h" #include /** @@ -183,14 +183,19 @@ int test_sysfs_get_root_devices(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: Root device %s does not have any devices under it\n", + __FUNCTION__, root_name); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device_list(list); dbg_print("\n"); + } break; case 1: if (list != NULL) @@ -378,10 +383,14 @@ int test_sysfs_get_device_parent(int flag) switch (flag) { case 0: - if (pdev == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (pdev == NULL) { + if (errno == 0) + dbg_print("%s: Device at %s does not have a parent\n", + __FUNCTION__, dev_path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device(pdev); @@ -502,7 +511,7 @@ int test_sysfs_get_device_attr(int flag) break; case 3: dev = NULL; - name = val_attr_name; + name = val_dev_attr; break; case 4: dev = NULL; @@ -519,10 +528,21 @@ int test_sysfs_get_device_attr(int flag) switch (flag) { case 0: - if (attr == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (attr == NULL) { + if (errno == EACCES) + dbg_print("%s: attribute %s does not support READ\n", + __FUNCTION__, name); + else if (errno == ENOENT) + dbg_print("%s: attribute %s not defined for device at %s\n", + __FUNCTION__, name, path); + else if (errno == 0) + dbg_print("%s: device at %s does not export attributes\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute(attr); @@ -588,10 +608,14 @@ int test_sysfs_get_device_attributes(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: device at %s does not export attributes\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute_list(list); @@ -655,10 +679,14 @@ int test_sysfs_refresh_device_attributes(int flag) switch (flag) { case 0: - if (list == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (list == NULL) { + if (errno == 0) + dbg_print("%s: device at %s does not export attributes\n", + __FUNCTION__, path); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute_list(list); @@ -871,10 +899,21 @@ int test_sysfs_open_device_attr(int flag) switch (flag) { case 0: - if (attr == NULL) - dbg_print("%s: FAILED with flag = %d errno = %d\n", + if (attr == NULL) { + if (errno == EACCES) + dbg_print("%s: attribute %s does not support READ\n", + __FUNCTION__, attrib); + else if (errno == ENOENT) + dbg_print("%s: attribute %s not defined for device %s\n", + __FUNCTION__, attrib, bus_id); + else if (errno == 0) + dbg_print("%s: device %s does not export attributes\n", + __FUNCTION__, bus_id); + else + dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); - else { + + } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_attribute(attr); diff --git a/test/test_utils.c b/test/test_utils.c index 412de12..3d970d5 100644 --- a/test/test_utils.c +++ b/test/test_utils.c @@ -41,7 +41,7 @@ ***************************************************************************** */ -#include "test.h" +#include "test-defs.h" #include /** @@ -575,7 +575,7 @@ int test_sysfs_open_bus_devices_list(int flag) switch (flag) { case 0: - name = val_bus; + name = val_bus_name; break; case 1: name = inval_name; diff --git a/test/testout.c b/test/testout.c index fb6e31c..711db00 100644 --- a/test/testout.c +++ b/test/testout.c @@ -24,7 +24,7 @@ * Display routines for test functions */ -#include +#include static void remove_end_newline(unsigned char *value) { -- cgit v1.2.1