Skip to contentSkip to conversation

About test suites for linux hot plug

DISCUSSION Guo, Min 4 participants 7 messages Nov 27, 2002 – Dec 26, 2002

lore
Share & tools
lore

Guo, Min

author
#0 lore raw

Hi

Thanks for your perfect work! I am interested in the Linux hot swap
project and now
doing some validation work about the compactPCI hot swap. So could you please tell me
whether there are some test suites for linux hot plug, if not, I'd like to write some test suites
for the project!

If you agree, could you please give me some requirements and
suggestion about the
test suites?

Thank you very much!

Best Regards
Guo Min
The content of this email message solely contains my own personal views.

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 7 lines · Min

Hi

Thanks for your perfect work! I am interested in the Linux hot swap
project and now doing some validation work about the compactPCI hot swap. So could you please tell me whether there are some test suites for linux hot plug, if not, I'd like to write some test suites for the project!

If you take a look at the archives for this list, you will see we just talked about this with another intel employee (who you also copied on the message) :)

In short, no there aren't any. Also, this is probably the wrong list for cPCI hotplug specific stuff.

Quoted 2 lines

If you agree, could you please give me some requirements and
suggestion about the test suites?

Requirements:
- whatever makes you, and your employer happy.

In short, write up whatever you want and need, and if you could, post it to the list for others to use in the future if they want to do the same.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Guo, Min
Quoted 6 lines
Quoted 6 lines

Thanks for your perfect work! I am interested in the Linux hot swap
project and now doing some validation work about the compactPCI hot swap. So could you please tell me whether there are some test suites for linux hot plug, if not, I'd like to write some test suites for the project!

To the extent that such tests cover things like verifying that streams of hotplug events are handled consistently, the latest CVS does have a simple facility to log events to files like /var/log/hotplug/pci.events (for CardBus, cPCI, hotplugPCI, etc) or /var/log/hotplug/events (for any event that doesn't have an agent enabled).

So you can collect hotplug events "live", and then (by writing simple software) play them back later ... Or just notice what kinds of hotplug events don't yet have /etc/hotplug/*.agent code.

I hope that facility will evolve -- and not primarily for testing support.

For example, I'd be interested in seeing some daemon thread monitoring /var/log/hotplug/input.events that's set up as a named fifo, as one way to solve hotplug's "need multiple security domains" issue. (That's an area where anyone who's familiar with those user mode APIs could contribute useful "seed" code in C, or likely even Perl ...)

Quoted 6 lines

If you take a look at the archives for this list, you will see we just talked about this with another intel employee (who you also copied on the message) :)

In short, no there aren't any. Also, this is probably the wrong list for cPCI hotplug specific stuff.

But any test scripts you put together that are general purpose would likely help down the line. Both automated "do these events get handled correctly" scripts, and manual "plug in the adapter and verify that these N things got set up right".

- Dave

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#3 lore raw
In reply to Guo, Min

Here is my initial test suite for cPCI (ZT5084 platform) and Compaq with e100 and e1000 hotplug network devices,
for the other hot plug device and features, I will give out the test suites later.

----------------------------Shell test script for cPCI and Network PCI hotPlug platform----------------------------------------------------------- #!/bin/sh

HOTSWAP_TEST_VERSION="0.1"

PCI_TOOLS="lspci"
HOT_SWAP_KEY="06"
COMPACTPCI_HOTPLUG_DEVICE=""
DRIVERS_NUMBER=$PCI_TOOLS|awk '{print $1}'
HOT_PLUG_SUPPORTúlse
HARD_PASSúlse
value=""
link="33"
PCI_FILE="pci_file"

COMPAQ_PCI_HOTPLUG_DIR="/pcihpfs"
#function capfind is used to find the capbilities of PCI devices and see whether
#there are some devices support the defined capbilities

capfind()

{
	link=$1
	link_tmp=0x$link
	link_tmp=`echo $((link_tmp))`
	startadd=`expr $link_tmp / 16 + 2`
	mod $link
	offset=`echo $?`
	offset1=`expr $offset + 2`
	offset=`expr $offset + 3`
	link_offset=`echo $((offset))`
	value_offset=`echo $((offset1))` 	
	value=`cat $PCI_FILE|head -n  $startadd|tail -n 1|cut -d ' ' -f

$value_offset`
link=`cat $PCI_FILE|head -n $startadd|tail -n 1|cut -d ' ' -f
$link_offset`
}

