Go to the first, previous, next, last section, table of contents.


Testsuite

The testsuite is an important component of the GDB package. While it is always worthwhile to encourage user testing, in practice this is rarely sufficient; users typically use only a small subset of the available commands, and it has proven all too common for a change to cause a significant regression that went unnoticed for some time.

testsuite´Â GDB ÆÐÅ°ÁöÀÇ Áß¿äÇÑ ÄÄÆ÷³ÍÆ®ÀÌ´Ù. ÀÌ°ÍÀÌ »ç¿ëÀÚ Å×½ºÆ®¸¦ °Ý·ÁÇÒÁ¤µµÀÇ °¡Ä¡´Â ÀÖÁö¸¸, ½ÇÁ¦·Î´Â ÃæºÐÇÏÁö´Â ¾Ê´Ù.; »ç¿ëÀÚµéÀº ÀüÇüÀûÀ¸·Î ÀÌ¿ë°¡´ÉÇÑ ¸í·É¾î ÁýÇÕ¸¸À» »ç¿ëÇÏ¸ç º¯È­¸¦ À§ÇÑ ÀϹÝÀûÀΰ͵éÀº ¾ó¸¶½Ã°£µ¿¾ÈÀº ÀνÄÇÏÁö ¸øÇÏ´Â Áß¿äÇÑ ÈÄÅ𸦠¾ß±âÇÑ´Ù.

The GDB testsuite uses the DejaGNU testing framework. DejaGNU is built using Tcl and expect. The tests themselves are calls to various Tcl procs; the framework runs all the procs and summarizes the passes and fails.

GDB testsuite´Â DejaGNU testing frameworkÀ» »ç¿ëÇÑ´Ù. DejaGNU´Â Tcl¿Í expect¸¦ »ç¿ëÇÏ¿© ¸¸µé¾îÁ³´Ù. ±×°Íµé Å×½ºÆ®´Â ´Ù¾çÇÑ Tcl procsÀ» È£ÃâÇϴ°ÍÀÌ´Ù; frameworkÀº ¸ðµç procs¿¡¼­ µ¹¾Æ°¡¸ç Àü´ÞÇÒ°ÍÀ» ¿ä¾àÇÏ°í ½ÇÆÐÇÑ´Ù.

Using the Testsuite

Testsuite »ç¿ëÇϱâ

