chiark / gitweb /
add edd_id tool to match BIOS EDD disk information
[elogind.git] / test / udevd-test / udev-log-amplify.pl
1 #!/usr/bin/perl -w
2 #
3 # udev-log-amplify
4 #
5 # Copyright (C) Intel Corp, 2004
6 #
7 # Author: Yin Hu <hu.yin@intel.com> 
8 #
9 # This is a script for replacing udev binary during udevsend/udevd testing.
10 # It first amplifies the execution time ( sleep 5 ) and then logs the event 
11 # information sent by udved in order that test script udevd-test.pl can
12 # analyze whether udved execute as we expected.
13 # You should not execute this script directly because it will be invoked by 
14 # udevd automatically.
15 #
16 # Before you run your test please modify $log_file to designate where the udev
17 # log file should be placed, in fact, the default value is ok. 
18 #
19 #
20 #       This program is free software; you can redistribute it and/or modify it
21 #       under the terms of the GNU General Public License as published by the
22 #       Free Software Foundation version 2 of the License.
23 #
24 #       This program is distributed in the hope that it will be useful, but
25 #       WITHOUT ANY WARRANTY; without even the implied warranty of
26 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27 #       General Public License for more details.
28 #
29 #       You should have received a copy of the GNU General Public License along
30 #       with this program; if not, write to the Free Software Foundation, Inc.,
31 #       675 Mass Ave, Cambridge, MA 02139, USA.
32 #
33
34 use warnings;
35 use strict;
36
37 # modifiable settings
38 my $udev_exe_time = 5;
39 my $log_file  = "/tmp/udev_log.txt";
40
41 if ($ARGV[0]) {
42         my $subsystem = $ARGV[0];
43         my $devpath = $ENV{DEVPATH};
44         my $action = $ENV{ACTION};
45         my $time = time();
46
47         # Logging
48         if (open(LOGF, ">>$log_file")) {
49                 print LOGF "$devpath,$action,$subsystem,$time\n";
50         } else {
51                 print "File open failed. \n";
52                 exit 1;
53         }
54         close(LOGF);
55
56         # Amplify the execution time of udev
57         sleep 5;
58
59         exit 0;
60 } else {
61         print "Too less argument count.\n";
62         exit 1;
63 }