#The function to give out the mod number

mod()

{
	number_tmp=$1
	number_tmp=0x$number_tmp
	number=`echo $((number_tmp))`
	while [ "$number" -ge "16" ];do
		number=`expr $number - 16`
	done
	return $number
}

#check which device have compact PCI hot_swap function #if have,give out the the results.

check_hotplug_cap()
{
i=0
echo "" > cpci_hotswap
for driver in $DRIVERS_NUMBER
do
#read the capbility number and verify whether the system has hotplug #controller
#confighead=lspci -s $driver -xxx|grep -v PCI'
lspci -s $driver -xxx > $PCI_FILE
#find the frist capbility link of configure header
while [ "$link" != "00" ]
do
capfind $link
if [ "$value" = "$HOT_SWAP_KEY" ];then
HOT_PLUG_SUPPORT=true
fi
if [ "$HOT_PLUG_SUPPORT" = "true" ];then
HARD_PASS=true COMPACT_HOTPLUG_DEVICE=$driver echo $COMPACT_HOTPLUG_DEVICE >> cpci_hotswap echo "The hardware supports cPCI HotSwap
function"

				descript=`lspci -s $driver`
				echo "The Compact PCI Hot Swap device is" \
				$descript
				i=`expr $i + 1`
			fi
		done
		link="33"
		HOT_PLUG_SUPPORT="false"
	done

	if [ "$HARD_PASS" = "false" ];then
		echo "Hardware does not support cPCI HotSwap function"
		return 1
	else
		return 0
	fi

}

#Check whether the device still exist after we remove the compactPCI hot swap de
#device

check_after_remove()

{
	cPCI_DEVICES=`cat cpci_hotswap`
	if [ "$cPCI_DEVICES" = "" ];then
		echo "There are no devices support cPCI hot plug function"
		exit 1
	fi
	for device in $cPCI_DEVICES 
	do
		device=`lspci|grep "$device"|awk -F ":" '{print $3}'`
		if [ $? -eq 0 ];then
			echo $device "still be pluged or can not be removed

successfully"
else
echo $device "has been removed successfully" return 1
fi
done
return 0
}

#the function is used to check the NET hot swap devices debug_on()
{
cp -f /sbin/hotplug /sbin/hotplug-bk
sed -e 's/#DEBUG/DEBUG/' /sbin/hotplug-bk > /sbin/hotplug dmesg -c
}
#Auto Enable the hot plug
pci_plug()
{
echo 1 > power
}
# Auto Disable the Hot plug
pci_remove()
{
echo 0 > power
}

check_pci_hardware()
{

HARD_PASS_1=true

#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=ls
if [ "$SUB_DIR" = "" ];then
echo "Hot Plug driver has not been installed" echo "Or there are no hot plug devices" exit 1
fi
else
exit 1
fi

for dir in $SUB_DIR
do
cd $dir
pci_remove
cd ..
done

for dir in $SUB_DIR
do
cd $dir
pci_plug
value=cat power
if [ $value -ne "1" ];then
HARD_PASS_1úlse
echo $HARD_PASS_1
echo "We can not Plug the devices
automatically,so check your hardware"

			fi
		cd ..
	done

	if [ "$HARD_PASS_1" = "true" ];then
			echo "PASS1: HardWare Check"
	fi

}

check_pci_hotplug_net_device()

{
	SOFT_PASSúlse

	#check whether module has been inserted
	if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
		cd $COMPAQ_PCI_HOTPLUG_DIR
		SUB_DIR=`ls`
		if [ "$SUB_DIR" = "" ];then
			exit 1
		fi
	else
		exit 1
	fi
	
	for dir in $SUB_DIR
	do
		cd $dir
			pci_remove 
		cd ..
	done

	debug_on > /dev/null 2>&1
	# Check whether the network inteface can be booted correctly.
	ethnum=`ifconfig|grep eth|wc -l`
	for dir in $SUB_DIR
	do
		SOFT_PASSúlse
		cd $dir
			pci_plug
			ethnum=`echo $((ethnum))`
			ifconfig|grep eth"$ethnum" >/dev/null 2>&1
			if [ "$?" -eq 0 ];then
				echo "The pci hot plug device can been
booted automatically"
				SOFT_PASS=true
			else
				ifup eth"$ethnum" >/dev/null 2>&1
				if [ "$?" -eq 0 ];then
					echo "The pci hotplug net device can

been booted correcty"
SOFT_PASS=true
else
SOFT_PASSúlse
echo "please check your network
configuration or hotplug device driver"
echo "the message in
/var/log/messages will help you locate your error"

				fi
			fi		
		cd ..
		ethnum=`expr $ethnum + 1`
	done

	if [ $SOFT_PASS = "true" ];then
		echo "PASS2: The software check"
	fi
}

hotplug_check()

{
	if [ $# -gt 0 ];then
		case "$1" in
		-l)
			check_hotplug_cap
			exit 0
		;;
		-c)
			check_after_remove $2
			exit 0
			;;
		-n)
			check_pci_hotplug_net_device
			;;
		-h)
			check_pci_hardware
			;;	
		*)
			usage
			;;
		esac
	fi
} 

usage()
{
cat << EOF
Usage: hotplug_test [options]
options:
--list|-l)
list the devices that support CompactPCI hotpwap
--platform|-p)
platform type (cPCI|PCI_NET|PCI_SCSI)
--help|-h)
help
--version|-v)
version
device:
device address

example:
hotplug_test -p=cPCI
EOF

        exit $1
}

if [ $# -eq 0 ];then
usage
exit
fi
for option
do

    case "$option" in
        -*=*) 
		optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'`
		option=`echo "$option"|sed 's/=.*$//'`
		;;
           *) optarg='' ;;
    esac
    case "$option" in
        --help|-h)
            echo "Usage: $usage"
            exit 0
            ;;
        --version|-v)
            echo "version is" $HOTSWAP_TEST_VERSION
            exit 0
            ;;
	--platform|-p)
	    case "$optarg" in
		cPCI)
			hotplug_check -c 
		;;	
		PCI_NET)
			hotplug_check -h
			hotplug_check -n
		;;
		*)
		usage
		exit 1
		;;
	    esac
		;;
	--list|-l)
		echo "only echo  the Devices support cPCI hot swap function"
		hotplug_check -l
		exit 1
		;;	
	*)
	   usage
	   exit 1
	   ;;
	esac

done
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--------------------
Best Regards
Guo Min
The content of this email message solely contains my own personal views.

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, November 28, 2002 12:32 AM
To: Guo, Min
Cc: David Brownell; [email protected]; Wang, Frank; Rusty Lynch; Xie, May
Subject: Re: About test suites for linux hot plug

Quoted 7 lines · Min

Hi

Thanks for your perfect work! I am interested in the Linux hot swap
project and now doing some validation work about the compactPCI hot swap. So could you please tell me whether there are some test suites for linux hot plug, if not, I'd like to write some test suites for the project!

If you take a look at the archives for this list, you will see we just talked about this with another intel employee (who you also copied on the message) :)

In short, no there aren't any. Also, this is probably the wrong list for cPCI hotplug specific stuff.

Quoted 2 lines

If you agree, could you please give me some requirements and
suggestion about the test suites?

Requirements:
- whatever makes you, and your employer happy.

In short, write up whatever you want and need, and if you could, post it to the list for others to use in the future if they want to do the same.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Guo, Min
Quoted 4 lines · Min

Here is my initial test suite for cPCI (ZT5084 platform) and Compaq with e100 and e1000 hotplug network devices,
for the other hot plug device and features, I will give out the test suites later.

Your testcase seems reasonable, but having the PCI device appear/disappear is IMO the trivial part of PCI hotplug. The vast majority of the problems I encountered while writing the cPCI drivers involved PCI resources. Most of my manual testing revolves around checking the contents of /proc/iomem and /proc/ioports before and after inserts and removes, as well as looking at the output of "lspci -vvv". With a fixed set of hardware, it may be possible to come up with testcases for resource allocation, but the general case is probably difficult to automate.

Something else to be aware of is that eventually I plan to support hardware that does not expose HS_CSR through the PCI extended capabilities. It looks like your testcase as it stands now will break if run in a setup that had such hardware.

Scott

