hns - 日記自動生成システム - Version 2.19.9

先月 2014年04月 来月
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Namazu for hns による簡易全文検索
詳しくは 詳細指定/ヘルプを参照して下さい
検索式:

2014年04月30日(水) 旧暦 [n年日記] [更新:"2014/05/02 15:55:57"]

#1 [dejagnu] (dejagnu) make test

make test には dejagnu が良く使われる。dejagnu の中の runtest が呼ばれる。
runtest は、./config/default.exp を参照する
例えば testsuite という directory を作って、その下の config/default.exp に 一言、mytest_init と書いておくと、それを実行しようとする。 (その中身を定義する前に実行して見ると) その様子は次の通り
modena@makoto 12:04:57/140430(..mydirectory/testsuite)% runtest
WARNING: Couldn't find the global config file.
WARNING: No tool specified
Test Run By makoto on Wed Apr 30 12:05:00 2014
Native configuration is x86_64-unknown-netbsd6.1.2

                ===  tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/pkg/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/pkg/share/dejagnu/config/unix.exp as generic interface file for target.
Using ./config/default.exp as tool-and-target-specific interface file.
ERROR: (DejaGnu) proc "mytest_init" does not exist.
The error code is NONE
The info on the error is:
invalid command name "mytest_init"
    while executing
"::tcl_unknown mytest_init"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::tcl_unknown $args"

                ===  Summary ===

modena@makoto 12:05:00/140430(..mydirectory/testsuite)% 
そこで、dejagnu 的 hello world はどうなるか、とい話も思い着く。

Hello World by dejagnu:

modena@makoto 12:18:20/140430(..my_directory/testsuite)% ls -lR        
total 8
drwxr-xr-x  2 makoto  wheel  512 Apr 30 12:16 config
drwxr-xr-x  2 makoto  wheel  512 Apr 30 12:16 lib

./config:
total 4
-rw-r--r--  1 makoto  wheel  37 Apr 30 12:14 default.exp

./lib:
total 4
-rw-r--r--  1 makoto  wheel  107 Apr 30 12:15 mytest-defs.exp
modena@makoto 12:18:22/140430(..my_directory/testsuite)% head config/default.exp lib/mytest-defs.exp 
==> config/default.exp <==
load_lib mytest-defs.exp
mytest_init

==> lib/mytest-defs.exp <==
proc mytest_init { args } {
#   global variable_name

    print "   ***  Hello World ! *** "
    return
}

modena@makoto 12:18:36/140430(..my_directory/testsuite)%
少し比較もあるといいかな、と思ったり。 dejagnu の info を見ると、次のような節がある
3.4.3 Remote testing "Hello world"

proc regexp_diff:

modena@makoto 12:13:47/140501(/export/local-src)% cat -n binutils-2.24/binutils/testsuite/lib/binutils-common.exp | sed -n 181,342p | head -40
181  # Compare two files line-by-line.  FILE_1 is the actual output and FILE_2
182  # is the expected output.  Ignore blank lines in either file.
183  #
184  # FILE_2 is a series of regexps, comments and # directives.  The directives
185  # are:
186  #
187  #    #pass
188  #        Treat the test as a PASS if everything up till this point has
189  #        matched.  Ignore any remaining lines in either FILE_1 or FILE_2.
190  #
191  #    #failif
192  #        Reverse the sense of the test: expect differences to exist.
193  #
194  #    #...
195  #    REGEXP
196  #        Skip all lines in FILE_1 until the first that matches REGEXP.
197  #
198  # Other # lines are comments.  Regexp lines starting with the `!' character
199  # specify inverse matching (use `\!' for literal matching against a leading
200  # `!').  Skip empty lines in both files.
201  #
202  # The first optional argument is a list of regexp substitutions of the form:
203  #
204  #    EXP1 SUBSPEC1 EXP2 SUBSPEC2 ...
205  #
206  # This tells the function to apply each regexp substitution EXPi->SUBSPECi
207  # in order to every line of FILE_2.
208  #
209  # Return nonzero if differences exist.
210  proc regexp_diff { file_1 file_2 args } {
211      set eof -1
212      set end_1 0
213      set end_2 0
214      set differences 0
215      set diff_pass 0
216      set fail_if_match 0
217      set ref_subst ""
218      if { [llength $args] > 0 } {
219          set ref_subst [lindex $args 0]
220      }
...

333          } else {
334              set differences 0
335          }
336      }
337
338      close $file_a
339      close $file_b
340
341      return $differences
342  }
この regexp_diff は (binutils-2.24 の場合に)
gas/testsuite/gas/all/gas.exp
    proc test_cond
