1f08c3bdfSopenharmony_ci 2f08c3bdfSopenharmony_ciMCE test suite HOWTO 3f08c3bdfSopenharmony_ci==================== 4f08c3bdfSopenharmony_ci 5f08c3bdfSopenharmony_ci11 November 2008 6f08c3bdfSopenharmony_ci 7f08c3bdfSopenharmony_ciHuang Ying 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ciSection 4.2 (Test with kdump test driver) is based on the README of 10f08c3bdfSopenharmony_ciLTP kdump test case. 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ciAbstract 13f08c3bdfSopenharmony_ci-------- 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_ciThis document explains the structure and design of MCE test suite, the 16f08c3bdfSopenharmony_cikernel patch and user space tools needed for automatic tests, usage 17f08c3bdfSopenharmony_ciguide and how to add new test cases into test suite. 18f08c3bdfSopenharmony_ci 19f08c3bdfSopenharmony_ci0. Quick shortcut 20f08c3bdfSopenharmony_ci------------------ 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci- Install the Linux kernel with full MCE injection support, including 23f08c3bdfSopenharmony_ci latest Linux kernel (2.6.31) and MCE injection enhancement patchset 24f08c3bdfSopenharmony_ci in: http://ftp.kernel.org/pub/linux/kernel/people/yhuang/mce/. Make 25f08c3bdfSopenharmony_ci sure following configuration options are enabled: 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci CONFIG_X86_MCE=y 28f08c3bdfSopenharmony_ci CONFIG_X86_MCE_INTEL=y 29f08c3bdfSopenharmony_ci CONFIG_X86_MCE_INJECT=y or CONFIG_X86_MCE_INJECT=m 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci- Get mcelog git version from 32f08c3bdfSopenharmony_ci git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git. 33f08c3bdfSopenharmony_ci and install in /usr/sbin (or rather first in your $PATH) 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci git clone git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git 36f08c3bdfSopenharmony_ci cd mcelog 37f08c3bdfSopenharmony_ci make 38f08c3bdfSopenharmony_ci sudo make install 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_ci- Get mce-inject git version from 41f08c3bdfSopenharmony_ci git://git.kernel.org/pub/scm/utils/cpu/mce/mce-inject.git. 42f08c3bdfSopenharmony_ci 43f08c3bdfSopenharmony_ci git clone git://git.kernel.org/pub/scm/utils/cpu/mce/mce-inject.git 44f08c3bdfSopenharmony_ci cd mce-inject 45f08c3bdfSopenharmony_ci make 46f08c3bdfSopenharmony_ci sudo make install 47f08c3bdfSopenharmony_ci 48f08c3bdfSopenharmony_ci- Install page-types tool (sec 3.4), which is accompanied with Linux kernel 49f08c3bdfSopenharmony_ci source (2.6.32 or newer). 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_ci cd $KERNEL_SRC/Documentation/vm/ 52f08c3bdfSopenharmony_ci gcc -o page-types page-types.c 53f08c3bdfSopenharmony_ci cp page-types /usr/bin/ 54f08c3bdfSopenharmony_ci 55f08c3bdfSopenharmony_ci- Run make test 56f08c3bdfSopenharmony_ci This will do the basic tests, but not the more complicated kdump ones. 57f08c3bdfSopenharmony_ci For more information on those read below. 58f08c3bdfSopenharmony_ci 59f08c3bdfSopenharmony_ci1. Introduction 60f08c3bdfSopenharmony_ci--------------- 61f08c3bdfSopenharmony_ci 62f08c3bdfSopenharmony_ciThe MCE test suite is a collection of tools and test scripts for 63f08c3bdfSopenharmony_citesting the Linux kernel MCE processing features. The goal is to cover 64f08c3bdfSopenharmony_cimost Linux kernel MCE processing code paths and features with 65f08c3bdfSopenharmony_ciautomation tests. 66f08c3bdfSopenharmony_ci 67f08c3bdfSopenharmony_ciIf you just want to start testing as quickly as possible, you can skip 68f08c3bdfSopenharmony_cisection 2 and section 3, and go section 4.1 directly. 69f08c3bdfSopenharmony_ci 70f08c3bdfSopenharmony_ci 71f08c3bdfSopenharmony_ci2. Structure 72f08c3bdfSopenharmony_ci------------ 73f08c3bdfSopenharmony_ci 74f08c3bdfSopenharmony_ciThe main intention behind the design is to re-use test cases amongst 75f08c3bdfSopenharmony_civarious test methods (represented as test drivers), such as kdump 76f08c3bdfSopenharmony_cibased, kernel MCE panic log (tolerant=3) based, etc. 77f08c3bdfSopenharmony_ci 78f08c3bdfSopenharmony_ci2.1 Test cases 79f08c3bdfSopenharmony_ci 80f08c3bdfSopenharmony_ciTest cases are grouped into test case classes. The test cases in one 81f08c3bdfSopenharmony_ciclass share the similar triggering, result collecting and result 82f08c3bdfSopenharmony_civerifying methods. They can be used in same set of test drivers. The 83f08c3bdfSopenharmony_ciinterface of a test case class is a shell script, usually named as 84f08c3bdfSopenharmony_cicases.sh under a sub-directory of cases/. The following command line 85f08c3bdfSopenharmony_cioption should be supported by the test case class shell script: 86f08c3bdfSopenharmony_ci 87f08c3bdfSopenharmony_cicases.sh enumerate enumerate test cases in class, print test 88f08c3bdfSopenharmony_ci case names to stdout 89f08c3bdfSopenharmony_cicases.sh trigger trigger the test case 90f08c3bdfSopenharmony_cicases.sh get_result get the result of test case 91f08c3bdfSopenharmony_cicases.sh verify verify the result of test case, and print 92f08c3bdfSopenharmony_ci the verify result to stdout 93f08c3bdfSopenharmony_ci 94f08c3bdfSopenharmony_ciWhen execute cases.sh [trigger|get_result|verify], the test case is 95f08c3bdfSopenharmony_cispecified via environment variable this_case, which must be one of the 96f08c3bdfSopenharmony_citest case names returned by "cases.sh enumerate". 97f08c3bdfSopenharmony_ci 98f08c3bdfSopenharmony_ciOther environment variables are also used to pass some information 99f08c3bdfSopenharmony_cifrom driver to test cases, such as: 100f08c3bdfSopenharmony_ci 101f08c3bdfSopenharmony_cithis_case name current test case 102f08c3bdfSopenharmony_cidriver name of test driver 103f08c3bdfSopenharmony_ciklog file name which holds kernel log during test 104f08c3bdfSopenharmony_ciKSRC_DIR (for gcov) kernel source code directory 105f08c3bdfSopenharmony_ciGCOV (for gcov) gcov collection method 106f08c3bdfSopenharmony_civmcore (for kdump) vmcore file name 107f08c3bdfSopenharmony_cireboot (for kdump) indicate there is a reboot between test 108f08c3bdfSopenharmony_ci case trigger and test case verify, some 109f08c3bdfSopenharmony_ci context has been gone. 110f08c3bdfSopenharmony_ci 111f08c3bdfSopenharmony_ciSeveral test case classes are provided with the test suite. 112f08c3bdfSopenharmony_cicases/soft-inj/* is based on mce-inject MCE software injection tool. 113f08c3bdfSopenharmony_cicases/apei-inj/* is based on apei-inj APEI haredware injection tool. 114f08c3bdfSopenharmony_ci 115f08c3bdfSopenharmony_cicases/<injection tool>/<class name>/cases.sh Interface of the test case class 116f08c3bdfSopenharmony_cicases/<injection tool>/<class name>/data/ Directory contains data file 117f08c3bdfSopenharmony_cicases/<injection tool>/<class name>/refer/ Directory contains data file for 118f08c3bdfSopenharmony_ci reference MCE records if necessary. 119f08c3bdfSopenharmony_ci 120f08c3bdfSopenharmony_ciFor document of various test cases, please refer to doc/cases/*. 121f08c3bdfSopenharmony_ci 122f08c3bdfSopenharmony_ci2.2 Test drivers 123f08c3bdfSopenharmony_ci 124f08c3bdfSopenharmony_ciTest drivers drive the test procedure, its main structure is a loop 125f08c3bdfSopenharmony_ciover test case classes specified in configuration file. For each test 126f08c3bdfSopenharmony_cicase class, test driver loops over test cases returned by "cases.sh 127f08c3bdfSopenharmony_cienumerate". And, for each test case, it calls "cases.sh" to trigger, 128f08c3bdfSopenharmony_ciget_result and verify the test case. Test driver also do some common 129f08c3bdfSopenharmony_ciwork for test cases, such as kdump driver collects vmcore file, and 130f08c3bdfSopenharmony_ciinvoking gcovdump command to get gcov data file. 131f08c3bdfSopenharmony_ci 132f08c3bdfSopenharmony_ciThe interface of test driver is driver.sh, which is usually put in 133f08c3bdfSopenharmony_cidrivers/<driver_name>/ directory. The test configuration file should 134f08c3bdfSopenharmony_cibe used as the only command line parameter for driver.sh. Test case 135f08c3bdfSopenharmony_ciclasses should be specified in test configuration file as CASES 136f08c3bdfSopenharmony_civariable, details below. 137f08c3bdfSopenharmony_ci 138f08c3bdfSopenharmony_ci2.3 Test configuration file 139f08c3bdfSopenharmony_ci 140f08c3bdfSopenharmony_ciTest configuration file is a shell script to specify parameters for 141f08c3bdfSopenharmony_citest drivers and test cases. It must be put in config/ directory. The 142f08c3bdfSopenharmony_ciparameters are represented as shell variables as follow: 143f08c3bdfSopenharmony_ci 144f08c3bdfSopenharmony_ciCASES Name of test case classes, separate by 145f08c3bdfSopenharmony_ci white space. 146f08c3bdfSopenharmony_ciSTART_BACKGROUND Shell command to start a background process 147f08c3bdfSopenharmony_ci during testing, used for random testing.* 148f08c3bdfSopenharmony_ciSTOP_BACKGROUND Shell command to stop the background process 149f08c3bdfSopenharmony_ci during testing. 150f08c3bdfSopenharmony_ciCOREDIR (for kdump) directory contains Linux kernel crash core 151f08c3bdfSopenharmony_ci dump after kdump. 152f08c3bdfSopenharmony_ciVMLINUX (for kdump, gcov) vmlinux of Linux kernel 153f08c3bdfSopenharmony_ciGCOV (for gcov) Enable GCOV if set none zero. 154f08c3bdfSopenharmony_ciKSRC_DIR (for gcov) Kernel source code directory 155f08c3bdfSopenharmony_ci 156f08c3bdfSopenharmony_ci* To test MCE processing under random environment, a background 157f08c3bdfSopenharmony_ci process can be automatically run simultaneously during MCE 158f08c3bdfSopenharmony_ci testing. The start/stop command is specified via START_BACKGROUND 159f08c3bdfSopenharmony_ci and STOP_BACKGROUND. 160f08c3bdfSopenharmony_ci 161f08c3bdfSopenharmony_ci2.4 Test result 162f08c3bdfSopenharmony_ci 163f08c3bdfSopenharmony_ciAfter test, the general test result will go results/<driver_name>/result. 164f08c3bdfSopenharmony_ciThe format of general test result is as follow: 165f08c3bdfSopenharmony_ci 166f08c3bdfSopenharmony_ci<test case name>: 167f08c3bdfSopenharmony_ci Passed: item 1 description 168f08c3bdfSopenharmony_ci Failed: item 2 description 169f08c3bdfSopenharmony_ci ... 170f08c3bdfSopenharmony_ci Passed: item n description 171f08c3bdfSopenharmony_ci 172f08c3bdfSopenharmony_ciOne blank line is used to separate test cases. 173f08c3bdfSopenharmony_ci 174f08c3bdfSopenharmony_ciAdditional test result for various test cases will go 175f08c3bdfSopenharmony_ci"results/<driver_name>/<case_name>/<xxx>. For in-package test case 176f08c3bdfSopenharmony_ciclass, additional test results include: 177f08c3bdfSopenharmony_ci 178f08c3bdfSopenharmony_ciresults/<driver_name>/<injection_tool>/<case_name>/klog 179f08c3bdfSopenharmony_ci Kernel log during testing 180f08c3bdfSopenharmony_ciresults/<driver_name>/<injection_tool>/<case_name>/mcelog 181f08c3bdfSopenharmony_ci mcelog output during testing 182f08c3bdfSopenharmony_ciresults/<driver_name>/<injection_tool>/<case_name>/mcelog_refer 183f08c3bdfSopenharmony_ci mcelog output reference 184f08c3bdfSopenharmony_ciresults/<driver_name>/<injection_tool>/<case_name>/mce_64.c.gcov (for gcov) 185f08c3bdfSopenharmony_ci gcov output file 186f08c3bdfSopenharmony_ci 187f08c3bdfSopenharmony_ci 188f08c3bdfSopenharmony_ci3. Tools 189f08c3bdfSopenharmony_ci-------- 190f08c3bdfSopenharmony_ci 191f08c3bdfSopenharmony_ci3.1 mce-inject 192f08c3bdfSopenharmony_ci 193f08c3bdfSopenharmony_cimce-inject is a software MCE injection tool, which is based on Linux 194f08c3bdfSopenharmony_cikernel software MCE injection mechanism. To inject a MCE into Linux 195f08c3bdfSopenharmony_cikernel via mce-inject, a data file should be provided. The syntax is 196f08c3bdfSopenharmony_cisimilar to the logging output by mcelog with some extensions. 197f08c3bdfSopenharmony_ciPlease refer to the documentation of mce-inject for more information. 198f08c3bdfSopenharmony_ci 199f08c3bdfSopenharmony_ciThe mce-inject program must be executable in $PATH. 200f08c3bdfSopenharmony_ci 201f08c3bdfSopenharmony_ci3.2 mcelog 202f08c3bdfSopenharmony_ci 203f08c3bdfSopenharmony_cimcelog read /dev/mcelog and prints the stored machine check records to 204f08c3bdfSopenharmony_cistdout. It is used by MCE test suite to verify MCE records generated 205f08c3bdfSopenharmony_ciby kernel is same as reference records, at most time, same as input 206f08c3bdfSopenharmony_cirecords. The current git mcelog version is needed for MCE test suite to 207f08c3bdfSopenharmony_ciwork properly. Please refer to document of mcelog for more 208f08c3bdfSopenharmony_ciinformation. The latest mcelog can be gotten via git snapshot from 209f08c3bdfSopenharmony_cigit://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git. 210f08c3bdfSopenharmony_ci 211f08c3bdfSopenharmony_ciNote you need the git version of mcelog available in $PATH. 212f08c3bdfSopenharmony_ci 213f08c3bdfSopenharmony_ci3.3 gcovdump 214f08c3bdfSopenharmony_ci 215f08c3bdfSopenharmony_cigcov is a test coverage tool, the original implementation is used for 216f08c3bdfSopenharmony_ciuser space program only. LTP (Linux Test Project) provides the kernel 217f08c3bdfSopenharmony_cigcov support. But MCE test involves panic or kdump, so gcovdump is 218f08c3bdfSopenharmony_cideveloped to dump gcov data from kdump crash dump core. gcovdump has 219f08c3bdfSopenharmony_cibeen merged by LTP cvs. For more information please refer to gcovdump 220f08c3bdfSopenharmony_cidocument. The latest gcovdump can be gotten from cvs: 221f08c3bdfSopenharmony_cihttp://ltp.cvs.sourceforge.net/viewvc/ltp/utils/analysis/gcov-kdump/. 222f08c3bdfSopenharmony_ci 223f08c3bdfSopenharmony_ci3.4 page-types 224f08c3bdfSopenharmony_ciA tool to query page types, which is accompanied with Linux kernel 225f08c3bdfSopenharmony_cisource (2.6.32 or newer, $KERNEL_SRC/Documentation/vm/page-types.c). 226f08c3bdfSopenharmony_ciIt is required for MCE apei-inj testing. 227f08c3bdfSopenharmony_ci 228f08c3bdfSopenharmony_ci4. Usage Guide 229f08c3bdfSopenharmony_ci-------------- 230f08c3bdfSopenharmony_ci 231f08c3bdfSopenharmony_ci4.1 Test with simple test driver 232f08c3bdfSopenharmony_ci 233f08c3bdfSopenharmony_ci4.1.1 Simple test driver 234f08c3bdfSopenharmony_ci 235f08c3bdfSopenharmony_ciThe simple test driver just call cases.sh of test cases one by one in 236f08c3bdfSopenharmony_cia loop. So it is not permitted for test cases to trigger real panic or 237f08c3bdfSopenharmony_cireboot during test. For MCE testing, a special processing mode to just 238f08c3bdfSopenharmony_cilog everything in case of MCE is used for the simple test driver, it 239f08c3bdfSopenharmony_ciis enabled via set MCE parameter "tolerant=3" during 240f08c3bdfSopenharmony_citesting. "tolerant" can be set via writing: 241f08c3bdfSopenharmony_ci /sys/devices/system/machinecheck/machinecheck0/tolerant 242f08c3bdfSopenharmony_ci 243f08c3bdfSopenharmony_ci4.1.2 test instruction 244f08c3bdfSopenharmony_ci 245f08c3bdfSopenharmony_ciThe following is the basic test instruction, for some additional 246f08c3bdfSopenharmony_cifeatures such as gcov support, please refer to corresponding 247f08c3bdfSopenharmony_ciinstructions. 248f08c3bdfSopenharmony_ci 249f08c3bdfSopenharmony_cia. Linux kernel and user space tools as follow should be installed 250f08c3bdfSopenharmony_ci 251f08c3bdfSopenharmony_ci - A Linux kernel with full MCE injection support (see 0) 252f08c3bdfSopenharmony_ci - mce-inject tool (see 3.1) 253f08c3bdfSopenharmony_ci - mcelog with proper version (see 3.2) 254f08c3bdfSopenharmony_ci - page-types (see 3.4) 255f08c3bdfSopenharmony_ci 256f08c3bdfSopenharmony_cib. Modify config/simple.conf or create a new test configuration 257f08c3bdfSopenharmony_ci file. Refer to section 2.3 for more instruction about test 258f08c3bdfSopenharmony_ci configuration file. 259f08c3bdfSopenharmony_ci 260f08c3bdfSopenharmony_cic. Run "make". Carefully check for any errors. 261f08c3bdfSopenharmony_ci 262f08c3bdfSopenharmony_cid. It is recommended to stop cron before testing. Because there 263f08c3bdfSopenharmony_ci might be another mcelog reading events running on background 264f08c3bdfSopenharmony_ci by cron, which will upset the test. 265f08c3bdfSopenharmony_ci 266f08c3bdfSopenharmony_ci /etc/init.d/crond stop 267f08c3bdfSopenharmony_ci 268f08c3bdfSopenharmony_cie. To be root and invoke simple test driver on test configuration file 269f08c3bdfSopenharmony_ci as follow 270f08c3bdfSopenharmony_ci 271f08c3bdfSopenharmony_ci Run "make test" to do all the standard tests that do not require 272f08c3bdfSopenharmony_ci special set up. 273f08c3bdfSopenharmony_ci 274f08c3bdfSopenharmony_cif. General test result will go results/simple/result. Test log will go 275f08c3bdfSopenharmony_ci work/simple/log. Additional test results for various test cases 276f08c3bdfSopenharmony_ci will go results/simple/<test case>/<xxx>. For more details about 277f08c3bdfSopenharmony_ci in-package test case class, please refer to section 2.1. 278f08c3bdfSopenharmony_ci 279f08c3bdfSopenharmony_ci 280f08c3bdfSopenharmony_ci4.2 Test with kdump test driver 281f08c3bdfSopenharmony_ci 282f08c3bdfSopenharmony_ci4.2.1 kdump test driver 283f08c3bdfSopenharmony_ci 284f08c3bdfSopenharmony_ciThe kdump test driver is based on the kdump test case in Linux Test 285f08c3bdfSopenharmony_ciProject, thank LTP for their excellent work! 286f08c3bdfSopenharmony_ci 287f08c3bdfSopenharmony_ciThe kdump driver helps run tests which trigger crash/panic and 288f08c3bdfSopenharmony_cigenerate result and report via kdump. The test scripts cycle through a 289f08c3bdfSopenharmony_ciseries of crash/panic scenarios. Each test cycle does the following: 290f08c3bdfSopenharmony_ci 291f08c3bdfSopenharmony_cia. Triggers a test case which triggers crash/panic (MCE with tolerant=1). 292f08c3bdfSopenharmony_cib. Kdump kernel boots and saves a vmcore. 293f08c3bdfSopenharmony_cic. System reboots to 1st kernel. 294f08c3bdfSopenharmony_cid. Verifies test case, generate result and report. 295f08c3bdfSopenharmony_cie. After a 1 to 2 minute delay, the next test case is run. 296f08c3bdfSopenharmony_ci 297f08c3bdfSopenharmony_ci4.2.2 test instruction 298f08c3bdfSopenharmony_ci 299f08c3bdfSopenharmony_ciFollow the steps to setup kdump test driver. 300f08c3bdfSopenharmony_ci 301f08c3bdfSopenharmony_ciThe test driver is written for SuSE Linux Enterprise Server 10 (and 302f08c3bdfSopenharmony_cionward releases), OpenSUSE, Fedora, Debian, as well as RedHat 303f08c3bdfSopenharmony_ciEnterprise Linux 5. Since KDUMP is supported by the above mentioned 304f08c3bdfSopenharmony_cidistro's the test driver was written and tested on them. Contribution 305f08c3bdfSopenharmony_citowards supporting more distributions are welcome. 306f08c3bdfSopenharmony_ci 307f08c3bdfSopenharmony_cia. Install Linux kernel with full MCE injection and KDUMP support. In 308f08c3bdfSopenharmony_ci addition to MCE injection support in section 0, the following 309f08c3bdfSopenharmony_ci configuration options should be enabled too: 310f08c3bdfSopenharmony_ci 311f08c3bdfSopenharmony_ci CONFIG_KEXEC=y 312f08c3bdfSopenharmony_ci CONFIG_CRASH_DUMP=y 313f08c3bdfSopenharmony_ci 314f08c3bdfSopenharmony_cib. Install these additional packages: 315f08c3bdfSopenharmony_ci 316f08c3bdfSopenharmony_ci For SLES10 or OpenSUSE Distro: 317f08c3bdfSopenharmony_ci 318f08c3bdfSopenharmony_ci * kernel-kdump 319f08c3bdfSopenharmony_ci * kernel-source 320f08c3bdfSopenharmony_ci * kexec-tools 321f08c3bdfSopenharmony_ci 322f08c3bdfSopenharmony_ci For RHEL5 or Fedora distro: 323f08c3bdfSopenharmony_ci 324f08c3bdfSopenharmony_ci * kexec-tools 325f08c3bdfSopenharmony_ci * kernel-devel 326f08c3bdfSopenharmony_ci 327f08c3bdfSopenharmony_cic. Configure where to put the kdump /proc/vmcore files. The path should be 328f08c3bdfSopenharmony_ci specified via COREDIR in test configuration file. 329f08c3bdfSopenharmony_ci By default, the kdump /proc/vmcore files will be put into /var/crash. 330f08c3bdfSopenharmony_ci 331f08c3bdfSopenharmony_ci For SLES10 or OpenSUSE Distro: 332f08c3bdfSopenharmony_ci * edit KDUMP_SAVEDIR in /etc/sysconfig/kdump 333f08c3bdfSopenharmony_ci For RHEL5 or Fedora distro: 334f08c3bdfSopenharmony_ci * edit path in /etc/kdump.conf 335f08c3bdfSopenharmony_ci 336f08c3bdfSopenharmony_cid. In addition to bzImage and modules of Linux kernel should be 337f08c3bdfSopenharmony_ci installed on test machine, the vmlinux of Linux kernel should be 338f08c3bdfSopenharmony_ci put on test machine and specified via VMLINUX in test configuration 339f08c3bdfSopenharmony_ci file. 340f08c3bdfSopenharmony_ci 341f08c3bdfSopenharmony_cie. Make sure the partition where the test driver is running has space 342f08c3bdfSopenharmony_ci for the tests results and one vmcore file (size of physical 343f08c3bdfSopenharmony_ci memory). 344f08c3bdfSopenharmony_ci 345f08c3bdfSopenharmony_cif. Now, reboot system. Test if kdump works by starting kdump and triggering 346f08c3bdfSopenharmony_ci kernel panic. 347f08c3bdfSopenharmony_ci 348f08c3bdfSopenharmony_ci For SLES10 or OpenSUSE Distro: 349f08c3bdfSopenharmony_ci service boot.kdump restart 350f08c3bdfSopenharmony_ci chkconfig boot.kdump on 351f08c3bdfSopenharmony_ci echo "c" > /proc/sysrq-trigger 352f08c3bdfSopenharmony_ci 353f08c3bdfSopenharmony_ci For RHEL5 or Fedora distro: 354f08c3bdfSopenharmony_ci service kdump restart 355f08c3bdfSopenharmony_ci /sbin/chkconfig kdump on 356f08c3bdfSopenharmony_ci echo "c" > /proc/sysrq-trigger 357f08c3bdfSopenharmony_ci 358f08c3bdfSopenharmony_ci After system reboot, check if there are vmcore files. By default, they are in /var/crash/*/. If yes, "kdump" works in the system. 359f08c3bdfSopenharmony_ci 360f08c3bdfSopenharmony_cig. Create a new test configuration file or use a existing one in 361f08c3bdfSopenharmony_ci config/, such as kdump.conf. Note: not all test case classes can be 362f08c3bdfSopenharmony_ci used with kdump test driver, see "important points" below. 363f08c3bdfSopenharmony_ci 364f08c3bdfSopenharmony_cih. Run "make". Carefully check for any errors. 365f08c3bdfSopenharmony_ci 366f08c3bdfSopenharmony_cii. To be root and run "drivers/kdump/driver.sh <conf>" or "make test-kdump" (for a full test) 367f08c3bdfSopenharmony_ci 368f08c3bdfSopenharmony_cij. After test is done, the test log of the last run of kdump driver will 369f08c3bdfSopenharmony_ci be displayed on main console. 370f08c3bdfSopenharmony_ci 371f08c3bdfSopenharmony_ciFew Important points to remember: 372f08c3bdfSopenharmony_ci 373f08c3bdfSopenharmony_ci- kdump test driver request that a real panic should be triggered when 374f08c3bdfSopenharmony_ci test case is triggered. So not all test case classes can be used 375f08c3bdfSopenharmony_ci with kdump test driver, for example, all test case classes for 376f08c3bdfSopenharmony_ci corrected MCE can not be used with kdump test driver. 377f08c3bdfSopenharmony_ci 378f08c3bdfSopenharmony_ci- If you need to stop the tests before all test cases have run, run 379f08c3bdfSopenharmony_ci "crontab -r" and "killall driver.sh" within 1 minute after the 1st 380f08c3bdfSopenharmony_ci kernel reboots. Then, if you'd like to carry on tests from that point 381f08c3bdfSopenharmony_ci on, run: 382f08c3bdfSopenharmony_ci rm work/kdump/stamps/setupped 383f08c3bdfSopenharmony_ci drivers/kdump/driver.sh <conf> 384f08c3bdfSopenharmony_ci If you'd like to start tests from the beginning, run: 385f08c3bdfSopenharmony_ci make reset 386f08c3bdfSopenharmony_ci drivers/kdump/driver.sh <conf> 387f08c3bdfSopenharmony_ci 388f08c3bdfSopenharmony_ci- If a failure occurs when booting the kdump kernel, you'll need to 389f08c3bdfSopenharmony_ci manually reset the system so it reboots back to the 1st kernel and 390f08c3bdfSopenharmony_ci continues on to the next test. For this reason, it's best to monitor 391f08c3bdfSopenharmony_ci the tests from a console. If possible, setup a serial console (not a 392f08c3bdfSopenharmony_ci must, any type of console setup will do). If using minicom, enable 393f08c3bdfSopenharmony_ci saving of kernel messages displayed on minicom into a file, by 394f08c3bdfSopenharmony_ci pressing ctrl+a+l on the console. Else, when it is observed that the 395f08c3bdfSopenharmony_ci kdump kernel has failed to boot, manually copy the boot message into 396f08c3bdfSopenharmony_ci a file to enable the debugging the cause of the hang. 397f08c3bdfSopenharmony_ci 398f08c3bdfSopenharmony_ci- The results are saved in results/kdump/result, which also shows 399f08c3bdfSopenharmony_ci where you are in the test run. When the "Test run complete" entry 400f08c3bdfSopenharmony_ci appears in that file, you're done. Verbose log can be found at 401f08c3bdfSopenharmony_ci work/log. 402f08c3bdfSopenharmony_ci 403f08c3bdfSopenharmony_ci- The test machine would be unavailable for any other work during the 404f08c3bdfSopenharmony_ci period of the test run. 405f08c3bdfSopenharmony_ci 406f08c3bdfSopenharmony_ci4.3 Gcov support 407f08c3bdfSopenharmony_ci 408f08c3bdfSopenharmony_ciGcov is a test coverage tool. It can be used to discover untested 409f08c3bdfSopenharmony_ciparts of program, collect branch taken statistics to optimize program, 410f08c3bdfSopenharmony_cietc. In MCE test suite, it is used to get test coverage, that is, 411f08c3bdfSopenharmony_ciwhich C statements are covered by each test case. 412f08c3bdfSopenharmony_ci 413f08c3bdfSopenharmony_ciGcov support is optional, if you don't care about test coverage 414f08c3bdfSopenharmony_ciinformation, just skip this section. 415f08c3bdfSopenharmony_ci 416f08c3bdfSopenharmony_cia. Make sure your kernel has gcov support. You can find lasted kernel 417f08c3bdfSopenharmony_ci gcov patches from: 418f08c3bdfSopenharmony_ci http://ltp.sourceforge.net/coverage/gcov.php 419f08c3bdfSopenharmony_ci 420f08c3bdfSopenharmony_ci A README for kernel gcov can be found from: 421f08c3bdfSopenharmony_ci http://ltp.sourceforge.net/coverage/gcov/readme.php 422f08c3bdfSopenharmony_ci 423f08c3bdfSopenharmony_ci Notes: CONFIG_GCOV_ALL does not work for me. Add the line 424f08c3bdfSopenharmony_ci EXTRA_CFLAGS += $(KBUILD_GCOV_FLAGS) 425f08c3bdfSopenharmony_ci to the respective Makefiles are more stable. For example, this line 426f08c3bdfSopenharmony_ci can be added into "linux/arch/x86/kernel/cpu/mcheck/Makefile" 427f08c3bdfSopenharmony_ci 428f08c3bdfSopenharmony_cib. If you want to use gcov with kdump test driver, please install 429f08c3bdfSopenharmony_ci gcovdump tool(see section 3.4). The latest gcovdump can be gotten 430f08c3bdfSopenharmony_ci from cvs: 431f08c3bdfSopenharmony_ci http://ltp.cvs.sourceforge.net/viewvc/ltp/utils/analysis/gcov-kdump/. 432f08c3bdfSopenharmony_ci 433f08c3bdfSopenharmony_cic. Linux kernel source source code should be put on the test 434f08c3bdfSopenharmony_ci machine. Its root directory should be specified in test 435f08c3bdfSopenharmony_ci configuration file via KSRC_DIR. 436f08c3bdfSopenharmony_ci 437f08c3bdfSopenharmony_cid. In addition to bzImage and modules of Linux kernel should be 438f08c3bdfSopenharmony_ci installed on test machine, the vmlinux of Linux kernel should be 439f08c3bdfSopenharmony_ci put on test machine and specified via VMLINUX of test configuration 440f08c3bdfSopenharmony_ci file. 441f08c3bdfSopenharmony_ci 442f08c3bdfSopenharmony_cie. Make sure gcov is available in your test system. It comes with gcc 443f08c3bdfSopenharmony_ci package normally. If kdump test driver is used, a tool named 444f08c3bdfSopenharmony_ci gcovdump is also needed to dump *.gcda from crash dump image. 445f08c3bdfSopenharmony_ci 446f08c3bdfSopenharmony_cif. In test configuration file, make sure the following setting is 447f08c3bdfSopenharmony_ci available: 448f08c3bdfSopenharmony_ci 449f08c3bdfSopenharmony_ci # enable GCOV support 450f08c3bdfSopenharmony_ci GCOV=1 451f08c3bdfSopenharmony_ci # kernel source is needed to get gcov graph 452f08c3bdfSopenharmony_ci KSRC_DIR=<kernel source directory> 453f08c3bdfSopenharmony_ci VMLINUX=<vmlinux> 454f08c3bdfSopenharmony_ci 455f08c3bdfSopenharmony_cig. After testing, *.c.gcov will be generated in test case result 456f08c3bdfSopenharmony_ci directory, such as 457f08c3bdfSopenharmony_ci results/kdump/soft-inj/non-panic/corrected/mce_64.c.gcov. 458f08c3bdfSopenharmony_ci 459f08c3bdfSopenharmony_cih. To merge gcov graph data from several test cases, a tool named 460f08c3bdfSopenharmony_ci gcov_merge.py in tools sub-directory can be used. For example, 461f08c3bdfSopenharmony_ci 462f08c3bdfSopenharmony_ci tools/gcov_merge results/kdump/soft-inj/*/*/mce_64.c.gcov 463f08c3bdfSopenharmony_ci 464f08c3bdfSopenharmony_ci Will output merged gcov graph from all test cases under 465f08c3bdfSopenharmony_ci soft-inj. This can be used to check coverage of several test cases. 466f08c3bdfSopenharmony_ci 467f08c3bdfSopenharmony_ci4.4 tool 468f08c3bdfSopenharmony_ci 469f08c3bdfSopenharmony_ciSome tools are provided to help analyze test result. 470f08c3bdfSopenharmony_ci 471f08c3bdfSopenharmony_ci- tools/grep_result.sh 472f08c3bdfSopenharmony_ci 473f08c3bdfSopenharmony_ci Grep from general test result (results/<driver_name>/result) in 474f08c3bdfSopenharmony_ci terms of test case instead of line, because the result of one test 475f08c3bdfSopenharmony_ci case may span several line. 476f08c3bdfSopenharmony_ci 477f08c3bdfSopenharmony_ci Usage: 478f08c3bdfSopenharmony_ci cat results/<driver_name>/result | tools/grep_result.sh <grep options> 479f08c3bdfSopenharmony_ci 480f08c3bdfSopenharmony_ci Where <grep options> are same as options available to /bin/grep. 481f08c3bdfSopenharmony_ci 482f08c3bdfSopenharmony_ci- tools/loop-mce-test 483f08c3bdfSopenharmony_ci 484f08c3bdfSopenharmony_ci Run mce test cases in a loop. It exits on failure of any one of the test 485f08c3bdfSopenharmony_ci cases. This script is using simple test driver. 486f08c3bdfSopenharmony_ci 487f08c3bdfSopenharmony_ci Usage: 488f08c3bdfSopenharmony_ci ./loop-mce-test <config_file> 489f08c3bdfSopenharmony_ci 490f08c3bdfSopenharmony_ci Note that only simple test configure file can be used here. 491f08c3bdfSopenharmony_ci 492f08c3bdfSopenharmony_ci5. Add test cases 493f08c3bdfSopenharmony_ci----------------- 494f08c3bdfSopenharmony_ci 495f08c3bdfSopenharmony_ci5.1 Add test case to in-package test class 496f08c3bdfSopenharmony_ci 497f08c3bdfSopenharmony_ciAll in-package test classes use mce-inject software injection tool and 498f08c3bdfSopenharmony_cifollows same structure. The steps to add a new test case is as follow: 499f08c3bdfSopenharmony_ci 500f08c3bdfSopenharmony_cia. Find an appropriate test case class to add your test case. 501f08c3bdfSopenharmony_ci 502f08c3bdfSopenharmony_cib. Add a new mce-inject data file into to cases/soft-inj/<class name>/data/. 503f08c3bdfSopenharmony_ci 504f08c3bdfSopenharmony_cic. If the reference mcelog is different from mce-inject input data 505f08c3bdfSopenharmony_ci file, put that reference file into cases/soft-inj/<class_name>/refer/. 506f08c3bdfSopenharmony_ci 507f08c3bdfSopenharmony_cid. In cases/soft-inj/<class name>/cases.sh, there are shell commands 508f08c3bdfSopenharmony_ci "case" in shell functions get_result() and verify(). Add a branch 509f08c3bdfSopenharmony_ci in each shell command "case" for your test case. 510f08c3bdfSopenharmony_ci 511f08c3bdfSopenharmony_ci5.2 Add test class 512f08c3bdfSopenharmony_ci 513f08c3bdfSopenharmony_ciTo add a new test class, add a cases.sh under a sub-directory of 514f08c3bdfSopenharmony_cicases/, and follow the test case class interface definition in section 515f08c3bdfSopenharmony_ci2.1. The general result output format should follow that in section 516f08c3bdfSopenharmony_ci2.4. 517