PS: Are you working with Harold Yang? He's also at Intel but seems to be
having troubles using cPCI hotplug on his ZT5084 system.

Signature · 15 lines
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: [email protected]



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
author
#5 lore raw
In reply to Guo, Min

Thank you very much!

-----Original Message-----
From: Scott Murray [mailto:[email protected]]
Sent: Saturday, November 30, 2002 5:25 AM
To: Guo, Min
Cc: [email protected]
Subject: RE: About test suites for linux hot plug

Quoted 3 lines · Min

Here is my initial test suite for cPCI (ZT5084 platform) and Compaq with e100 and e1000 hotplug network devices,
for the other hot plug device and features, I will give out the test

suites

Quoted 1 line

later.

Your testcase seems reasonable, but having the PCI device appear/disappear is IMO the trivial part of PCI hotplug. The vast majority of the problems I encountered while writing the cPCI drivers involved PCI resources. Most of my manual testing revolves around checking the contents of /proc/iomem and /proc/ioports before and after inserts and removes, as well as looking at the output of "lspci -vvv". With a fixed set of hardware, it may be possible to come up with testcases for resource allocation, but the general case is probably difficult to automate.

[Guo,Min] Thank you for your kind suggestion, I will investigate and try to realize such
function.

Something else to be aware of is that eventually I plan to support hardware that does not expose HS_CSR through the PCI extended capabilities. It looks like your testcase as it stands now will break if run in a setup that had such hardware.

[Guo Min]: I will take a look at the platform and revise my test cases, thank you very much!

Scott

PS: Are you working with Harold Yang? He's also at Intel but seems to be
having troubles using cPCI hotplug on his ZT5084 system.

[Guo Min]: Yes, I thought he had already solved the problems.

Signature · 14 lines
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: [email protected]


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
author
#6 lore raw
In reply to Guo, Min

Hi,

I enhanced my test suites, added the following features

1. Check the io ports and io mem for cPCI devices,including two procedures, one is plug/remove ,the other is remove/plug. it needs to manual operation

2. check the io ports and io mem for PCI hotplug devices,including two procedures,
one is plug/remove ,the other is remove/plug.it can work automatically.

I had verified the ZT5550 cpci and Compaq hotplug PCI net devices with
the test cases.

----------------------------------------------------------------------------
---------------------------------------

#!/bin/sh

HOTSWAP_TEST_VERSION="0.1"

PCI_TOOLS="lspci"
HOT_SWAP_KEY="06"
COMPACTPCI_HOTPLUG_DEVICE=""
DRIVERS_NUMBER=$PCI_TOOLS|awk '{print $1}'
HOT_PLUG_SUPPORTúlse
HARD_PASSúlse
value=""
link="33"
PCI_FILE="pci_file"
cPCI_DEVICE=""
CPCI_NONE=0
CPCI_PLUG=1
CPCI_REMOVE=2

COMPAQ_PCI_HOTPLUG_DIR="/pcihpfs"
#function capfind is used to find the capbilities of PCI devices and see whether
#there are some devices support the defined capbilities

capfind()

{
	link=$1
	link_tmp=0x$link
	link_tmp=`echo $((link_tmp))`
	startadd=`expr $link_tmp / 16 + 2`
	mod $link
	offset=`echo $?`
	offset1=`expr $offset + 2`
	offset=`expr $offset + 3`
	link_offset=`echo $((offset))`
	value_offset=`echo $((offset1))` 	
	value=`cat $PCI_FILE|head -n  $startadd|tail -n 1|cut -d ' ' -f

$value_offset`
link=`cat $PCI_FILE|head -n $startadd|tail -n 1|cut -d ' ' -f
$link_offset`
}

#The function to give out the mod number

mod()

{
	number_tmp=$1
	number_tmp=0x$number_tmp
	number=`echo $((number_tmp))`
	while [ "$number" -ge "16" ];do
		number=`expr $number - 16`
	done
	return $number
}

#check which device have compact PCI hot_swap function #if have,give out the the results.

