udevd test script
PATCH 1/1 udevd test script
Thanks to Yin, Hu <[email protected]>, 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.
thanks,
Kay
test/udevd-test/udev-log-amplify.pl new file +87 -0
@@ -0,0 +1,87 @@ +#!/usr/bin/perl -w +# +# udev-log-amplify +# +# Copyright (C) Intel Corp, 2004 +# +# Author: Yin Hu <[email protected]> +# +# This is a script for replacing udev binary during udevsend/udevd testing. +# It first amplifies the execution time ( sleep 5 ) and then logs the event +# information sent by udved in order that 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 $udev_exe_time = 5; +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]) { + $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); + + # Amplify the execution time of udev + sleep 5; + + exit 0; +} else { + print "Too less argument count.\n"; + exit 1; +}
test/udevd-test/udev-log-script.pl new file +82 -0
82 lines not on this page · raw message
test/udevd-test/udevd-test.pl new file +669 -0
669 lines not on this page · raw message
udevd.c +9 -1
@@ -60,6 +60,7 @@static void msg_queue_manager (void );static void user_sighandler (void );static void reap_kids (void ); +char *udev_bin;#ifdef LOG unsigned char logname[LOGNAME_SIZE ];
@@ -146,7 +147,7 @@switch (pid) {case 0 :/* child */ -execle (UDEV_BIN ,"udev" , msg->subsystem,NULL , env); +execle (udev_bin,"udev" , msg->subsystem,NULL , env);dbg ("exec of child failed" );exit (1 );break ;
@@ -457,6 +458,13 @@/* enable receiving of the sender credentials */ setsockopt (ssock,SOL_SOCKET ,SO_PASSCRED , &on,sizeof (on)); + +/* possible override of udev binary, used for testing */ + udev_bin =getenv ("UDEV_BIN" ); +if (udev_bin !=NULL ) +dbg ("udev binary is set to '%s'" , udev_bin); +else + udev_bin =UDEV_BIN ;FD_ZERO (&readfds);FD_SET (ssock, &readfds);
Quoted 4 lines · Kay Sievers
Thanks to Yin, Hu <[email protected]>, 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.
Hm, I've applied this but can't run it :(
I keep getting the error:
Opening file /tmp/udev_log.txt: No such file or directory at ./udevd-test.pl line 148.
It looks like the log file is deleted and then it is attempted to be opened, but this fails as it isn't there anymore...
Care to fix this?
Oh, and if you run the latest udev_test.pl, we have a bunch more tests, including a few that fail, if you were looking for something to do :)
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · Greg KH
Quoted 4 lines · Kay Sievers
Thanks to Yin, Hu <[email protected]>, 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.
Hm, I've applied this but can't run it :(
I keep getting the error:
Opening file/tmp/udev_log.txt: No such file or directory at ./udevd-test.pl line 148.
I can't reproduce it. In which test does it happen?
Quoted 7 lines
It looks like the log file is deleted and then it is attempted to be opened, but this fails as it isn't there anymore...
Care to fix this?
Oh, and if you run the latest udev_test.pl, we have a bunch more tests, including a few that fail, if you were looking for something to do :)
Will do it. We need to change apply_format(). I tries to expand the '%%' with the next iteration over the string and removes the '%'.
thanks,
Kay
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 7 lines · Kay Sievers
Quoted 6 lines · Greg KH
Quoted 4 lines · Kay Sievers
Thanks to Yin, Hu <[email protected]>, 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.
Quoted 6 lines
Quoted 4 lines
Hm, I've applied this but can't run it :(
I keep getting the error:
Opening file/tmp/udev_log.txt: No such file or directory at ./udevd-test.pl line 148.I can't reproduce it. In which test does it happen?
I only tried test 1 and 2 and gave up after that.
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 8 lines · Greg KH
Quoted 7 lines · Kay Sievers
Quoted 6 lines · Greg KH
Quoted 4 lines · Kay Sievers
Thanks to Yin, Hu <[email protected]>, 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.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Hm, I've applied this but can't run it :(
I keep getting the error:
Opening file/tmp/udev_log.txt: No such file or directory at ./udevd-test.pl line 148.I can't reproduce it. In which test does it happen?
I only tried test 1 and 2 and gave up after that.
Is your copy of udevd compiled and installed _after_ the applied patch? It's needed for overriding UDEV_BIN.
Kay
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 14 lines · Kay Sievers
Quoted 13 lines · Greg KH
Quoted 12 lines · Kay Sievers
Quoted 10 lines · Greg KH
Quoted 4 lines · Kay Sievers
Thanks to Yin, Hu <[email protected]>, 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.
Hm, I've applied this but can't run it :(
I keep getting the error:
Opening file/tmp/udev_log.txt: No such file or directory at ./udevd-test.pl line 148.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I can't reproduce it. In which test does it happen?
I only tried test 1 and 2 and gave up after that.
Is your copy of udevd compiled and installed _after_ the applied patch? It's needed for overriding
UDEV_BIN.
Bah, that's what it was, sorry for the false alarm...
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Kay Sievers
Quoted 2 lines · Greg KH
Oh, and if you run the latest udev_test.pl, we have a bunch more tests, including a few that fail, if you were looking for something to do :)
Will do it. We need to change
apply_format(). I tries to expand the '%%' with the next iteration over the string and removes the '%'.
The tests are all successful now.
If this patch breaks something else, we simply have too few tests :)
thanks,
Kay
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · Kay Sievers
Quoted 6 lines · Kay Sievers
Quoted 2 lines · Greg KH
Oh, and if you run the latest udev_test.pl, we have a bunch more tests, including a few that fail, if you were looking for something to do :)
Will do it. We need to change
apply_format(). I tries to expand the '%%' with the next iteration over the string and removes the '%'.The tests are all successful now.
If this patch breaks something else, we simply have too few tests :)
Sorry, this silly keyboard layout with the 'y' next to the 'a' :) Here is the patch too.
thanks,
Kay
===== namedev.c 1.139 vs edited =====
namedev.c +11 -12
@@ -199,23 +199,21 @@struct sysfs_attribute *tmpattr; pos = string; -while (1 ) { - pos =strchr (string,'%' ); -if (pos !=NULL ) { - pos[0 ] ='\0' ; - tail = pos+1 ; - len =get_format_len (&tail); - c = tail[0 ]; -strfieldcpy (temp, tail+1 ); - tail = temp; - }else { + pos =strchr (pos,'%' ); +if (pos ==NULL )break ; - } -dbg ("format=%c, string='%s', tail='%s'" ,c , string, tail); + pos[0 ] ='\0' ; + tail = pos+1 ; + len =get_format_len (&tail); + c = tail[0 ]; +strfieldcpy (temp, tail+1 ); + tail = temp; +dbg ("format=%c, string='%s', tail='%s'" ,c , string, tail); attr =get_format_attribute (&tail); +switch (c) {case 'b' :if (strlen (udev->bus_id) ==0 )
@@ -286,6 +284,7 @@break ;case '%' :strfieldcatmax (string,"%" , maxsize); + pos++;break ;default :dbg ("unknown substitution type '%%%c'" , c);
Thanks, Greg! Thanks, Kay!
After applied this patch you have to recompile udev, and change the mode of those three scripts in directory test/udevd-test to 0755. Thus i believe that you can run it successfully.
I'm sorry that i cannot response quickly, because it's midnight here when you discuss this issue. :-)
Thanks for key's help and support again! Without his help i cannot accomplish these scripts. Thanks!
Nick
Quoted 30 lines
From: Greg KH <[email protected]>
To: Kay Sievers <[email protected]>
CC: hotplug <[email protected]>
Subject: Re: [PATCH] udevd test script
Date: Fri, 16 Apr 2004 17:16:51 -0700Quoted 4 lines · Kay Sievers
Quoted 3 lines · Greg KH
Quoted 2 lines · Kay Sievers
Thanks to Yin, Hu <[email protected]>, who made a nice perl script to test the expected behavior of the udevd sequence number handling.
The
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
test sends different SEQNUM sequences to udevd, while analyzing the reordering and timeout handling of udevd.
Hm, I've applied this but can't run it :(
I keep getting the error:
Opening file/tmp/udev_log.txt: No such file or directory at./udevd-test.pl line 148.
Quoted 2 lines
I can't reproduce it. In which test does it happen?
I only tried test 1 and 2 and gave up after that.
thanks,
greg k-h
Quoted 9 lines
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?pageþatures/junkmail
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Kay Sievers
Quoted 5 lines · Kay Sievers
Quoted 4 lines · Kay Sievers
Quoted 2 lines · Greg KH
Oh, and if you run the latest udev_test.pl, we have a bunch more tests, including a few that fail, if you were looking for something to do :)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Will do it. We need to change
apply_format(). I tries to expand the '%%' with the next iteration over the string and removes the '%'.The tests are all successful now.
If this patch breaks something else, we simply have too few tests :)Sorry, this silly keyboard layout with the 'y' next to the 'a' :) Here is the patch too.
Heh, applied, thanks.
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel