# Copyright (C) Intel Corp, 2004
#
# Author: Yin Hu <hu.yin@intel.com>
# Copyright (C) Intel Corp, 2004
#
# Author: Yin Hu <hu.yin@intel.com>
#
# Provides automated testing of the udevd binary.This test script is self-contained.
# Before you run this script please modify $sysfs to locate your sysfs filesystem,
#
# Provides automated testing of the udevd binary.This test script is self-contained.
# Before you run this script please modify $sysfs to locate your sysfs filesystem,
# modify $udev_bin to locate dummy udev script,
# modify $udev_bin2 to locate another dummy udev script ( amplify the execution time for test),
# modify $log_file to locate where udev script have placed the log file,
# modify $udev_bin to locate dummy udev script,
# modify $udev_bin2 to locate another dummy udev script ( amplify the execution time for test),
# modify $log_file to locate where udev script have placed the log file,
-my $sysfs = "../sys";
-my $udevd_bin = "../../udevsend";
-my $udev_bin = "$ENV{PWD}/udev-log-script.pl";
-my $udev_bin2 = "$ENV{PWD}/udev-log-amplify.pl";
-my $log_file = "/tmp/udev_log.txt";
-my $time_out = 10;
-my $udev_exe_time = 5;
+my $sysfs = "../sys";
+my $udevd_bin = "../../udevd";
+my $udevsend_bin = "../../udevsend";
+my $udev_bin = "$ENV{'PWD'}/udev-log-script.pl";
+my $udev_bin2 = "$ENV{'PWD'}/udev-log-amplify.pl";
+my $log_file = "/tmp/udev_log.txt";
+my $time_out = 10;
+my $udev_exe_time = 5;
- # and then call $udevd_bin to send event.
+ # and then call $udevsend_bin to send event.
+
+ my ($seqnum, $devpath, $action, $subsystem, $script) = @_;
- my ($seqnum, $devpath, $action, $subsystem, $udev_bin_tmp) = @_;
+ %ENV = ();
+ $ENV{'DEVPATH'} = $devpath;
+ $ENV{'ACTION'} = $action;
+ $ENV{'SUBSYSTEM'} = $subsystem;
print " forking udev time: $line_items[-1]";
$diff = cmpDate($line_items[-1], $event_recv_time);
print " the delay time is: $diff s \n\n";
print " forking udev time: $line_items[-1]";
$diff = cmpDate($line_items[-1], $event_recv_time);
print " the delay time is: $diff s \n\n";
print " the delay time between event receiving and forking udev for udevd should be negligible, \n";
print " that is, udev should be forked at once. please notice the following time...\n\n";
print " the delay time between event receiving and forking udev for udevd should be negligible, \n";
print " that is, udev should be forked at once. please notice the following time...\n\n";
udevsend(-1, "/block/sda", "add", "block");
# check if execution is successful in time
udevsend(-1, "/block/sda", "add", "block");
# check if execution is successful in time
udevsend(-1, "/block/sda", "remove", "block");
# check if execution is successful in time
udevsend(-1, "/block/sda", "remove", "block");
# check if execution is successful in time
print " event to udev for each device. \n";
print " We can see the delay time for each device should be negligible. \n\n";
print " event to udev for each device. \n";
print " We can see the delay time for each device should be negligible. \n\n";
# we'd better wait the udev to create all the device for a few seconds
print " wait for udevd processing about $time_out s... \n\n";
# we'd better wait the udev to create all the device for a few seconds
print " wait for udevd processing about $time_out s... \n\n";
# we'd better wait the udev to create all the device for a few seconds
print " waiting for udev removing devices (about $time_out s)...\n";
# we'd better wait the udev to create all the device for a few seconds
print " waiting for udev removing devices (about $time_out s)...\n";
print " We have disordered the events sent to udevd, if udevd can order them correctly, the devices' \n";
print " add/remove sequence should be tty0, tty1, tty2. \n\n";
print " We have disordered the events sent to udevd, if udevd can order them correctly, the devices' \n";
print " add/remove sequence should be tty0, tty1, tty2. \n\n";
udevsend(3, "/class/tty/tty2", "remove", "tty");
udevsend(2, "/class/tty/tty1", "remove", "tty");
udevsend(1, "/class/tty/tty0", "remove", "tty");
udevsend(3, "/class/tty/tty2", "remove", "tty");
udevsend(2, "/class/tty/tty1", "remove", "tty");
udevsend(1, "/class/tty/tty0", "remove", "tty");
print " should fork udev immediately, the delay time should be negligible. \n";
print " where: event 7 is (add device /class/tty/tty2) \n\n";
print " should fork udev immediately, the delay time should be negligible. \n";
print " where: event 7 is (add device /class/tty/tty2) \n\n";
my $time;
# check if devices /class/tty0, tty1, tty2 exist
check_sysfs_device_exist("$sysfs/class/tty/tty0", "$sysfs/class/tty/tty1", "$sysfs/class/tty/tty2");
my $time;
# check if devices /class/tty0, tty1, tty2 exist
check_sysfs_device_exist("$sysfs/class/tty/tty0", "$sysfs/class/tty/tty1", "$sysfs/class/tty/tty2");
# parameters: 1 sequence number, 2 device, 3 action, 4 subsystem
udevsend(3, "/class/tty/tty2", "add", "tty");
# parameters: 1 sequence number, 2 device, 3 action, 4 subsystem
udevsend(3, "/class/tty/tty2", "add", "tty");
udevsend(6, "/class/tty/tty2", "remove", "tty");
print " wait for udevd timing out for disorder events (about $time_out s) \n\n";
udevsend(6, "/class/tty/tty2", "remove", "tty");
print " wait for udevd timing out for disorder events (about $time_out s) \n\n";
print " we send a add event for device /block/sda, and then we send a remove event, so the \n";
print " execution of remove event should be delayed until add is finished. \n\n";
print " we send a add event for device /block/sda, and then we send a remove event, so the \n";
print " execution of remove event should be delayed until add is finished. \n\n";
- # fork udved
- udevsend(-1, "/block/sda", "add", "block", $udev_bin2);
- udevsend(-1, "/block/sda", "remove", "block", $udev_bin2);
+ udevsend(-1, "/block/sda", "add", "block");
+ udevsend(-1, "/block/sda", "remove", "block");
print " event ( add device /class/tty/tty1 ) should be delayed for $time_out s than its previous \n";
print " event ( remove device /block/sda ) \n\n";
print " event ( add device /class/tty/tty1 ) should be delayed for $time_out s than its previous \n";
print " event ( remove device /block/sda ) \n\n";
udevsend(0, "/block/sda", "add", "block");
# log current system date/time
udevsend(0, "/block/sda", "add", "block");
# log current system date/time
udevsend(1, "/block/sda", "remove", "block");
udevsend(1, "/class/tty/tty1", "add", "tty");
udevsend(1, "/block/sda", "remove", "block");
udevsend(1, "/class/tty/tty1", "add", "tty");
print "Test expected visible results:\n";
print " the delay time for event(add device /block/sda) should be about $time_out s.\n\n";
print "Test expected visible results:\n";
print " the delay time for event(add device /block/sda) should be about $time_out s.\n\n";
udevsend(0, "/class/tty/tty1", "add", "tty");
udevsend(1, "/class/tty/tty1", "remove", "tty");
sleep 1;
udevsend(0, "/class/tty/tty1", "add", "tty");
udevsend(1, "/class/tty/tty1", "remove", "tty");
sleep 1;
udevsend(3, "/block/sda", "add", "block");
# show results
udevsend(3, "/block/sda", "add", "block");
# show results