check_hotplug_cap()
{
i=0
echo "" > cpci_hotswap
for driver in $DRIVERS_NUMBER
do
#read the capbility number and verify whether the system has hotplug #controller
#confighead=lspci -s $driver -xxx|grep -v PCI'
lspci -s $driver -xxx > $PCI_FILE
#find the frist capbility link of configure header
while [ "$link" != "00" ]
do
capfind $link
if [ "$value" = "$HOT_SWAP_KEY" ];then
HOT_PLUG_SUPPORT=true
fi
if [ "$HOT_PLUG_SUPPORT" = "true" ];then
HARD_PASS=true COMPACT_HOTPLUG_DEVICE=$driver echo $COMPACT_HOTPLUG_DEVICE >> cpci_hotswap echo "The hardware supports cPCI HotSwap
function"

				descript=`lspci -s $driver`
				echo "The Compact PCI Hot Swap device is" \
				$descript
				i=`expr $i + 1`
			fi
		done
		link="33"
		HOT_PLUG_SUPPORT="false"
	done

	if [ "$HARD_PASS" = "false" ];then
		echo "Hardware does not support cPCI HotSwap function"
		return 1
	else
		return 0
	fi

}
#Check whether the device still exist after we remove the compactPCI hot swap de
#device

check_after_remove()

{
	cPCI_DEVICES=`cat cpci_hotswap`
	if [ "$cPCI_DEVICES" = "" ];then
		echo "There are no devices support cPCI hot plug function"
		exit 1
	fi
	for device in $cPCI_DEVICES 
	do
		device=`lspci|grep "$device"|awk -F ":" '{print $3}'`
		if [ $? -eq 0 ];then
			echo $device "still be pluged or can not be removed

successfully"
else
echo $device "has been removed successfully" return 1
fi
done
return 0
}
check_resource()

{
	cat /proc/ioports > /tmp/cpci_ioport_$1
	cat /proc/iomem	> /tmp/cpci_iomem_$1
}

cpci_check_remove_plug()
{
check_hotplug_cap
CPCI_CAP=$?
Mark=cat /tmp/mark
if [ ! -f /tmp/entry ];then
echo 0 > /tmp/entry
fi
entry=cat /tmp/entry
if [ $CPCI_CAP -eq 0 -a $entry -ne $CPCI_PLUG ];then
check_resource plug
Mark=expr $Mark + 1
echo $Mark > /tmp/mark
echo $CPCI_PLUG > /tmp/entry
fi
entry=cat /tmp/entry
if [ $CPCI_CAP -ne 0 -a $entry -ne $CPCI_REMOVE ];then
check_resource remove
Mark=expr $Mark + 1
echo $Mark > /tmp/mark
echo $CPCI_REMOVE > /tmp/entry
fi
Mark=cat /tmp/mark
if [ $CPCI_CAP -ne 0 -a $Mark -lt 2 ];then
echo "Pls plug your devices manually" echo "............................" exit 1
fi
if [ $CPCI_CAP -eq 0 -a $Mark -lt 2 ];then
echo "PLs remove your cpci devices manually" echo "....................................." exit 0
fi
Mark=cat /tmp/mark
if [ $Mark -eq 2 ];then
cpci_information remove_plug
echo $CPCI_NONE > /tmp/mark
echo $CPCI_NONE > /tmp/entry
rm -f /tmp/cpci*
rm -f /tmp/diff*
fi

}
cpci_information()

{	
	if [ $1 = "remove_plug" ];then
		flag="allocate"
	else
		flag="deallocate"
	fi	
	diff  /tmp/cpci_ioport_remove /tmp/cpci_ioport_plug|grep ">" >
/tmp/diff_cpci_ioports
	diff /tmp/cpci_iomem_remove /tmp/cpci_iomem_plug|grep ">" >
/tmp/diff_cpci_iomem
        ioport=`cat /tmp/diff_cpci_ioports|awk '{print $2}'`
        io_name=`cat /tmp/diff_cpci_ioports|cut -d : -f 2|head -n 1`
        mem=`cat /tmp/diff_cpci_iomem|awk '{print $2}'`
        mem_name=`cat /tmp/diff_cpci_iomem|cut -d : -f 2|head -n 1`
        if [ -n "$ioport"  -o -n "$mem"  ];then
                 if [ -n "$ioport" ];then
                        echo "system $flag the io port address" $ioport for

"device" $io_name
fi
if [ -n "$mem" ];then
echo "System $flag the io mem address" $mem for
"device" $mem_name
fi
else
echo "System deallocate error"
fi

}

