1#!/bin/bash 2################################################################################ 3## ## 4## Copyright (c) International Business Machines Corp., 2007 ## 5## ## 6## This program is free software; you can redistribute it and#or modify ## 7## it under the terms of the GNU General Public License as published by ## 8## the Free Software Foundation; either version 2 of the License, or ## 9## (at your option) any later version. ## 10## ## 11## This program is distributed in the hope that it will be useful, but ## 12## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## 13## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## 14## for more details. ## 15## ## 16## You should have received a copy of the GNU General Public License ## 17## along with this program; if not, write to the Free Software ## 18## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 19## ## 20################################################################################ 21# 22# Author: Sivakumar Chinnaiah, Sivakumar.C@in.ibm.com 23# 24# History: July 04 2007 - Created - Sivakumar Chinnaiah. 25# 26# File : numa01.sh 27# 28# Description: Test Basic functionality of numactl command. 29# Test #1: Verifies cpunodebind and membind 30# Test #2: Verifies preferred node bind for memory allocation 31# Test #3: Verifies memory interleave on all nodes 32# Test #4: Verifies physcpubind 33# Test #5: Verifies localalloc 34# Test #6: Verifies memory policies on shared memory 35# Test #7: Verifies numademo 36# Test #8: Verifies memhog 37# Test #9: Verifies numa_node_size api 38# Test #10:Verifies Migratepages 39# - it uses numastat output which is expected to be in the format 40# node0 node1 41#numa_hit 4280408 4605341 42#numa_miss 0 0 43#numa_foreign 0 0 44#interleave_hit 12445 13006 45#local_node 4277766 4566799 46#other_node 2642 38542 47 48 49 50# Function: chk_ifexists 51# 52# Description: - Check if command required for this test exits. 53# 54# Input: - $1 - calling test case. 55# - $2 - command that needs to be checked. 56# 57# Return: - zero on success. 58# - non-zero on failure. 59chk_ifexists() 60{ 61 RC=0 62 63 which $2 &>$LTPTMP/tst_numa.err || RC=$? 64 if [ $RC -ne 0 ] 65 then 66 tst_brkm TBROK NULL "$1: command $2 not found." 67 fi 68 return $RC 69} 70 71# Function: extract_numastat 72# 73# Description: - extract the value of given row,column from the numastat output . 74# 75# Input: - $1 - row number. 76# - $2 - column number. 77# 78# Return: - zero on success. 79# - non-zero on failure. 80extract_numastat() 81{ 82 RC=0 83 84 # check whether numastat output is changed 85 86 RC=$(awk ' 87 { if ( NR == '$2' ){ 88 print $1; 89 } 90 } 91 ' $LTPTMP/numalog) 92 if [ $RC != $1 ] 93 then 94 tst_brkm TBROK NULL "numastat o/p seems to be changed, $1 expected to be in the row $2" 95 return 1 96 fi 97 98 RC=$(awk ' 99 { if ( NR == '$2' ){ 100 print $'$3'; 101 } 102 } 103 ' $LTPTMP/numalog) 104 return 0 105} 106 107 108 109# Function: comparelog 110# 111# Description: - return the difference of input arguments if they are in 112# increasing order. 113# 114# Input: - $1 - original value. 115# - $2 - changed value. 116# 117# Return: - difference of arguments on success. 118comparelog() 119{ 120 121 if [ $2 -gt $1 ] 122 then 123 RC=$[$2-$1] 124 else 125 RC=0 126 fi 127 return 0 128} 129 130 131 132# Function: init 133# 134# Description: - Check if command required for this test exits. 135# - Initialize global variables. 136# 137# Return: - zero on success. 138# - non-zero on failure. 139init() 140{ 141 # Initialize global variables. 142 export RC=0 143 export TST_TOTAL=6 144 export TCID="Initnuma" 145 export TST_COUNT=0 146 147 # Page Size 148 page_size=0 149 150 # row definitions, pls see at the top of this file 151 numa_hit=2 152 numa_miss=3 153 numa_foreign=4 154 interleave_hit=5 155 local_node=6 156 other_node=7 157 158 #arguments to memory exercise program support_numa.c 159 PRT_PG_SIZE=1 160 ALLOC_1MB=2 161 PAUSE=3 162 163 # Inititalize cleanup function. 164 trap "cleanup" 0 165 166 # create the temporary directory used by this testcase 167 if [ -z $TMP ] 168 then 169 LTPTMP=/tmp/tst_numa.$$ 170 else 171 LTPTMP=$TMP/tst_numa.$$ 172 fi 173 174 mkdir -p $LTPTMP &>/dev/null || RC=$? 175 if [ $RC -ne 0 ] 176 then 177 tst_brkm TBROK NULL "INIT: Unable to create temporary directory" 178 return $RC 179 fi 180 181 # check if commands tst_*, numa*, awk exists. 182 chk_ifexists INIT tst_resm || return $RC 183 chk_ifexists INIT numactl || return $RC 184 chk_ifexists INIT numastat || return $RC 185 chk_ifexists INIT awk || return $RC 186 chk_ifexists INIT cat || return $RC 187 chk_ifexists INIT kill || return $RC 188 189 RC=0 190 #Set pagesize 191 support_numa $PRT_PG_SIZE > $LTPTMP/numaarg || RC=$? 192 if [ $RC -ne 0 ] 193 then 194 tst_resm TFAIL "INIT: memory exerciser program support_numa exits abnormally" 195 fi 196 page_size=$(cat $LTPTMP/numaarg) 197 198 tst_resm TINFO "INIT: Numa tests will start now !!" 199} 200 201 202 203# Function: cleanup 204# 205# Description: - remove temporaty files and directories. 206# 207# Return: - zero on success. 208# - non-zero on failure. 209cleanup() 210{ 211 TCID=exitnuma 212 RC=0 213 214 # remove all the temporary files created by this test. 215 tst_resm TINFO "CLEAN: removing $LTPTMP" 216 rm -fr $LTPTMP || RC=$? 217 return $RC 218} 219 220 221 222# Function: test01 223# 224# Description: - Verification of local node and memory affinity 225# 226# Return: - zero on success. 227# - non-zero on failure. 228test01() 229{ 230 TCID=numa01 231 TST_COUNT=1 232 233 RC=0 # Return value from commands. 234 Prev_value=0 # extracted from the numastat o/p 235 Curr_value=0 # Current value extracted from numastat o/p 236 Exp_incr=0 # 1 MB/ PAGESIZE 237 col=0 238 MB=$[1024*1024] 239 240 # Increase in numastat o/p is interms of pages 241 Exp_incr=$[$MB/$page_size] 242 243 COUNTER=1 244 for node in `echo $nodes_list`; do 245 col=$[$COUNTER+1] #Node number in numastat o/p 246 numastat > $LTPTMP/numalog 247 extract_numastat local_node $local_node $col || return 1 248 Prev_value=$RC 249 numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB 250 numastat > $LTPTMP/numalog 251 extract_numastat local_node $local_node $col || return 1 252 Curr_value=$RC 253 comparelog $Prev_value $Curr_value 254 if [ $RC -lt $Exp_incr ] 255 then 256 tst_resm TFAIL \ 257 "Test #1: NUMA hit and localnode increase in node$node is less than expected" 258 return 1 259 fi 260 COUNTER=$[$COUNTER+1] 261 done 262 tst_resm TPASS "NUMA local node and memory affinity -TEST01 PASSED !!" 263 return 0 264} 265 266 267 268# Function: test02 269# 270# Description: - Verification of memory allocated from preferred node 271# 272# Return: - zero on success. 273# - non-zero on failure. 274test02() 275{ 276 TCID=numa02 277 TST_COUNT=2 278 279 RC=0 # Return value from commands. 280 Prev_value=0 # extracted from the numastat o/p 281 Curr_value=0 # Current value extracted from numastat o/p 282 Exp_incr=0 # 1 MB/ PAGESIZE 283 col=0 284 MB=$[1024*1024] 285 286 # Increase in numastat o/p is interms of pages 287 Exp_incr=$[$MB/$page_size] 288 289 COUNTER=1 290 for node in `echo $nodes_list`; do 291 292 if [ $total_nodes -eq 1 ] 293 then 294 tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine" 295 return 1 296 fi 297 298 if [ $COUNTER -eq $total_nodes ] #wrap up for last node 299 then 300 Preferred_node=`echo $nodes_list | cut -d ' ' -f 1` 301 col=2 #column represents node0 in numastat o/p 302 else 303 # always next node is preferred node 304 Preferred_node=`echo $nodes_list | cut -d ' ' -f $[COUNTER+1]` 305 col=$[$COUNTER+2] #Preferred Node number in numastat o/p 306 fi 307 308 numastat > $LTPTMP/numalog 309 extract_numastat other_node $other_node $col || return 1 310 Prev_value=$RC 311 numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $ALLOC_1MB 312 sleep 2s #In RHEL collection of statistics takes more time. 313 numastat > $LTPTMP/numalog 314 extract_numastat other_node $other_node $col || return 1 315 Curr_value=$RC 316 comparelog $Prev_value $Curr_value 317 if [ $RC -lt $Exp_incr ] 318 then 319 tst_resm TFAIL \ 320 "Test #2: NUMA hit and othernode increase in node$node is less than expected" 321 return 1 322 fi 323 COUNTER=$[$COUNTER+1] 324 done 325 tst_resm TPASS "NUMA preferred node policy -TEST02 PASSED !!" 326 return 0 327} 328 329 330# Function: test03 331# 332# Description: - Verification of memory interleaved on all nodes 333# 334# Return: - zero on success. 335# - non-zero on failure. 336test03() 337{ 338 TCID=numa03 339 TST_COUNT=3 340 341 RC=0 # Return value from commands. 342 Prev_value=0 # extracted from the numastat o/p 343 declare -a parray # array contains previous value of all nodes 344 Curr_value=0 # Current value extracted from numastat o/p 345 Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) 346 col=0 347 MB=$[1024*1024] 348 349 # Increase in numastat o/p is interms of pages 350 Exp_incr=$[$MB/$page_size] 351 # Pages will be allocated using round robin on nodes. 352 Exp_incr=$[$Exp_incr/$total_nodes] 353 354 # Check whether the pages are equally distributed among available nodes 355 numastat > $LTPTMP/numalog 356 COUNTER=1 357 for node in `echo $nodes_list`; do 358 col=$[$COUNTER+1] #Node number in numastat o/p 359 extract_numastat interleave_hit $interleave_hit $col || return 1 360 Prev_value=$RC 361 parray[$COUNTER]=$Prev_value 362 COUNTER=$[$COUNTER+1] 363 done 364 365 numactl --interleave=all support_numa $ALLOC_1MB 366 sleep 2s #In RHEL collection of statistics takes more time. 367 368 numastat > $LTPTMP/numalog 369 COUNTER=1 370 for node in `echo $nodes_list`; do 371 col=$[$COUNTER+1] #Node number in numastat o/p 372 extract_numastat interleave_hit $interleave_hit $col || return 1 373 Curr_value=$RC 374 comparelog ${parray[$COUNTER]} $Curr_value 375 if [ $RC -lt $Exp_incr ] 376 then 377 tst_resm TFAIL \ 378 "Test #3: NUMA interleave hit in node$node is less than expected" 379 return 1 380 fi 381 COUNTER=$[$COUNTER+1] 382 done 383 tst_resm TPASS "NUMA interleave policy -TEST03 PASSED !!" 384 return 0 385} 386 387 388 389# Function: test04 390# 391# Description: - Verification of physical cpu bind 392# 393# Return: - zero on success. 394# - non-zero on failure. 395test04() 396{ 397 398 TCID=numa04 399 TST_COUNT=4 400 401 no_of_cpus=0 #no. of cpu's exist 402 run_on_cpu=0 403 running_on_cpu=0 404 405 no_of_cpus=$(tst_ncpus) 406 # not sure whether cpu's can't be in odd number 407 run_on_cpu=$[$[$no_of_cpus+1]/2] 408 numactl --physcpubind=$run_on_cpu support_numa $PAUSE & #just waits for sigint 409 pid=$! 410 var=`awk '{ print $2 }' /proc/$pid/stat` 411 while [ $var = '(numactl)' ]; do 412 var=`awk '{ print $2 }' /proc/$pid/stat` 413 done 414 # Warning !! 39 represents cpu number, on which process pid is currently running and 415 # this may change if Some more fields are added in the middle, may be in future 416 running_on_cpu=$(awk '{ print $39; }' /proc/$pid/stat) 417 if [ $running_on_cpu -ne $run_on_cpu ] 418 then 419 tst_resm TFAIL \ 420 "Test #4: Process running on cpu$running_on_cpu but expected to run on cpu$run_on_cpu" 421 return 1 422 fi 423 RC=0 424 kill -INT $pid || RC=$? 425 if [ $RC -ne 0 ] 426 then 427 tst_brkm TBROK NULL "Kill on process $pid fails" 428 fi 429 tst_resm TPASS "NUMA phycpubind policy -TEST04 PASSED !!" 430 return 0 431} 432 433 434 435# Function: test05 436# 437# Description: - Verification of local node allocation 438# 439# Return: - zero on success. 440# - non-zero on failure. 441test05() 442{ 443 TCID=numa05 444 TST_COUNT=5 445 446 RC=0 # Return value from commands. 447 Prev_value=0 # extracted from the numastat o/p 448 Curr_value=0 # Current value extracted from numastat o/p 449 Exp_incr=0 # 1 MB/ PAGESIZE 450 col=0 451 MB=$[1024*1024] 452 453 # Increase in numastat o/p is interms of pages 454 Exp_incr=$[$MB/$page_size] 455 456 COUNTER=1 457 for node in `echo $nodes_list`; do 458 col=$[$COUNTER+1] #Node number in numastat o/p 459 numastat > $LTPTMP/numalog 460 extract_numastat local_node $local_node $col || return 1 461 Prev_value=$RC 462 numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB 463 numastat > $LTPTMP/numalog 464 extract_numastat local_node $local_node $col || return 1 465 Curr_value=$RC 466 comparelog $Prev_value $Curr_value 467 if [ $RC -lt $Exp_incr ] 468 then 469 tst_resm TFAIL \ 470 "Test #5: NUMA hit and localnode increase in node$node is less than expected" 471 return 1 472 fi 473 COUNTER=$[$COUNTER+1] 474 done 475 tst_resm TPASS "NUMA local node allocation -TEST05 PASSED !!" 476 return 0 477} 478 479 480 481# Function: test06 482# 483# Description: - Verification of shared memory interleaved on all nodes 484# 485# Return: - zero on success. 486# - non-zero on failure. 487test06() 488{ 489 TCID=numa06 490 TST_COUNT=6 491 492 RC=0 # Return value from commands. 493 Prev_value=0 # extracted from the numastat o/p 494 declare -a parray # array contains previous value of all nodes 495 Curr_value=0 # Current value extracted from numastat o/p 496 Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) 497 col=0 498 MB=$[1024*1024] 499 500 # Increase in numastat o/p is interms of pages 501 Exp_incr=$[$MB/$page_size] 502 # Pages will be allocated using round robin on nodes. 503 Exp_incr=$[$Exp_incr/$total_nodes] 504 505 # Check whether the pages are equally distributed among available nodes 506 numastat > $LTPTMP/numalog 507 COUNTER=1 508 for node in `echo $nodes_list`; do 509 col=$[$COUNTER+1] #Node number in numastat o/p 510 extract_numastat numa_hit $numa_hit $col || return 1 511 Prev_value=$RC 512 parray[$COUNTER]=$Prev_value 513 COUNTER=$[$COUNTER+1] 514 done 515 516 numactl --length=1M --file /dev/shm/numa_shm --interleave=all --touch 517 sleep 2s #In RHEL collection of statistics takes more time. 518 519 numastat > $LTPTMP/numalog 520 COUNTER=1 521 for node in `echo $nodes_list`; do 522 col=$[$COUNTER+1] #Node number in numastat o/p 523 extract_numastat numa_hit $numa_hit $col || return 1 524 Curr_value=$RC 525 comparelog ${parray[$COUNTER]} $Curr_value 526 if [ $RC -lt $Exp_incr ] 527 then 528 tst_resm TFAIL \ 529 "Test #6: NUMA numa_hit for shm file numa_shm in node$node is less than expected" 530 return 1 531 fi 532 COUNTER=$[$COUNTER+1] 533 done 534 tst_resm TPASS "NUMA interleave policy on shared memory -TEST06 PASSED !!" 535 RC=0 536 rm -r /dev/shm/numa_shm || RC=$? 537 if [ $RC -ne 0 ] 538 then 539 tst_resm TINFO "Test #6: Failed removing shared memory file numa_shm" 540 return 1 541 fi 542 return 0 543} 544 545# Function: test07 546# 547# Description: - Verification of numademo 548# 549# Return: - zero on success. 550# - non-zero on failure. 551test07() 552{ 553 TCID=numa07 554 TST_COUNT=7 555 556 RC=0 # Return value from commands. 557 Prev_value=0 # extracted from the numastat o/p 558 declare -a parray # array contains previous value of all nodes 559 Curr_value=0 # Current value extracted from numastat o/p 560 Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) 561 col=0 562 msize=1000 563 KB=1024 564 # Increase in numastat o/p is interms of pages 565 Exp_incr=$[($KB * $msize)/$page_size] 566 # Pages will be allocated using round robin on nodes. 567 Exp_incr=$[$Exp_incr/$total_nodes] 568 569 # Check whether the pages are equally distributed among available nodes 570 numastat > $LTPTMP/numalog 571 COUNTER=1 572 for node in `echo $nodes_list`; do 573 col=$[$COUNTER+1] #Node number in numastat o/p 574 extract_numastat interleave_hit $interleave_hit $col || return 1 575 Prev_value=$RC 576 parray[$COUNTER]=$Prev_value 577 COUNTER=$[$COUNTER+1] 578 done 579 580 numademo -c ${msize}k > $LTPTMP/demolog 581 sleep 2s #In RHEL collection of statistics takes more time. 582 583 numastat > $LTPTMP/numalog 584 COUNTER=1 585 x=0 586 for node in `echo $nodes_list`; do 587 col=$[$COUNTER+1] #Node number in numastat o/p 588 extract_numastat interleave_hit $interleave_hit $col || return 1 589 Curr_value=$RC 590 comparelog ${parray[$COUNTER]} $Curr_value 591 counter=$[$counter+1] 592 if [ $RC -le $Exp_incr ] 593 then 594 x=1 595 break; 596 fi 597 COUNTER=$[$COUNTER+1] 598 done 599 if [ $x -eq 0 ] 600 then 601 tst_resm TPASS "NUMADEMO policies -TEST07 PASSED !!" 602 return 0 603 else 604 tst_resm TFAIL "Test #7: NUMA interleave hit is less than expected" 605 return 1 606 fi 607} 608 609# Function: test08 610# 611# Description: - Verification of memhog with interleave policy 612# 613# Return: - zero on success. 614# - non-zero on failure. 615test08() 616{ 617 TCID=numa08 618 TST_COUNT=8 619 620 RC=0 # Return value from commands. 621 Prev_value=0 # extracted from the numastat o/p 622 declare -a parray # array contains previous value of all nodes 623 Curr_value=0 # Current value extracted from numastat o/p 624 Exp_incr=0 # 1 MB/ (PAGESIZE*num_of_nodes) 625 col=0 626 MB=$[1024*1024] 627 628 # Increase in numastat o/p is interms of pages 629 Exp_incr=$[$MB/$page_size] 630 # Pages will be allocated using round robin on nodes. 631 Exp_incr=$[$Exp_incr/$total_nodes] 632 633 # Check whether the pages are equally distributed among available nodes 634 numastat > $LTPTMP/numalog 635 COUNTER=1 636 for node in `echo $nodes_list`; do 637 col=$[$COUNTER+1] #Node number in numastat o/p 638 extract_numastat interleave_hit $interleave_hit $col || return 1 639 Prev_value=$RC 640 parray[$COUNTER]=$Prev_value 641 COUNTER=$[$COUNTER+1] 642 done 643 numactl --interleave=all memhog 1MB 644 sleep 2s #In RHEL collection of statistics takes more time. 645 646 numastat > $LTPTMP/numalog 647 COUNTER=1 648 for node in `echo $nodes_list`; do 649 col=$[$COUNTER+1] #Node number in numastat o/p 650 extract_numastat interleave_hit $interleave_hit $col || return 1 651 Curr_value=$RC 652 comparelog ${parray[$COUNTER]} $Curr_value 653 if [ $RC -lt $Exp_incr ] 654 then 655 tst_resm TFAIL \ 656 "Test #8: NUMA interleave hit in node$node is less than expected" 657 return 1 658 fi 659 COUNTER=$[$COUNTER+1] 660 done 661 tst_resm TPASS "NUMA MEMHOG policy -TEST08 PASSED !!" 662 return 0 663} 664 665# Function: hardware cheking with numa_node_size api 666# 667# Description: - Returns the size of available nodes if success. 668# 669# Input: - o/p of numactl --hardware command which is expected in the format 670# shown below 671# available: 2 nodes (0-1) 672# node 0 size: 7808 MB 673# node 0 free: 7457 MB 674# node 1 size: 5807 MB 675# node 1 free: 5731 MB 676# node distances: 677# node 0 1 678# 0: 10 20 679# 1: 20 10 680# 681# Return: - zero on success. 682# - non-zero on failure. 683# 684test09() 685{ 686 TCID=numa09 687 TST_COUNT=9 688 689 RC=0 # Return value from commands. 690 Prev_value=0 # extracted from the numastat o/p 691 Curr_value=0 # Current value extracted from numastat o/p 692 Exp_incr=0 # 1 MB/ PAGESIZE 693 col=0 694 MB=$[1024*1024] 695 # Increase in numastat o/p is interms of pages 696 Exp_incr=$[$MB/$page_size] 697 698 numactl --hardware > $LTPTMP/avail_nodes 699 RC=$(awk '{ if ( NR == 1 ) {print $1;} }' $LTPTMP/avail_nodes) 700 if [ $RC = "available:" ] 701 then 702 703 RC=$(awk '{ if ( NR == 1 ) {print $3;} }' $LTPTMP/avail_nodes) 704 if [ $RC = "nodes" ] 705 then 706 RC=$(awk '{ if ( NR == 1 ) {print $2;} }' $LTPTMP/avail_nodes) 707 708 tst_resm TPASS "NUMA policy on lib NUMA_NODE_SIZE API -TEST09 PASSED !!" 709 else 710 tst_resm TINFO "Test #9: Failed with numa policy" 711 fi 712 else 713 tst_resm TINFO "Test #9: Failed with numa policy" 714 fi 715} 716# Function: test10 717# 718# Description: - Verification of migratepages 719# 720# Return: - zero on success. 721# - non-zero on failure. 722test010() 723{ 724 TCID=numa10 725 TST_COUNT=10 726 RC=0 727 Prev_value=0 728 Curr_value=0 729 730 COUNTER=1 731 for node in `echo $nodes_list`; do 732 733 if [ $total_nodes -eq 1 ] 734 then 735 tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine" 736 return 1 737 fi 738 739 if [ $COUNTER -eq $total_nodes ]; then 740 Preferred_node=`echo $nodes_list | cut -d ' ' -f 1` 741 col=2 742 else 743 Preferred_node=`echo $nodes_list | cut -d ' ' -f $[$COUNTER+1]` 744 col=$[$COUNTER+2] 745 fi 746 747 numastat > $LTPTMP/numalog 748 extract_numastat other_node $other_node $col || return 1 749 Prev_value=$RC 750 numactl --preferred=$node support_numa $PAUSE & 751 pid=$! 752 migratepages $pid $node $Preferred_node 753 numastat > $LTPTMP/numalog 754 extract_numastat other_node $other_node $col || return 1 755 Curr_value=$RC 756 kill -INT $pid 757 if [ $RC -lt $Prev_value ]; then 758 tst_resm TFAIL \ 759 "Test #10: NUMA migratepages is not working fine" 760 return 1 761 fi 762 COUNTER=$[$COUNTER+1] 763 done 764 tst_resm TPASS "NUMA MIGRATEPAGES policy -TEST10 PASSED !!" 765 return 0 766} 767 768# Function: main 769# 770# Description: - Execute all tests and report results. 771# 772# Exit: - zero on success 773# - non-zero on failure. 774 #WARNING!! Never use duplicate variables here... 775 TCID=numa 776 no_of_test=10 #total no. of testcases 777 no_of_test_failed=0 #total no. of testcases failed 778 numa_ret=0 #return value of main script 779 780 init_ret=0 781 init || init_ret=$? 782 if [ $init_ret -ne 0 ] 783 then 784 tst_resm TFAIL "INIT NUMA FAILED !!" 785 exit $RC 786 fi 787 788 total_nodes=0 # total no. of numa nodes 789 # all availiable nodes id list 790 nodes_list=`numactl --show | grep nodebind | cut -d ':' -f 2` 791 for node in `echo $nodes_list`; do 792 total_nodes=$[$total_nodes+1] 793 done 794 tst_resm TINFO "The system contains $total_nodes nodes: $nodes_list" 795 if [ $total_nodes -le 1 ]; then 796 tst_resm TCONF "your machine does not support numa policy or 797 your machine is not a NUMA machine" 798 exit 0 799 fi 800 801 # call each testcases sequentially 802 COUNT=1 803 while [ $COUNT -le $no_of_test ]; do 804 call_test=$(echo test0$COUNT) 805 func_ret=0 806 $call_test || func_ret=$? 807 if [ $func_ret -ne 0 ] 808 then 809 no_of_test_failed=$[$no_of_test_failed+1] 810 fi 811 COUNT=$[$COUNT+1] 812 done 813 814 TCID=numa 815 TST_COUNT=0 816 817 if [ $no_of_test_failed -ne 0 ] 818 then 819 numa_ret=1 #set return value to non-zero if any one of the testcas got failed 820 tst_resm TINFO "A total of $no_of_test_failed numa testcases FAILED !!" 821 else 822 numa_ret=0 823 tst_resm TINFO "All numa testcases PASSED !!" 824 fi 825 826exit $numa_ret 827 828