chiark / gitweb /
[PATCH] introduce OPTIONS=ignore_device, ignore_remove, all_partitions" key
[elogind.git] / test / udevd-test / udev-log-script.pl
1 #!/usr/bin/perl -w
2 #
3 # udev-log-script
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 just simply logs the event information sent by udved in order to
11 # test script udevd-test.pl can analyze whether udved execute as we expected.
12 # You should not execute this script directly because it will be invoked by
13 # udevd automatically.
14 #
15 # Before you run your test please modify $log_file to designate where the udev
16 # log file should be placed, in fact, the default value is ok.
17 #
18
19 #       This program is free software; you can redistribute it and/or modify it
20 #       under the terms of the GNU General Public License as published by the
21 #       Free Software Foundation version 2 of the License.
22 #  
23 #       This program is distributed in the hope that it will be useful, but
24 #       WITHOUT ANY WARRANTY; without even the implied warranty of
25 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26 #       General Public License for more details.
27 #
28 #       You should have received a copy of the GNU General Public License along
29 #       with this program; if not, write to the Free Software Foundation, Inc.,
30 #       675 Mass Ave, Cambridge, MA 02139, USA.
31 #
32
33 use warnings;
34 use strict;
35
36 # modifiable settings
37 my $log_file  = "/tmp/udev_log.txt";
38
39 if ($ARGV[0]) {
40         my $subsystem = $ARGV[0];
41         my $devpath = $ENV{DEVPATH};
42         my $action = $ENV{ACTION};
43         my $time = time();
44
45         # Logging
46         if (open(LOGF, ">>$log_file")) {
47                 print LOGF "$devpath,$action,$subsystem,$time\n";
48         } else {
49                 print "File open failed. \n";
50                 exit 1;
51         }
52         close(LOGF);
53
54         exit 0;
55 } else {
56         print "Too less argument count.\n";
57         exit 1;
58 }