cpci_check_plug_remove()
{
check_hotplug_cap
CPCI_CAP=$?
Mark=cat /tmp/mark
if [ ! -f /tmp/entry ];then
echo 0 > /tmp/entry
fi
entry=cat /tmp/entry
if [ $CPCI_CAP -eq 0 -a $entry -ne $CPCI_PLUG ];then
check_resource plug
Mark=expr $Mark + 1
echo $Mark > /tmp/mark
echo $CPCI_PLUG > /tmp/entry
fi
if [ $CPCI_CAP -ne 0 -a $entry -ne $CPCI_REMOVE ];then
check_resource remove
Mark=expr $Mark + 1
echo $Mark > /tmp/mark
echo $CPCI_REMOVE > /tmp/entry
fi
Mark=cat /tmp/mark
if [ $CPCI_CAP -ne 0 -a $Mark -lt 2 ];then
echo "Pls plug your devices manually" echo "............................" exit 1
fi
if [ $CPCI_CAP -eq 0 -a $Mark -lt 2 ];then
echo "PLs remove your cpci devices manually" echo "....................................." exit 0
fi
Mark=cat /tmp/mark
if [ $Mark -eq 2 ];then
cpci_information plug_remove
echo $CPCI_NONE > /tmp/mark
echo $CPCI_NONE > /tmp/entry
rm -f /tmp/cpci*
rm -f /tmp/diff*
fi

}
notice()
{
echo "You should remove the Hot swap devices manually and check" echo "whether the device is still there"
}
#the function is used to check the NET hot swap devices debug_on()
{
cp -r /sbin/hotplug /sbin/hotplug-bk
sed -e 's/#DEBUG/DEBUG/' /sbin/hotplug-bk > /sbin/hotplug dmesg -c
}
#Auto Enable the hot plug
pci_plug()
{
echo 1 > power
}
# Auto Disable the Hot plug
pci_remove()
{
echo 0 > power
}
change_sub_dir()
{
echo "If only some of your hotplug slots have been inserted " echo "devices, so you should set the SUB_DIR by yourselves" SUB_DIR="1"
}
check_pci_hardware()
{

HARD_PASS_1=true

#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=ls
change_sub_dir
if [ "$SUB_DIR" = "" ];then
echo "Hot Plug driver has not been installed" echo "Or there are no hot plug devices" exit 1
fi
else
exit 1
fi

for dir in $SUB_DIR
do
cd $dir
pci_remove
cd ..
done

for dir in $SUB_DIR
do
cd $dir
pci_plug
value=cat power
if [ $value -ne "1" ];then
HARD_PASS_1úlse
echo $HARD_PASS_1
echo "We can not Plug the devices
automatically,so check your hardware"
echo "Or check whether the hotplug slot have
been filled"

			fi
		cd ..
	done

	if [ "$HARD_PASS_1" = "true" ];then
			echo "PASS1: HardWare Check"
	fi

}

check_pci_hotplug_net_device()