To run the testsuite, simply go to the GDB object directory (or to the testsuite's objdir) and type make check. This just sets up some environment variables and invokes DejaGNU's runtest script. While the testsuite is running, you'll get mentions of which test file is in use, and a mention of any unexpected passes or fails. When the testsuite is finished, you'll get a summary that looks like this:

testsuite·ê µ¹¸®±â À§ÇØ, GDB °´Ã¼ µð·ºÅ丮(¶Ç´Â testsuite objdir)·Î °¡¼­ make check¸¦ ŸÀÌÇÎÇضó. ÀÌ°ÍÀº ¸î¸î ȯ°æ º¯¼ö¿Í DejaGNU runtest ½ºÅ©¸³Æ®¸¦ È£ÃâÇÑ´Ù. testsuite¸¦ µ¹¸®´Â µ¿¾È, ¿©·¯ºÐÀº ¾î¶² test ÆÄÀÏÀÌ »ç¿ëÁßÀÎÁö ¿¹»óÄ¡ ¸øÇÑ pass³ª fail¿¡ ´ëÇÑ ³»¿ëÀ» ¾òÀ»¼ö ÀÖ´Ù. testsuite°¡ ³¡³ª¸é, ¿©·¯ºÐÀº ´ÙÀ½°ú °°Àº ¿ä¾àÀ» °¡Áø´Ù.:

                === gdb Summary ===

# of expected passes            6016
# of unexpected failures        58
# of unexpected successes       5
# of expected failures          183
# of unresolved testcases       3
# of untested testcases         5

The ideal test run consists of expected passes only; however, reality conspires to keep us from this ideal. Unexpected failures indicate real problems, whether in GDB or in the testsuite. Expected failures are still failures, but ones which have been decided are too hard to deal with at the time; for instance, a test case might work everywhere except on AIX, and there is no prospect of the AIX case being fixed in the near future. Expected failures should not be added lightly, since you may be masking serious bugs in GDB. Unexpected successes are expected fails that are passing for some reason, while unresolved and untested cases often indicate some minor catastrophe, such as the compiler being unable to deal with a test program.

ÀÌ»óÀûÀÎ test´Â ¿¹»óµÈ pass·Î¸¸ ±¸¼ºµÇ¾î µ¹¾Æ°£´Ù.; ±×·¯³ª Çö½ÇÀº ¿ì¸®°¡ ÀÌ·¯ÇÑ ÀÌ»óÀûÀÎ Å×½ºÆ®¸¦ Çϵµ·Ï ÇÑ´Ù. ¿¹»óÄ¡ ¸øÇÑ failure´Â GDB³ª testsuite¿¡¼­ ½ÇÁ¦ ¹®Á¦¸¦ °¡¸®Å²´Ù. ¿¹»óµÈ ½ÇÆд ¿©ÀüÈ÷ ½ÇÆÐÁö¸¸, °áÁ¤µÈ °ÍµéÀº ±×¶§ ó¸®Çϱ⠳ʹ« ¾î·Æ´Ù.; ¿¹¸¦ µé¾î, test °æ¿ì´Â AIX¸¦ Á¦¿ÜÇÏ°í´Â ¾îµð¼­µç ÀÛµ¿Çϸç AIX °æ¿ì´Â °¡±î¿î ¹Ì·¡¿¡ °íÃÄÁú°ÍÀ¸·Î´Â ±â´ëµÇÁö ¾Ê´Â´Ù. ¿¡»óµÈ failure´Â °£´ÜÈ÷ Ãß°¡µÇ¾î¼­´Â ¾ÈµÈ´Ù. ¿Ö³ÄÇÏ¸é ¿©·¯ºÐÀº GDB³» ½É°¢ÇÑ ¹ö±×¸¦ maskÇϱ⠶§¹®ÀÌ´Ù. ¿¹»óÄ¡ ¸øÇÑ ¼º°øÀº ¸î¸î ÀÌÀ¯¶§¹®¿¡ failÇÒ°ÍÀ¸·Î ¿¹»óµÈ´Ù. ¹Ý¸é Çؼ®ÇÏÁö ¸øÇϰųª Å×½ºÆ®µÇÁö ¸øÇÑ °æ¿ì´Â test ÇÁ·Î±Û¸ÅÀ» ´Ù·çÁö ¸øÇÏ´Â ÄÄÆÄÀÏ·¯ °°ÀÌ ¸î¸î Å« ½ÇÆи¦ °¡¸®Å²´Ù.

When making any significant change to GDB, you should run the testsuite before and after the change, to confirm that there are no regressions. Note that truly complete testing would require that you run the testsuite with all supported configurations and a variety of compilers; however this is more than really necessary. In many cases testing with a single configuration is sufficient. Other useful options are to test one big-endian (Sparc) and one little-endian (x86) host, a cross config with a builtin simulator (powerpc-eabi, mips-elf), or a 64-bit host (Alpha).

GDB¿¡ Áß¿äÇÑ º¯°æ»çÇ×À» ÀÛ¾÷ÇÒ¶§, ¿©·¯ºÐÀº ¿¹ÀüÀ¸·Î ȸº¹½ÃÅ°´Â °Í ¾øÀÌ È®½ÇÈ÷ Çϱâ À§ÇØ º¯°æ»çÇ× ÀüÈÄ¿¡ testsuite¸¦ µ¹·Á¾ß ÇÑ´Ù. »ç½Ç ¿ÏÀüÇÑ testingÀº ¸ðµç Áö¿ø ¼³Á¤ »çÇ×°ú ´Ù¾çÇÑ ÄÄÆÄÀÏ·¯¸¦ °¡Áø testsuite¸¦ µ¹·Á¾ß¸¸ ¾òÀ»¼ö ÀÖ´Ù.; ±×·¯³ª ÀÌ°ÍÀº ½ÇÁ¦·Î ÇÊ¿äÇÑ°Í ÀÌ»óÀÌ´Ù. ¸¹Àº °æ¿ì, ´ÜÀÏ ¼³Á¤ »çÇ×À» °¡Áø testing¸¸À¸·Îµµ ÃæºÐÇÏ´Ù. ´Ù¸¥ À¯¿ëÇÑ ¿É¼ÇµéÀº big-endian(Sparc)°ú little-endian(x86) È£½ºÆ®, builtin simulator(powerpc-eabi, mips-elf)¸¦ °¡Áø cross ¼³Á¤ ¶Ç´Â 64 ºñÆ® È£½ºÆ®(Alpha)¿¡¼­ Å×½ºÆ® ÇÏ´Â °ÍÀÌ´Ù.

If you add new functionality to GDB, please consider adding tests for it as well; this way future GDB hackers can detect and fix their changes that break the functionality you added. Similarly, if you fix a bug that was not previously reported as a test failure, please add a test case for it. Some cases are extremely difficult to test, such as code that handles host OS failures or bugs in particular versions of compilers, and it's OK not to try to write tests for all of those.

¸¸ÀÏ ¿©·¯ºÐÀÌ GDB¿¡ »õ·Î¿î ±â´ÉÀ» Ãß°¡ÇÑ´Ù¸é, ¿ª½Ã test Ãß°¡µµ °í·ÁÇضó.; ÀÌ·± ¹æ¹ýÀº ¾ÕÀ¸·ÎÀÇ GDB hackerµéÀÌ ¿©·¯ºÐÀÌ Ãß°¡ÇÑ ±â´ÉÀ» ã°í º¯°æ»çÇ×À» °íÄ¡µµ·Ï ÇØÁØ´Ù. ºñ½ÁÇÏ°Ô, ¸¸ÀÏ ¿©·¯ºÐÀÌ test failure·Î º¸°íµÇÁö ¾ÊÀº ¹ö±×¸¦ °íÃÆ´Ù¸é, ±× °æ¿ì¸¦ À§ÇÑ test caseµµ Ãß°¡Çضó. È£½ºÆ® OS failure³ª ƯÁ¤ ¹öÀüÀÇ ÄÄÆÄÀÏ·¯ ¹ö±×¸¦ ó¸®ÇÏ´Â ÄÚµå °°ÀÌ ¸î¸î °æ¿ì´Â Å×½ºÆ®Çϱ⠹«Ã´ ¾î·Æ´Ù. ±×¸®°í ÀÌ°Íµé ¸ðµÎ¸¦ À§ÇÑ test¸¦ ¾µ·Á°í ÇÏÁö ¸¶¶ó.

Testsuite Organization

Testsuite ±¸¼º

The testsuite is entirely contained in `gdb/testsuite'. While the testsuite includes some makefiles and configury, these are very minimal, and used for little besides cleaning up, since the tests themselves handle the compilation of the programs that GDB will run. The file `testsuite/lib/gdb.exp' contains common utility procs useful for all GDB tests, while the directory `testsuite/config' contains configuration-specific files, typically used for special-purpose definitions of procs like gdb_load and gdb_start.

testsuite´Â ÀüüÀûÀ¸·Î `gdb/testsuite'¿¡ Æ÷ÇԵȴÙ. testsuite°¡ ¸î¸î makefile°ú configury¸¦ Æ÷ÇÔÇÏÁö¸¸, À̰͵éÀº ¸Å¿ì ÀÛÀ¸¸ç Áö¿ï¶§ ¿Ü¿¡´Â °ÅÀÇ »ç¿ëµÇÁö ¾Ê´Â´Ù. ¿Ö³ÄÇϸé testµé ÀÚü´Â GDB¸¦ µ¹¸± ÇÁ·Î±×·¥ÀÇ ÆíÁý¹°À» ó¸®Çϱ⠶§¹®ÀÌ´Ù. ÆÄÀÏ `testsuite/lib/gdb.exp'´Â ¸ðµç GDB test¿¡ À¯¿ëÇÑ procs À¯Æ¿¸®Æ¼¸¦ Æ÷ÇÔÇϸç, µð·ºÅ丮 `testsuite/config'´Â gdb_load¿Í gdb_startó·³ Ưº°ÇÑ ¸ñÀûÀÇ procs¿¡ »ç¿ëµÇ´Â ¼³Á¤»çÇ×-ÀÇÁ¸ÀûÀÎ ÆÄÀÏÀ» Æ÷ÇÔÇÑ´Ù.

The tests themselves are to be found in `testsuite/gdb.*' and subdirectories of those. The names of the test files must always end with `.exp'. DejaGNU collects the test files by wildcarding in the test directories, so both subdirectories and individual files get chosen and run in alphabetical order.

testµé ÀÚü´Â `testsuite/gdb.*'¿Í À̰͵éÀÇ ÇÏÀ§ µð·ºÅ丮¿¡¼­ ¹ß°ßµÈ´Ù. test fileÀÇ À̸§Àº Ç×»ó `.exp'·Î ³¡³ª¾ß ÇÑ´Ù. DejaGNU´Â test µð·ºÅ丮¿¡¼­ wildcard·Î test ÆÄÀϵéÀ» ¸ðÀ¸°í, ÇÏÀ§ µð·ºÅ丮¿Í °¢ ÆÄÀϵéÀ» ¼±ÅÃÇÏ°í ¾ËÆĺª ¼ø¼­·Î µ¹¸°´Ù.

The following table lists the main types of subdirectories and what they are for. Since DejaGNU finds test files no matter where they are located, and since each test file sets up its own compilation and execution environment, this organization is simply for convenience and intelligibility.

´ÙÀ½ Å×À̺íÀº ÇÏÀ§ µð·ºÅ丮ÀÇ ÁÖ Å¸ÀÔ°ú ¹«¾ùÀÎÁö¸¦ ³ª¿­ÇÑ °ÍÀÌ´Ù. DejaGNU´Â À§Ä¡ÇØ Àִ°÷¿¡ °ü°è¾øÀÌ test ÆÄÀϵéÀ» ã±â ¶§¹®¿¡, ±×¸®°í °¢ Å×½ºÆ® ÆÄÀÏÀº ÀÚ½ÅÀÇ ÆíÁý¹°°ú ½ÇÇàȯ°æÀ» ¼³Á¤Çϱ⠶§¹®¿¡, ÀÌ ±¸¼ºÀº Æí¸®¼º°ú ¸íÈ®¼ºÀ» À§ÇÑ °ÍÀÌ´Ù.

`gdb.base'
This is the base testsuite. The tests in it should apply to all configurations of GDB (but generic native-only tests may live here). The test programs should be in the subset of C that is valid K&R, ANSI/ISO, and C++ (#ifdefs are allowed if necessary, for instance for prototypes).

±âº» testsuite. À̰ͳ» test´Â GDB ¸ðµç ¼³Á¤ »çÇ׿¡ Àû¿ëµÇ¾î¾ß ÇÑ´Ù. (±×·¯³ª ÀϹÝÀûÀÎ native-only test´Â ¿©±â¿¡ ÀÖ´Ù.) test ÇÁ·Î±×·¥Àº K&R, ANSI/ISO, and C++ °°ÀÌ CÀÇ ºÎºÐÁýÇÕÀ̾î¾ß ÇÑ´Ù. (¿øÇüÀ» À§ÇØ, ÇÊ¿äÇÏ´Ù¸é #ifdef´Â Çã¿ëµÈ´Ù.)

`gdb.lang'
Language-specific tests for any language lang besides C. Examples are `gdb.c++' and `gdb.java'.

CÀÌ¿ÜÀÇ ¾î¶² ¾ð¾î lang¸¦ À§ÇÑ ¾ð¾î-ÀÇÁ¸ÀûÀÎ test. ¿¹¸¦ µé¾î `gdb.c++'°ú `gdb.java'.

`gdb.platform'
Non-portable tests. The tests are specific to a specific configuration (host or target), such as HP-UX or eCos. Example is `gdb.hp', for HP-UX.

ºñ-ȣȯ test. ÀÌ test´Â HP-UX³ª eCos °°ÀÌ Æ¯º°ÇÑ ¼³Á¤ »çÇ×(È£½ºÆ®³ª Ÿ°Ù)À» À§ÇÑ °ÍÀÌ´Ù. ¿¹¸¦ µé¾î, HP-UX¸¦ À§ÇØ `gdb.hp'.

`gdb.compiler'
Tests specific to a particular compiler. As of this writing (June 1999), there aren't currently any groups of tests in this category that couldn't just as sensibly be made platform-specific, but one could imagine a `gdb.gcc', for tests of GDB's handling of GCC extensions.

ƯÁ¤ ÄÄÆÄÀÏ·¯¿¡ ÀÇÁ¸ÀûÀÎ test. ÀÌ°ÍÀ» ¾µ¶§(1999, 6¿ù), °Å±â¿¡´Â Ç÷§Æû-ÀÇÁ¸ÀûÀ¸·Î ¸¸µé¼ö ¾ø¾î¼­ ÀÌ Ä«Å×°í¸®³» ¾î¶°ÇÑ ±×·ìÀÇ testµµ ¾ø¾ú´Ù. ±×·¯³ª GCC È®ÀåÀ» À§ÇÑ GDB Çڵ鸵 Å×½ºÆ®¸¦ À§ÇØ `gdb.gcc'ÀÌ °¡´ÉÇÏ´Ù.

`gdb.subsystem'
Tests that exercise a specific GDB subsystem in more depth. For instance, `gdb.disasm' exercises various disassemblers, while `gdb.stabs' tests pathways through the stabs symbol reader.

´õ ±íÀÌ Æ¯Á¤ GDB ÇÏÀ§ ½Ã½ºÅÛÀ» À§ÇÑ test. ¿¹¸¦ µé¾î, `gdb.disasm'´Â ´Ù¾çÇÑ disassember¸¦ ´Ù·ç¸ç, ¹Ý¸é¿¡ `gdb.stabs'´Â stab ½Éº¼ ¸®Å͸¦ ÅëÇØ Å×½ºÆ®ÇÑ´Ù.

Writing Tests

Tests ¾²±â

In many areas, the GDB tests are already quite comprehensive; you should be able to copy existing tests to handle new cases.

¸¹Àº ¿µ¿ª¿¡¼­, GDB test´Â ÀÌ¹Ì ²Ï Æ÷°ýÀûÀÌ´Ù.;¿©·¯ºÎÀº »õ·Î¿î case¸¦ ó¸®Çϱâ À§ÇØ ÇöÀç Á¸ÀçÇÏ´Â test¸¦ º¹»çÇØ¾ß ÇÑ´Ù.

You should try to use gdb_test whenever possible, since it includes cases to handle all the unexpected errors that might happen. However, it doesn't cost anything to add new test procedures; for instance, `gdb.base/exprs.exp' defines a test_expr that calls gdb_test multiple times.

¿©·¯ºÐÀº °¡´ÉÇÒ¶§ gdb_test¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù. ¿Ö³ÄÇϸé ÀÌ°ÍÀº ÀϾ¼ö ÀÖ´Â ¿¹»óÄ¡ ¸øÇÑ ¸ðµç ¿¡·¯¸¦ ó¸®ÇÏ´Â °æ¿ì¸¦ Æ÷ÇÏÇϱ⠶§¹®ÀÌ´Ù. ±×·¯³ª ÀÌ°ÍÀº »õ·Î¿î test ÀýÂ÷¸¦ Ãß°¡Çϴµ¥ ºñ¿ëÀÌ µéÁö ¾Ê´Â´Ù.; ¿¹¸¦ µé¾î, `gdb.base/exprs.exp'´Â gdb_test¸¦ ¿©·¯¹ø È£ÃâÇÏ´Â test_expr¸¦ Á¤ÀÇÇÑ´Ù.

Only use send_gdb and gdb_expect when absolutely necessary, such as when GDB has several valid responses to a command.

GDB°¡ ¸í·É¾î¿¡ ´ëÇÑ À¯È¿ÇÑ ÀÀ´äÀ» °¡Áú¶§ ó·³, ÇÊ¿äÇÒ¶§¸¸ send_gdb¿Í gdb_expect¸¦ »ç¿ëÇضó.

The source language programs do not need to be in a consistent style. Since GDB is used to debug programs written in many different styles, it's worth having a mix of styles in the testsuite; for instance, some GDB bugs involving the display of source lines would never manifest themselves if the programs used GNU coding style uniformly.

¼Ò½º ¾ð¾î ÇÁ·Î±×·¥Àº ÀÏ°ü¼º ÀÖ´Â ½ºÅ¸ÀÏÀÏ ÇÊ¿ä´Â ¾ø´Ù. GDB°¡ ¸¹Àº ´Ù¸¥ ½ºÅ¸ÀÏ·Î ¾²¿©Áø ÇÁ·Î±×·¥À» µð¹ö±ëÇϴµ¥ »ç¿ëµÇ±â ¶§¹®¿¡, ±×°ÍÀº testsuite¿¡ ½ºÅ¸ÀÏÀ» ¼¯À» °¡Ä¡°¡ ÀÖ´Ù.; ¿¹¸¦ µé¾î, ¼Ò½º ¶óÀÎ Ãâ·Â°ú °ü·ÃÀÌ ÀÖ´Â ¸î¸î GDB ¹ö±×´Â ¸¸ÀÏ ÇÁ·Î±×·¥ÀÌ GNU ÄÚµù ½ºÅ¸ÀÏÀ» »ç¿ëÇÑ´Ù¸é ±×°ÍµéÀ» °áÄÚ ³ªÅ¸³»Áö ¾Ê±â ¶§¹®ÀÌ´Ù.


Go to the first, previous, next, last section, table of contents.