Chinaunix首页 | 论坛 | 博客
  • 博客访问: 915625
  • 博文数量: 453
  • 博客积分: 7865
  • 博客等级: 少将
  • 技术积分: 5673
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-29 16:21
个人简介

时光荏苒..

文章分类
文章存档

2015年(46)

2014年(22)

2013年(68)

2012年(218)

2011年(99)

分类: Python/Ruby

2013-06-25 17:09:34

sed 匹配 /* xq0 <- tmp4 */ 等
sed -i 's#\/\* .* tmp.* \*\/#  #g' $i
sed -i 's#\/\* tmp.* \*\/#  #g' $i



  1. #!/bin/bash

  2. # This shell script is used to run 'test' binary and diff
  3. # the execute result with the expected 'result' file.
  4. #
  5. #
  6. # The 'result' file example:
  7. # ArithmeticConversions_Vectors_uintn: uintn vs bool: (2, 2)
  8. # ArithmeticConversions_Vectors_uintn: uintn vs char: (2, 2)
  9. # ArithmeticConversions_Vectors_uintn: uintn vs uchar: (2, 2)


  10. topdir=`pwd`

  11. ########################################################
  12. ## log file definations, user can change them
  13. logfile_dir=log_dir
  14. ok_log_file=ok_item.log
  15. ng_log_file=ng_item.log
  16. warning_log_file=warning_item.log
  17. ########################################################



  18. # the following is important for test, user do not
  19. logfile=$topdir/$logfile_dir/$ng_log_file
  20. okfile=$topdir/$logfile_dir/$ok_log_file
  21. Warningfile=$topdir/$logfile_dir/$warning_log_file

  22. linefile=$topdir/linefile
  23. diff_file=$topdir/diff.log
  24. tmplog=$topdir/tmplog


  25. ## variable used for count
  26. OK_CNT=0
  27. NG_CNT=0
  28. TOTAL_CNT=0
  29. num=0
  30. ok_num=0

  31. ## function definations
  32. log_title()
  33. {
  34.         # creat log dir
  35.         mkdir -p $logfile_dir

  36.         #Test result log file title
  37.         echo "Test result log:" >$logfile
  38.         echo "" >>$logfile

  39.         #echo "[NG Item Directory Path]:[item in test case]" >>$logfile


  40.         #OK log file title
  41.         echo "OK item:" >$okfile
  42.         echo "Warning item:" >$Warningfile
  43.         #echo "=========" >>$okfile
  44. }

  45. print_note()
  46. {
  47.         #echo ""
  48.         #echo "----- Printing the log file '$logfile': -----"
  49.         #cat $logfile

  50.         echo ""
  51.         echo -e "\033[41;37m**********************************************\033[0m"
  52.         echo -e "\033[41;37m* Please see the test result in the directory:\033[0m"
  53.         echo -e "\033[41;37m* $logfile_dir \033[0m"
  54. # echo "'$logfile'"
  55. # echo "*And see the OK items for detail in file:"
  56. # echo "'$okfile'"
  57.         echo -e "\033[41;37m**********************************************\033[0m"
  58.         #echo "********************************************"
  59.         echo ""
  60. }

  61. count()
  62. {
  63.         # print to ng log file
  64.         ((TOTAL_CNT=OK_CNT+NG_CNT))
  65.         echo "" >>$logfile
  66.         echo "========================" >>$logfile
  67.         echo "Total items count: $TOTAL_CNT" >> $logfile
  68.         echo "OK items count: $OK_CNT" >> $logfile
  69.         echo "NG items count: $NG_CNT" >> $logfile
  70.         echo "========================" >>$logfile

  71.         # print to ok log file
  72.         echo "" >>$okfile
  73.         echo "========================" >>$okfile
  74.         echo "Total items count: $TOTAL_CNT" >> $okfile
  75.         echo "OK items count: $OK_CNT" >> $okfile
  76.         echo "NG items count: $NG_CNT" >> $okfile
  77.         echo "========================" >>$okfile
  78. }

  79. ok_case()
  80. {
  81.                 while read line
  82.                 do
  83.                         echo $line >$linefile
  84.                         ok_case_str=`awk -F '[:]' '{printf $2}' $linefile`

  85.                         # add Directory for each item:
  86.                         echo "" >>$okfile
  87.                         #echo " - Directory: -" >>$okfile
  88.                         ((ok_num++))
  89.                         echo "-- OK item$ok_num --" >>$okfile
  90.                         #echo " - : -" >>$okfile
  91.                         #ng_item=`pwd`
  92.                         #ng_dir=${ng_item#*"$topdir/"}
  93.                         ok_item=`pwd`
  94.                         ok_dir=${ok_item#*"$topdir/"}
  95.                         echo "$ok_dir" >>$okfile
  96. # echo "################## $ok_case_str"
  97.                         if [[ $ok_case_str != *Makefil* ]];then
  98.                                 echo "Case:$ok_case_str" >> $okfile
  99.                         else
  100. # echo '@@@@@@@@@@@@@@@@@@@@@@'
  101.                                 echo 'Case: *' >> $okfile
  102.                         fi

  103. # awk -F '[:]' '{printf substr($1,3)}' $linefile >> $logfile

  104.                         #record the test items in the test case if exist
  105.                 done < result
  106. }

  107. exec_diff()
  108. {
  109.         ./test &> $tmplog
  110.         diff_ret=`diff -a $tmplog result|grep -a \>`
  111.         diff_ret2=`diff -a $tmplog result|grep -a \<`
  112.         diff -a $tmplog result|grep -a \> >$diff_file
  113.         case_item_cnt=`wc -l result|awk '{printf $1}'`


  114.         if [ -z "$diff_ret" ];then
  115.                 if [ -n "$diff_ret2" ]; then
  116.                         echo "Warning! in '`pwd`'" >> $Warningfile
  117. # exit 1
  118.                 else
  119.                 #run OK.
  120.                 #record OK item:
  121.                 ok_item=`pwd`
  122.                 ok_dir=${ok_item#*"$topdir/"}
  123.                 #echo "@@@@@@@@@@@@@@@@@@@@@@" >>$okfile
  124.                 #echo "" >>$okfile
  125.                 #echo "-111 Directory: -" >>$okfile #mv to else
  126.                 #echo "$ok_dir" >>$okfile

  127.                 #record OK cases:
  128.                 if [ $case_item_cnt -gt 1 ];then
  129.                         # there are more than one test cases.
  130.                         ok_case
  131.                 else
  132.                         # there is only one test case.
  133.                         echo "" >>$okfile
  134.                         ((ok_num++))
  135.                         echo "-- OK item$ok_num --" >>$okfile
  136.                         #echo "- Directory: -" >>$okfile
  137.                         echo "$ok_dir" >>$okfile
  138.                 fi

  139.                 ((OK_CNT=OK_CNT+case_item_cnt)) #add OK item count number.
  140.                 fi
  141.         else
  142.         #run NG.
  143.                 case_ng_cnt=`wc -l $diff_file|awk '{printf $1}'`
  144.                 ((NG_CNT=NG_CNT+case_ng_cnt))
  145.                 ((OK_CNT=OK_CNT+case_item_cnt-case_ng_cnt))

  146. # cat $diff_file|
  147.                 while read line
  148.                 do
  149.                         (( num++ ))
  150.                         #echo "----------" >>$logfile
  151.                         echo "-- NG item$num --" >>$logfile
  152. # echo "In test directroy:" >>$logfile

  153.                         #record the Directory Structure of test case
  154.                         echo $line >$linefile
  155. # awk -F '[:]' '{printf substr($1,3)}' $linefile >> $logfile
  156.                         ng_item=`pwd`
  157.                         ng_dir=${ng_item#*"$topdir/"}
  158.                         echo "$ng_dir" >>$logfile


  159.                         #record the test items in the test case if exist
  160.                         case_str=`awk -F '[:]' '{printf $2}' $linefile`
  161.                         #judge test items exist and test items is not none case
  162.                         #if [ -n "$case_str" -a "$case_str" != "none" ];then
  163.                         if [ -n "$case_str" ];then
  164.                                 if [ "$case_str" != "none" ];then
  165.                                         echo "Case:$case_str" >> $logfile
  166.                         #else
  167.                                 #enter newline
  168. # echo "" >> $logfile
  169.                         # echo "" #do nothing
  170.                                 fi
  171.                         fi
  172. # #echo "------------------------------------------------" >>$logfile
  173.                 echo "" >>$logfile
  174.                 done <$diff_file

  175.                 #record ok item cases:
  176.                 if [ $case_item_cnt -gt 1 ];then
  177.                         #echo "****************************" >>$okfile
  178. # echo "" >>$okfile
  179. # echo "- Directory: -" >>$okfile #mv to each item
  180. # echo "$ng_dir" >>$okfile

  181.                         #ok_case
  182.                         while read line
  183.                         do
  184.                                 echo $line >$linefile
  185.                                 ok_case_str=`awk -F '[:]' '{printf $2}' $linefile`

  186.                                 while read line
  187.                                 do
  188.                                         echo $line >$linefile
  189.                                 #record the test items in the test case if exist
  190.                                 case_str=`awk -F '[:]' '{printf $2}' $linefile`
  191.                                 #judge test items exist and test items is not none case
  192.                                 if [ "$ok_case_str" == "$case_str" ];then
  193.                                                 #echo "Case:$ok_case_str" >> $okfile
  194.                                                 ok_case_str="NG"
  195.                                 fi
  196.                                 done <$diff_file

  197.                                 if [ "$ok_case_str" != "NG" ];then
  198.                                         # there are ok test cases.
  199.                                         echo "" >>$okfile
  200.                                         ((ok_num++))
  201.                                         echo "-- OK item$ok_num --" >>$okfile
  202.                                         #echo " - Directory: -" >>$okfile
  203.                                         echo "$ng_dir" >>$okfile
  204.                                         echo "Case:$ok_case_str" >> $okfile
  205.                                 fi

  206.                         done < result #end while

  207.                         #echo "))))))))))))))))))))))))))))" >>$okfile
  208.                 fi
  209.                 #end record ok item

  210.         fi
  211. }

  212. main_fun()
  213. {
  214.         if [ -f Makefile ];then # if Makefile exist
  215.         list=`grep SUBDIRS.*= Makefile |awk -F= '{printf $2}'`
  216.         if [ -z "$list" ];then
  217.                 #there is no sub dir any more
  218.                 if [ $OK_CNT != $ok_num ];then
  219.         # echo "error found: ok_item_count is error! in: `pwd`" >> $Warningfile
  220.         # exit 1
  221.                 echo ""
  222.                 fi
  223.                 exec_diff
  224.                 #cd ../
  225.         else
  226. # echo "There is sub dir in [`pwd`]--- $list ---"
  227. # echo "Entering directory '`pwd`'"
  228. # echo "Testing subdir '$list'"
  229.                 for dir in $list
  230.                         do
  231.                                 if [ -d $dir ];then
  232.                                         cd $dir
  233.                                         echo "Entering directory '`pwd`'"
  234.                                         main_fun
  235.                                         cd ..
  236.                                 else
  237.                                         echo "Warning: no such directory: `pwd`/$dir" >>$logfile
  238.                                 fi
  239.                         done
  240.                 fi
  241. else
  242.         echo "Warning: there is no 'Makefile' find in '`pwd`'" >>$logfile
  243. fi #end if Makefile exist
  244. }

  245. del_log()
  246. {
  247.         rm -f $linefile
  248.         rm -f $diff_file
  249.         rm -f $tmplog
  250. }

  251. usage_help()
  252. {
  253.         while true;do
  254.                 echo ""
  255.                 echo "The work top directory is:"
  256.                 echo -e "\033[41;37m $WORKTOP_DIR\033[0m"
  257. # echo "$WORKTOP_DIR"
  258. # echo ""
  259.                 echo "---------------------------------------------------"
  260.                 echo "Please make sure that is right?(y/n)"
  261.                 echo "---------------------------------------------------"
  262. # echo " source setup_env.sh (y/n)"
  263.                 #echo "(y/n)"
  264.                 read Arg
  265.                 case $Arg in
  266.                 Y|y|yes|YES)
  267.                         break
  268.                         ;;
  269.                 N|n|NO|no)
  270.                         echo "Please modify environment setting in 'setup_env.sh'"
  271.                         echo "See how to modify according to the User Manual."
  272.                         echo ""
  273.                         exit
  274.                         ;;
  275.                 esac
  276.         done
  277. }

  278. #Main flow

  279. source setup_env.sh
  280. usage_help
  281. make clean;make
  282. touch /tmp/test_opencl.h
  283. log_title
  284. main_fun
  285. count
  286. del_log
  287. make clean;
  288. print_note
  289. rm -f /tmp/test_opencl.h


  1. #target="1409_s16.c"
  2. target="1409_s16.c 1417_s32.c 1428_s32.c 1440_su.c 1449_s16.c 1512_i8.c 1516_s16.c 1409_s8.c 1417_u32.c 1428_u32.c 1441_s16.c 1449_s8.c 1513_s16.c 1517_s16.c 1409_u16.c 1420_s8.c 1429_s9.c 1441_s8.c 1450_su16.c 1513_s32.c 1518_s16.c 1409_u8.c 1421_su8.c 1430_su9.c 1442_su8.c 1450_su8.c 1513_s8.c 1519_s16.c 1410_su16.c 1422_s16.c 1431_u16.c 1443_s16.c 1451_s32.c 1513_u16.c 1520_s16.c 1410_su8.c 1422_s8.c 1431_u8.c 1443_s8.c 1451_u32.c 1513_u32.c 1521_s16.c 1411_s32.c 1423_su8.c 1432_s16.c 1443_u16.c 1454_s8.c 1513_u8.c 1522_s16.c 1411_u32.c 1424_s16.c 1432_s8.c 1443_u8.c 1455_su8.c 1514_i16.c 1523_s16.c 1412_s9.c 1424_s8.c 1433_su16.c 1444_su16.c 1456_s16.c 1514_i32.c 1524_s16.c 1413_su9.c 1425_su8.c 1433_su8.c 1444_su8.c 1456_s8.c 1514_i8.c 1414_u16.c 1426_s16.c 1434_s32.c 1445_s32.c 1457_su.c 1515_s16.c 1414_u8.c 1426_s8.c 1434_u32.c 1445_u32.c 1458_s16.c 1515_s32.c 1415_s16.c 1426_u16.c 1437_s8.c 1446_s9.c 1458_s8.c 1515_s8.c 1415_s8.c 1426_u8.c 1438_su8.c 1447_su9.c 1459_su8.c 1515_u16.c 1416_su16.c 1427_su16.c 1439_s16.c 1448_u16.c 1512_i16.c 1515_u32.c 1416_su8.c 1427_su8.c 1439_s8.c 1448_u8.c 1512_i32.c 1515_u8.c"


  3. for i in $target
  4. do
  5. #ls $i > aa
  6. #num=`cat aa| awk -F '_' '{print $1}'`
  7. #echo $num

  8. #grep -rn "void optimize_asm_" $i > bb
  9. #str=`cat bb|awk -F '_' '{print $4}'`
  10. #echo $str > cc
  11. #str1=`cat cc|awk -F '(' '{print $1}'`
  12. #echo $str1
  13. #sed -i "s/$str1(/${str1}_$num(/g" $i
  14. #sed -i 's/static void expect_/void expect_/g' $i

  15. #line=`grep -rn "main" $i`
  16. #echo $line > dd
  17. #line1=`cat dd|awk -F ':' '{print $1}'`
  18. #echo $line1
  19. #re=$(($line1+5))
  20. #echo $re
  21. #sed -i "${re}a#endif" $i
  22. #sed -i "${line1}i#ifndef COMBINE" $i
  23. #sed -i 's/vr0:vr1/vxd0/g' $i
  24. #sed -i 's/vr2:vr3/vxd1/g' $i
  25. sed -i 's/vr4:vr5/vxd2/g' $i
  26. sed -i 's/vr6:vr7/vxd3/g' $i
  27. sed -i 's/vr8:vr9/vxd4/g' $i
  28. sed -i 's/vr10:vr11/vxd5/g' $i
  29. #sed -i 's/, xq/, vxq/g' $i
  30. #sed -i 's/,xq/,vxq/g' $i
  31. #sed -i 's/:xq/:vxq/g' $i
  32. done




阅读(1024) | 评论(0) | 转发(0) |
0

上一篇:c++ primer 习题

下一篇:sed 换行符

给主人留下些什么吧!~~