{
	SOFT_PASSúlse

	#check whether module has been inserted
	if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
		cd $COMPAQ_PCI_HOTPLUG_DIR
		SUB_DIR=`ls`
		change_sub_dir
		if [ "$SUB_DIR" = "" ];then
			exit 1
		fi
	else
		exit 1
	fi
	
	for dir in $SUB_DIR
	do
		cd $dir
			pci_remove 
		cd ..
	done

	debug_on > /dev/null 2>&1
	# Check whether the network inteface can be booted correctly.
	ethnum=`ifconfig|grep eth|wc -l`
	for dir in $SUB_DIR
	do
		SOFT_PASSúlse
		cd $dir
			pci_plug
			ethnum=`echo $((ethnum))`
			ifconfig|grep eth"$ethnum" >/dev/null 2>&1
			if [ "$?" -eq 0 ];then
				echo "The pci hot plug device can been
booted automatically"
				SOFT_PASS=true
			else
				ifup eth"$ethnum" >/dev/null 2>&1
				if [ "$?" -eq 0 ];then
					echo "The pci hotplug net device can

been booted correctly"
SOFT_PASS=true
else
SOFT_PASSúlse
echo "please check your network
configuration or hotplug device driver"
echo "the message in
/var/log/messages will help you locate your error"

				fi
			fi		
		cd ..
		ethnum=`expr $ethnum + 1`
	done

	if [ $SOFT_PASS = "true" ];then
		echo "PASS2: The software check"
	fi
}
check_file()
{
	awk '{
                name=$4
                add=$2
                print addrtype
                if (name != "" && add !="")
                {
                        printf("System allocate name %s addr_type %s
%s\n",name,addrtype,add)
                }else
                {
                        printf("System allocation error %s",name)
                }
        }
        ' $1

}
check_mem_info()
{
#set -x

#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=ls
change_sub_dir
if [ "$SUB_DIR" = "" ];then
exit 1
fi
else
exit 1
fi

echo "Checking the Mem information procedure remove/plug" for dir in $SUB_DIR
do
cd $dir
pci_remove
cat /proc/iomem > /tmp/before_mm_$dir pci_plug
cat /proc/iomem > /tmp/after_mm_$dir diff /tmp/before_mm_$dir /tmp/after_mm_$dir >
/tmp/diff_mm
check_file /tmp/diff_mm
cd ..
done

echo "Checking the Mem information procedure plug/remove" for dir in $SUB_DIR
do
cd $dir
pci_remove
pci_plug
cat /proc/iomem > /tmp/before_mm_$dir pci_remove
cat /proc/iomem > /tmp/after_dmm_$dir

diff /tmp/before_mm_$dir /tmp/after_mm_$dir >
/tmp/diff_mm

		        check_file /tmp/diff_mm
                cd ..
        done

}
check_io_mem_info()
{
#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=ls
change_sub_dir
if [ "$SUB_DIR" = "" ];then
exit 1
fi
else
exit 1
fi

echo "Checking the IO information procedure remove/plug" for dir in $SUB_DIR
do
cd $dir
pci_remove
cat /proc/ioports > /tmp/before_ioports_$dir cat /proc/iomem > /tmp/before_mm_$dir pci_plug
cat /proc/ioports > /tmp/after_ioports_$dir cat /proc/iomem > /tmp/after_mm_$dir diff /tmp/before_mm_$dir /tmp/after_mm_$dir|grep ">"

Quoted 1 line

/tmp/diff_mm

diff /tmp/before_ioports_$dir
/tmp/after_ioports_$dir|grep ">" > /tmp/diff_ioports

			ioport=`cat /tmp/diff_ioports|awk '{print $2}'`
			io_name=`cat /tmp/diff_ioports|awk '{print $4}'|head
-n 1`
			mem=`cat /tmp/diff_mm|awk '{print $2}'`
			mem_name=`cat /tmp/diff_mm|awk '{print $4}'|head -n
1`
			if [ -n "$ioport"  -o -n "$mem"  ];then
				if [ -n "$ioport" ];then
					echo "system allocate the io
address" $ioport for "device" $io_name 
				fi
				if [ -n "$mem" ];then
					echo "System allocate the mem

address" $mem for "device" $mem_name
fi
else
echo "System allocate error"
fi
cd ..
done

for dir in $SUB_DIR
do
cd $dir
pci_remove
cd ..
done

echo "Checking the IO information procedure plug/remove" for dir in $SUB_DIR
do
cd $dir
pci_plug
cat /proc/ioports > /tmp/before_ioports_$dir cat /proc/iomem > /tmp/before_mm_$dir pci_remove
cat /proc/ioports > /tmp/after_ioports_$dir cat /proc/iomem > /tmp/after_mm_$dir diff /tmp/before_mm_$dir /tmp/after_mm_$dir|grep "<"

Quoted 1 line

/tmp/diff_mm

diff /tmp/before_ioports_$dir
/tmp/after_ioports_$dir|grep "<" > /tmp/diff_ioports

                        ioport=`cat /tmp/diff_ioports|awk '{print $2}'`
                        io_name=`cat /tmp/diff_ioports|awk '{print $4}'|head
-n 1`
                        mem=`cat /tmp/diff_mm|awk '{print $2}'`
                        nem_name=`cat /tmp/diff_mm|awk '{print $4}'|head -n
1`
                        if [ -n "$ioport"  -o -n "$mem"  ];then
                                if [ -n "$ioport" ];then
                                        echo "system deallocate the io

address" $ioport for "device" $io_name
fi
if [ -n "$mem" ];then
echo "System deallocate the mem
address" $mem for "device" $mem_name
fi
else
echo "System deallocate error"
fi
cd ..
done
}