gas/testsuite/gas/*/*.exp
gas/testsuite/lib/gas-defs.exp
    proc run_dump_test
から呼ばれる
binutils-2.24/gas/testsuite/config/default.exp
  load_lib gas-defs.exp
  binutils-2.24/gas/testsuite/lib/gas-defs.exp
modena@makoto 11:34:59/140502(~)% grep '^proc ' binutils-2.24/gas/testsuite/lib/gas-defs.exp
proc load_common_lib { name } {
proc gas_version {} {
proc gas_host_run { cmd redir } {
proc gas_run { prog as_opts redir } {
proc gas_run_stdin { prog as_opts redir } {
proc all_ones { args } {
proc gas_start { prog as_opts } {
proc gas_finish { } {
proc want_no_output { testname } {
proc gas_test_old { file as_opts testname } {
proc gas_test { file as_opts var_opts testname } {
proc gas_test_ignore_stdout { file as_opts testname } {
proc gas_test_error { file as_opts testname } {
proc gas_exit {} {}
proc gas_init { args } {
proc get_standard_section_names {} {
proc run_dump_tests { testcases {extra_options {}} } {
proc run_dump_test { name {extra_options {}} } {
proc slurp_options { file } {
proc objdump { opts } {
proc objdump_start_no_subdir { prog opts } {
proc objdump_finish { } {
proc file_contents { filename } {
proc write_file { filename contents } {
proc verbose_eval { expr { level 1 } } {
proc run_list_test { name {opts {}} {testname {}} } {
proc run_list_test_stdin { name {opts {}} {testname {}} } {
config/default.exp -> gas_init
を呼出す。gas_init は、次の中に定義してある

testsuite/lib/gas-defs.exp
proc gas_init

/usr/pkg/bin/runtest:

which runtest とすると、/usr/pkg/bin/runtest を表示する。これは shell script。
modena@makoto 14:01:39/140502(..binutils-2.24/gas)% file `which runtest`
/usr/pkg/bin/runtest: POSIX shell script, ASCII text executable
この中で、runtest.exp を探し
# Find runtest.exp. First we look in its installed location,
# otherwise start if from the source tree.
最後に、次のように runtest.exp を呼んでいる
exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}

runtest.exp, /usr/pkg/share/dejagnu/runtest.exp:

runtest.exp では、いくつかの proc を定義した後で、
modena@makoto 14:13:32/140502(..binutils-2.24/gas)% \
grep  ^proc /usr/pkg/share/dejagnu/runtest.exp 
proc verbose { args } {
proc transform { name } {
proc findfile { args } {
proc load_file { args } {
proc search_and_load_file { type filelist dirlist } {
proc usage { } {
proc lookfor_file { dir name } {
proc load_lib { file } {
proc get_local_hostname { } {
proc setup_target_hook { whole_name name } {
proc cleanup_target_hook { name } {
proc setup_host_hook { name } {
proc setup_build_hook { name } {
proc load_tool_init { file } {
proc load_generic_config { name } {
proc load_config { args } {
proc load_tool_target_config { name } {
proc load_board_description { board_name args } {
proc load_base_board_description { board_name } {
proc runtest { test_file_name } {
proc process_target_variants { target_list } {
proc iterate_target_variants { target variants } {
proc iterate_target_variants_two { orig_target target variants } {
modena@makoto 14:13:36/140502(..binutils-2.24/gas)% 
最後に本体がある
modena@makoto 14:16:25/140502(..share/dejagnu)% cat -n runtest.exp| sed -n 1590,1625p
  1590  #
  1591  # main test execution loop
  1592  #
  1593
  1594  if {[info exists errorInfo]} {
  1595      unset errorInfo
  1596  }
  1597  # make sure we have only single path delimiters
  1598  regsub -all "\(\[^/\]\)//*" $srcdir "\\1/" srcdir
  1599
  1600  if {![info exists target_list]} {
  1601      # Make sure there is at least one target machine. It's probably a Unix box,
  1602      # but that's just a guess.
  1603      set target_list { "unix" }
  1604  } else {
  1605      verbose "target list is $target_list"
  1606  }
  1607
  1608  #
  1609  # Iterate through the list of targets.
  1610  #
  1611  global current_target
  1612
  1613  set target_list [process_target_variants $target_list]
  1614
  1615  set target_count [llength $target_list]
  1616
  1617  clone_output "Schedule of variations:"
  1618  foreach current_target $target_list {
  1619      clone_output "    $current_target"
  1620  }
  1621  clone_output ""
  1622
  1623
  1624  foreach current_target $target_list {
  1625      verbose "target is $current_target"

site.exp:

runtest.exp の中に
  68:set configfile  site.exp     ;# (local to this file)
635:    load_file $objdir/$configfile
という行があるので、 site.exp に何か書いておくと読んでくれる (その他に読むのは何かと調べると)
modena@makoto 15:21:52/140502(..my_directory/testsuite)% \
grep -n "^\ *load_file" /usr/pkg/share/dejagnu/runtest.exp
624:load_file ~/.dejagnurc $base_dir/$configfile
635:    load_file $objdir/$configfile

strace:

runtest に --strace N (N は数字)を付けると N 段階までの情報を表示する

#2 (dejagnu) Reading info

改めて info の中の dejagnu を読んでいる訳だが、
3.2.1 A simple project without the GNU autotools
の節に
  • automake を使えば site.exp を作ってくれる (make site.exp と入力)
  • その中身は、次のようになるはずだ、とある。
         set tool calc
         set srcdir .
         set objdir /home/dgt/dejagnu.test
    
作ってくれなくても良いので、自分で真似をして作ろう

"Hello world" locally:

こんな説明もあった
3.3.4 Testing "Hello world" locally



最近の日記
2024年05月06日
py-setuptools (python 3.11.9)
make release took 1 hours and 10 min
qemu invocation for 10.99.10
2024年05月05日
Windows 10 version
serial connection
bc bench
2024年05月04日
Trial on 10.99.10
another version (later trial) to succeed
2024年04月29日
dkim
2024年03月10日
停電 (瞬電)
以上、1 日分です。
タイトル一覧
カテゴリ分類
Powered by hns-2.19.9, HyperNikkiSystem Project

Count.cgi (since 2000/02/05)