summaryrefslogtreecommitdiff
path: root/test/udevd-test/udev-log-script.pl
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-04-16 23:58:05 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:15 -0700
commit7d855c3116ec9ddab9adde96b568681930d9855b (patch)
tree31794ef4fc3d2c198b0451f972280d5120bdb2f9 /test/udevd-test/udev-log-script.pl
parentaf5b5178fa9cb8b75d00fb364f266c3919f12cd2 (diff)
[PATCH] udevd test script
Thanks to Yin, Hu <hu.yin@intel.com>, who made a nice perl script to test the expected behavior of the udevd sequence number handling. The test sends different SEQNUM sequences to udevd, while analyzing the reordering and timeout handling of udevd.
Diffstat (limited to 'test/udevd-test/udev-log-script.pl')
-rw-r--r--test/udevd-test/udev-log-script.pl82
1 files changed, 82 insertions, 0 deletions
diff --git a/test/udevd-test/udev-log-script.pl b/test/udevd-test/udev-log-script.pl
new file mode 100644
index 0000000000..5f4f8a4495
--- /dev/null
+++ b/test/udevd-test/udev-log-script.pl
@@ -0,0 +1,82 @@
+#!/usr/bin/perl -w
+#
+# udev-log-script
+#
+# Copyright (C) Intel Corp, 2004
+#
+# Author: Yin Hu <hu.yin@intel.com>
+#
+# This is a script for replacing udev binary during udevsend/udevd testing.
+# It just simply logs the event information sent by udved in order to
+# test script udevd-test.pl can analyze whether udved execute as we expected.
+# You should not execute this script directly because it will be invoked by
+# udevd automatically.
+#
+# Before you run your test please modify $log_file to designate where the udev
+# log file should be placed, in fact, the default value is ok.
+#
+#
+# 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.
+#
+
+use warnings;
+use strict;
+
+# modifiable settings
+my $log_file = "/tmp/udev_log.txt";
+
+# global variables
+my $devpath;
+my $action;
+my $subsystem;
+
+# common functions
+sub getDate {
+ # Get current date/time
+ # If we want GTM time, simply pass GMT as first argument to this function.
+ my $format = @_;
+ my $date;
+
+ if( $format =~ /GMT/i ) {
+ $date = gmtime() . " GMT";
+ } else {
+ $date = localtime();
+ }
+ return $date;
+}
+
+# main program
+if ($ARGV[0]) {
+ # prepare
+ $subsystem = $ARGV[0];
+ $devpath = $ENV{DEVPATH};
+ $action = $ENV{ACTION};
+
+ # Get current system date
+ my $time = getDate();
+
+ # Logging
+ if (open(LOGF, ">>$log_file")) {
+ print LOGF "$devpath,$action,$subsystem,$time\n";
+ } else {
+ print "File open failed. \n";
+ exit 1;
+ }
+ close(LOGF);
+
+ exit 0;
+} else {
+ print "Too less argument count.\n";
+ exit 1;
+}