hotplug_check()

{
	if [ $# -gt 0 ];then
		case "$1" in
		-l)
			check_hotplug_cap
			exit 0
			;;
		-c)
			check_after_remove 
			exit 0
			;;
		-n)
			check_pci_hotplug_net_device
			;;
		-h)
			check_pci_hardware
			;;	
		-i)
			check_io_mem_info 
			;;
		*)
			usage
			;;
		esac
	fi
} 

usage()
{
cat << EOF
Usage: hotplug_test [options]
options:
--list|-l)
list the devices that support CompactPCI
hotpwap,only user for cPCI platform
--platform|-p=cPCI|PCI_NET|PCI_SCSI)
platform type (cPCI|PCI_NET|PCI_SCSI), it will check
whether the devices can
be plug and removed correctly, only check basic
hardware information.
cPCI means CompactPCI
PCI_NET means PCI hotplug net devices PCI_SCSI means PCI hotplug SCSI devices
--checkiomem|-c=PCI|cPCI_RP|cPCI_RP)
Check io information before and after remove the hot
plug devices(PCI|cPCI_RP|cPCI_RP)
R means Remove ,P means Plug
PCI means common PCI hot plug devices cPCI_RP means frist Remove then Plug cPCI_PR means frist Plug then Remove
--help|-h)
help and usage
--version|-v)
Test suites version
device:
device address
EOF

        exit $1
}

if [ $# -eq 0 ];then
usage
exit
fi
if [ ! -f /tmp/mark ];then
touch /tmp/mark
echo $CPCI_NONE > /tmp/mark
fi
for option
do

    case "$option" in
        -*=*) 
		optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'`
		option=`echo "$option"|sed 's/=.*$//'`
		;;
           *) optarg='' ;;
    esac
    case "$option" in
        --help|-h)
            echo "Usage: $usage"
            exit 0
            ;;
        --version|-v)
            echo "version is" $HOTSWAP_TEST_VERSION
            exit 0
            ;;
	--platform|-p)
	    case "$optarg" in
		cPCI)
			hotplug_check -c 
		;;	
		PCI_NET)
			hotplug_check -h
			hotplug_check -n
		;;
		*)
		usage
		exit 1
		;;
	    esac
	    ;;
	--checkiomem|-c)
   	     case "$optarg" in
		PCI)
			hotplug_check -i
		;;
		cPCI_RP)
			cpci_check_remove_plug
		;;
		cPCI_PR)
			cpci_check_plug_remove 
		;;
		*)
		usage
		exit 1
		;;
	     esac
		;;	
	--list|-l)
		echo "only echo the Devices support cPCI hot swap function"
		hotplug_check -l
		exit 1
		;;	
	*)
	   usage
	   exit 1
	   ;;
	esac

done
________________________________________________________________
-----Original Message-----
From: Scott Murray [mailto:[email protected]]
Sent: Saturday, November 30, 2002 5:25 AM
To: Guo, Min
Cc: [email protected]
Subject: RE: About test suites for linux hot plug

Quoted 3 lines · Min

Here is my initial test suite for cPCI (ZT5084 platform) and Compaq with e100 and e1000 hotplug network devices,
for the other hot plug device and features, I will give out the test

suites

Quoted 1 line

later.

Your testcase seems reasonable, but having the PCI device appear/disappear is IMO the trivial part of PCI hotplug. The vast majority of the problems I encountered while writing the cPCI drivers involved PCI resources. Most of my manual testing revolves around checking the contents of /proc/iomem and /proc/ioports before and after inserts and removes, as well as looking at the output of "lspci -vvv". With a fixed set of hardware, it may be possible to come up with testcases for resource allocation, but the general case is probably difficult to automate.

Something else to be aware of is that eventually I plan to support hardware that does not expose HS_CSR through the PCI extended capabilities. It looks like your testcase as it stands now will break if run in a setup that had such hardware.

Scott

PS: Are you working with Harold Yang? He's also at Intel but seems to be
having troubles using cPCI hotplug on his ZT5084 system.

Signature · 14 lines
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: [email protected]


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel