summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormananth <mananth>2004-02-24 05:10:37 +0000
committermananth <mananth>2004-02-24 05:10:37 +0000
commitd21d3bc4234b224d70e7b567df64d9b28734f4e7 (patch)
tree78c6da26d8bca1df7fa0ede2c8c0f41143114fd2
parent748d5c9950268d039bdd799572c5b9c0eb488a43 (diff)
downloadsysfsutils-d21d3bc4234b224d70e7b567df64d9b28734f4e7.tar.gz
Test params validation, doc updates, etc.
-rw-r--r--CREDITS2
-rw-r--r--ChangeLog5
-rw-r--r--NEWS10
-rw-r--r--README33
-rw-r--r--TODO3
-rw-r--r--docs/libsysfs.txt9
-rwxr-xr-xtest/create-test3
-rw-r--r--test/libsysfs.conf43
-rw-r--r--test/test-defs.h2
-rw-r--r--test/test.c142
10 files changed, 214 insertions, 38 deletions
diff --git a/CREDITS b/CREDITS
index 0835883..e3dfa96 100644
--- a/CREDITS
+++ b/CREDITS
@@ -18,3 +18,5 @@ have made contributions:
- Supplied initial makefiles for lsbus and systool
o Martin Hicks <mort@bork.org>
- Supplied patch to fix class_device functions
+ o Brian King <brking@us.ibm.com>
+ - Supplied patch to fix a memory leak in sysfs_dir.c
diff --git a/ChangeLog b/ChangeLog
index 8e06fbe..397c789 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
+02/24/2004 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
+ * Added validation code for test defines
+ * Updated the README, libsyfs.txt and NEWS files
+ * Provided descriptive comments for the libsysfs.conf file
+
02/19/2004 - Brian King <brking@us.ibm.com>
* Fixed memory leak in sysfs_read_attribute()
diff --git a/NEWS b/NEWS
index 13d5a0c..61b03dc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,16 @@
Version History:
---------------
+ 1.0.0 - Released February 24, 2004
+ * Libsysfs now ships with a comprehensive testsuite.
+ * List elements are now maintained in sorted order.
+ * Updated systool for better output and removed lsbus
+ from the package.
+ * Populated sysfs_device->drivername field correctly.
+ If device does not have a driver, field reflects
+ "unknown".
+ * Added additional CFLAGS while building the package.
+
0.4.0 - Released December 18, 2003
* Lots of optimizations. Structure elements that are dlists
or structs themselves are not populated by default.
diff --git a/README b/README
index 89076df..3e8212f 100644
--- a/README
+++ b/README
@@ -6,6 +6,7 @@ Contents
--------
1. Introduction
2. How to Install
+ 2.1 Caveats/Known issues
3. Licenses
4. Reporting Bugs
@@ -36,23 +37,35 @@ This package currently includes:
-----------------
Run the "configure" script to generate Makefiles. Use "make" to build the
-library and utilities. Use "make install" to install the binaries and the
-header files. "make uninstall" will delete all installed binaries and
-header files.
+library and utilities.
-The header files are installed in /usr/include/sysfs by default. In case
-a different path is desired, specify "includedir=xxx" while running configure
-as in
+For a successful install, run "make install" as super-user. "make uninstall"
+will clean up all installed files.
-./configure --includedir="path for header installs"
+
+2.1 Caveats/Known issues
+------------------------
+
+The header files (libsysfs.h and dlist.h) are installed in /usr/include/sysfs
+by default. This _cannot_ be changed by using the --prefix or --includedir
+parameters while running the "configure" script.
+
+As a consequence, when a non-root user runs the "configure" script with these
+options and builds the package, and tries to install it, "make install" will
+return an error since the non-root user will not have "write" permission to
+/usr/include/sysfs to install the headers.
+
+However, the library and binaries will be installed at the requested location.
+The header files will have to be manually copied over by the user to the
+desired directory.
3. Licenses
-----------
-The commands are licensed under the GNU Public License (GPL) Version2,
-June 1991. The full text of the GPL is located in this package's "cmd"
-directory:
+The commands and tests are licensed under the GNU Public License (GPL)
+Version2, June 1991. The full text of the GPL is located in this package's
+"cmd" directory:
sysfsutils/cmd/GPL
diff --git a/TODO b/TODO
index 488ad8c..82cf700 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,8 @@
Library:
--------
- Rework debugging error messages and look into better logging on error.
-- Need to properly set errno.
Commands:
---------
- Add topology tree view.
-- Need to clean up error messages.
-- Clean up how attribute values are printed.
diff --git a/docs/libsysfs.txt b/docs/libsysfs.txt
index 9d18c4a..6001495 100644
--- a/docs/libsysfs.txt
+++ b/docs/libsysfs.txt
@@ -1898,9 +1898,9 @@ the tests are built.
To use the testsuite:
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).
+ 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.
@@ -1910,6 +1910,9 @@ c. Run the testsuite:
The default logfile is stdout.
+NOTE: If the libsysfs.conf file is changed, make sure to run "make clean" in
+the test directory and then a "make" for the changes to take effect.
+
10. Conclusion
--------------
diff --git a/test/create-test b/test/create-test
index 0e40c63..2d1fb85 100755
--- a/test/create-test
+++ b/test/create-test
@@ -24,7 +24,6 @@ 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
@@ -33,7 +32,5 @@ 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
index de1f977..e5bca81 100644
--- a/test/libsysfs.conf
+++ b/test/libsysfs.conf
@@ -1,19 +1,27 @@
# The config file for libsysfs testsuite
# All values in this file are in relation to the sysfs filesystem only
+#
+# Values defined here will be used to dynamically build a header file that
+# gets used while compiling the testsuite.
-# A valid directory path
+# NOTE NOTE NOTE: If you change values in this file, please make sure that
+# you run "make clean" and "make" (in the "test" directory) for the changes
+# to take effect.
+
+
+# A valid directory path under sysfs
+# A valid link name under a subidirectory of VALID_DIRECTORY_PATH... eg., if
+# the VALID_DIRECTORY_PATH is /sys/bus/pci, then enter a pci device name for
+# VALID SUBDIR_LINK_NAME
VALID_DIRECTORY_PATH=/sys/bus/pci
+VALID_SUBDIR_LINK_NAME=0000:00:00.0
-# A valid link path under sysfs
+# A valid link path under sysfs - enter the absolute path to a soft-link here
VALID_LINK_PATH=/sys/block/sda/device
-# Path to a regular attribute (file)
+# Absolute path to a regular (readable) attribute (a normal file) under sysfs
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
@@ -51,27 +59,24 @@ VALID_CLASS_DEV_ATTR=type
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
+# 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)
+# Another valid driver - but one that is not being used by any device
+# Absolute path to the driver
+# The bus the driver is registered
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
+# Path to a writable attribute - make sure that the tester has permission to
+# "write" to the file at VALID_WRITE_ATTR_PATH
VALID_WRITE_ATTR_PATH=/sys/class/net/eth0/tx_queue_len
diff --git a/test/test-defs.h b/test/test-defs.h
index f9fde7a..b9996a3 100644
--- a/test/test-defs.h
+++ b/test/test-defs.h
@@ -37,6 +37,8 @@
#include "dlist.h"
#include "test.h"
+#define val_drv1_dev_name "dummy1"
+#define val_drv1_attr_name "dummy2"
#define inval_name "invalid_name"
#define inval_path "/sys/invalid/path"
#define FUNC_TABLE_SIZE 81
diff --git a/test/test.c b/test/test.c
index 3ecdc37..98a4b9e 100644
--- a/test/test.c
+++ b/test/test.c
@@ -196,6 +196,145 @@ int (*func_table[81])(int) = {
test_sysfs_open_classdev_attr,
};
+unsigned char *dir_paths[] = {
+ val_dir_path,
+ val_root_dev_path,
+ val_class_dev_path,
+ val_block_class_dev_path,
+ val_drv_path,
+ val_drv1_path,
+ NULL
+};
+
+unsigned char *file_paths[] = {
+ val_file_path,
+ val_write_attr_path,
+ NULL
+};
+
+unsigned char *link_paths[] = {
+ val_link_path,
+ NULL
+};
+
+static int path_is_dir(const unsigned char *path)
+{
+ struct stat astats;
+
+ if ((lstat(path, &astats)) != 0)
+ goto direrr;
+
+ if (S_ISDIR(astats.st_mode))
+ return 0;
+
+direrr:
+ fprintf(stdout, "Config error: %s not a directory\n", path);
+ return 1;
+}
+
+static int path_is_file(const unsigned char *path)
+{
+ struct stat astats;
+
+ if ((lstat(path, &astats)) != 0)
+ goto fileerr;
+
+ if (S_ISREG(astats.st_mode))
+ return 0;
+
+fileerr:
+ fprintf(stdout, "Config error: %s not a file\n", path);
+ return 1;
+}
+
+static int path_is_link(const unsigned char *path)
+{
+ struct stat astats;
+
+ if ((lstat(path, &astats)) != 0)
+ goto linkerr;
+
+ if (S_ISLNK(astats.st_mode))
+ return 0;
+
+linkerr:
+ fprintf(stdout, "Config error: %s not a link\n", path);
+ return 1;
+}
+
+/*
+ * Check validity of the test.h file entries
+ */
+static int check_header(void)
+{
+ unsigned char *var_path = NULL;
+ unsigned char path1[SYSFS_PATH_MAX];
+ unsigned int i = 0;
+
+ for (i = 0; dir_paths[i] != NULL; i++) {
+ var_path = dir_paths[i];
+ if (path_is_dir(var_path) != 0)
+ return 1;
+ }
+
+ for (i = 0; file_paths[i] != NULL; i++) {
+ var_path = file_paths[i];
+ if (path_is_file(var_path) != 0)
+ return 1;
+ }
+
+ for (i = 0; link_paths[i] != NULL; i++) {
+ var_path = link_paths[i];
+ if (path_is_link(var_path) != 0)
+ return 1;
+ }
+
+ memset(path1, 0, SYSFS_PATH_MAX);
+ strcpy(path1, val_root_dev_path);
+ strcat(path1, "/");
+ strcat(path1, val_subdir_name);
+ if (path_is_dir(path1) != 0)
+ return 1;
+
+ memset(path1, 0, SYSFS_PATH_MAX);
+ strcpy(path1, val_drv_path);
+ strcat(path1, "/");
+ strcat(path1, val_drv_dev_name);
+ if (path_is_link(path1) != 0)
+ return 1;
+
+ memset(path1, 0, SYSFS_PATH_MAX);
+ strcpy(path1, val_dir_path);
+ strcat(path1, "/devices");
+ strcat(path1, "/");
+ strcat(path1, val_subdir_link_name);
+ if (path_is_link(path1) != 0)
+ return 1;
+
+ memset(path1, 0, SYSFS_PATH_MAX);
+ strcpy(path1, val_class_dev_path);
+ strcat(path1, "/");
+ strcat(path1, val_class_dev_attr);
+ if (path_is_file(path1) != 0)
+ return 1;
+
+ memset(path1, 0, SYSFS_PATH_MAX);
+ strcpy(path1, val_dev_path);
+ strcat(path1, "/");
+ strcat(path1, val_dev_attr);
+ if (path_is_file(path1) != 0)
+ return 1;
+
+ memset(path1, 0, SYSFS_PATH_MAX);
+ strcpy(path1, val_drv_path);
+ strcat(path1, "/");
+ strcat(path1, val_drv_attr_name);
+ if (path_is_file(path1) != 0)
+ return 1;
+
+ return 0;
+}
+
static void usage(void)
{
fprintf(stdout, "testlibsysfs <no-of-times> [log-file]\n");
@@ -220,6 +359,9 @@ int main(int argc, char *argv[])
} else
num = strtol(argv[1], NULL, 0);
+ if (check_header() != 0)
+ return 1;
+
dbg_print("\nTest running %d times\n", num);
for (k = 0; k < num ; k++) {